default title to file-relative-name for file-nodes if title is empty

This commit is contained in:
Jethro Kuan
2021-03-25 13:21:35 +08:00
parent 47c3b024d7
commit 6ac3a84057
2 changed files with 5 additions and 5 deletions

View File

@ -278,8 +278,9 @@ first encapsulating ID."
(org-with-point-at 1
(when-let ((id (org-id-get)))
(let ((file (buffer-file-name (buffer-base-buffer)))
(title (cadr (assoc "TITLE" (org-collect-keywords '("title"))
#'string-equal)))
(title (or (cadr (assoc "TITLE" (org-collect-keywords '("title"))
#'string-equal))
(file-relative-name file org-roam-directory)))
(pos (point))
(todo nil)
(priority nil)

View File

@ -158,13 +158,12 @@ is the `org-roam-node'."
:left-join nodes
:on (= aliases:node-id nodes:id)]))
collect (pcase-let* ((`(,file ,pos ,alias ,title ,id) row)
(fname (file-name-nondirectory file))
(node (org-roam-node-create :id id
:file file
:title (or title fname)
:title title
:point pos
:tags (gethash id tags-table))))
(cons (propertize (or alias fname) 'node node) node)))))
(cons (propertize alias 'node node) node)))))
(defun org-roam-node-read (&optional initial-input filter-fn require-match)
"Read and return an `org-roam-node'.