comparison lisp/imenu.el @ 16698:13920eac02e0

(imenu-generic-expression): Doc fix. (imenu--make-index-alist): Do `widen' and save-restriction here. (imenu): Not here.
author Richard M. Stallman <rms@gnu.org>
date Mon, 16 Dec 1996 07:39:34 +0000
parents 64d5a9772d14
children b48a8dd2d8ce
comparison
equal deleted inserted replaced
16697:83946dc6f4e7 16698:13920eac02e0
117 117
118 ;;;###autoload 118 ;;;###autoload
119 (defvar imenu-generic-expression nil 119 (defvar imenu-generic-expression nil
120 "The regex pattern to use for creating a buffer index. 120 "The regex pattern to use for creating a buffer index.
121 121
122 If non-nil this pattern is passed to `imenu-create-index-with-pattern' 122 If non-nil this pattern is passed to `imenu--generic-function'
123 to create a buffer index. 123 to create a buffer index.
124 124
125 The value should be an alist with elements that look like this: 125 The value should be an alist with elements that look like this:
126 (MENU-TITLE REGEXP INDEX) 126 (MENU-TITLE REGEXP INDEX)
127 or like this: 127 or like this:
463 (and imenu-auto-rescan 463 (and imenu-auto-rescan
464 (> (buffer-size) imenu-auto-rescan-maxout)))) 464 (> (buffer-size) imenu-auto-rescan-maxout))))
465 ;; Get the index 465 ;; Get the index
466 (setq imenu--index-alist 466 (setq imenu--index-alist
467 (save-excursion 467 (save-excursion
468 (funcall imenu-create-index-function)))) 468 (save-restriction
469 (widen)
470 (funcall imenu-create-index-function)))))
469 (or imenu--index-alist noerror 471 (or imenu--index-alist noerror
470 (error "No items suitable for an index found in this buffer")) 472 (error "No items suitable for an index found in this buffer"))
471 (or imenu--index-alist 473 (or imenu--index-alist
472 (setq imenu--index-alist (list nil))) 474 (setq imenu--index-alist (list nil)))
473 ;; Add a rescan option to the index. 475 ;; Add a rescan option to the index.
879 881
880 ;;;###autoload 882 ;;;###autoload
881 (defun imenu (index-item) 883 (defun imenu (index-item)
882 "Jump to a place in the buffer chosen using a buffer menu or mouse menu. 884 "Jump to a place in the buffer chosen using a buffer menu or mouse menu.
883 See `imenu-choose-buffer-index' for more information." 885 See `imenu-choose-buffer-index' for more information."
884 (interactive 886 (interactive (list (imenu-choose-buffer-index)))
885 (list (save-restriction
886 (widen)
887 (imenu-choose-buffer-index))))
888 ;; Convert a string to an alist element. 887 ;; Convert a string to an alist element.
889 (if (stringp index-item) 888 (if (stringp index-item)
890 (setq index-item (assoc index-item (imenu--make-index-alist)))) 889 (setq index-item (assoc index-item (imenu--make-index-alist))))
891 (and index-item 890 (and index-item
892 (progn 891 (progn