;;; Commentary:
;;
;; Purpose of this package:
-;;
-;; Installation instructions
-;;
-;; Usage instructions:
-;;
-;; Known bugs:
-;;
-;; Purpose of this package:
;; To present a framework for mode-specific buffer indexes.
;; A buffer index is an alist of names and buffer positions.
;; For instance all functions in a C-file and their positions.
;; Lisp/Emacs Lisp but it is easy to customize for other modes. A
;; function for jumping to the chosen index position is also
;; supplied.
-;;
-;; Installation:
-;; Put this file in your load-path and insert the following in .emacs
-;;
-;; (autoload 'imenu-choose-buffer-index "imenu" "Menu of buffer index." t)
-;; (autoload 'goto-index-pos "imenu" "Goto buffer index position." t)
-;; (define-key global-map "\C-cj" 'goto-index-pos) ;; Or some other key
-;; (cond (window-system
-;; (define-key global-map [S-down-mouse-3] 'goto-index-pos)))
-;; Also run the 'add-hook' examples at the bottom of imenu.el.
;;; Change Log:
;; v1.7 Apr 12 1994 Ake Stenhoff
Non-nil means always display the index in a completion buffer.
Nil means display the index as a mouse menu when the mouse was
-used to trigger `goto-index-pos'.")
+used to invoke `imenu'.")
(defvar imenu-sort-function nil
"*The function to use for sorting the index mouse-menu.
The variable is buffer-local.")
(make-variable-buffer-local 'imenu-create-index-function)
-(defvar prev-index-position-function 'beginning-of-defun
+(defvar imenu-prev-index-position-function 'beginning-of-defun
"Function for finding the next index position.
If `imenu-create-index-function' is set to
The function should leave point at the place to be connected to the
index and it should return nil when it doesn't find another index. ")
-(make-variable-buffer-local 'prev-index-position-function)
+(make-variable-buffer-local 'imenu-prev-index-position-function)
-(defvar extract-index-name-function nil
+(defvar imenu-extract-index-name-function nil
"Function for extracting the index name.
This function is called after the function pointed out by
-`prev-index-position-function'.")
-(make-variable-buffer-local 'extract-index-name-function)
+`imenu-prev-index-position-function'.")
+(make-variable-buffer-local 'imenu-extract-index-name-function)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
"*Wrapper for index searching functions.
Moves point to end of buffer and then repeatedly calls
-`prev-index-position-function' and `extract-index-name-function'.
+`imenu-prev-index-position-function' and `imenu-extract-index-name-function'.
Their results are gathered into an index alist."
- (or (and (fboundp prev-index-position-function)
- (fboundp extract-index-name-function))
+ (or (and (fboundp imenu-prev-index-position-function)
+ (fboundp imenu-extract-index-name-function))
(error "The mode \"%s\" does not take full advantage of imenu.el yet."
mode-name))
(let ((index-alist '())
(goto-char (point-max))
(imenu-progress-message 0 t)
;; Search for the function
- (while (funcall prev-index-position-function)
+ (while (funcall imenu-prev-index-position-function)
(imenu-progress-message nil t)
(save-excursion
- (setq name (funcall extract-index-name-function)))
+ (setq name (funcall imenu-extract-index-name-function)))
(and (stringp name)
(push (cons name (point)) index-alist)))
(imenu-progress-message 100 t)
(imenu--completion-buffer (cdr choice) prompt))
(t
choice))))))
+
(defun imenu--mouse-menu (index-alist event &optional title)
"Let the user select from a buffer index from a mouse menu.
(setq imenu--index-alist nil)))
result))
-(defun goto-index-pos ()
- "Jump to selected part of buffer, using a buffer menu or mouse menu.
-
+;;;###autoload
+(defun imenu ()
+ "Jump to a place in the buffer chosen using a buffer menu or mouse menu.
See `imenu-choose-buffer-index' for more information."
(interactive)
(let ((index-item (imenu-choose-buffer-index)))