ymherklotz / emacs-zettelkasten

Simple zettelkasten mode for emacs. Mirror of https://sr.ht/~ymherklotz/emacs-zettelkasten/
https://sr.ht/~ymherklotz/emacs-zettelkasten/
GNU General Public License v3.0
58 stars 3 forks source link

Allow custom IDs on zettelkasten #6

Open rockstorm101 opened 2 years ago

rockstorm101 commented 2 years ago

Hi thanks for this mode. I'm trying to use the basic zettelkasten mode with markdown files instead of org files. It works good but I wish I could use custom IDs instead of the default date-based IDs . Would it be possible to add it as another option to zettelkasten-create-new-note? The same way it asks for a title and a parent note, could it ask for a custom ID? And if left blank then the auto-generated date-based one would be used.

(For context, I've got notes with the "original" ID system where notes are named like '12a3b'. I can easily fix the use of alphanumeric IDs instead of the default pure numeric ones but adding the functionality that I'm requesting here is above my elisp level)

ymherklotz commented 2 years ago

Yeah that actually would be a useful feature, I'll probably be able to quickly add it. I do prefer the custom ID to the date ID now, and am mostly using that inside of org-zettelkasten.el.

ymherklotz commented 2 years ago

Let me know if this addresses your issue, I've added a new function called zettelkasten-create-new-custom-note now which does this. However, I haven't tested yet if the custom-id integrates well with everything else.

rockstorm101 commented 2 years ago

Hi @ymherklotz, thanks a lot for your quick response. I've tested your custom-id-support branch and it works great. Only thing I would add is a key-map for that function like maybe (define-key map "c" #'zettelkasten-create-new-custom-note).

I made some tweaks to this mode in this branch so it adheres fully to my workflow and setup. I'd be happy to submit any or all of them as PRs if you would accept them. Let me know what you think.

ymherklotz commented 2 years ago

That looks great, happy to accept something like that as a PR, I wanted the mode to work for most kinds of setups, so this is great. Some people might still want to use the Org version too, so my suggestion would be to add those changes you made as options, as was already done with the link formats and ID format to some extent:

https://github.com/ymherklotz/emacs-zettelkasten/blob/cfa7ecdb4835bb61f8900866a86998a2651e8621/zettelkasten.el#L58-L61

So something like:

(defcustom zettelkasten-id-regexp "[0-9]+"
  "Regexp for IDs."
  :type 'string
  :group 'zettelkasten)

So that you can then set it to:

(setq zettelkasten-id-regexp "[a-zA-Z0-9]+")

You can even do something similar with the YAML patch. Let me know if you are happy with doing something like that, otherwise when I have time this week I can work on that too, now that I know what more you'd like to configure.

ymherklotz commented 2 years ago

And about the keybinding, I could add a default, but was also thinking about just leaving it like that, so that you can add:

(define-key zettelkasten-mode-map "c" #'zettelkasten-create-new-custom-note)

locally.

rockstorm101 commented 2 years ago

Thanks a lot again for looking into this.

Some people might still want to use the Org version too, so my suggestion would be to add those changes you made as options, as was already done with the link formats and ID format to some extent:

Absolutely, that's way more elegant and customisable than my quick and dirty fix. I'll give it a go.

You can even do something similar with the YAML patch. Let me know if you are happy with doing something like that, otherwise when I have time this week I can work on that too, now that I know what more you'd like to configure.

I'm not overly familiar/comfortable with elisp so it'll probably take you way less time to implement any of this than me. I don't currently see an easy way to implement the customisable metadata section so please go ahead and implement it yourself if you wish. All these little tweaks I consider them a bit too niche so don't worry if you don't want to spend too much time on them. Only the custom ID feature seemed relevant enough for me to submit a feature request for it.

Thanks once again for your time and effort.