GNU bug report logs -
#14029
24.2.50; [PATCH] imenu problems with special elements
Previous Next
Reported by: Andreas Politz <politza <at> fh-trier.de>
Date: Fri, 22 Mar 2013 01:27:02 UTC
Severity: normal
Tags: patch
Found in version 24.2.50
Fixed in version 24.4
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 14029 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Changelog:
* imenu.el (imenu--subalist-p): Don't error on non-conses and
allow non-lambda lists as functions.
In my opinion a predicate should not throw an error. Anyway more
important is the `non-lambda' lists part.
(imenu--index-alist): Don't recurse into non-subalists.
Looking at the commentary, the ability to embed functions in a menu has
clearly been added after this functions was written.
(imenu): Don't pass function itself as an argument.
,----[ C-h v (describe-variable 'imenu-generic-expression) RET ]
| Each element of this list should have the form
|
| (MENU-TITLE REGEXP INDEX [FUNCTION] [ARGUMENTS...])
|
| FUNCTION, if present, specifies a function to call when the index
| item is selected by the user. This function is called with
| arguments consisting of the item name, the buffer position, and
| the ARGUMENTS.
`----
(cddr index-item) == (FUNCTION . ARGS), is wrong as argument list, we
need one more cdr.
* doc/lispref/modes.texi: Make it clear that sub-alist is the cdr.
-ap
[imenu.patch (text/x-diff, inline)]
=== modified file 'doc/lispref/modes.texi'
*** doc/lispref/modes.texi 2013-08-17 11:14:10 +0000
--- doc/lispref/modes.texi 2013-11-25 00:39:51 +0000
***************
*** 2483,2489 ****
A nested sub-alist element looks like this:
@example
! (@var{menu-title} @var{sub-alist})
@end example
It creates the submenu @var{menu-title} specified by @var{sub-alist}.
--- 2483,2489 ----
A nested sub-alist element looks like this:
@example
! (@var{menu-title} . @var{sub-alist})
@end example
It creates the submenu @var{menu-title} specified by @var{sub-alist}.
=== modified file 'lisp/ChangeLog'
*** lisp/ChangeLog 2013-11-24 22:53:35 +0000
--- lisp/ChangeLog 2013-11-25 00:45:59 +0000
***************
*** 1,3 ****
--- 1,10 ----
+ 2013-11-22 Andreas Politz <politza <at> fh-trier.de>
+ * imenu.el (imenu--subalist-p): Don't error on non-conses and
+ allow non-lambda lists as functions.
+ (imenu--index-alist): Don't recurse into non-subalists.
+ (imenu): Don't pass function itself as an argument.
+ * doc/lispref/modes.texi: Make it clear that sub-alist is the cdr.
+
2013-11-24 Simon Schubert <2 <at> 0x2c.org> (tiny change)
* json.el (json-alist-p): Only return non-nil if the alist has
=== modified file 'lisp/imenu.el'
*** lisp/imenu.el 2013-11-24 21:23:47 +0000
--- lisp/imenu.el 2013-11-25 01:26:34 +0000
***************
*** 293,300 ****
(defun imenu--subalist-p (item)
! (and (consp (cdr item)) (listp (cadr item))
! (not (eq (car (cadr item)) 'lambda))))
(defmacro imenu-progress-message (_prevpos &optional _relpos _reverse)
"Macro to display a progress message.
--- 293,302 ----
(defun imenu--subalist-p (item)
! (and (consp item)
! (consp (cdr item))
! (listp (cadr item))
! (not (functionp (cadr item)))))
(defmacro imenu-progress-message (_prevpos &optional _relpos _reverse)
"Macro to display a progress message.
***************
*** 645,653 ****
;; (INDEX-NAME (INDEX-NAME . INDEX-POSITION) ...)
;; while a bottom-level element looks like
;; (INDEX-NAME . INDEX-POSITION)
;; We are only interested in the bottom-level elements, so we need to
! ;; recurse if TAIL is a list.
! (cond ((listp tail)
(if (setq res (imenu--in-alist str tail))
(setq alist nil)))
((if imenu-name-lookup-function
--- 647,657 ----
;; (INDEX-NAME (INDEX-NAME . INDEX-POSITION) ...)
;; while a bottom-level element looks like
;; (INDEX-NAME . INDEX-POSITION)
+ ;; or
+ ;; (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
;; We are only interested in the bottom-level elements, so we need to
! ;; recurse if TAIL is a nested ALIST.
! (cond ((imenu--subalist-p elt)
(if (setq res (imenu--in-alist str tail))
(setq alist nil)))
((if imenu-name-lookup-function
***************
*** 1033,1040 ****
(nth 2 index-item) imenu-default-goto-function))
(position (if is-special-item
(cadr index-item) (cdr index-item)))
! (rest (if is-special-item (cddr index-item))))
! (apply function (car index-item) position rest))
(run-hooks 'imenu-after-jump-hook)))
(provide 'imenu)
--- 1037,1044 ----
(nth 2 index-item) imenu-default-goto-function))
(position (if is-special-item
(cadr index-item) (cdr index-item)))
! (args (if is-special-item (cdr (cddr index-item)))))
! (apply function (car index-item) position args))
(run-hooks 'imenu-after-jump-hook)))
(provide 'imenu)
This bug report was last modified 11 years and 181 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.