Subject: bug#12717: closed (Re: bug#12717: 24.2.50; [PATCH] `imenu--split-submenus' incorrectly distinguishes submenus)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 15 Nov 2012 02:05:02 +0000

Your bug report

#12717: 24.2.50; [PATCH] `imenu--split-submenus' incorrectly distinguishes submenus

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
12717: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12717
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#12717: 24.2.50; [PATCH] `imenu--split-submenus' incorrectly distinguishes submenus
From: Stefan Monnier <[email-masked]>
To: "Drew Adams" <[email-masked]>
Cc: [email-masked]
Date: Wed, 14 Nov 2012 21:03:33 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> 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?

Well, I installed it in trunk, it looks safe enough there,

        Stefan

Subject: 24.2.50; [PATCH] `imenu--split-submenus' incorrectly distinguishes submenus
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Tue, 23 Oct 2012 17:07:11 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Imenu allows the use of something it calls "special" menu elements,
which have this form: (INDEX-NAME POSITION FUNCTION ARGUMENTS...)
 
`imenu--split-submenus' needs to distinguish submenus from ordinary menu
elements, including from special menu elements.  Currently this is
bugged.
 
The current code for `imenu--split-submenus' does this:
 
(defun imenu--split-submenus (alist)
  "..."
  (mapcar (lambda (elt)
            (if (and (consp elt) (stringp (car elt)) (listp (cdr elt)))
                (imenu--split-menu (cdr elt) (car elt))
              elt))
   alist))
 
The `if' condition should instead test whether the element is a submenu.
We have a function that does that: `imenu--subalist-p'.  I believe this
is the correct code:
 
(defun imenu--split-submenus (alist)
  "..."
  (mapcar (lambda (elt)
            (if (imenu--subalist-p elt)
                (imenu--split-menu (cdr elt) (car elt))
              elt))
   alist))

In GNU Emacs 24.2.50.1 (i386-mingw-nt5.1.2600)
 of 2012-10-22 on DANI-PC
Bzr revision: 110618 [email-masked]
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.7) --no-opt --enable-checking --cflags
 -I../../libs/libxpm-3.5.8/include -I../../libs/libxpm-3.5.8/src
 -I../../libs/libpng-1.4.10 -I../../libs/zlib-1.2.6
 -I../../libs/giflib-4.1.4-1/include -I../../libs/jpeg-6b-4/include
 -I../../libs/tiff-3.8.2-1/include
 -I../../libs/libxml2-2.7.8-w32-bin/include/libxml2
 -I../../libs/gnutls-3.0.16/include
 -I../../libs/libiconv-1.14-2-mingw32-dev/include'