* imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines)
@ 2024-06-14 6:10 Samuel Wales
2024-06-14 11:35 ` Morgan Smith
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Wales @ 2024-06-14 6:10 UTC (permalink / raw)
To: Morgan Smith; +Cc: emacs-orgmode@gnu.org
[-- 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 --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines)
2024-06-14 6:10 imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines) Samuel Wales
@ 2024-06-14 11:35 ` Morgan Smith
2024-06-15 7:22 ` Samuel Wales
0 siblings, 1 reply; 3+ messages in thread
From: Morgan Smith @ 2024-06-14 11:35 UTC (permalink / raw)
To: Samuel Wales; +Cc: emacs-orgmode@gnu.org
Samuel Wales <samologist@gmail.com> writes:
> how does imenu compare against completion systems like ido combined with org
> refile set to goto? when would you use imenu vs. other completion?
For my specific use case, all I want is a simple minibuffer completion
that offers me all the headings in the current buffer and allows me to
jump to the one I select. Something which sounds easy, but in practice
I haven't found a good solution yet.
I assume you are suggesting `C-u M-x org-refile'. This is a solution I
haven't seen before. Being the refile command doesn't make it an
intuitive solution and I wonder if users would be able to find this
easily (I wasn't able to).
In order to get completion for subheadings I had to add this to my
configuration file:
`(setopt org-refile-targets '((nil . (:maxlevel . 5))))'
I'm actually quite pleased with this interface and it is really nice.
It is exactly what I'm trying to get from imenu.
My only gripe is that it is org specific whereas imenu isn't. If I get
imenu working the way I like, then I'll benefit in other modes as well.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines)
2024-06-14 11:35 ` Morgan Smith
@ 2024-06-15 7:22 ` Samuel Wales
0 siblings, 0 replies; 3+ messages in thread
From: Samuel Wales @ 2024-06-15 7:22 UTC (permalink / raw)
To: Morgan Smith; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
if i am not mistaken, imenu only works for a single buffer, while org
refile goto can go to any file configured for it.
at least, i /think/ imenu cannot be configured to, for example, find a
shell function definition that is not in the current file. for example,
you might be in a script called myscript1, with a call like "myscript2
myfunc", where myscript2 is a script that defines myfunc and calls it when
its first argument is it. if htat made sense.... then again maybe xref
and dumb-jump cannot either. i have not investigated.
--
The Kafka Pandemic
A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com
[-- Attachment #2: Type: text/html, Size: 809 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-15 7:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 6:10 imenu vs. refile goto (was Re: [PATCH] lisp/org-compat.el: Allow using imenu to visit non-leaf headlines) Samuel Wales
2024-06-14 11:35 ` Morgan Smith
2024-06-15 7:22 ` Samuel Wales
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).