mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(feat): add org-roam-file-completion-tag-position
(#1396)
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
## 1.2.4 (TBD)
|
## 1.2.4 (TBD)
|
||||||
|
|
||||||
### Added
|
### 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`.
|
- [#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
|
- [#1353](https://github.com/org-roam/org-roam/pull/1353) support file-level property drawers
|
||||||
|
|
||||||
|
36
org-roam.el
36
org-roam.el
@ -268,6 +268,13 @@ The currently supported symbols are:
|
|||||||
(symbol)))
|
(symbol)))
|
||||||
:group 'org-roam)
|
: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
|
(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."
|
"Enable linking to headlines, which includes automatic :ID: creation and scanning of :ID:s for org-roam database."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
@ -844,13 +851,22 @@ file."
|
|||||||
(format org-roam-link-title-format description)))
|
(format org-roam-link-title-format description)))
|
||||||
(org-link-make-string (concat type ":" target) description))
|
(org-link-make-string (concat type ":" target) description))
|
||||||
|
|
||||||
(defun org-roam--prepend-tag-string (str tags)
|
(defun org-roam--add-tag-string (str tags)
|
||||||
"Prepend TAGS to STR."
|
"Add TAGS to STR.
|
||||||
(concat
|
|
||||||
(when tags
|
Depending on the value of `org-roam-file-completion-tag-position', this function
|
||||||
(propertize (format "(%s) " (s-join org-roam-tag-separator tags))
|
prepends TAGS to STR, appends TAGS to STR or omits TAGS from STR."
|
||||||
'face 'org-roam-tag))
|
(pcase org-roam-file-completion-tag-position
|
||||||
str))
|
('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 ()
|
(defun org-roam--get-title-path-completions ()
|
||||||
"Return an alist for completion.
|
"Return an alist for completion.
|
||||||
@ -868,7 +884,7 @@ plist containing the path and title for the file."
|
|||||||
rows))
|
rows))
|
||||||
(dolist (row rows completions)
|
(dolist (row rows completions)
|
||||||
(pcase-let ((`(,file-path ,title ,tags) row))
|
(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)))
|
(v (list :path file-path :title title)))
|
||||||
(push (cons k v) completions))))))
|
(push (cons k v) completions))))))
|
||||||
|
|
||||||
@ -951,8 +967,8 @@ FILTER can either be a string or a function:
|
|||||||
(concat
|
(concat
|
||||||
(when org-roam-include-type-in-ref-path-completions
|
(when org-roam-include-type-in-ref-path-completions
|
||||||
(format "{%s} " type))
|
(format "{%s} " type))
|
||||||
(org-roam--prepend-tag-string (format "%s (%s)" title ref)
|
(org-roam--add-tag-string (format "%s (%s)" title ref)
|
||||||
tags))
|
tags))
|
||||||
ref))
|
ref))
|
||||||
(v (list :path file-path :type type :ref ref)))
|
(v (list :path file-path :type type :ref ref)))
|
||||||
(push (cons k v) completions)))))))
|
(push (cons k v) completions)))))))
|
||||||
|
Reference in New Issue
Block a user