aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2020-01-07 20:07:24 +0000
committerAlan Mackenzie2020-01-07 20:11:37 +0000
commitfb432446f5378b99e284e237cf1341600ddb1636 (patch)
tree2f6b37868d5c5509c7d13fc09359e7d8c7740bf2
parenta18373a999dcb5603e27900394dbd7e1fc139fe0 (diff)
downloademacs-fb432446f5378b99e284e237cf1341600ddb1636.tar.gz
emacs-fb432446f5378b99e284e237cf1341600ddb1636.zip
Objective C Mode imenu: cease recognizing "functions" within comments, etc.
This fixes bug #38749. * lisp/progmodes/cc-menus.el (cc-imenu-objc-function): Put a c-literal-limits test around the innards of the main re-search-backward loop.
-rw-r--r--lisp/progmodes/cc-menus.el98
1 files changed, 50 insertions, 48 deletions
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el
index 9c8c7ab56f5..97037dea6e8 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -45,6 +45,7 @@
45(cc-bytecomp-defvar imenu-case-fold-search) 45(cc-bytecomp-defvar imenu-case-fold-search)
46(cc-bytecomp-defvar imenu-generic-expression) 46(cc-bytecomp-defvar imenu-generic-expression)
47(cc-bytecomp-defvar imenu-create-index-function) 47(cc-bytecomp-defvar imenu-create-index-function)
48(cc-bytecomp-defun c-literal-limits)
48 49
49 50
50;; imenu integration 51;; imenu integration
@@ -437,55 +438,56 @@ Example:
437 (goto-char (point-max)) 438 (goto-char (point-max))
438 ;; 439 ;;
439 (while (re-search-backward cc-imenu-objc-generic-expression nil t) 440 (while (re-search-backward cc-imenu-objc-generic-expression nil t)
440 (setq langnum (if (match-beginning OBJC) 441 (when (not (c-literal-limits))
441 OBJC 442 (setq langnum (if (match-beginning OBJC)
442 (cond 443 OBJC
443 ((match-beginning Cproto) Cproto) 444 (cond
444 ((match-beginning Cgeneralfunc) Cgeneralfunc) 445 ((match-beginning Cproto) Cproto)
445 ((match-beginning Cnoreturn) Cnoreturn)))) 446 ((match-beginning Cgeneralfunc) Cgeneralfunc)
446 (setq str (funcall func (match-beginning langnum) (match-end langnum))) 447 ((match-beginning Cnoreturn) Cnoreturn))))
447 ;; 448 (setq str (funcall func (match-beginning langnum) (match-end langnum)))
448 (cond 449 ;;
449 ;;
450 ;; C
451 ;;
452 ((not (eq langnum OBJC))
453 (setq clist (cons (cons str (match-beginning langnum)) clist)))
454 ;;
455 ;; ObjC
456 ;;
457 ;; An instance Method
458 ((eq (aref str 0) ?-)
459 (setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
460 (setq methodlist (cons (cons str
461 (match-beginning langnum))
462 methodlist)))
463 ;; A factory Method
464 ((eq (aref str 0) ?+)
465 (setq str (concat "+" (cc-imenu-objc-method-to-selector str)))
466 (setq methodlist (cons (cons str
467 (match-beginning langnum))
468 methodlist)))
469 ;; Interface or implementation or protocol
470 ((eq (aref str 0) ?@)
471 (setq classcount (1+ classcount))
472 (cond 450 (cond
473 ((and (> (length str) implen) 451 ;;
474 (string= (substring str 0 implen) "@implementation")) 452 ;; C
475 (setq str (substring str implen) 453 ;;
476 str2 "@implementation")) 454 ((not (eq langnum OBJC))
477 ((string= (substring str 0 intflen) "@interface") 455 (setq clist (cons (cons str (match-beginning langnum)) clist)))
478 (setq str (substring str intflen) 456 ;;
479 str2 "@interface")) 457 ;; ObjC
480 ((string= (substring str 0 prtlen) "@protocol") 458 ;;
481 (setq str (substring str prtlen) 459 ;; An instance Method
482 str2 "@protocol"))) 460 ((eq (aref str 0) ?-)
483 (setq str (cc-imenu-objc-remove-white-space str)) 461 (setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
484 (setq methodlist (cons (cons str2 462 (setq methodlist (cons (cons str
485 (match-beginning langnum)) 463 (match-beginning langnum))
486 methodlist)) 464 methodlist)))
487 (setq toplist (cons (cons str methodlist) toplist) 465 ;; A factory Method
488 methodlist nil)))) 466 ((eq (aref str 0) ?+)
467 (setq str (concat "+" (cc-imenu-objc-method-to-selector str)))
468 (setq methodlist (cons (cons str
469 (match-beginning langnum))
470 methodlist)))
471 ;; Interface or implementation or protocol
472 ((eq (aref str 0) ?@)
473 (setq classcount (1+ classcount))
474 (cond
475 ((and (> (length str) implen)
476 (string= (substring str 0 implen) "@implementation"))
477 (setq str (substring str implen)
478 str2 "@implementation"))
479 ((string= (substring str 0 intflen) "@interface")
480 (setq str (substring str intflen)
481 str2 "@interface"))
482 ((string= (substring str 0 prtlen) "@protocol")
483 (setq str (substring str prtlen)
484 str2 "@protocol")))
485 (setq str (cc-imenu-objc-remove-white-space str))
486 (setq methodlist (cons (cons str2
487 (match-beginning langnum))
488 methodlist))
489 (setq toplist (cons (cons str methodlist) toplist)
490 methodlist nil)))))
489 491
490 ;; In this buffer, there is only one or zero @{interface|implementation|protocol}. 492 ;; In this buffer, there is only one or zero @{interface|implementation|protocol}.
491 (if (< classcount 2) 493 (if (< classcount 2)