emacs-devel
[Top][All Lists]
Advanced

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

Re: [imenu.el] Attempt to fix broken imenu--generic-function


From: Filipp Gunbin
Subject: Re: [imenu.el] Attempt to fix broken imenu--generic-function
Date: Wed, 18 Jul 2018 01:14:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin)

On 17/07/2018 13:55 -0700, Drew Adams wrote:

>> Drew, I'm sorry, your commit 77166e0da2d58f2f6436989b7059d913be5b3439
>> broke imenu.  Do you have objections for this fix?
>
> Sorry, but I have no idea what you're talking about.
> I haven't committed anything.
>
> Is this about some Emacs bug?  If so, what bug #?
>
> Can you please specify what was broken, how/why, etc.?
>
> Thx.

Yes, it's in emacs master (emacs-devel list is in CC).  I gave commit
hash (77166e0da2d58f2f6436989b7059d913be5b3439).

Below is the relevant diff of your change.

What is broken: result of nconc is no longer returned from the function.
And, it's unclear why test `(consp (car index-alist))' before filtering
empty menus - by this time main-element is already "spliced" into the
index-alist, so index-alist element may be a usual element (INDEX-NAME
. INDEX-POSITION) or nested index alist (INDEX-NAME . INDEX-ALIST).  So
the test appears obscure.

That results in imenu errors.

My fix attempts to preseve the behavior you added, while fixing that.
I'm not attaching the diff again, it's in the previous message.


commit 77166e0da2d58f2f6436989b7059d913be5b3439
Author: Drew Adams <address@hidden>
Date:   Sat Jul 7 19:20:45 2018 +0300

    Fix 2 minor bugs in 'imenu--generic-function'
    
    * lisp/imenu.el (imenu--generic-function): Move point to START
    before checking whether the current item is inside a comment
    or a string.  Remove any empty menus that could have been
    added before returning.  (Bug#32024)

diff --git a/lisp/imenu.el b/lisp/imenu.el
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -828,9 +830,15 @@
          (set-syntax-table old-table)))
     ;; Sort each submenu by position.
     ;; This is in case one submenu gets items from two different regexps.
     (dolist (item index-alist)
       (when (listp item)
        (setcdr item (sort (cdr item) 'imenu--sort-by-position))))
     (let ((main-element (assq nil index-alist)))
       (nconc (delq main-element (delq 'dummy index-alist))
-            (cdr main-element)))))
+             (cdr main-element)))
+    ;; Remove any empty menus.  That can happen because of skipping
+    ;; things inside comments or strings.
+    (when (consp (car index-alist))
+      (setq index-alist  (cl-delete-if-not
+                          (lambda (it) (cdr it))
+                          index-alist)))))




reply via email to

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