fix(org): improve parsing of flag-only module link

This commit is contained in:
TEC 2022-09-26 02:43:59 +08:00 committed by Henrik Lissner
parent 24f98d49ec
commit 7e50f239c4

View file

@ -78,13 +78,20 @@ exist, and `org-link' otherwise."
keystr) keystr)
(defun +org-link--read-module-spec (module-spec-str) (defun +org-link--read-module-spec (module-spec-str)
(cl-destructuring-bind (category &optional module flag)
(if (string-prefix-p "+" (string-trim-left module-spec-str)) (if (string-prefix-p "+" (string-trim-left module-spec-str))
(list nil nil (intern module-spec-str)) (let ((title (cadar (org-collect-keywords '("TITLE")))))
(mapcar #'intern (split-string module-spec-str " " nil))) (if (and title (string-match-p "\\`:[a-z]+ [a-z]+\\'" title))
(+org-link--read-module-spec (concat title " " module-spec-str))
(list :category nil :module nil :flag (intern module-spec-str))))
(cl-destructuring-bind (category &optional module flag)
(mapcar #'intern (split-string
(if (string-prefix-p ":" module-spec-str)
module-spec-str
(concat ":" module-spec-str))
"[ \n]+" nil))
(list :category category (list :category category
:module module :module module
:flag flag))) :flag flag))))
;;;###autoload ;;;###autoload
(defun +org-link--doom-module-link-face-fn (module-path) (defun +org-link--doom-module-link-face-fn (module-path)