(feat): Use TITLE as description when linking before first heading (#491)

Fixes #487
This commit is contained in:
Jürgen Hötzel 2020-04-18 18:41:38 +02:00 committed by GitHub
parent 9e138e259a
commit de4f5477d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -540,6 +540,15 @@ for Org-ref cite links."
:order-by (asc from)]
target))
(defun org-roam-store-link ()
"Store a link to an `org-roam' file."
(when (org-before-first-heading-p)
(when-let ((title (cdr (assoc "TITLE" (org-roam--extract-global-props '("TITLE"))))))
(org-link-store-props
:type "file"
:link (format "file:%s" (abbreviate-file-name buffer-file-name))
:description title))))
;;;###autoload
(defalias 'org-roam 'org-roam-buffer-toggle-display)
@ -594,7 +603,7 @@ Otherwise, behave as if called interactively."
(setq org-roam-last-window (get-buffer-window))
(add-hook 'post-command-hook #'org-roam-buffer--update-maybe nil t)
(add-hook 'after-save-hook #'org-roam-db--update-file nil t)
(org-link-set-parameters "file" :face 'org-roam--roam-link-face)
(org-link-set-parameters "file" :face 'org-roam--roam-link-face :store #'org-roam-store-link)
(org-roam-buffer--update-maybe :redisplay t)))
(defun org-roam--delete-file-advice (file &optional _trash)