1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

org-id: Guard against unwarranted major-mode change when querying id

* lisp/org-id.el (org-id-find-id-file): Only fallback to the
current-buffer filename when it is an org-mode buffer.  This avoids
accidental change of the major-mode when querying a non-existent id
from a non-org-mode buffer.

Reported-by: Visuwesh <visuweshm@gmail.com>
Link: https://list.orgmode.org/87ikuuwmz4.fsf@gmail.com/
This commit is contained in:
Visuwesh 2024-09-22 14:38:54 +05:30 committed by Ihor Radchenko
parent 10adc2bbd7
commit 5dc7028d7f
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -705,8 +705,9 @@ This is to be able to write it to a file."
(hash-table-p org-id-locations)
(gethash id org-id-locations))
;; Fall back on current buffer
(buffer-file-name (or (buffer-base-buffer (current-buffer))
(current-buffer)))))
(when (derived-mode-p 'org-mode)
(buffer-file-name (or (buffer-base-buffer (current-buffer))
(current-buffer))))))
(defun org-id-find-id-in-file (id file &optional markerp)
"Return the position of the entry ID in FILE.