diff options
| author | Richard M. Stallman | 1994-03-07 23:24:02 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-07 23:24:02 +0000 |
| commit | 26d6bb604cffd7e7e0a0e1d7e04d6e0021914f01 (patch) | |
| tree | 1c350b5c1f945023bcaee959488b243fb4ea11fe | |
| parent | eaa3cac5f42205c9703d9f509c69c107e754dfc2 (diff) | |
| download | emacs-26d6bb604cffd7e7e0a0e1d7e04d6e0021914f01.tar.gz emacs-26d6bb604cffd7e7e0a0e1d7e04d6e0021914f01.zip | |
entered into RCS
| -rw-r--r-- | lisp/imenu.el | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 30bf2374b10..f6aecb7b1ee 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> | 5 | ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> |
| 6 | ;; Lars Lindberg <lli@sypro.cap.se> | 6 | ;; Lars Lindberg <lli@sypro.cap.se> |
| 7 | ;; Created: 8 Feb 1994 | 7 | ;; Created: 8 Feb 1994 |
| 8 | ;; Version: 1.4 | 8 | ;; Version: 1.6 |
| 9 | ;; Keywords: tools | 9 | ;; Keywords: tools |
| 10 | ;; | 10 | ;; |
| 11 | ;; This program is free software; you can redistribute it and/or modify | 11 | ;; This program is free software; you can redistribute it and/or modify |
| @@ -49,12 +49,18 @@ | |||
| 49 | ;; (autoload 'goto-index-pos "imenu" "Goto buffer index position." t) | 49 | ;; (autoload 'goto-index-pos "imenu" "Goto buffer index position." t) |
| 50 | ;; (define-key global-map "\C-cj" 'goto-index-pos) ;; Or some other key | 50 | ;; (define-key global-map "\C-cj" 'goto-index-pos) ;; Or some other key |
| 51 | ;; (cond (window-system | 51 | ;; (cond (window-system |
| 52 | ;; (define-key global-map [S-down-mouse-3] 'goto-index-pos)) | 52 | ;; (define-key global-map [S-down-mouse-3] 'goto-index-pos))) |
| 53 | 53 | ;; Also run the 'add-hook' examples at the bottom of imenu.el. | |
| 54 | ;;; Change Log: | ||
| 55 | ;; v1.4 Feb 18 1994ine-key global-map [S-down-mouse-3] 'goto-index-pos)) | ||
| 56 | 54 | ||
| 57 | ;;; Change Log: | 55 | ;;; Change Log: |
| 56 | ;; v1.6 Feb 28 1994 Ake Stenhoff | ||
| 57 | ;; Added alist as an optional argument to | ||
| 58 | ;; 'imenu-choose-buffer-index'. | ||
| 59 | ;; Thanks [dean]. | ||
| 60 | ;; v1.5 Feb 25 1994 Ake Stenhoff | ||
| 61 | ;; Added code to parse DEFSTRUCT, DEFCLASS, DEFTYPE, | ||
| 62 | ;; DEFINE-CONDITION in the lisp example function. | ||
| 63 | ;; Thanks [simon]. | ||
| 58 | ;; v1.4 Feb 18 1994 Ake Stenhoff | 64 | ;; v1.4 Feb 18 1994 Ake Stenhoff |
| 59 | ;; Added 'imenu-create-submenu-name' for creating a submenu name. | 65 | ;; Added 'imenu-create-submenu-name' for creating a submenu name. |
| 60 | ;; This is for getting a general look of submenu names. | 66 | ;; This is for getting a general look of submenu names. |
| @@ -74,6 +80,11 @@ | |||
| 74 | ;; v1.0 Feb 8 1994 Ake Stenhoff & Lars Lindberg | 80 | ;; v1.0 Feb 8 1994 Ake Stenhoff & Lars Lindberg |
| 75 | ;; Based on func-menu.el 3.5. | 81 | ;; Based on func-menu.el 3.5. |
| 76 | 82 | ||
| 83 | ;;; Thanks goes to | ||
| 84 | ;; [simon] - Simon Leinen simon@lia.di.epfl.ch | ||
| 85 | ;; [dean] - Dean Andrews ada@unison.com | ||
| 86 | ;; | ||
| 87 | |||
| 77 | ;;; Code | 88 | ;;; Code |
| 78 | (require 'cl) | 89 | (require 'cl) |
| 79 | 90 | ||
| @@ -159,9 +170,6 @@ index and it should return nil when it doesn't find another index. ") | |||
| 159 | "Function for extracting the index name. | 170 | "Function for extracting the index name. |
| 160 | 171 | ||
| 161 | This function is called after the function pointed out by | 172 | This function is called after the function pointed out by |
| 162 | 'prev-index-position-functioname. | ||
| 163 | |||
| 164 | This function is called after the function pointed out by | ||
| 165 | 'prev-index-position-function'.") | 173 | 'prev-index-position-function'.") |
| 166 | (make-variable-buffer-local 'extract-index-name-function) | 174 | (make-variable-buffer-local 'extract-index-name-function) |
| 167 | 175 | ||
| @@ -287,7 +295,6 @@ This function is called after the function pointed out by | |||
| 287 | 295 | ||
| 288 | Moves point to end of buffer and then repeatedly calls | 296 | Moves point to end of buffer and then repeatedly calls |
| 289 | 'prev-index-position-function' and 'extract-index-name-function'. | 297 | 'prev-index-position-function' and 'extract-index-name-function'. |
| 290 | Their results are gathered into an index aliition-function' and 'extract-index-name-function'. | ||
| 291 | Their results are gathered into an index alist." | 298 | Their results are gathered into an index alist." |
| 292 | 299 | ||
| 293 | (or (and (fboundp prev-index-position-function) | 300 | (or (and (fboundp prev-index-position-function) |
| @@ -398,7 +405,7 @@ Returns t for rescan and otherwise a position number." | |||
| 398 | (cond | 405 | (cond |
| 399 | ((eq position nil) | 406 | ((eq position nil) |
| 400 | position) | 407 | position) |
| 401 | ((not (numberp position)) | 408 | ((listp position) |
| 402 | (imenu--mouse-menu position event | 409 | (imenu--mouse-menu position event |
| 403 | (if title | 410 | (if title |
| 404 | (concat title imenu-level-separator | 411 | (concat title imenu-level-separator |
| @@ -409,14 +416,19 @@ Returns t for rescan and otherwise a position number." | |||
| 409 | (t | 416 | (t |
| 410 | (rassq position index-alist))))) | 417 | (rassq position index-alist))))) |
| 411 | 418 | ||
| 412 | (defun imenu-choose-buffer-index (&optional prompt) | 419 | (defun imenu-choose-buffer-index (&optional prompt alist) |
| 413 | "Let the user select from a buffer index and return the chosen index. | 420 | "Let the user select from a buffer index and return the chosen index. |
| 414 | 421 | ||
| 415 | If the user originally activated this function with the mouse, a mouse | 422 | If the user originally activated this function with the mouse, a mouse |
| 416 | menu is used. Otherwise f the user originally activated this function with the mouse, a mouse | ||
| 417 | menu is used. Otherwise a completion buffer is used and the user is | 423 | menu is used. Otherwise a completion buffer is used and the user is |
| 418 | prompted with PROMPT. | 424 | prompted with PROMPT. |
| 419 | 425 | ||
| 426 | If you call this function with index alist ALIST, then it lets the user | ||
| 427 | select from ALIST. | ||
| 428 | |||
| 429 | With no index alist ALIST, it calls 'imenu--make-index-alist' to | ||
| 430 | create the index alist. | ||
| 431 | |||
| 420 | If 'imenu-always-use-completion-buffer-p' is non-nil, then the | 432 | If 'imenu-always-use-completion-buffer-p' is non-nil, then the |
| 421 | completion buffer is always used, no matter if the mouse was used or | 433 | completion buffer is always used, no matter if the mouse was used or |
| 422 | not. | 434 | not. |
| @@ -432,7 +444,7 @@ The returned value is on the form (INDEX-NAME . INDEX-POSITION)." | |||
| 432 | (or (framep window) (select-window window)))) | 444 | (or (framep window) (select-window window)))) |
| 433 | ;; Create a list for this buffer only when needed. | 445 | ;; Create a list for this buffer only when needed. |
| 434 | (while (eq result t) | 446 | (while (eq result t) |
| 435 | (setq index-alist (imenu--make-index-alist)) | 447 | (setq index-alist (if alist alist (imenu--make-index-alist))) |
| 436 | (setq result | 448 | (setq result |
| 437 | (if (and mouse-triggered | 449 | (if (and mouse-triggered |
| 438 | (not imenu-always-use-completion-buffer-p)) | 450 | (not imenu-always-use-completion-buffer-p)) |
| @@ -493,6 +505,7 @@ See 'imenu-choose-buffer-index' for more information." | |||
| 493 | ;; It will generate a nested index of definitions. | 505 | ;; It will generate a nested index of definitions. |
| 494 | (let ((index-alist '()) | 506 | (let ((index-alist '()) |
| 495 | (index-var-alist '()) | 507 | (index-var-alist '()) |
| 508 | (index-type-alist '()) | ||
| 496 | (index-unknown-alist '())) | 509 | (index-unknown-alist '())) |
| 497 | (goto-char (point-max)) | 510 | (goto-char (point-max)) |
| 498 | (imenu-progress-message 0) | 511 | (imenu-progress-message 0) |
| @@ -512,6 +525,15 @@ See 'imenu-choose-buffer-index' for more information." | |||
| 512 | (forward-sexp 2) | 525 | (forward-sexp 2) |
| 513 | (push (imenu-example--name-and-position) | 526 | (push (imenu-example--name-and-position) |
| 514 | index-alist)) | 527 | index-alist)) |
| 528 | ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)") | ||
| 529 | (forward-sexp 2) | ||
| 530 | (if (= (char-after (1- (point))) ?\)) | ||
| 531 | (progn | ||
| 532 | (forward-sexp -1) | ||
| 533 | (down-list 1) | ||
| 534 | (forward-sexp 1))) | ||
| 535 | (push (imenu-example--name-and-position) | ||
| 536 | index-type-alist)) | ||
| 515 | (t | 537 | (t |
| 516 | (forward-sexp 2) | 538 | (forward-sexp 2) |
| 517 | (push (imenu-example--name-and-position) | 539 | (push (imenu-example--name-and-position) |
| @@ -520,6 +542,9 @@ See 'imenu-choose-buffer-index' for more information." | |||
| 520 | (and index-var-alist | 542 | (and index-var-alist |
| 521 | (push (cons (imenu-create-submenu-name "Variables") index-var-alist) | 543 | (push (cons (imenu-create-submenu-name "Variables") index-var-alist) |
| 522 | index-alist)) | 544 | index-alist)) |
| 545 | (and index-type-alist | ||
| 546 | (push (cons (imenu-create-submenu-name "Types") index-type-alist) | ||
| 547 | index-alist)) | ||
| 523 | (and index-unknown-alist | 548 | (and index-unknown-alist |
| 524 | (push (cons (imenu-create-submenu-name "Syntax-unknown") index-unknown-alist) | 549 | (push (cons (imenu-create-submenu-name "Syntax-unknown") index-unknown-alist) |
| 525 | index-alist)) | 550 | index-alist)) |
| @@ -539,10 +564,6 @@ See 'imenu-choose-buffer-index' for more information." | |||
| 539 | "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name | 564 | "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name |
| 540 | )) | 565 | )) |
| 541 | 566 | ||
| 542 | (defun imenu-example--create-c-index (&opter | ||
| 543 | "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name | ||
| 544 | )) | ||
| 545 | |||
| 546 | (defun imenu-example--create-c-index (&optional regexp) | 567 | (defun imenu-example--create-c-index (&optional regexp) |
| 547 | (let ((index-alist '()) | 568 | (let ((index-alist '()) |
| 548 | (char)) | 569 | (char)) |