(fix): fix prop extraction failures (#772)

This fixes a bug introduced in #770. Interestingly,
`org-element-property` always returns the prop in allcaps, so a
string-equal would have been sufficient. This commit reverts all usages
of `org-roam--extract-global-props` to use the upcase version of the
properties.
This commit is contained in:
Jethro Kuan
2020-06-07 22:10:47 +08:00
committed by GitHub
parent 9d5a34d0f4
commit 30599cc3e8
2 changed files with 10 additions and 10 deletions

View File

@ -93,7 +93,7 @@ AST is the org-element parse tree."
(org-element-map ast 'keyword (org-element-map ast 'keyword
(lambda (kw) (lambda (kw)
(let ((key (org-element-property :key kw))) (let ((key (org-element-property :key kw)))
(when (and (string-prefix-p "roam_" key t) (when (and (string-prefix-p "ROAM_" key t)
(not (member key org-roam-doctor--supported-roam-properties))) (not (member key org-roam-doctor--supported-roam-properties)))
(push (push
`(,(org-element-property :begin kw) `(,(org-element-property :begin kw)

View File

@ -450,7 +450,7 @@ The search terminates when the first property is encountered."
(dolist (prop props) (dolist (prop props)
(let ((p (org-element-map buf 'keyword (let ((p (org-element-map buf 'keyword
(lambda (kw) (lambda (kw)
(when (string-collate-equalp (org-element-property :key kw) prop nil t) (when (string-equal (org-element-property :key kw) prop)
(org-element-property :value kw))) (org-element-property :value kw)))
:first-match t))) :first-match t)))
(push (cons prop p) res))) (push (cons prop p) res)))
@ -534,16 +534,16 @@ it as FILE-PATH."
(defun org-roam--extract-titles-title () (defun org-roam--extract-titles-title ()
"Return title from \"#+title\" of the current buffer." "Return title from \"#+title\" of the current buffer."
(let* ((prop (org-roam--extract-global-props '("title"))) (let* ((prop (org-roam--extract-global-props '("TITLE")))
(title (cdr (assoc "title" prop)))) (title (cdr (assoc "TITLE" prop))))
(when title (when title
(list title)))) (list title))))
(defun org-roam--extract-titles-alias () (defun org-roam--extract-titles-alias ()
"Return the aliases from the current buffer. "Return the aliases from the current buffer.
Reads from the \"roam_alias\" property." Reads from the \"roam_alias\" property."
(let* ((prop (org-roam--extract-global-props '("roam_alias"))) (let* ((prop (org-roam--extract-global-props '("ROAM_ALIAS")))
(aliases (cdr (assoc "roam_alias" prop)))) (aliases (cdr (assoc "ROAM_ALIAS" prop))))
(condition-case nil (condition-case nil
(org-roam--str-to-list aliases) (org-roam--str-to-list aliases)
(error (error
@ -597,7 +597,7 @@ The final directory component is used as a tag."
(defun org-roam--extract-tags-prop (_file) (defun org-roam--extract-tags-prop (_file)
"Extract tags from the current buffer's \"#roam_tags\" global property." "Extract tags from the current buffer's \"#roam_tags\" global property."
(let* ((prop (cdr (assoc "roam_tags" (org-roam--extract-global-props '("roam_tags")))))) (let* ((prop (cdr (assoc "ROAM_TAGS" (org-roam--extract-global-props '("ROAM_TAGS"))))))
(condition-case nil (condition-case nil
(org-roam--str-to-list prop) (org-roam--str-to-list prop)
(error (error
@ -656,8 +656,8 @@ Examples:
(defun org-roam--extract-ref () (defun org-roam--extract-ref ()
"Extract the ref from current buffer and return the type and the key of the ref." "Extract the ref from current buffer and return the type and the key of the ref."
(pcase (cdr (assoc "roam_key" (pcase (cdr (assoc "ROAM_KEY"
(org-roam--extract-global-props '("roam_key")))) (org-roam--extract-global-props '("ROAM_KEY"))))
('nil nil) ('nil nil)
((pred string-empty-p) ((pred string-empty-p)
(user-error "Org property #+roam_key cannot be empty")) (user-error "Org property #+roam_key cannot be empty"))
@ -945,7 +945,7 @@ for Org-ref cite links."
(defun org-roam-store-link () (defun org-roam-store-link ()
"Store a link to an `org-roam' file." "Store a link to an `org-roam' file."
(when (org-before-first-heading-p) (when (org-before-first-heading-p)
(when-let ((title (cdr (assoc "title" (org-roam--extract-global-props '("title")))))) (when-let ((title (cdr (assoc "TITLE" (org-roam--extract-global-props '("TITLE"))))))
(org-link-store-props (org-link-store-props
:type "file" :type "file"
:link (format "file:%s" (abbreviate-file-name buffer-file-name)) :link (format "file:%s" (abbreviate-file-name buffer-file-name))