felko / neuron-mode

An emacs mode for editing Zettelkasten notes with neuron

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request: jump back in history to previous zettel

evanrichter opened this issue · comments

In doom-emacs, C-o is mapped to better-jumper-jump-backward which has the behavior similar to a browser's back button. It will jump the cursor back to previous search results, or any location the cursor was previously, even in another buffer or file. This doesn't work when traversing zettels in neuron-mode.

What I expect to happen in a history of: (previous file to neuron-mode) -> enter neuron-mode with index.md -> follow link to "thing" zettel at 12345.md -> search for text "text" and jump to first result -> jump second result of "text" -> follow link to "text" zettel.

I would expect C-o, or any command that I can map to C-o in neuron-mode, to be able to exactly reverse this history.

Currently, only moving backward in searches works, without regard to zettel history. If it's possible, making better-jumper-jump-backward aware of the forward jump when user follows a zettel link should fix the behavior.

commented

Thank you for the idea.
While thinking about how to implement this, I thought it would also be useful to display in the minibuffer the "trail" of zettels. This way you can see to which zettel will C-o bring you back, and it also allows to visualize the "line of thought" when browsing the zettelkasten.

Absolutely, I like the idea of breadcrumbs as they are called elsewhere. If at all possible, the best case would be to simply add the zettel jump to the history, interleaved into the history of other jump locations like searches.

IIRC, SPC , in doom-emacs shows recently opened files. Something like that which also shows the zettel title would be nice.

commented

If at all possible, the best case would be to simply add the zettel jump to the history, interleaved into the history of other jump locations like searches.

Sorry, I misunderstood then. This should be achievable without changing neuron-mode at all (though I like the idea of breadcrumbs anyway). Maybe it's just my config, but I can't make sense of better-jumper-jump-backward, as it doesn't always take me back to the previous location. If it is indeed just my particular config, that I managed to mess up somehow, then adding the following hook should work:

(add-hook 'neuron-mode-hook #'better-jumper-set-jump)

But I'm not sure why better-jump isn't doing this automatically, since it is enabled globally by default in doom.

another way to communicate it: any time your cursor jumps to a new location (e.g. text search and jump two results forward, LSP "jump to definition", switch to buffer 2, etc) the previous location is added to the trail of breadcrumbs that can be backwards traversed with C-o. My "bug report" then, is simply when following a neuron link, the previous location wasn't being added to that breadcrumb trail as expected.

anyway, I will try out that configuration! and certainly go for the visual neuron breadcrumbs indicator, I think that would be a useful addition!

commented

I talked with a maintainer (I think) of better-jumper and the right way of doing this in doom would be:

(advice-add 'neuron-follow-thing-at-point :around #'doom-set-jump-a)

Since tracking the breadcrumbs already provides a mechanism for jumping forward/backward from a zettel to another, I will still provide this feature from neuron-mode, but better-jumper users will be able to advise better-jumper-jump-backward and better-jumper-jump-forward to show the breadcrumbs (currently being implemented) which will work as expected.