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.
This commit is contained in:
Daniel - 2022-04-16 10:08:11 +02:00
parent 1d5f318b5b
commit b670ee57f6
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 9 additions and 8 deletions

View File

@ -814,11 +814,11 @@ not."
(defun db/org-get-location (&optional arg) (defun db/org-get-location (&optional arg)
"Interactively query for location and return mark. "Interactively query for location and return mark.
Searches through the current buffer if that one is associated Searches through the current buffer if that one is an Org buffer
with a file, or `db/org-default-org-file'. When ARG is non-nil, and is associated with a file, or `db/org-default-org-file'.
search through all files in the variables `org-agenda-files', When ARG is non-nil, search through all files in the variables
`org-agenda-text-search-extra-files', and the current file or `org-agenda-files', `org-agenda-text-search-extra-files', and the
`db/org-default-org-file'. current file or `db/org-default-org-file'.
Search is always conducted up to level 9. If the selected Search is always conducted up to level 9. If the selected
location does not have an associated point or mark, error out. 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." linking to any item."
(let ((org-refile-target-verify-function nil) (let ((org-refile-target-verify-function nil)
(org-refile-use-cache nil) (org-refile-use-cache nil)
;; If the current buffer is associated with a file, search through it; ;; If the current buffer is an Org buffer and is associated with a file,
;; otherwise, use the default Org Mode file as default buffer ;; search through it; otherwise, use the default Org Mode file as
(default-buffer (if (buffer-file-name) ;; default buffer
(default-buffer (if (and (buffer-file-name) (derived-mode-p 'org-mode))
(current-buffer) (current-buffer)
(find-file-noselect db/org-default-org-file)))) (find-file-noselect db/org-default-org-file))))
(when (null default-buffer) (when (null default-buffer)