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)
"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)