tweak(org): separate roam tags from types
- No longer hard-code fontification of tags and types in roam completion. - Prefix types with @ and tags with # -- makes them easier to search for in completion -- and swap types and hierarchy columns. I.e. before: TYPE TITLE [TAG [TAG...]] after: TITLE @TYPE [#TAG [#TAG...]] - Exclude unwanted (i.e. meta) tags from public display, like ATTACH, ARCHIVE, or anything in org-num-skip-tags.
This commit is contained in:
parent
11cc896e8f
commit
7304a8de8f
2 changed files with 34 additions and 19 deletions
|
@ -35,27 +35,37 @@ If some elements are missing, they will be stripped out."
|
||||||
(cl-defmethod org-roam-node-doom-subdirs ((node org-roam-node))
|
(cl-defmethod org-roam-node-doom-subdirs ((node org-roam-node))
|
||||||
"Return subdirectories of `org-roam-directory' in which NODE resides in.
|
"Return subdirectories of `org-roam-directory' in which NODE resides in.
|
||||||
If there's none, return an empty string."
|
If there's none, return an empty string."
|
||||||
(if-let ((dirs (thread-first node
|
(thread-first
|
||||||
(org-roam-node-file)
|
node
|
||||||
(file-relative-name org-roam-directory)
|
(org-roam-node-file)
|
||||||
(file-name-directory))))
|
(file-relative-name org-roam-directory)
|
||||||
dirs
|
(file-name-directory)))
|
||||||
""))
|
|
||||||
|
|
||||||
;;;###autoload (autoload 'org-roam-node-doom-tags "lang/org/autoload/contrib-roam2" nil t)
|
;;;###autoload (autoload 'org-roam-node-doom-tags "lang/org/autoload/contrib-roam2" nil t)
|
||||||
(cl-defmethod org-roam-node-doom-tags ((node org-roam-node))
|
(cl-defmethod org-roam-node-doom-tags ((node org-roam-node))
|
||||||
"Return tags formatted in the same way how they appear in org files.
|
"Return tags formatted in the same way how they appear in org files."
|
||||||
Treat subdirectories as tags too. If there's no elements to build
|
(when-let* ((tags (org-roam-node-tags node))
|
||||||
the tags of, return an empty string."
|
(tags (cl-remove-if
|
||||||
(let ((tags (org-roam-node-tags node))
|
(doom-rpartial
|
||||||
(subdirs (org-roam-node-doom-subdirs node)))
|
#'member (delq
|
||||||
(when tags
|
nil (append
|
||||||
(setq tags (propertize (concat (mapconcat (lambda (s) (concat ":" s)) tags nil) ":")
|
(list (bound-and-true-p org-archive-tag)
|
||||||
'face 'shadow)))
|
(bound-and-true-p org-attach-auto-tag))
|
||||||
(unless (string-empty-p subdirs)
|
(bound-and-true-p org-num-skip-tags))))
|
||||||
(setq subdirs (propertize (concat ":" (replace-regexp-in-string "/\\|\\\\" ":" subdirs))
|
tags)))
|
||||||
'face '(shadow italic))))
|
tags))
|
||||||
(replace-regexp-in-string ":+" (propertize ":" 'face 'shadow) (concat subdirs tags))))
|
|
||||||
|
;;;###autoload (autoload 'org-roam-node-doom-type "lang/org/autoload/contrib-roam2" nil t)
|
||||||
|
(cl-defmethod org-roam-node-doom-type ((node org-roam-node))
|
||||||
|
"Return the directory relative to `org-roam-directory' as a note's \"type\"."
|
||||||
|
(when-let (dir (thread-first
|
||||||
|
node
|
||||||
|
(org-roam-node-file)
|
||||||
|
(file-relative-name org-roam-directory)
|
||||||
|
(file-name-directory)))
|
||||||
|
(directory-file-name dir)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -72,12 +72,17 @@ In case of failure, fail gracefully."
|
||||||
(file-truename)
|
(file-truename)
|
||||||
(file-name-as-directory))
|
(file-name-as-directory))
|
||||||
org-roam-node-display-template
|
org-roam-node-display-template
|
||||||
"${doom-hierarchy:*} ${doom-tags:45}"
|
(format "${doom-hierarchy:*} %s %s"
|
||||||
|
(propertize "${doom-type:15}" 'face 'font-lock-keyword-face)
|
||||||
|
(propertize "${doom-tags:-1}" 'face 'org-tag))
|
||||||
org-roam-completion-everywhere t
|
org-roam-completion-everywhere t
|
||||||
org-roam-db-gc-threshold most-positive-fixnum
|
org-roam-db-gc-threshold most-positive-fixnum
|
||||||
;; Reverse the default to favor faster searchers over slower ones.
|
;; Reverse the default to favor faster searchers over slower ones.
|
||||||
org-roam-list-files-commands '(fd fdfind rg find))
|
org-roam-list-files-commands '(fd fdfind rg find))
|
||||||
|
|
||||||
|
(add-to-list 'org-roam-node-template-prefixes '("doom-tags" . "#"))
|
||||||
|
(add-to-list 'org-roam-node-template-prefixes '("doom-type" . "@"))
|
||||||
|
|
||||||
(setq-hook! 'org-roam-find-file-hook
|
(setq-hook! 'org-roam-find-file-hook
|
||||||
org-id-link-to-org-use-id +org-roam-link-to-org-use-id)
|
org-id-link-to-org-use-id +org-roam-link-to-org-use-id)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue