Mercurial > emacs
comparison lisp/imenu.el @ 20249:c42156dab61b
(imenu-default-create-index-function):
Test imenu-prev-index-position-function and
imenu-extract-index-name-function for non-nil, not fboundp.
(imenu-add-to-menubar): Likewise.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 11 Nov 1997 03:54:00 +0000 |
parents | 68621d697ee2 |
children | aa3481dd4d84 |
comparison
equal
deleted
inserted
replaced
20248:b87f3ba0e1d7 | 20249:c42156dab61b |
---|---|
617 Moves point to end of buffer and then repeatedly calls | 617 Moves point to end of buffer and then repeatedly calls |
618 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. | 618 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. |
619 Their results are gathered into an index alist." | 619 Their results are gathered into an index alist." |
620 ;; These should really be done by setting imenu-create-index-function | 620 ;; These should really be done by setting imenu-create-index-function |
621 ;; in these major modes. But save that change for later. | 621 ;; in these major modes. But save that change for later. |
622 (cond ((and (fboundp imenu-prev-index-position-function) | 622 (cond ((and imenu-prev-index-position-function |
623 (fboundp imenu-extract-index-name-function)) | 623 imenu-extract-index-name-function) |
624 (let ((index-alist '()) | 624 (let ((index-alist '()) |
625 prev-pos name) | 625 prev-pos name) |
626 (goto-char (point-max)) | 626 (goto-char (point-max)) |
627 (imenu-progress-message prev-pos 0 t) | 627 (imenu-progress-message prev-pos 0 t) |
628 ;; Search for the function | 628 ;; Search for the function |
900 (defun imenu-add-to-menubar (name) | 900 (defun imenu-add-to-menubar (name) |
901 "Adds an `imenu' entry to the menu bar for the current buffer. | 901 "Adds an `imenu' entry to the menu bar for the current buffer. |
902 NAME is a string used to name the menu bar item. | 902 NAME is a string used to name the menu bar item. |
903 See the command `imenu' for more information." | 903 See the command `imenu' for more information." |
904 (interactive "sImenu menu item name: ") | 904 (interactive "sImenu menu item name: ") |
905 (if (or (not (eq imenu-create-index-function | 905 (if (or (and imenu-prev-index-position-function |
906 'imenu-default-create-index-function)) | 906 imenu-extract-index-name-function) |
907 (and (fboundp imenu-prev-index-position-function) | 907 imenu-generic-expression |
908 (fboundp imenu-extract-index-name-function)) | 908 (not (eq imenu-create-index-function |
909 (and imenu-generic-expression)) | 909 'imenu-default-create-index-function))) |
910 (let ((newmap (make-sparse-keymap)) | 910 (let ((newmap (make-sparse-keymap)) |
911 (menu-bar (lookup-key (current-local-map) [menu-bar]))) | 911 (menu-bar (lookup-key (current-local-map) [menu-bar]))) |
912 (define-key newmap [menu-bar] | 912 (define-key newmap [menu-bar] |
913 (append (make-sparse-keymap) menu-bar)) | 913 (append (make-sparse-keymap) menu-bar)) |
914 (define-key newmap [menu-bar index] | 914 (define-key newmap [menu-bar index] |
915 (cons name (nconc (make-sparse-keymap "Imenu") | 915 (cons name (nconc (make-sparse-keymap "Imenu") |
916 (make-sparse-keymap)))) | 916 (make-sparse-keymap)))) |
917 (use-local-map (append newmap (current-local-map))) | 917 (use-local-map (append newmap (current-local-map))) |
918 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) | 918 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) |
919 (error "The mode `%s' does not support Imenu" mode-name))) | 919 (error "The mode `%s' does not support Imenu" mode-name))) |
920 | 920 |
921 (defvar imenu-buffer-menubar nil) | 921 (defvar imenu-buffer-menubar nil) |
922 | 922 |
923 (defun imenu-update-menubar () | 923 (defun imenu-update-menubar () |