(fix): set-global-prop: prefer lowercase (#1352)

Prefer lower-case version of Org properties. Fixed bug where
adding/deleting props will alter the original case of the Org property.

Addresses #1342
This commit is contained in:
Jethro Kuan
2020-12-19 19:23:27 +08:00
committed by GitHub
parent 3ce6e299d4
commit 8f1cf7b449
2 changed files with 19 additions and 18 deletions

View File

@ -5,6 +5,7 @@
- [#1270](https://github.com/org-roam/org-roam/pull/1270) capture: create OLP if it does not exist. Removes need for OLP setup in `:head`.
### Changed
- [#1352](https://github.com/org-roam/org-roam/pull/1352) prefer lower-case for roam_tag and roam_alias in interactive commands
### Fixed
- [#1281](https://github.com/org-roam/org-roam/pull/1281) fixed idle-timer not instantiated on `org-roam-mode`
@ -13,6 +14,7 @@
- [#1327](https://github.com/org-roam/org-roam/pull/1327) preserve existing link description during automatic replacement
- [#1346](https://github.com/org-roam/org-roam/pull/1346) prevent malformed path to `org-roam-index-file`
- [#1347](https://github.com/org-roam/org-roam/pull/1347) allow use of `%a` element in regular Org-roam captures
- [#1352](https://github.com/org-roam/org-roam/pull/1352) fixed org-roam-{tag/alias}-{add/delete} altering the original case of the Org property
## 1.2.3 (13-11-2020)

View File

@ -882,20 +882,19 @@ whose title is 'Index'."
"Set a file property called NAME to VALUE.
If the property is already set, it's value is replaced."
(save-excursion
(widen)
(goto-char (point-min))
(if (re-search-forward (concat "^#\\+" name ": \\(.*\\)") (point-max) t)
(replace-match (concat "#+" name ": " value) 'fixedcase)
(while (and (not (eobp))
(looking-at "^[#:]"))
(if (save-excursion (end-of-line) (eobp))
(progn
(end-of-line)
(insert "\n"))
(forward-line)
(beginning-of-line)))
(insert "#+" name ": " value "\n"))))
(org-with-point-at 1
(let ((case-fold-search t))
(if (re-search-forward (concat "^#\\+" name ":\\(.*\\)") (point-max) t)
(replace-match (concat " " value) 'fixedcase nil nil 1)
(while (and (not (eobp))
(looking-at "^[#:]"))
(if (save-excursion (end-of-line) (eobp))
(progn
(end-of-line)
(insert "\n"))
(forward-line)
(beginning-of-line)))
(insert "#+" name ": " value "\n")))))
;;;; org-roam-find-ref
(defun org-roam--get-ref-path-completions (&optional arg filter)
@ -1708,7 +1707,7 @@ Return added alias."
(when (string-empty-p alias)
(user-error "Alias can't be empty"))
(org-roam--set-global-prop
"ROAM_ALIAS"
"roam_alias"
(combine-and-quote-strings
(seq-uniq (cons alias
(org-roam--extract-titles-alias)))))
@ -1723,7 +1722,7 @@ Return added alias."
(if-let ((aliases (org-roam--extract-titles-alias)))
(let ((alias (completing-read "Alias: " aliases nil 'require-match)))
(org-roam--set-global-prop
"ROAM_ALIAS"
"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")))
@ -1741,7 +1740,7 @@ Return added tag."
(when (string-empty-p tag)
(user-error "Tag can't be empty"))
(org-roam--set-global-prop
"ROAM_TAGS"
"roam_tags"
(combine-and-quote-strings (seq-uniq (cons tag existing-tags))))
(org-roam-db--insert-tags 'update)
tag))
@ -1754,7 +1753,7 @@ Return added tag."
(tags (org-roam--extract-tags-prop file)))
(let ((tag (completing-read "Tag: " tags nil 'require-match)))
(org-roam--set-global-prop
"ROAM_TAGS"
"roam_tags"
(combine-and-quote-strings (delete tag tags)))
(org-roam-db--insert-tags 'update))
(user-error "No tag to delete")))