From 9ac977253620e719b239e08b2ff8aa1082ae8db3 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sun, 22 Sep 2024 14:38:54 +0530 Subject: [PATCH] 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 Link: https://list.orgmode.org/87ikuuwmz4.fsf@gmail.com/ --- lisp/org-id.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/org-id.el b/lisp/org-id.el index e247fab1d..17568ab31 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -705,8 +705,9 @@ (defun org-id-find-id-file (id) (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. -- 2.45.2