From b670ee57f688b88f375e5b77333d8208581bd85a Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 16 Apr 2022 10:08:11 +0200 Subject: [PATCH] Only search Org buffers when querying for backlinks It does not make sense to look in non-Org buffers for backlinks of items, but this was indeed what happend until now: the function `db/org-get-location` only checked whether the current buffer is associated with a file, and if so uses it for querying the user for an item to select. This does not make sense, as `db/org-get-location` is supposed to return a mark to an Org item. This is now fixed by `db/org-get-location` to also check whether the current buffer is also an Org buffer. It's as simple as that. --- site-lisp/db-org.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 3db667e..44c5e87 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -814,11 +814,11 @@ not." (defun db/org-get-location (&optional arg) "Interactively query for location and return mark. -Searches through the current buffer if that one is associated -with a file, or `db/org-default-org-file'. When ARG is non-nil, -search through all files in the variables `org-agenda-files', -`org-agenda-text-search-extra-files', and the current file or -`db/org-default-org-file'. +Searches through the current buffer if that one is an Org buffer +and is associated with a file, or `db/org-default-org-file'. +When ARG is non-nil, search through all files in the variables +`org-agenda-files', `org-agenda-text-search-extra-files', and the +current file or `db/org-default-org-file'. Search is always conducted up to level 9. If the selected location does not have an associated point or mark, error out. @@ -826,9 +826,10 @@ Disable refile cache and any active refile filter hooks to allow linking to any item." (let ((org-refile-target-verify-function nil) (org-refile-use-cache nil) - ;; If the current buffer is associated with a file, search through it; - ;; otherwise, use the default Org Mode file as default buffer - (default-buffer (if (buffer-file-name) + ;; If the current buffer is an Org buffer and is associated with a file, + ;; search through it; otherwise, use the default Org Mode file as + ;; default buffer + (default-buffer (if (and (buffer-file-name) (derived-mode-p 'org-mode)) (current-buffer) (find-file-noselect db/org-default-org-file)))) (when (null default-buffer)