summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVisuwesh <visuweshm@gmail.com>2024-09-22 14:38:54 +0530
committerIhor Radchenko <yantar92@posteo.net>2024-09-22 12:41:54 +0200
commit5dc7028d7fbda589962af6fdad8ed0ad6b48b231 (patch)
tree61eaf045913d29c233cb24bc1731af49937b093a
parent10adc2bbd7aa868c433818af897160a8232019f0 (diff)
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/
-rw-r--r--lisp/org-id.el5
1 files 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 @@ 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.