aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-08-05 22:14:54 +0800
committerChong Yidong2012-08-05 22:14:54 +0800
commitb7ccbdc2e39ff834a03a7f30516b71cd98e84a44 (patch)
tree709716de67fb79a23bf4e78346dabf808b3310fb
parentd32e47aff6cc01e3ccdfdf5e8f163f8a52285a75 (diff)
downloademacs-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/ChangeLog9
-rw-r--r--lisp/emacs-lisp/lisp-mode.el7
-rw-r--r--lisp/imenu.el77
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 @@
12012-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
12012-08-05 Vegard Øye <vegard_oye@hotmail.com> (tiny change) 102012-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.
191Each element of this list should have the form
192
193 (MENU-TITLE REGEXP INDEX [FUNCTION] [ARGUMENTS...])
194
195MENU-TITLE should be nil (in which case the matches for this
196element are put in the top level of the buffer index) or a
197string (which specifies the title of a submenu into which the
198matches are put).
199REGEXP is a regular expression matching a definition construct
200which is to be displayed in the menu. REGEXP may also be a
201function, called without arguments. It is expected to search
202backwards. It must return true and set `match-data' if it finds
203another element.
204INDEX is an integer specifying which subexpression of REGEXP
205matches the definition's name; this subexpression is displayed as
206the menu item.
207FUNCTION, if present, specifies a function to call when the index
208item is selected by the user. This function is called with
209arguments consisting of the item name, the buffer position, and
210the ARGUMENTS.
211
212The variable `imenu-case-fold-search' determines whether or not
213the regexp matches are case sensitive, and `imenu-syntax-alist'
214can be used to alter the syntax table for the search.
191 215
192If non-nil this pattern is passed to `imenu--generic-function' to 216If non-nil this pattern is passed to `imenu--generic-function' to
193create a buffer index. Look there for the documentation of this 217create a buffer index.
194pattern's structure.
195 218
196For example, see the value of `fortran-imenu-generic-expression' used by 219For example, see the value of `fortran-imenu-generic-expression'
197`fortran-mode' with `imenu-syntax-alist' set locally to give the 220used by `fortran-mode' with `imenu-syntax-alist' set locally to
198characters which normally have \"symbol\" syntax \"word\" syntax 221give the characters which normally have \"symbol\" syntax
199during 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.
720PATTERNS should be an alist which has the same form as
721`imenu-generic-expression'.
697 722
698PATTERNS is an alist with elements that look like this: 723The return value is an alist of the form
699 (MENU-TITLE REGEXP INDEX)
700or like this:
701 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
702with zero or more ARGUMENTS. The former format creates a simple
703element in the index alist when it matches; the latter creates a
704special element of the form (INDEX-NAME POSITION-MARKER FUNCTION
705ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS.
706
707MENU-TITLE is a string used as the title for the submenu or nil
708if the entries are not nested.
709
710REGEXP is a regexp that should match a construct in the buffer
711that is to be displayed in the menu; i.e., function or variable
712definitions, etc. It contains a substring which is the name to
713appear in the menu. See the info section on Regexps for more
714information. REGEXP may also be a function, called without
715arguments. It is expected to search backwards. It shall return
716true and set `match-data' if it finds another element.
717
718INDEX points to the substring in REGEXP that contains the
719name (of the function, variable or type) that is to appear in the
720menu.
721
722The variable `imenu-case-fold-search' determines whether or not the
723regexp matches are case sensitive, and `imenu-syntax-alist' can be
724used to alter the syntax table for the search.
725
726See `lisp-imenu-generic-expression' for an example of PATTERNS.
727
728Returns an index of the current buffer as an alist. The elements in
729the alist look like:
730 (INDEX-NAME . INDEX-POSITION) 724 (INDEX-NAME . INDEX-POSITION)
731or like: 725or
732 (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...) 726 (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
733They may also be nested index alists like: 727The return value may also consist of nested index alists like:
734 (INDEX-NAME . INDEX-ALIST) 728 (INDEX-NAME . INDEX-ALIST)
735depending on PATTERNS." 729depending 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)))