From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#12717: 24.2.50; [PATCH] `imenu--split-submenus' incorrectly distinguishes submenus Date: Mon, 29 Oct 2012 23:18:30 -0700 Message-ID: <00BA7268CCD34A4CA7D11B7F83CE61E8@us.oracle.com> References: <9212825D880B4B2581E22420DB3B53DC@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1351577984 29012 80.91.229.3 (30 Oct 2012 06:19:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2012 06:19:44 +0000 (UTC) Cc: 12717@debbugs.gnu.org To: "'Stefan Monnier'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 30 07:19:51 2012 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 1TT5Az-0005Iw-Dq for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 07:19:49 +0100 Original-Received: from localhost ([::1]:43995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TT5Ar-0001D3-5u for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 02:19:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TT5Al-0001Cx-CL for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 02:19:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TT5Ai-0000L9-My for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 02:19:35 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TT5Ai-0000L4-JQ for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 02:19:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TT5D7-0005SP-Qe for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 02:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Oct 2012 06:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12717 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12717-submit@debbugs.gnu.org id=B12717.135157806920918 (code B ref 12717); Tue, 30 Oct 2012 06:22:01 +0000 Original-Received: (at 12717) by debbugs.gnu.org; 30 Oct 2012 06:21:09 +0000 Original-Received: from localhost ([127.0.0.1]:38834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TT5CH-0005RL-Dx for submit@debbugs.gnu.org; Tue, 30 Oct 2012 02:21:09 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:25076) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TT5CE-0005RC-H6 for 12717@debbugs.gnu.org; Tue, 30 Oct 2012 02:21:07 -0400 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9U6IYGa019309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Oct 2012 06:18:35 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9U6IX3R018310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Oct 2012 06:18:34 GMT Original-Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q9U6IXfl021871; Tue, 30 Oct 2012 01:18:34 -0500 Original-Received: from dradamslap1 (/10.159.222.205) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Oct 2012 23:18:33 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac22S2SWsEbYSdf3SnyFm31qJOzVFgAGGd6Q X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:66226 Archived-At: > This looks eminently reasonable, except that I don't > understand the code enough to be sure (e.g. the current test > includes (consp elt) whereas imenu--split-menu starts right > off by calling cdr). Do you happen to have some kind of test > case? I ran into the bug when trying to make use of so-called "special" menu items. I add two general toggle items to the menus, along with the general item *Rescan*. In doing that I discovered the bug. This is the redefinition of `imenu--make-index-alist' that I use. It is here that I add two menu items: one to toggle sorting on/off, and one to toggle case-sensitivity of sorting when sorting by name. ;; REPLACE ORIGINAL in `imenu.el'. ;; ;; 1. Respect `ignore-comments-flag', if defined: ;; use `with-comments-hidden'. ;; 2. Add Imenu+ toggle commands to menu. ;; (defun imenu--make-index-alist (&optional noerror) "Create an index alist for the definitions in the current buffer. This works by using the hook function `imenu-create-index-function'. Report an error if the list is empty unless NOERROR is supplied and non-nil. If `ignore-comments-flag' is defined and non-nil, then respect it, ignoring hidden comments. See `imenu--index-alist' for the format of the index alist." (or (and imenu--index-alist (or (not imenu-auto-rescan) (and imenu-auto-rescan (> (buffer-size) imenu-auto-rescan-maxout)))) ;; Get the index; truncate if necessary (progn (setq imenu--index-alist (save-excursion (save-restriction (widen) (if (and (> emacs-major-version 20) (require 'hide-comnt nil t)) (let ((search-invisible nil)) (with-comments-hidden (point-min) (point-max) (funcall imenu-create-index-function))) (funcall imenu-create-index-function))))) (imenu--truncate-items imenu--index-alist))) (or imenu--index-alist noerror (user-error "No items suitable for an index found in this buffer")) (or imenu--index-alist (setq imenu--index-alist (list nil))) (cons imenu--rescan-item ; `*Rescan*'. (cons '("Toggle Case-Sensitive Name-Sort" IGNORE (lambda (&rest _ignore) (imenup-toggle-case-sensitive-sorting))) (cons '("Toggle Sorting" IGNORE (lambda (&rest _ignore) (imenup-toggle-sort))) imenu--index-alist)))) Clearly, adding general menu items this way is a make-do hack. I don't use the POSITION, and the functions invoked don't use any of the args. And I don't know how, using this kind of menu creation, to, for example, make the case-sensitivity toggle item inactive when the sort method is not by name. But I didn't find a better way to add ordinary, non-indexing menu items. Anyway, that's how I ran into the bug. The full code is here, FWIW: http://www.emacswiki.org/emacs-en/download/imenu%2b.el