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 (org-with-point-at 1
(when-let ((id (org-id-get))) (when-let ((id (org-id-get)))
(let ((file (buffer-file-name (buffer-base-buffer))) (let ((file (buffer-file-name (buffer-base-buffer)))
(title (cadr (assoc "TITLE" (org-collect-keywords '("title")) (title (or (cadr (assoc "TITLE" (org-collect-keywords '("title"))
#'string-equal))) #'string-equal))
(file-relative-name file org-roam-directory)))
(pos (point)) (pos (point))
(todo nil) (todo nil)
(priority nil) (priority nil)

View File

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