From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.bugs Subject: bug#14029: 24.2.50; [PATCH] imenu problems with special elements Date: Mon, 25 Nov 2013 02:32:33 +0100 Message-ID: <878uwdmfke.fsf@hochschule-trier.de> References: <87hak4gram.fsf@fh-trier.de> <5ABDF35DFCF64DEEAA37AFAE5048578D@us.oracle.com> <87ip4iwfoe.fsf@fh-trier.de> <878v5ew1pp.fsf@fh-trier.de> <87iovhqrve.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1385343193 18846 80.91.229.3 (25 Nov 2013 01:33:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Nov 2013 01:33:13 +0000 (UTC) Cc: 14029@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 25 02:33:18 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vkl35-0001kO-Tp for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Nov 2013 02:33:16 +0100 Original-Received: from localhost ([::1]:49192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkl35-0005kB-Hk for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Nov 2013 20:33:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkl2x-0005jy-Or for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2013 20:33:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vkl2s-0005zx-PI for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2013 20:33:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkl2s-0005zs-FM for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2013 20:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vkl2s-0002WY-7E for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2013 20:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Nov 2013 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14029 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 14029-submit@debbugs.gnu.org id=B14029.13853431809694 (code B ref 14029); Mon, 25 Nov 2013 01:33:02 +0000 Original-Received: (at 14029) by debbugs.gnu.org; 25 Nov 2013 01:33:00 +0000 Original-Received: from localhost ([127.0.0.1]:43082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vkl2p-0002WH-C8 for submit@debbugs.gnu.org; Sun, 24 Nov 2013 20:33:00 -0500 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:54341) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vkl2l-0002Vz-NS for 14029@debbugs.gnu.org; Sun, 24 Nov 2013 20:32:57 -0500 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier] Original-Received: from luca (dslb-178-004-033-213.pools.arcor-ip.net [178.4.33.213]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id AED971788D49; Mon, 25 Nov 2013 02:32:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1385343154; bh=ATf8pXWp9VR+REGfU3kaSNqbghM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type; b=pA834ETZb0raVEP14hfuL6P6iCyrxFfsAoHnLggA0sI3thcNBbdtnM7nAsgX5xcLV H8I00F37aY0Wh4hHpmxQy0ns9qLFeKI5rwbe3rxhHrW+mb8UV/lKlvcaxZ9lGI/SX4 F9is2hGAMKiN67YJrZAPDuW076ZhkKlwB+PZKfTo= Original-Received: from politza by luca with local (Exim 4.72) (envelope-from ) id 1Vkl2P-0007GZ-Ui; Mon, 25 Nov 2013 02:32:33 +0100 In-Reply-To: <87iovhqrve.fsf@yandex.ru> (Dmitry Gutov's message of "Mon, 25 Nov 2013 01:53:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80927 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=imenu.patch === 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 + * 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@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) --=-=-=--