diff options
| author | Chong Yidong | 2012-08-05 22:14:54 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-05 22:14:54 +0800 |
| commit | b7ccbdc2e39ff834a03a7f30516b71cd98e84a44 (patch) | |
| tree | 709716de67fb79a23bf4e78346dabf808b3310fb | |
| parent | d32e47aff6cc01e3ccdfdf5e8f163f8a52285a75 (diff) | |
| download | emacs-b7ccbdc2e39ff834a03a7f30516b71cd98e84a44.tar.gz emacs-b7ccbdc2e39ff834a03a7f30516b71cd98e84a44.zip | |
In Imenu, don't show defvars with no second argument.
* lisp/emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression): Don't
show defvars which have no second argument.
* lisp/imenu.el (imenu-generic-expression): Move documentation here
from imenu--generic-function.
(imenu--generic-function): Refer to imenu-generic-expression.
Fixes: debbugs:8638
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 7 | ||||
| -rw-r--r-- | lisp/imenu.el | 77 |
3 files changed, 50 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 004a3eaf451..e211bacbb02 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-08-05 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression): Don't | ||
| 4 | show defvars which have no second argument (Bug#8638). | ||
| 5 | |||
| 6 | * imenu.el (imenu-generic-expression): Move documentation here | ||
| 7 | from imenu--generic-function. | ||
| 8 | (imenu--generic-function): Refer to imenu-generic-expression. | ||
| 9 | |||
| 1 | 2012-08-05 Vegard Øye <vegard_oye@hotmail.com> (tiny change) | 10 | 2012-08-05 Vegard Øye <vegard_oye@hotmail.com> (tiny change) |
| 2 | 11 | ||
| 3 | * emulation/viper-init.el (viper-deflocalvar): Add docstring and | 12 | * emulation/viper-init.el (viper-deflocalvar): Add docstring and |
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index e29407f5a8b..7e9dd9e6cfe 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -117,10 +117,15 @@ It has `lisp-mode-abbrev-table' as its parent." | |||
| 117 | (purecopy (concat "^\\s-*(" | 117 | (purecopy (concat "^\\s-*(" |
| 118 | (eval-when-compile | 118 | (eval-when-compile |
| 119 | (regexp-opt | 119 | (regexp-opt |
| 120 | '("defvar" "defconst" "defconstant" "defcustom" | 120 | '("defconst" "defconstant" "defcustom" |
| 121 | "defparameter" "define-symbol-macro") t)) | 121 | "defparameter" "define-symbol-macro") t)) |
| 122 | "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) | 122 | "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) |
| 123 | 2) | 123 | 2) |
| 124 | ;; For `defvar', we ignore (defvar FOO) constructs. | ||
| 125 | (list (purecopy "Variables") | ||
| 126 | (purecopy (concat "^\\s-*(defvar\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" | ||
| 127 | "[[:space:]\n]+[^)]")) | ||
| 128 | 1) | ||
| 124 | (list (purecopy "Types") | 129 | (list (purecopy "Types") |
| 125 | (purecopy (concat "^\\s-*(" | 130 | (purecopy (concat "^\\s-*(" |
| 126 | (eval-when-compile | 131 | (eval-when-compile |
diff --git a/lisp/imenu.el b/lisp/imenu.el index 8cef5161a37..c2a80d69675 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -187,16 +187,39 @@ with name concatenation." | |||
| 187 | 187 | ||
| 188 | ;;;###autoload | 188 | ;;;###autoload |
| 189 | (defvar imenu-generic-expression nil | 189 | (defvar imenu-generic-expression nil |
| 190 | "The regex pattern to use for creating a buffer index. | 190 | "List of definition matchers for creating an Imenu index. |
| 191 | Each element of this list should have the form | ||
| 192 | |||
| 193 | (MENU-TITLE REGEXP INDEX [FUNCTION] [ARGUMENTS...]) | ||
| 194 | |||
| 195 | MENU-TITLE should be nil (in which case the matches for this | ||
| 196 | element are put in the top level of the buffer index) or a | ||
| 197 | string (which specifies the title of a submenu into which the | ||
| 198 | matches are put). | ||
| 199 | REGEXP is a regular expression matching a definition construct | ||
| 200 | which is to be displayed in the menu. REGEXP may also be a | ||
| 201 | function, called without arguments. It is expected to search | ||
| 202 | backwards. It must return true and set `match-data' if it finds | ||
| 203 | another element. | ||
| 204 | INDEX is an integer specifying which subexpression of REGEXP | ||
| 205 | matches the definition's name; this subexpression is displayed as | ||
| 206 | the menu item. | ||
| 207 | FUNCTION, if present, specifies a function to call when the index | ||
| 208 | item is selected by the user. This function is called with | ||
| 209 | arguments consisting of the item name, the buffer position, and | ||
| 210 | the ARGUMENTS. | ||
| 211 | |||
| 212 | The variable `imenu-case-fold-search' determines whether or not | ||
| 213 | the regexp matches are case sensitive, and `imenu-syntax-alist' | ||
| 214 | can be used to alter the syntax table for the search. | ||
| 191 | 215 | ||
| 192 | If non-nil this pattern is passed to `imenu--generic-function' to | 216 | If non-nil this pattern is passed to `imenu--generic-function' to |
| 193 | create a buffer index. Look there for the documentation of this | 217 | create a buffer index. |
| 194 | pattern's structure. | ||
| 195 | 218 | ||
| 196 | For example, see the value of `fortran-imenu-generic-expression' used by | 219 | For example, see the value of `fortran-imenu-generic-expression' |
| 197 | `fortran-mode' with `imenu-syntax-alist' set locally to give the | 220 | used by `fortran-mode' with `imenu-syntax-alist' set locally to |
| 198 | characters which normally have \"symbol\" syntax \"word\" syntax | 221 | give the characters which normally have \"symbol\" syntax |
| 199 | during matching.") | 222 | \"word\" syntax during matching.") |
| 200 | ;;;###autoload(put 'imenu-generic-expression 'risky-local-variable t) | 223 | ;;;###autoload(put 'imenu-generic-expression 'risky-local-variable t) |
| 201 | 224 | ||
| 202 | ;;;###autoload | 225 | ;;;###autoload |
| @@ -694,46 +717,16 @@ for modes which use `imenu--generic-function'. If it is not set, but | |||
| 694 | ;; so it needs to be careful never to loop! | 717 | ;; so it needs to be careful never to loop! |
| 695 | (defun imenu--generic-function (patterns) | 718 | (defun imenu--generic-function (patterns) |
| 696 | "Return an index alist of the current buffer based on PATTERNS. | 719 | "Return an index alist of the current buffer based on PATTERNS. |
| 720 | PATTERNS should be an alist which has the same form as | ||
| 721 | `imenu-generic-expression'. | ||
| 697 | 722 | ||
| 698 | PATTERNS is an alist with elements that look like this: | 723 | The return value is an alist of the form |
| 699 | (MENU-TITLE REGEXP INDEX) | ||
| 700 | or like this: | ||
| 701 | (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) | ||
| 702 | with zero or more ARGUMENTS. The former format creates a simple | ||
| 703 | element in the index alist when it matches; the latter creates a | ||
| 704 | special element of the form (INDEX-NAME POSITION-MARKER FUNCTION | ||
| 705 | ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS. | ||
| 706 | |||
| 707 | MENU-TITLE is a string used as the title for the submenu or nil | ||
| 708 | if the entries are not nested. | ||
| 709 | |||
| 710 | REGEXP is a regexp that should match a construct in the buffer | ||
| 711 | that is to be displayed in the menu; i.e., function or variable | ||
| 712 | definitions, etc. It contains a substring which is the name to | ||
| 713 | appear in the menu. See the info section on Regexps for more | ||
| 714 | information. REGEXP may also be a function, called without | ||
| 715 | arguments. It is expected to search backwards. It shall return | ||
| 716 | true and set `match-data' if it finds another element. | ||
| 717 | |||
| 718 | INDEX points to the substring in REGEXP that contains the | ||
| 719 | name (of the function, variable or type) that is to appear in the | ||
| 720 | menu. | ||
| 721 | |||
| 722 | The variable `imenu-case-fold-search' determines whether or not the | ||
| 723 | regexp matches are case sensitive, and `imenu-syntax-alist' can be | ||
| 724 | used to alter the syntax table for the search. | ||
| 725 | |||
| 726 | See `lisp-imenu-generic-expression' for an example of PATTERNS. | ||
| 727 | |||
| 728 | Returns an index of the current buffer as an alist. The elements in | ||
| 729 | the alist look like: | ||
| 730 | (INDEX-NAME . INDEX-POSITION) | 724 | (INDEX-NAME . INDEX-POSITION) |
| 731 | or like: | 725 | or |
| 732 | (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...) | 726 | (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...) |
| 733 | They may also be nested index alists like: | 727 | The return value may also consist of nested index alists like: |
| 734 | (INDEX-NAME . INDEX-ALIST) | 728 | (INDEX-NAME . INDEX-ALIST) |
| 735 | depending on PATTERNS." | 729 | depending on PATTERNS." |
| 736 | |||
| 737 | (let ((index-alist (list 'dummy)) | 730 | (let ((index-alist (list 'dummy)) |
| 738 | (case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) | 731 | (case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) |
| 739 | (not (local-variable-p 'font-lock-defaults))) | 732 | (not (local-variable-p 'font-lock-defaults))) |