Harden shortcut to jump to any Org heading from anywhere

In the previous implementation, when in some buffer which is not an Org
buffer that accidentally contains lines that partially match the regular
expression describing an Org heading, errors could occur when the Org
refile cache was empty.  To address this issue, let's temporarily switch
to some Org buffer before generating the list of all Org heading
targets.
This commit is contained in:
Daniel - 2024-03-16 17:08:00 +01:00
parent 3099e642ce
commit 8876f04756
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 9 additions and 1 deletions

View File

@ -1044,7 +1044,15 @@ Current Task: %s(replace-regexp-in-string \"%\" \"%%\" (or org-clock-current-tas
"
("c" (db/org-clock-goto-first-open-checkbox nil)
nil)
("a" (org-refile '(4)) nil)
("a" (with-current-buffer
;; Make sure we are in some Org buffer, as `org-refile-get-location'
;; might try to parse the current buffer in search for some Org
;; headings, possibly producing errors along the way.
(->> (org-agenda-files :unrestricted)
cl-first
get-file-buffer)
(org-refile '(4)))
nil)
("s" (db/org-clock-goto-first-open-checkbox t)
nil))