Code from Org-roam tags blogpost.
-
-
Save d12frosted/4a55f3d072a813159c1d7b31c21bac9a to your computer and use it in GitHub Desktop.
Yes, good point! Depending on the value of org-roam-directory
you might need to expand it.
Thanks for your code. It really helps to tag the ZK notes.
Do you consider to merge into org-roam? I think this is a useful function.
Thanks for the kind words. Actually, I didn't think about contributing this to org-roam
🤔 Maybe I should to think about it haha.
By the way, I have more utilities for working with tags and filetags. You can read about them here.
Similar stuff for aliases:
(defun +org-notes-alias-add ()
"Add an alias to current note."
(interactive)
(unless (+org-notes-buffer-p)
(user-error "Current buffer is not a note"))
(let ((alias (read-string "Alias: " )))
(when (string-empty-p alias)
(user-error "Alias can't be empty"))
(+org-buffer-prop-set
"ROAM_ALIAS"
(combine-and-quote-strings (seq-uniq (cons alias (+org-notes-alias-read)))))
(org-roam-db--update-file (buffer-file-name (buffer-base-buffer)))))
(defun +org-notes-alias-delete ()
"Delete an alias from current note."
(interactive)
(unless (+org-notes-buffer-p)
(user-error "Current buffer is not a note"))
(let* ((aliases (+org-notes-alias-read))
(alias (completing-read "Alias: " aliases nil 'require-match)))
(+org-buffer-prop-set
"ROAM_ALIAS"
(combine-and-quote-strings (delete alias aliases)))
(org-roam-db--update-file (buffer-file-name (buffer-base-buffer)))))
(defun +org-notes-alias-read ()
"Return list of aliases as set in the buffer."
(unless (+org-notes-buffer-p)
(user-error "Current buffer is not a note"))
(org-roam--extract-titles-alias))
Thanks for sharing this. Tiny functions but very useful.
@randomwangran shared this also because of this org-roam/org-roam#1149 (comment)
@randomwangran FYI org-roam/org-roam#1183
The version there is even better than I have in my configurations 😸
Was already merged https://github.com/org-roam/org-roam/pull/1183/files
Does this code works with v2 ?
@anoopd See previous comments. This code was already merged into org-roam
and available as part of V2.
@anoopd just realised that the linked post contains instructions for V2. See screenshot attached.
Thank you for the reply .......... will have a look :)
I find I need to add
expand-file-name
to tell the buffer is a note or not.(defun +org-notes-buffer-p ()
: