From: Visuwesh <visuweshm@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] org-id-find might change the major-mode of a buffer [9.8-pre (release_9.7.8-713-g62cbac @ /home/viz/lib/emacs/straight/build/org/)]
Date: Sun, 22 Sep 2024 14:39:17 +0530 [thread overview]
Message-ID: <877cb4f41u.fsf@gmail.com> (raw)
In-Reply-To: <87bk0grub9.fsf@localhost> (Ihor Radchenko's message of "Sun, 22 Sep 2024 08:01:14 +0000")
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
[ஞாயிறு செப்டம்பர் 22, 2024] Ihor Radchenko wrote:
> Visuwesh <visuweshm@gmail.com> writes:
>
>> The patch below is what I had in mind. With it, I can no longer
>> reproduce the recipe above.
>> ...
>
> The patch looks reasonable.
> May you format it properly, adding a proper commit message? See
> https://orgmode.org/worg/org-contribute.html#commit-messages
Please find attached.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-id-Guard-against-unwarranted-major-mode-change-w.patch --]
[-- Type: text/x-diff, Size: 1284 bytes --]
From 9ac977253620e719b239e08b2ff8aa1082ae8db3 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
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 <visuweshm@gmail.com>
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
next prev parent reply other threads:[~2024-09-22 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 11:14 [BUG] org-id-find might change the major-mode of a buffer [9.8-pre (release_9.7.8-713-g62cbac @ /home/viz/lib/emacs/straight/build/org/)] Visuwesh
2024-09-19 15:14 ` Visuwesh
2024-09-22 8:01 ` Ihor Radchenko
2024-09-22 9:09 ` Visuwesh [this message]
2024-09-22 10:42 ` Ihor Radchenko
2024-09-22 11:13 ` Visuwesh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877cb4f41u.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).