diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6ee1f..1536038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.2.4 (TBD) ### Added +- [#1396](https://github.com/org-roam/org-roam/pull/1396) add option to choose between prepending, appending, and omitting `roam_tags` in file completion - [#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`. - [#1353](https://github.com/org-roam/org-roam/pull/1353) support file-level property drawers diff --git a/org-roam.el b/org-roam.el index 87bf47b..995d596 100644 --- a/org-roam.el +++ b/org-roam.el @@ -268,6 +268,13 @@ The currently supported symbols are: (symbol))) :group 'org-roam) +(defcustom org-roam-file-completion-tag-position 'prepend + "Prepend, append, or omit tags from the file titles during completion." + :type '(choice (const :tag "Prepend" prepend) + (const :tag "Append" append) + (const :tag "Omit" omit)) + :group 'org-roam) + (defcustom org-roam-enable-headline-linking t "Enable linking to headlines, which includes automatic :ID: creation and scanning of :ID:s for org-roam database." :type 'boolean @@ -844,13 +851,22 @@ file." (format org-roam-link-title-format description))) (org-link-make-string (concat type ":" target) description)) -(defun org-roam--prepend-tag-string (str tags) - "Prepend TAGS to STR." - (concat - (when tags - (propertize (format "(%s) " (s-join org-roam-tag-separator tags)) - 'face 'org-roam-tag)) - str)) +(defun org-roam--add-tag-string (str tags) + "Add TAGS to STR. + +Depending on the value of `org-roam-file-completion-tag-position', this function +prepends TAGS to STR, appends TAGS to STR or omits TAGS from STR." + (pcase org-roam-file-completion-tag-position + ('prepend (concat + (when tags (propertize (format "(%s) " (s-join org-roam-tag-separator tags)) + 'face 'org-roam-tag)) + str)) + ('append (concat + str + (when tags (propertize (format " (%s)" (s-join org-roam-tag-separator tags)) + 'face 'org-roam-tag)))) + ('omit str))) + (defun org-roam--get-title-path-completions () "Return an alist for completion. @@ -868,7 +884,7 @@ plist containing the path and title for the file." rows)) (dolist (row rows completions) (pcase-let ((`(,file-path ,title ,tags) row)) - (let ((k (org-roam--prepend-tag-string title tags)) + (let ((k (org-roam--add-tag-string title tags)) (v (list :path file-path :title title))) (push (cons k v) completions)))))) @@ -951,8 +967,8 @@ FILTER can either be a string or a function: (concat (when org-roam-include-type-in-ref-path-completions (format "{%s} " type)) - (org-roam--prepend-tag-string (format "%s (%s)" title ref) - tags)) + (org-roam--add-tag-string (format "%s (%s)" title ref) + tags)) ref)) (v (list :path file-path :type type :ref ref))) (push (cons k v) completions)))))))