mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): fix backlink-to-current-p killing buffers (#1263)
Change `org-roam--backlink-to-current-p` to only perform a DB query.
This commit is contained in:
28
org-roam.el
28
org-roam.el
@ -1015,24 +1015,18 @@ Return nil if the file does not exist."
|
|||||||
(and (boundp org-roam-backlinks-mode)
|
(and (boundp org-roam-backlinks-mode)
|
||||||
org-roam-backlinks-mode))
|
org-roam-backlinks-mode))
|
||||||
|
|
||||||
(defun org-roam--retrieve-link-destination (&optional pom)
|
|
||||||
"Retrieve the destination of the link at POM.
|
|
||||||
The point-or-marker POM can either be a position in the current
|
|
||||||
buffer or a marker."
|
|
||||||
(let ((pom (or pom (point))))
|
|
||||||
(org-with-point-at pom
|
|
||||||
(let* ((context (org-element-context))
|
|
||||||
(type (org-element-property :type context))
|
|
||||||
(dest (org-element-property :path context)))
|
|
||||||
(pcase type
|
|
||||||
("id" (car (org-roam-id-find dest)))
|
|
||||||
(_ dest))))))
|
|
||||||
|
|
||||||
(defun org-roam--backlink-to-current-p ()
|
(defun org-roam--backlink-to-current-p ()
|
||||||
"Return t if backlink is to the current Org-roam file."
|
"Return t if the link at point is to the current Org-roam file."
|
||||||
(let ((current (buffer-file-name org-roam-buffer--current))
|
(save-match-data
|
||||||
(backlink-dest (org-roam--retrieve-link-destination)))
|
(let ((current-file (buffer-file-name org-roam-buffer--current))
|
||||||
(string= current backlink-dest)))
|
(backlink-dest (save-excursion
|
||||||
|
(let* ((context (org-element-context))
|
||||||
|
(type (org-element-property :type context))
|
||||||
|
(dest (org-element-property :path context)))
|
||||||
|
(pcase type
|
||||||
|
("id" (org-roam-id-get-file dest))
|
||||||
|
(_ dest))))))
|
||||||
|
(string= current-file backlink-dest))))
|
||||||
|
|
||||||
(defun org-roam-open-at-point ()
|
(defun org-roam-open-at-point ()
|
||||||
"Open an Org-roam link or visit the text previewed at point.
|
"Open an Org-roam link or visit the text previewed at point.
|
||||||
|
Reference in New Issue
Block a user