felko / neuron-mode

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

[FR] Add `title` method to neuron-id-format #47

Closed NightMachinery closed 4 years ago

NightMachinery commented 4 years ago

This can use the first title with which the zettle is created, or it can keep the id and the title in sync (which would be cooler but more complex).

felko commented 4 years ago

Hello, thanks for the suggestion.

I could implement this by allowing neuron-id-format to be set to a function which would be called using the ID and title. This would cover virtually every possible use cases, since users might want both the title and ID in the file name (e.g. to avoid collision with zettels having the same title), or even want to format the title so that it is slugged, etc...

In general, I would recommend using the IDs and nothing else. The point of this is that you can rename without any additional work, though using titles in the file names can be used for small and rarely changing zettelkastens, e.g. for documentations. In "knowledge base" zettelkastens, I would argue this is a very bad idea.

Syncing the ID and the title would solve this issue, but I have no idea how to implement this efficiently. I think this should be implemented neuron side, or maybe as a separate tooling, instead of neuron-mode.

felko commented 4 years ago

I have partly implemented this in https://github.com/felko/neuron-mode/commit/6cf3475ed778784fe127a755a3213cf7eabac920 If a function is assigned to neuron-id-format, it only takes the title as an argument, and not the ID. This is because the ID generation logic is handled by neuron itself, at the same time that it creates the file. I'm closing this for now because I don't think I can do better (without doing something that feels like a hack), so I leave @srid decide whether the neuron CLI should allow generating an ID alone without creating a new file.