aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-04-23 16:43:30 +0000
committerRichard M. Stallman2005-04-23 16:43:30 +0000
commit1cade2b675ffb1eaac5f8c78e87b60efb84eb9f6 (patch)
tree193403cc8bca72b17d0d16f48733d7b406e0c7be
parented4761a92723c785dc7873409fd769dcbc9c1d72 (diff)
downloademacs-1cade2b675ffb1eaac5f8c78e87b60efb84eb9f6.tar.gz
emacs-1cade2b675ffb1eaac5f8c78e87b60efb84eb9f6.zip
(imenu--generic-function): The official position of a
definition is the start of the line that BEG is in.
-rw-r--r--lisp/imenu.el23
1 files changed, 13 insertions, 10 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 85430bbdbfc..831550bd7a3 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -777,7 +777,7 @@ They may also be nested index alists like:
777depending on PATTERNS." 777depending on PATTERNS."
778 778
779 (let ((index-alist (list 'dummy)) 779 (let ((index-alist (list 'dummy))
780 prev-pos beg 780 prev-pos
781 (case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) 781 (case-fold-search (if (or (local-variable-p 'imenu-case-fold-search)
782 (not (local-variable-p 'font-lock-defaults))) 782 (not (local-variable-p 'font-lock-defaults)))
783 imenu-case-fold-search 783 imenu-case-fold-search
@@ -807,7 +807,7 @@ depending on PATTERNS."
807 (index (nth 2 pat)) 807 (index (nth 2 pat))
808 (function (nth 3 pat)) 808 (function (nth 3 pat))
809 (rest (nthcdr 4 pat)) 809 (rest (nthcdr 4 pat))
810 start) 810 start beg)
811 ;; Go backwards for convenience of adding items in order. 811 ;; Go backwards for convenience of adding items in order.
812 (goto-char (point-max)) 812 (goto-char (point-max))
813 (while (and (re-search-backward regexp nil t) 813 (while (and (re-search-backward regexp nil t)
@@ -815,32 +815,35 @@ depending on PATTERNS."
815 ;; because it means a bad regexp was specified. 815 ;; because it means a bad regexp was specified.
816 (not (= (match-beginning 0) (match-end 0)))) 816 (not (= (match-beginning 0) (match-end 0))))
817 (setq start (point)) 817 (setq start (point))
818 (goto-char (match-end index)) 818 ;; Record the start of the line in which the match starts.
819 (setq beg (match-beginning index))
820 ;; Go to the start of the match.
821 ;; That's the official position of this definition. 819 ;; That's the official position of this definition.
822 (goto-char start) 820 (goto-char (match-beginning index))
821 (beginning-of-line)
822 (setq beg (point))
823 (imenu-progress-message prev-pos nil t) 823 (imenu-progress-message prev-pos nil t)
824 ;; Add this sort of submenu only when we've found an 824 ;; Add this sort of submenu only when we've found an
825 ;; item for it, avoiding empty, duff menus. 825 ;; item for it, avoiding empty, duff menus.
826 (unless (assoc menu-title index-alist) 826 (unless (assoc menu-title index-alist)
827 (push (list menu-title) index-alist)) 827 (push (list menu-title) index-alist))
828 (if imenu-use-markers 828 (if imenu-use-markers
829 (setq start (copy-marker start))) 829 (setq beg (copy-marker beg)))
830 (let ((item 830 (let ((item
831 (if function 831 (if function
832 (nconc (list (match-string-no-properties index) 832 (nconc (list (match-string-no-properties index)
833 start function) 833 beg function)
834 rest) 834 rest)
835 (cons (match-string-no-properties index) 835 (cons (match-string-no-properties index)
836 start))) 836 beg)))
837 ;; This is the desired submenu, 837 ;; This is the desired submenu,
838 ;; starting with its title (or nil). 838 ;; starting with its title (or nil).
839 (menu (assoc menu-title index-alist))) 839 (menu (assoc menu-title index-alist)))
840 ;; Insert the item unless it is already present. 840 ;; Insert the item unless it is already present.
841 (unless (member item (cdr menu)) 841 (unless (member item (cdr menu))
842 (setcdr menu 842 (setcdr menu
843 (cons item (cdr menu)))))))) 843 (cons item (cdr menu)))))
844 ;; Go to the start of the match, to make sure we
845 ;; keep making progress backwards.
846 (goto-char start))))
844 (set-syntax-table old-table))) 847 (set-syntax-table old-table)))
845 (imenu-progress-message prev-pos 100 t) 848 (imenu-progress-message prev-pos 100 t)
846 ;; Sort each submenu by position. 849 ;; Sort each submenu by position.