0

I'm not yet interested in using Zettelkasten Method to organize my org files. I just use a hierarchical index (index.org). So I don't have the use of packages such as org-roam or denote.

However, I'm quite interested in being able to use denote's file-naming scheme.

Every note produced by Denote follows this pattern (Points of entry):

DATE--TITLE__KEYWORDS.EXTENSION

The DATE field represents the date in year-month-day format followed by the capital letter T (for “time”) and the current time in hour-minute-second notation. The presentation is compact: 20220531T091625. The DATE serves as the unique identifier of each note.

The TITLE field is the title of the note, as provided by the user. It automatically gets downcased and hyphenated. An entry about “Economics in the Euro Area” produces an economics-in-the-euro-area string for the TITLE of the file name. [...] The EXTENSION is the file type. By default, it is .org (org-mode) [...]

source

If we say an org-link [[l][r]] is composed of two elements, l and r. And that l is composed of 4 elements p, d, t, e, where

  • p is a path (a series of directories names),
  • d, the 1st part of the file name, is the current date,
  • t, the 2d part of the file name, is T (the title of the document) downcased and hyphenated,
  • e, the 3d part of the file name, is the .org extension

I'd like to create a command that would ask me for p and T (the document title). Then it would automatically produce a link with:

  • l = p + d + t + e
  • r = T

Optionally the file would be opened in a new buffer with the following content:

#+TITLE: T

How could I achieve this?

5
  • 1
    You should be able to do this using custom links.
    – NickD
    Jan 9, 2023 at 16:21
  • Thx, I'll try to adapt ol-man.el (unfortunately though I'm not yet able to fully understand it) to my use case, and post the code here if I manage to make it work.
    – crocefisso
    Jan 9, 2023 at 16:30
  • Thinking about it some more, isn't what you are asking for just a capture template? I don't think you need a custom link for it.
    – NickD
    Jan 9, 2023 at 17:53
  • Would capture allow me to create the desired link within the buffer from which I would be using it? If yes it would do the job. Do you think using capture would be best than creating a new command?
    – crocefisso
    Jan 9, 2023 at 18:02
  • I think it would (but I haven't sat down to create the appropriate template, so I might be wrong - again). As for a new command, you can try it, but IME it's always easier to adapt an existing mechanism than to reinvent all the little gears that always seem to be required.
    – NickD
    Jan 9, 2023 at 18:31

1 Answer 1

0

Generate denote schemed org-link:

(defun mda/link (p T)
  "Create an org-link with denote naming scheme"
  (interactive "sEnter path: \nsEnter title: ")
  (insert (concat "[[" p (d-part) "--" (t-part T) ".org][" T "]]")))
(define-key org-mode-map (kbd "C-d") nil)
(global-set-key (kbd "C-d") 'mda/link)  

Generate timestamp-based ID:

(defun d-part ()
  (replace-regexp-in-string "\+.*$" ""
    (replace-regexp-in-string "[-:]" ""
      (format-time-string "%FT%T%z"))))

Downcase and hyphenate org-link description:

(defun t-part (T)
  (downcase 
    (replace-regexp-in-string "[^a-zA-ZÀ-ÿ0-9-]" "" 
      (replace-regexp-in-string "\s+" "-" T))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.