emacs-devel
[Top][All Lists]
Advanced

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

Re: master 431f8ff1e38: * lisp/imenu.el: Support more values for imenu-f


From: Juri Linkov
Subject: Re: master 431f8ff1e38: * lisp/imenu.el: Support more values for imenu-flatten (bug#70846)
Date: Fri, 09 Aug 2024 09:59:40 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>> Both of these changes look like nice improvements to me :)
>
> Now the documentation change is pushed to emacs-30,
> but implementation of the 'suffix' value is problematic
> since I remembered it's ambiguous:
> https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg01224.html
> So probably need two separate suffix values.

Ok, here are two new suffix values for both variants:

  "<IDENT> <SUB-CATEGORY-TOP> <SUB-CATEGORY-BOTTOM>"
and
  "<IDENT> <SUB-CATEGORY-BOTTOM> <SUB-CATEGORY-TOP>"

diff --git a/lisp/imenu.el b/lisp/imenu.el
index 8f1b1f22a67..99d9d4a5582 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -154,6 +154,10 @@ imenu-flatten
 If the value is `prefix', pop up the completion buffer with a
 flattened menu where section names are prepended to completion
 candidates as prefixes.
+If the value is `suffix', use section names appended to completion
+candidates as suffixes.
+The value `suffix-reverse' is like `suffix', but the section names
+are in reverse order.
 If the value is `annotation', annotate each completion candidate
 with a suffix that is the section name to which it belongs.
 If the value is `group', split completion candidates into groups
@@ -168,6 +172,8 @@ imenu-flatten
 names of completion candidates."
   :type '(choice (const :tag "Show nested list" nil)
                  (const :tag "Flat list with sections as prefix" prefix)
+                 (const :tag "Flat list with sections as suffix" suffix)
+                 (const :tag "Flat list with reverse sections as suffix" 
suffix-reverse)
                  (const :tag "Flat list annotated with sections" annotation)
                  (const :tag "Flat list grouped by sections" group))
   :version "30.1")
@@ -816,7 +822,9 @@ imenu--flatten-index-alist
            (pos (cdr item))
            (new-prefix (and concat-names
                             (if prefix
-                                (concat prefix imenu-level-separator name)
+                                (if (eq imenu-flatten 'suffix-reverse)
+                                     (concat name imenu-level-separator prefix)
+                                   (concat prefix imenu-level-separator name))
                               name))))
        (cond
        ((not (imenu--subalist-p item))
@@ -830,6 +838,9 @@ imenu--flatten-index-alist
                        ('group (propertize name
                                            'imenu-section (or prefix "*")
                                            'imenu-choice item))
+                       ('suffix (if prefix
+                                   (concat name imenu-level-separator prefix)
+                                 name))
                        (_ new-prefix))
                     pos)))
        (t



reply via email to

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