From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 0CfhJv7e72ZeYwEA62LTzQ:P1 (envelope-from ) for ; Sun, 22 Sep 2024 09:10:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 0CfhJv7e72ZeYwEA62LTzQ (envelope-from ) for ; Sun, 22 Sep 2024 11:10:22 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IQf38BeF; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726996222; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/Gjh9xiQl9F1N1d5tBj8XAnhE8BMCtw3bYgN/0bM0mE=; b=O6rouvEoonFU8HxabYmfko2X2p+S6ettPkTzo7atOy29CAyXIGSSGNZk+npqup/C7r2Udd plPxQrOalXvIFSafI3TE0EN0jV5JjP9sAqutpsqIg4hm+npBPlJQ9/RUxy/trwx0BOu42u sGkt2houQywLpt64TDybFHQoVaCdUx10Gcys6Xsf+7TMjztfWDvofAHPTCkkeJHzIGz3zw FjaRvbvGgQ8Wah7F1d+9RVBBee6ZqEFlxSP+Wl/I6uJvmzIXvjgTz47uRYwXgwGA1INkmj 6t1shDvCzvTBBNRf53Qi+1c94TUxYJaHwTeJSvvzUvIYcO8UkkJe6cU4In6g/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IQf38BeF; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726996222; a=rsa-sha256; cv=none; b=UdOvu1UibBgmcBPW3cRveN5us7GzzhQblP2kXnIrZGbTBBW5aTz0douPai5pEu7F27k7La GLsyvgneAYI1xMY1VNYjD55uan/yePb7/EZ2TrafYNPe//O3vq9AwVr0ssyEG7cyXs0LzP 1hq88lGBegt0WdrLi8uouv/sV7W318tUm3ZuJracQ+lrDqcSv7vsIFD+3UlLJZzX/HeZyf WJQRE7sMV48Gub2k4lvMaw5ovdfD884POI3IkVNNJmkqFEcLhZ3ayUyqWmx8z0aDjJPZWW IFM1up/n+d+g3hzAhpiurzEwSsSaBHP25dZyd7cyX4kdYgxIlPgos6K13rdwKg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 377EB7E70A for ; Sun, 22 Sep 2024 11:10:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ssIaw-0003be-87; Sun, 22 Sep 2024 05:09:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssIau-0003b9-35 for emacs-orgmode@gnu.org; Sun, 22 Sep 2024 05:09:28 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ssIas-0002Ja-80 for emacs-orgmode@gnu.org; Sun, 22 Sep 2024 05:09:27 -0400 Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-205909afad3so40327545ad.2 for ; Sun, 22 Sep 2024 02:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726996164; x=1727600964; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=/Gjh9xiQl9F1N1d5tBj8XAnhE8BMCtw3bYgN/0bM0mE=; b=IQf38BeFYYkjA19aaI5kLAd1FSwbmJrd01NriE+3MxySVBxcvYpjG44eM8v1YrJ+t7 +PPa7pDHKQErzkGeAQEA2FkjUWDpzHRf68aN+VsSiGmuJvobk6rhK1FxrBUpBgAol70t btXVEU0uzf4MzBf0jTcYlbVWOcpEtpXqQf+EzOKVFhUpaM8rVkaUgiLeq8JEBOW6nma5 qUUNwdHny/xCrrGjH53gnuZFUJ/KtP4w0/+p7uu9upaZkXakLSFjPlOeJUbB02Lhsir+ lf4d5XirHdKO8clmjyboeLhoNAORFLkLe+pclmseMF4UNONxFO3HIz94/10mgQZJp3T4 LESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726996164; x=1727600964; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/Gjh9xiQl9F1N1d5tBj8XAnhE8BMCtw3bYgN/0bM0mE=; b=xB7Kc7uCt7Twv+JDNPIEMGBDnB1J+80Br6e6gjsmcz10HtzIizLQ/wufZZ4QF9yjgy PJGLYdzI2r6kqVgvZuawn9t3Mg4xHAJP3oMrv7whHDuulySvcQl9R5MK3guW7hkmHwMr Fx/BixsSN3MkSol8XYRq33YbFtq7DckXIAtoo4QevehcsAc8PPto/m8Bp2uh+0w/+jbC MFzWs562feYgMHI5MvVXnX/WveCRlCuJPpuECYU8gQaseXTyIdBrJyvSrc0kySwwWGnC 3HpkgxgY3ZFaOWdjrPxzBGn+QIr2C7jc/5A3TodLhNDF3Xm/SpWnzAL2dMSsIOhbRRk6 Dpew== X-Gm-Message-State: AOJu0YyyAbB7pJGFLV+pYY/G/mj5YNjKDt5kabZ/rJxqJ4QJGw3osfoP wIXcC3+fDGfWJ0cJj4gkw0EyoVlWfmoXcO/MHmJbPW7WVFb1fM9wnsObXRvM X-Google-Smtp-Source: AGHT+IFevZLePhHKs415QgciX0Zdv/FqLpawNuD+TQ3R6Jh5U+UQ67osidhIvR69E9Ar4xLbqSuFsQ== X-Received: by 2002:a17:903:181:b0:206:9640:e751 with SMTP id d9443c01a7336-208d830ed11mr135360355ad.3.1726996163930; Sun, 22 Sep 2024 02:09:23 -0700 (PDT) Received: from localhost ([118.185.152.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207946d169csm117273125ad.138.2024.09.22.02.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 02:09:23 -0700 (PDT) From: Visuwesh To: Ihor Radchenko 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/)] In-Reply-To: <87bk0grub9.fsf@localhost> (Ihor Radchenko's message of "Sun, 22 Sep 2024 08:01:14 +0000") References: <87ikuuwmz4.fsf@gmail.com> <871q1fhe0p.fsf@gmail.com> <87bk0grub9.fsf@localhost> Date: Sun, 22 Sep 2024 14:39:17 +0530 Message-ID: <877cb4f41u.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x643.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -5.61 X-Spam-Score: -5.61 X-Migadu-Queue-Id: 377EB7E70A X-Migadu-Scanner: mx10.migadu.com X-TUID: kQtCNJE0r5pT --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=9E=E0=AE=BE=E0=AE=AF=E0=AE=BF=E0=AE=B1=E0=AF=81 =E0=AE=9A=E0=AF=86= =E0=AE=AA=E0=AF=8D=E0=AE=9F=E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 22= , 2024] Ihor Radchenko wrote: > Visuwesh 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-id-Guard-against-unwarranted-major-mode-change-w.patch >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 --=-=-=--