[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add new option 'org-imenu-flatten'
From: |
Morgan Smith |
Subject: |
[PATCH] Add new option 'org-imenu-flatten' |
Date: |
Thu, 7 Dec 2023 15:52:26 -0500 |
* 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
- [PATCH] Add new option 'org-imenu-flatten',
Morgan Smith <=
- Re: [PATCH] Add new option 'org-imenu-flatten', Ihor Radchenko, 2023/12/08
- Re: [PATCH] Add new option 'org-imenu-flatten', Morgan Smith, 2023/12/08
- Re: [PATCH] Add new option 'org-imenu-flatten', William Denton, 2023/12/08
- [FR] Allow flattened imenu index (was: [PATCH] Add new option 'org-imenu-flatten'), Ihor Radchenko, 2023/12/09
- Re: [FR] Allow flattened imenu index (was: [PATCH] Add new option 'org-imenu-flatten'), Eli Zaretskii, 2023/12/09
- Re: [FR] Allow flattened imenu index (was: [PATCH] Add new option 'org-imenu-flatten'), Ihor Radchenko, 2023/12/09
- Re: [FR] Allow flattened imenu index, Juri Linkov, 2023/12/09
- Re: [FR] Allow flattened imenu index, João Távora, 2023/12/11
- Re: [FR] Allow flattened imenu index, Juri Linkov, 2023/12/11
- Re: [FR] Allow flattened imenu index, João Távora, 2023/12/11