Customise the ${slug}

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."
1 Like

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 :slight_smile:

No worries. Don’t find these annoying :slight_smile:

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).

  1. M-x customize
    And search for Org Roam in the search box.
    And then find the string you are looking for.

  2. Read source
    Easy to navigate via C-h f (functions) or C-h v (variables) to the main .el file—for Org-roam, org-roam.el. Look for defcustom, 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.

  3. 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!

1 Like