Skip to content

Commit

Permalink
(feat): Use TITLE as description when linking before first heading
Browse files Browse the repository at this point in the history
Fixes #487
  • Loading branch information
juergenhoetzel committed Apr 18, 2020
1 parent 9e138e2 commit bb346c0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion org-roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bb346c0

Please sign in to comment.