(feat): interactive functions for managing aliases and tags#1183
Conversation
040e8f9 to
fee6b4e
Compare
fee6b4e to
0d609fb
Compare
| index))) | ||
|
|
||
| ;;;; dealing with file-wide properties | ||
| (defun org-roam--set-global-prop (name value) |
There was a problem hiding this comment.
I actually have an idea how we can remove this function in the future. Since 9.4 is out, and files also have properties, we can gradually migrate to storing ROAM_xxx as properties (aka :ROAM_xxx:) instead of 'settings' (aka #+ROAM_xxx).
There was a problem hiding this comment.
Yeah, this is fine, I think we can file this as a feature request (supporting fetching from property drawers).
| "ROAM_ALIAS" | ||
| (combine-and-quote-strings (delete alias aliases))) | ||
| (org-roam-db--update-file (buffer-file-name (buffer-base-buffer)))) | ||
| (user-error "No aliases to delete"))) |
There was a problem hiding this comment.
Here I just want to avoid empty completion list. Plus required-match...
| Return added tag." | ||
| (interactive) | ||
| (unless org-roam-mode (org-roam-mode)) | ||
| (let* ((all-tags |
There was a problem hiding this comment.
Here I just want to provide completion from existing tags.
There was a problem hiding this comment.
(org-roam-db--get-tags) gives you what you want, and also applies the distinct op via SQL, which should be faster.
There was a problem hiding this comment.
Oh wow, didn't know about this. Really works great and simplifies implementation 🙇
| index))) | ||
|
|
||
| ;;;; dealing with file-wide properties | ||
| (defun org-roam--set-global-prop (name value) |
There was a problem hiding this comment.
Yeah, this is fine, I think we can file this as a feature request (supporting fetching from property drawers).
| (let ((found)) | ||
| (while (not (or found (eobp))) | ||
| (beginning-of-line) | ||
| (if (or (looking-at "^#") | ||
| (looking-at "^:")) | ||
| (line-move 1 t) | ||
| (setq found t))) |
There was a problem hiding this comment.
| (let ((found)) | |
| (while (not (or found (eobp))) | |
| (beginning-of-line) | |
| (if (or (looking-at "^#") | |
| (looking-at "^:")) | |
| (line-move 1 t) | |
| (setq found t))) | |
| (while (and (not (eobp)) | |
| (looking-at "^[#:]")) | |
| (if (save-excursion (end-of-line) (eobp)) | |
| (progn | |
| (end-of-line) | |
| (insert "\n")) | |
| (forward-line) | |
| (beginning-of-line))) |
There was a problem hiding this comment.
Just for explain this diff:
-
line-moveruns a lot of things, and depends on some user config options (like whether to create new lines).forward-lineis the simplest way to go one line down -
We need to explicitly check the boundary condition so we know when to create a new line, since
forward-linedoes not error
There was a problem hiding this comment.
Makes sense! Thank you.
| (org-roam--set-global-prop | ||
| "ROAM_ALIAS" | ||
| (combine-and-quote-strings (delete alias aliases))) | ||
| (org-roam-db--update-file (buffer-file-name (buffer-base-buffer)))) |
There was a problem hiding this comment.
you can leave out the argument, it defaults to the current buffer.
| Return added tag." | ||
| (interactive) | ||
| (unless org-roam-mode (org-roam-mode)) | ||
| (let* ((all-tags |
There was a problem hiding this comment.
(org-roam-db--get-tags) gives you what you want, and also applies the distinct op via SQL, which should be faster.
0d609fb to
b273bdf
Compare
|
Updated PR with suggestions @jethrokuan :) |
|
I've noticed these functions use uppercase ROAM_TAGS and ROAM_ALIAS. Should these instead be lowercase to be more consistent (#769)? I've got a branch on my fork where this is the case, I can submit a quick PR if you like. (there's also a patch in there to maintain the original case of the property, so people who already have upper case ones won't really be affected) |
|
Oh wow, didn't know that the new convention is to use lowercase. Will send PR to follow this convention in new functions. |
Motivation for this change
See my comment in #1149 (comment)
See it in action: