aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-11-25 02:57:47 +0000
committerRichard M. Stallman2004-11-25 02:57:47 +0000
commit71eb63089686581963cd7a34aa39f7a901cff82e (patch)
treef0d3f0dd39a18f412f0fcbd0e4d1e634c02e6917
parentdbc165ffe2a646002ed4389e41d0d8310367fd4a (diff)
downloademacs-71eb63089686581963cd7a34aa39f7a901cff82e.tar.gz
emacs-71eb63089686581963cd7a34aa39f7a901cff82e.zip
Don't always require newcomment.
(imenu--generic-function): Call comment-normalize-vars if we have a comment syntax. Exit the loop if REGEXP matches the null string. Test comment-start as well as comment-start-skip when deciding whether to check for comments.
-rw-r--r--lisp/imenu.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index d20dc4bccb8..32dda9fd3c6 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -62,8 +62,6 @@
62 62
63;;; Code: 63;;; Code:
64 64
65(require 'newcomment)
66
67(eval-when-compile (require 'cl)) 65(eval-when-compile (require 'cl))
68 66
69;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 67;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -745,8 +743,8 @@ for modes which use `imenu--generic-function'. If it is not set, but
745;;;###autoload 743;;;###autoload
746(make-variable-buffer-local 'imenu-case-fold-search) 744(make-variable-buffer-local 'imenu-case-fold-search)
747 745
748;; Originally "Built on some ideas that Erik Naggum <erik@naggum.no> 746;; This function can be called with quitting disabled,
749;; once posted to comp.emacs" but since substantially re-written. 747;; so it needs to be careful never to loop!
750(defun imenu--generic-function (patterns) 748(defun imenu--generic-function (patterns)
751 "Return an index of the current buffer as an alist. 749 "Return an index of the current buffer as an alist.
752 750
@@ -800,6 +798,9 @@ depending on PATTERNS."
800 (unwind-protect ; for syntax table 798 (unwind-protect ; for syntax table
801 (save-match-data 799 (save-match-data
802 (set-syntax-table table) 800 (set-syntax-table table)
801 (if (or comment-start comment-start-skip)
802 (comment-normalize-vars))
803
803 ;; map over the elements of imenu-generic-expression 804 ;; map over the elements of imenu-generic-expression
804 ;; (typically functions, variables ...) 805 ;; (typically functions, variables ...)
805 (dolist (pat patterns) 806 (dolist (pat patterns)
@@ -812,12 +813,16 @@ depending on PATTERNS."
812 cs) 813 cs)
813 ;; Go backwards for convenience of adding items in order. 814 ;; Go backwards for convenience of adding items in order.
814 (goto-char (point-max)) 815 (goto-char (point-max))
815 (while (re-search-backward regexp nil t) 816 (while (and (re-search-backward regexp nil t)
817 ;; Exit the loop if we get an empty match,
818 ;; because it means a bad regexp was specified.
819 (not (= (match-beginning 0) (match-end 0))))
816 (setq start (point)) 820 (setq start (point))
817 (goto-char (match-end index)) 821 (goto-char (match-end index))
818 (setq beg (match-beginning index)) 822 (setq beg (match-beginning index))
819 (setq cs (and comment-start-skip 823 (setq cs (and (or comment-start comment-start-skip)
820 (save-match-data (comment-beginning)))) 824 (save-match-data
825 (comment-beginning))))
821 (if cs 826 (if cs
822 (goto-char (min cs beg)) ; skip this one, it's in a comment 827 (goto-char (min cs beg)) ; skip this one, it's in a comment
823 (goto-char beg) 828 (goto-char beg)