(chore)utils: standardize org-roam-property-add/remove fn signatures (#1930)

This commit is contained in:
Jethro Kuan
2021-10-30 16:21:43 +08:00
committed by GitHub
parent 1b221a1d4a
commit c789531e36
3 changed files with 34 additions and 2 deletions

View File

@ -221,6 +221,14 @@ nodes." org-id-locations-file)
'org-roam-dailies-find-date
'org-roam-dailies-goto-date "org-roam 2.0")
(define-obsolete-function-alias
'org-roam-add-property
'org-roam-property-add "org-roam 2.1")
(define-obsolete-function-alias
'org-roam-remove-property
'org-roam-property-remove "org-roam 2.1")
;;; Obsolete functions
(make-obsolete 'org-roam-get-keyword 'org-collect-keywords "org-roam 2.0")

View File

@ -1009,7 +1009,7 @@ and when nil is returned the node will be filtered out."
(let ((node (org-roam-node-at-point 'assert)))
(save-excursion
(goto-char (org-roam-node-point node))
(org-roam-add-property ref "ROAM_REFS"))))
(org-roam-property-add "ROAM_REFS" ref))))
(defun org-roam-ref-remove (&optional ref)
"Remove a REF from the node at point."
@ -1017,7 +1017,7 @@ and when nil is returned the node will be filtered out."
(let ((node (org-roam-node-at-point 'assert)))
(save-excursion
(goto-char (org-roam-node-point node))
(org-roam-remove-property "ROAM_REFS" ref))))
(org-roam-property-remove "ROAM_REFS" ref))))
;;; Tags
;;;; Getters

View File

@ -271,6 +271,30 @@ Both, VAL and PROP are strings."
"Remove VAL value from PROP property for the node at point.
Both VAL and PROP are strings.
If VAL is not specified, user is prompted to select a value."
(let* ((p (org-entry-get (point) prop))
(lst (when p (split-string-and-unquote p)))
(prop-to-remove (or val (completing-read "Remove: " lst)))
(lst (delete prop-to-remove lst)))
(if lst
(org-set-property prop (combine-and-quote-strings lst))
(org-delete-property prop))
prop-to-remove))
(defun org-roam-property-add (prop val)
"Add VAL value to PROP property for the node at point.
Both, VAL and PROP are strings."
(let* ((p (org-entry-get (point) prop))
(lst (when p (split-string-and-unquote p)))
(lst (if (memq val lst) lst (cons val lst)))
(lst (seq-uniq lst)))
(org-set-property prop (combine-and-quote-strings lst))
val))
(defun org-roam-property-remove (prop &optional val)
"Remove VAL value from PROP property for the node at point.
Both VAL and PROP are strings.
If VAL is not specified, user is prompted to select a value."
(let* ((p (org-entry-get (point) prop))
(lst (when p (split-string-and-unquote p)))