From: Samuel Wales <samologist@gmail.com>
To: Morgan Smith <Morgan.J.Smith@outlook.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines)
Date: Thu, 13 Jun 2024 23:10:48 -0700 [thread overview]
Message-ID: <CAJcAo8sf5P-Rfuoeahx67zo6wuHA5dspN-Mdbi5Xr-=ZrEzLXg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2367 bytes --]
how does imenu compare against completion systems like ido combined with
org refile set to goto? when would you use imenu vs. other completion?
On Wednesday, June 12, 2024, Morgan Smith <Morgan.J.Smith@outlook.com>
wrote:
> With a file like this:
>
> * headline 1
> ** headline 2
>
> We currently produce an imenu tree that looks like this:
>
> '(("headline 1" ("headline 2" . marker-2)))
>
> imenu has no clue where "headline 1" is located and thus the user
> can't navigate to it. With this patch installed imenu knows where
> non-leaf headlines are as the tree will now look like this:
>
> '(("headline 1" . marker-1)
> ("headline 1" ("headline 2" . marker-2)))
>
> Quirks:
>
> With the default `imenu-flatten' value of nil, it is still impossible
> to visit non-leaf headlines and no change is perceived.
>
> Setting `imenu-flatten' to 'group works as expected with the quirk
> that top level headlines don't end up in the group.
>
> Ex:
> * Headline 1
> Group is "*"
> Setting the group to "Headline 1" somehow might be nice but would
> require upstream changes in imenu.
> ** Headline 2
> Group is "Headline 1"
> *** Headline 3
> Group is "Headline 1:Headline 2"
>
> Everything seems to work as expected when `imenu-flatten' is set to
> 'prefix or 'annotation.
>
> * lisp/org-compat.el (org-imenu-get-tree): Add the current headline to
> the tree as a simple item even if it isn't a leaf.
> ---
> lisp/org-compat.el | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org-compat.el b/lisp/org-compat.el
> index d6620f962..a1152186d 100644
> --- a/lisp/org-compat.el
> +++ b/lisp/org-compat.el
> @@ -1447,8 +1447,8 @@ This also applied for speedbar access."
> (let* ((m (point-marker))
> (item (propertize headline 'org-imenu-marker m
> 'org-imenu t)))
> (push m org-imenu-markers)
> - (if (>= level last-level)
> - (push (cons item m) (aref subs level))
> + (push (cons item m) (aref subs level))
> + (unless (>= level last-level)
> (push (cons item
> (cl-mapcan #'identity (cl-subseq subs (1+
> level))))
> (aref subs level))
> --
> 2.45.1
>
>
>
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
[-- Attachment #2: Type: text/html, Size: 3090 bytes --]
next reply other threads:[~2024-06-14 6:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 6:10 Samuel Wales [this message]
2024-06-14 11:35 ` imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines) Morgan Smith
2024-06-15 7:22 ` Samuel Wales
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJcAo8sf5P-Rfuoeahx67zo6wuHA5dspN-Mdbi5Xr-=ZrEzLXg@mail.gmail.com' \
--to=samologist@gmail.com \
--cc=Morgan.J.Smith@outlook.com \
--cc=emacs-orgmode@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.