emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add new option 'org-imenu-flatten'
@ 2023-12-07 20:52 Morgan Smith
  2023-12-08 22:19 ` Ihor Radchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Morgan Smith @ 2023-12-07 20:52 UTC (permalink / raw)
  To: emacs-orgmode

* lisp/org/org-compat.el: Add definition of 'org-imenu-flatten'.
(org-imenu-get-tree): Use 'org-imenu-flatten'.
---

Hello!

I've been using this patch for a bit and I quite like it.  One would think
there would be an option in imenu itself to flatten trees but that does not
seem to be the case.  I copied the defcustom from 'doc-view-imenu-flatten'.

Thanks,

Morgan

 lisp/org-compat.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 2697342d6..f2112e4e9 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -1333,6 +1333,10 @@ Pass COLUMN and FORCE to `move-to-column'."
 This also applied for speedbar access."
   :type 'integer)
 
+(defcustom org-imenu-flatten nil
+  "Whether to flatten the list of sections in an imenu or show it nested."
+  :type 'boolean)
+
 ;;;; Imenu
 
 (defvar-local org-imenu-markers nil
@@ -1353,7 +1357,8 @@ This also applied for speedbar access."
 			(org-link-display-format (org-get-heading t t t t)))))
 	 (when (and (<= level org-imenu-depth) (org-string-nw-p headline))
 	   (let* ((m (point-marker))
-		  (item (propertize headline 'org-imenu-marker m 'org-imenu t)))
+		  (item (propertize headline 'org-imenu-marker m 'org-imenu t))
+                  (level (if org-imenu-flatten 1 level)))
 	     (push m org-imenu-markers)
 	     (if (>= level last-level)
 		 (push (cons item m) (aref subs level))
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-05-11  9:40 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-07 20:52 [PATCH] Add new option 'org-imenu-flatten' Morgan Smith
2023-12-08 22:19 ` Ihor Radchenko
2023-12-09  1:46   ` Morgan Smith
2023-12-09  2:01     ` William Denton
2023-12-09 10:57     ` [FR] Allow flattened imenu index (was: [PATCH] Add new option 'org-imenu-flatten') Ihor Radchenko
2023-12-09 11:28       ` Eli Zaretskii
2023-12-09 11:39         ` Ihor Radchenko
2023-12-09 17:37           ` [FR] Allow flattened imenu index Juri Linkov
2023-12-11 11:51             ` João Távora
2023-12-11 17:20               ` Juri Linkov
2023-12-11 17:40                 ` João Távora
     [not found]                 ` <cf91ddb8-7759-52be-345f-fb85eadb9717@gutov.dev>
2023-12-11 18:00                   ` João Távora
     [not found]                     ` <595d6418-71f6-eec7-e37c-e3987265364c@gutov.dev>
2023-12-11 23:10                       ` João Távora
     [not found]                         ` <303c567e-7f0d-1fac-1ab4-0099bd98d8dd@gutov.dev>
2023-12-11 23:35                           ` João Távora
     [not found]                             ` <31ede4fc-8ebe-39ac-40c5-91ba08c35178@gutov.dev>
2023-12-11 23:48                               ` João Távora
     [not found]                                 ` <7eab6e94-cb8e-9ae1-d2cd-c0eb1b3bab43@gutov.dev>
2023-12-11 23:57                                   ` João Távora
2023-12-11 19:30                 ` Ihor Radchenko
2023-12-11 23:07                   ` João Távora
2023-12-14 23:11           ` Spencer Baugh
2024-05-11  9:41   ` [PATCH] Add new option 'org-imenu-flatten' Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).