777 |
depending on PATTERNS." |
depending on PATTERNS." |
778 |
|
|
779 |
(let ((index-alist (list 'dummy)) |
(let ((index-alist (list 'dummy)) |
780 |
prev-pos beg |
prev-pos |
781 |
(case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) |
(case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) |
782 |
(not (local-variable-p 'font-lock-defaults))) |
(not (local-variable-p 'font-lock-defaults))) |
783 |
imenu-case-fold-search |
imenu-case-fold-search |
807 |
(index (nth 2 pat)) |
(index (nth 2 pat)) |
808 |
(function (nth 3 pat)) |
(function (nth 3 pat)) |
809 |
(rest (nthcdr 4 pat)) |
(rest (nthcdr 4 pat)) |
810 |
start) |
start beg) |
811 |
;; Go backwards for convenience of adding items in order. |
;; Go backwards for convenience of adding items in order. |
812 |
(goto-char (point-max)) |
(goto-char (point-max)) |
813 |
(while (and (re-search-backward regexp nil t) |
(while (and (re-search-backward regexp nil t) |
815 |
;; because it means a bad regexp was specified. |
;; because it means a bad regexp was specified. |
816 |
(not (= (match-beginning 0) (match-end 0)))) |
(not (= (match-beginning 0) (match-end 0)))) |
817 |
(setq start (point)) |
(setq start (point)) |
818 |
(goto-char (match-end index)) |
;; Record the start of the line in which the match starts. |
|
(setq beg (match-beginning index)) |
|
|
;; Go to the start of the match. |
|
819 |
;; That's the official position of this definition. |
;; That's the official position of this definition. |
820 |
(goto-char start) |
(goto-char (match-beginning index)) |
821 |
|
(beginning-of-line) |
822 |
|
(setq beg (point)) |
823 |
(imenu-progress-message prev-pos nil t) |
(imenu-progress-message prev-pos nil t) |
824 |
;; Add this sort of submenu only when we've found an |
;; Add this sort of submenu only when we've found an |
825 |
;; item for it, avoiding empty, duff menus. |
;; item for it, avoiding empty, duff menus. |
826 |
(unless (assoc menu-title index-alist) |
(unless (assoc menu-title index-alist) |
827 |
(push (list menu-title) index-alist)) |
(push (list menu-title) index-alist)) |
828 |
(if imenu-use-markers |
(if imenu-use-markers |
829 |
(setq start (copy-marker start))) |
(setq beg (copy-marker beg))) |
830 |
(let ((item |
(let ((item |
831 |
(if function |
(if function |
832 |
(nconc (list (match-string-no-properties index) |
(nconc (list (match-string-no-properties index) |
833 |
start function) |
beg function) |
834 |
rest) |
rest) |
835 |
(cons (match-string-no-properties index) |
(cons (match-string-no-properties index) |
836 |
start))) |
beg))) |
837 |
;; This is the desired submenu, |
;; This is the desired submenu, |
838 |
;; starting with its title (or nil). |
;; starting with its title (or nil). |
839 |
(menu (assoc menu-title index-alist))) |
(menu (assoc menu-title index-alist))) |
840 |
;; Insert the item unless it is already present. |
;; Insert the item unless it is already present. |
841 |
(unless (member item (cdr menu)) |
(unless (member item (cdr menu)) |
842 |
(setcdr menu |
(setcdr menu |
843 |
(cons item (cdr menu)))))))) |
(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)))) |
847 |
(set-syntax-table old-table))) |
(set-syntax-table old-table))) |
848 |
(imenu-progress-message prev-pos 100 t) |
(imenu-progress-message prev-pos 100 t) |
849 |
;; Sort each submenu by position. |
;; Sort each submenu by position. |