diff options
| author | Richard M. Stallman | 1994-05-04 21:34:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-05-04 21:34:13 +0000 |
| commit | 68e01f5af89d42b2eb92d7265f5a66888a97d627 (patch) | |
| tree | cb1fb3dfb45b1d17d8156cf17babb7f31bf3ddcc | |
| parent | f46831b07296d35401f87628494ac12acdb6117e (diff) | |
| download | emacs-68e01f5af89d42b2eb92d7265f5a66888a97d627.tar.gz emacs-68e01f5af89d42b2eb92d7265f5a66888a97d627.zip | |
(imenu): Renamed from goto-index-pos.
Add autoload.
(imenu-prev-index-position-function): Renamed from prev-...
(imenu-extract-index-name-function): Renamed from extract-...
| -rw-r--r-- | lisp/imenu.el | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 64b70d212a8..9d0e6695a61 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -25,14 +25,6 @@ | |||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | ;; | 26 | ;; |
| 27 | ;; Purpose of this package: | 27 | ;; Purpose of this package: |
| 28 | ;; | ||
| 29 | ;; Installation instructions | ||
| 30 | ;; | ||
| 31 | ;; Usage instructions: | ||
| 32 | ;; | ||
| 33 | ;; Known bugs: | ||
| 34 | ;; | ||
| 35 | ;; Purpose of this package: | ||
| 36 | ;; To present a framework for mode-specific buffer indexes. | 28 | ;; To present a framework for mode-specific buffer indexes. |
| 37 | ;; A buffer index is an alist of names and buffer positions. | 29 | ;; A buffer index is an alist of names and buffer positions. |
| 38 | ;; For instance all functions in a C-file and their positions. | 30 | ;; For instance all functions in a C-file and their positions. |
| @@ -49,16 +41,6 @@ | |||
| 49 | ;; Lisp/Emacs Lisp but it is easy to customize for other modes. A | 41 | ;; Lisp/Emacs Lisp but it is easy to customize for other modes. A |
| 50 | ;; function for jumping to the chosen index position is also | 42 | ;; function for jumping to the chosen index position is also |
| 51 | ;; supplied. | 43 | ;; supplied. |
| 52 | ;; | ||
| 53 | ;; Installation: | ||
| 54 | ;; Put this file in your load-path and insert the following in .emacs | ||
| 55 | ;; | ||
| 56 | ;; (autoload 'imenu-choose-buffer-index "imenu" "Menu of buffer index." t) | ||
| 57 | ;; (autoload 'goto-index-pos "imenu" "Goto buffer index position." t) | ||
| 58 | ;; (define-key global-map "\C-cj" 'goto-index-pos) ;; Or some other key | ||
| 59 | ;; (cond (window-system | ||
| 60 | ;; (define-key global-map [S-down-mouse-3] 'goto-index-pos))) | ||
| 61 | ;; Also run the 'add-hook' examples at the bottom of imenu.el. | ||
| 62 | 44 | ||
| 63 | ;;; Change Log: | 45 | ;;; Change Log: |
| 64 | ;; v1.7 Apr 12 1994 Ake Stenhoff | 46 | ;; v1.7 Apr 12 1994 Ake Stenhoff |
| @@ -111,7 +93,7 @@ | |||
| 111 | 93 | ||
| 112 | Non-nil means always display the index in a completion buffer. | 94 | Non-nil means always display the index in a completion buffer. |
| 113 | Nil means display the index as a mouse menu when the mouse was | 95 | Nil means display the index as a mouse menu when the mouse was |
| 114 | used to trigger `goto-index-pos'.") | 96 | used to invoke `imenu'.") |
| 115 | 97 | ||
| 116 | (defvar imenu-sort-function nil | 98 | (defvar imenu-sort-function nil |
| 117 | "*The function to use for sorting the index mouse-menu. | 99 | "*The function to use for sorting the index mouse-menu. |
| @@ -166,7 +148,7 @@ This function is called within a `save-excursion'. | |||
| 166 | The variable is buffer-local.") | 148 | The variable is buffer-local.") |
| 167 | (make-variable-buffer-local 'imenu-create-index-function) | 149 | (make-variable-buffer-local 'imenu-create-index-function) |
| 168 | 150 | ||
| 169 | (defvar prev-index-position-function 'beginning-of-defun | 151 | (defvar imenu-prev-index-position-function 'beginning-of-defun |
| 170 | "Function for finding the next index position. | 152 | "Function for finding the next index position. |
| 171 | 153 | ||
| 172 | If `imenu-create-index-function' is set to | 154 | If `imenu-create-index-function' is set to |
| @@ -176,14 +158,14 @@ file. | |||
| 176 | 158 | ||
| 177 | The function should leave point at the place to be connected to the | 159 | The function should leave point at the place to be connected to the |
| 178 | index and it should return nil when it doesn't find another index. ") | 160 | index and it should return nil when it doesn't find another index. ") |
| 179 | (make-variable-buffer-local 'prev-index-position-function) | 161 | (make-variable-buffer-local 'imenu-prev-index-position-function) |
| 180 | 162 | ||
| 181 | (defvar extract-index-name-function nil | 163 | (defvar imenu-extract-index-name-function nil |
| 182 | "Function for extracting the index name. | 164 | "Function for extracting the index name. |
| 183 | 165 | ||
| 184 | This function is called after the function pointed out by | 166 | This function is called after the function pointed out by |
| 185 | `prev-index-position-function'.") | 167 | `imenu-prev-index-position-function'.") |
| 186 | (make-variable-buffer-local 'extract-index-name-function) | 168 | (make-variable-buffer-local 'imenu-extract-index-name-function) |
| 187 | 169 | ||
| 188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 170 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 189 | ;;; | 171 | ;;; |
| @@ -306,11 +288,11 @@ This function is called after the function pointed out by | |||
| 306 | "*Wrapper for index searching functions. | 288 | "*Wrapper for index searching functions. |
| 307 | 289 | ||
| 308 | Moves point to end of buffer and then repeatedly calls | 290 | Moves point to end of buffer and then repeatedly calls |
| 309 | `prev-index-position-function' and `extract-index-name-function'. | 291 | `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. |
| 310 | Their results are gathered into an index alist." | 292 | Their results are gathered into an index alist." |
| 311 | 293 | ||
| 312 | (or (and (fboundp prev-index-position-function) | 294 | (or (and (fboundp imenu-prev-index-position-function) |
| 313 | (fboundp extract-index-name-function)) | 295 | (fboundp imenu-extract-index-name-function)) |
| 314 | (error "The mode \"%s\" does not take full advantage of imenu.el yet." | 296 | (error "The mode \"%s\" does not take full advantage of imenu.el yet." |
| 315 | mode-name)) | 297 | mode-name)) |
| 316 | (let ((index-alist '()) | 298 | (let ((index-alist '()) |
| @@ -318,10 +300,10 @@ Their results are gathered into an index alist." | |||
| 318 | (goto-char (point-max)) | 300 | (goto-char (point-max)) |
| 319 | (imenu-progress-message 0 t) | 301 | (imenu-progress-message 0 t) |
| 320 | ;; Search for the function | 302 | ;; Search for the function |
| 321 | (while (funcall prev-index-position-function) | 303 | (while (funcall imenu-prev-index-position-function) |
| 322 | (imenu-progress-message nil t) | 304 | (imenu-progress-message nil t) |
| 323 | (save-excursion | 305 | (save-excursion |
| 324 | (setq name (funcall extract-index-name-function))) | 306 | (setq name (funcall imenu-extract-index-name-function))) |
| 325 | (and (stringp name) | 307 | (and (stringp name) |
| 326 | (push (cons name (point)) index-alist))) | 308 | (push (cons name (point)) index-alist))) |
| 327 | (imenu-progress-message 100 t) | 309 | (imenu-progress-message 100 t) |
| @@ -400,6 +382,7 @@ Returns t for rescan and otherwise a position number." | |||
| 400 | (imenu--completion-buffer (cdr choice) prompt)) | 382 | (imenu--completion-buffer (cdr choice) prompt)) |
| 401 | (t | 383 | (t |
| 402 | choice)))))) | 384 | choice)))))) |
| 385 | |||
| 403 | (defun imenu--mouse-menu (index-alist event &optional title) | 386 | (defun imenu--mouse-menu (index-alist event &optional title) |
| 404 | "Let the user select from a buffer index from a mouse menu. | 387 | "Let the user select from a buffer index from a mouse menu. |
| 405 | 388 | ||
| @@ -471,9 +454,9 @@ The returned value is on the form (INDEX-NAME . INDEX-POSITION)." | |||
| 471 | (setq imenu--index-alist nil))) | 454 | (setq imenu--index-alist nil))) |
| 472 | result)) | 455 | result)) |
| 473 | 456 | ||
| 474 | (defun goto-index-pos () | 457 | ;;;###autoload |
| 475 | "Jump to selected part of buffer, using a buffer menu or mouse menu. | 458 | (defun imenu () |
| 476 | 459 | "Jump to a place in the buffer chosen using a buffer menu or mouse menu. | |
| 477 | See `imenu-choose-buffer-index' for more information." | 460 | See `imenu-choose-buffer-index' for more information." |
| 478 | (interactive) | 461 | (interactive) |
| 479 | (let ((index-item (imenu-choose-buffer-index))) | 462 | (let ((index-item (imenu-choose-buffer-index))) |