From: Andreas Politz <politza@hochschule-trier.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 14029@debbugs.gnu.org
Subject: bug#14029: 24.2.50; [PATCH] imenu problems with special elements
Date: Mon, 25 Nov 2013 02:32:33 +0100 [thread overview]
Message-ID: <87vbzhl05s.fsf@hochschule-trier.de> (raw)
In-Reply-To: <87iovhqrve.fsf@yandex.ru> (Dmitry Gutov's message of "Mon, 25 Nov 2013 01:53:09 +0200")
[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]
Let's do that again.
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--in-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.
,----[ (info "(elisp) Imenu") ]
| Selecting a simple element has the effect of moving to position
| INDEX-POSITION in the buffer. Special elements look like this:
|
| (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
|
| Selecting a special element performs:
|
| (funcall FUNCTION
| INDEX-NAME INDEX-POSITION 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: imenu.patch --]
[-- Type: text/x-diff, Size: 3580 bytes --]
=== 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@fh-trier.de>
+ * imenu.el (imenu--subalist-p): Don't error on non-conses and
+ allow non-lambda lists as functions.
+ (imenu--in-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@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)
next prev parent reply other threads:[~2013-11-25 1:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 1:24 bug#14029: 24.2.50; [PATCH] imenu problems with special elements Andreas Politz
2013-03-22 5:12 ` Drew Adams
[not found] ` <87ip4iwfoe.fsf@fh-trier.de>
2013-03-23 15:54 ` Andreas Politz
2013-03-23 16:15 ` Drew Adams
2013-11-24 23:53 ` Dmitry Gutov
2013-11-25 1:32 ` Andreas Politz
2013-11-25 1:40 ` Andreas Politz
2013-11-25 1:32 ` Andreas Politz [this message]
2013-11-29 3:43 ` Dmitry Gutov
2013-11-29 13:36 ` Andreas Politz
2013-11-29 14:35 ` Dmitry Gutov
2013-11-29 15:34 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbzhl05s.fsf@hochschule-trier.de \
--to=politza@hochschule-trier.de \
--cc=14029@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.