Is there a way to customise the ${slug}
element of the capture template?
Looks like you can define your own function, and set this customizing variable to use it.
(defcustom org-roam-title-to-slug-function #'org-roam--title-to-slug
"Function to be used in converting a title to the filename slug.
Function should return a filename string based on title."
Thanks - that’s perfect. May I ask how you found this? I assume it’s discoverable in Emacs in some way, and I figure that if I can know how to discover such things I’ll ask fewer annoying questions
No worries. Don’t find these annoying
For user options, two or three ways. For Org-roam, I usually start with reading source (Option 2 below) these days (as I have read its source so many times).
-
M-x customize
And search for Org Roam in the search box.
And then find the string you are looking for.
-
Read source
Easy to navigate viaC-h f
(functions) orC-h v
(variables) to the main.el
file—for Org-roam,org-roam.el
. Look fordefcustom
, which is a macro to define a customizing variable. As Emacs convention, customizing variables usually appear at the beginning of the source, so you can look through them to have a feel of what sort of things are designed to be customizable.You can usually expect the documentation string (the text between “” added as part of the
defcustom
definition) to be a good guide. In addition, I also look for places where the variable is used. I just search the text string in the source. Alternatively,helpful-variable
gives you “where used” search—I don’t use it often, but might be useful.
-
Read user manual
C-h i
. Org-roam has an in-system user manual. For the case of slug config, it does not seem to be on the manual. But usually, I try to glance through at least the main chapters of the manual to have a feel of the package.
That’s super helpful - thank you!
Is it still possible to do this in v2?
I no longer see org-roam-title-to-slug-function
in the code - only org-roam-node-slug
, and I’m not sure this is customisable.
No, I didn’t think so. I thought there was a comment from Jethro about it in this Discourse or Slack. I suggest you search – if I recall correctly, you would need to provide an advice function and vaguely remember someone provided a sample code. It could have been a GitHub issue. One of these places.
Thank you for the pointer
I have found some discussion here: Customization for character replacement generated slug by aruscher · Pull Request #1544 · org-roam/org-roam · GitHub
It looks like the suggestion is to override the whole org-roam-node-slug
function.
Would it be alright for you to add this to the wiki (or anyone who feel up for it) by any chance?
I feel that the solution would benefit many people.
I have added it in: Hitchhiker's Rough Guide to Org roam V2 · org-roam/org-roam Wiki · GitHub
Thank you