bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14029: 24.2.50; [PATCH] imenu problems with special elements


From: Andreas Politz
Subject: bug#14029: 24.2.50; [PATCH] imenu problems with special elements
Date: Mon, 25 Nov 2013 02:32:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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

=== 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  <address@hidden>
+       * 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  <address@hidden>  (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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]