felko / neuron-mode

An emacs mode for editing Zettelkasten notes with neuron
GNU General Public License v3.0
119 stars 21 forks source link

Quick selecting of a recently chosen zettelkasten #10

Closed srid closed 4 years ago

srid commented 4 years ago

I have been using neuron-select-zettelkasten to switch between multiple zettelkastens. Each time, this command prompts me to enter the full path (doom-emacs' auto-completion makes this comfortable).

It would be nice if there was command (neuron-switch-zettelkasten?) that gave me a list of recently selected zettelkastens. That would be a faster way to switch.

Just like counsel-recentf behaves.

felko commented 4 years ago

Yeah that was my idea in #2, but I thought switching would be rare. I have no idea how to implement this, I'll investigate how counsel-recentf works.

srid commented 4 years ago

SPC p p (projectile-switch-project) works like this.

pjones commented 4 years ago

I think that neuron-zettelkasten should be a function and not a variable. It would first check to see if default-directory is a zettelkasten and if so use it. Otherwise fall back on neuron-default-zettelkasten-directory.

In a similar fashion, neuron-default-zettelkasten-directory should be settable to a directory path (like how it is now) or a user-supplied function that returns a directory path. This would allow the user to decide what directory to use if neuron-zettelkasten can't figure it out automatically.

felko commented 4 years ago

Yeah that would be an easy way to implement it. To detect the current zettelkasten root, we could also wait for https://github.com/srid/neuron/issues/161 which could provide a command to get the zettelkasten's root from the current directory, like git rev-parse --show-toplevel. But for now, the hierarchy could be recursively traversed upwards until a file named neuron.dhall is detected.

felko commented 4 years ago

This has been implemented in https://github.com/felko/neuron-mode/commit/60be5c1740385a2b1cb92c83931494667fb1da3c, neuron-select-zettelkasten is now deprecated. The detection of the zettelkasten is achieved by traversing upwards the directory tree until a neuron.dhall file is found. When no neuron.dhall file is found, it choses neuron-default-zettelkasten-directory. The zettel cache is refreshed accordingly.