unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: [imenu.el] Attempt to fix broken imenu--generic-function
Date: Wed, 18 Jul 2018 01:14:20 +0300	[thread overview]
Message-ID: <m2a7qp5x37.fsf@fastmail.fm> (raw)
In-Reply-To: <5bda37af-3edd-4938-8ba4-ad6e04032e69@default> (Drew Adams's message of "Tue, 17 Jul 2018 13:55:27 -0700 (PDT)")

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 <drew.adams@oracle.com>
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	other threads:[~2018-07-17 22:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 20:34 [imenu.el] Attempt to fix broken imenu--generic-function Filipp Gunbin
2018-07-17 20:55 ` Drew Adams
2018-07-17 22:14   ` Filipp Gunbin [this message]
2018-07-17 23:18     ` Drew Adams
2018-07-18  2:38       ` Eli Zaretskii
2018-07-18 13:12       ` Filipp Gunbin
     [not found]     ` <<03bf24b4-7040-451d-9a98-e02315b33f91@default>
     [not found]       ` <<83a7qp6zg5.fsf@gnu.org>
2018-07-18  4:36         ` Drew Adams
2018-07-18  5:01           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2a7qp5x37.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).