From unknown Fri Aug 15 12:52:00 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#48294 <48294@debbugs.gnu.org> To: bug#48294 <48294@debbugs.gnu.org> Subject: Status: Use 'with-current-buffer' byte-compiler warning seems wrong Reply-To: bug#48294 <48294@debbugs.gnu.org> Date: Fri, 15 Aug 2025 19:52:00 +0000 retitle 48294 Use 'with-current-buffer' byte-compiler warning seems wrong reassign 48294 emacs submitter 48294 rswgnu@gmail.com severity 48294 normal tag 48294 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sat May 08 16:14:38 2021 Received: (at submit) by debbugs.gnu.org; 8 May 2021 20:14:38 +0000 Received: from localhost ([127.0.0.1]:52047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfTLS-00051N-Fo for submit@debbugs.gnu.org; Sat, 08 May 2021 16:14:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:54794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfTLQ-00051F-UA for submit@debbugs.gnu.org; Sat, 08 May 2021 16:14:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfTLQ-0006d5-P4 for bug-gnu-emacs@gnu.org; Sat, 08 May 2021 16:14:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44726) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfTLQ-0006So-IL for bug-gnu-emacs@gnu.org; Sat, 08 May 2021 16:14:36 -0400 Received: from mail-lj1-f182.google.com ([209.85.208.182]:37736) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfTLQ-0002Zw-8N for bug-gnu-emacs@gnu.org; Sat, 08 May 2021 16:14:36 -0400 Received: by mail-lj1-f182.google.com with SMTP id b7so15905563ljr.4 for ; Sat, 08 May 2021 13:14:36 -0700 (PDT) X-Gm-Message-State: AOAM530RFCFfIHqs9IEDS+ASMFD38r0K5xy6iVsM+vCSu5u5YW2eUvY2 L8zDQbE1jlSln7oFRvayqQ0wlzOVU4mdfeW1tKQ= X-Google-Smtp-Source: ABdhPJxtvB1veYHmVw7d4U7bdOinrTAuopc8W2ribcd3pd6SGgUQLReycPiuYuvd5bo5qUavTef9vYu+J6ynwEtKoS8= X-Received: by 2002:a2e:a60c:: with SMTP id v12mr13533123ljp.310.1620504874735; Sat, 08 May 2021 13:14:34 -0700 (PDT) MIME-Version: 1.0 From: Robert Weiner Date: Sat, 8 May 2021 16:14:09 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Use 'with-current-buffer' byte-compiler warning seems wrong To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000006a5b7805c1d731b5" X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: rswgnu@gmail.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --0000000000006a5b7805c1d731b5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi: I get a lot of these byte-compile warnings in my Elisp code: hbut.el:683:26:Warning: Use =E2=80=98with-current-buffer=E2=80=99 rather th= an save-excursion+set-buffer but since with-current-buffer does not save the value of point, it is not a valid substitute for save-excursion and should not be suggested. Evaluate the two samples below and you will see that they are not equivalent. If I am correct, I'd like this suggestion disabled. Thanks. -- rsw (save-excursion (set-buffer (current-buffer)) (forward-char 20)) (with-current-buffer (current-buffer) (forward-char 20)) ------ In GNU Emacs 27.1.90 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2020-12-18 built on builder10-14.porkrind.org Windowing system distributor 'Apple', version 10.3.1894 System Description: Mac OS X 10.15.7 Configured using: 'configure --with-ns '--enable-locallisppath=3D/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS JSON PDUMPER Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction --0000000000006a5b7805c1d731b5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi:

I get a lot of these byte-compile warnings in my Elisp cod= e:

hbut.el:683:26:Warning: Use =E2=80=98with-current-buffer=E2=80=99= rather than
=C2=A0 =C2=A0 save-excursion+set-buffer

but since wi= th-current-buffer does not save the value of point, it is
not a valid su= bstitute for save-excursion and should not be suggested.
Evaluate the tw= o samples below and you will see that they are not
equivalent.=C2=A0 If = I am correct, I'd like this suggestion disabled.=C2=A0 Thanks. =C2=A0--= rsw

(save-excursion
=C2=A0 (set-buffer (current-buffer))
=C2= =A0 (forward-char 20))

(with-current-buffer (current-buffer)
=C2= =A0 (forward-char 20))

------


In GNU Emacs 27.1.90 (build= 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G= 95))
=C2=A0of 2020-12-18 built on builder10-14.porkrind.org
Windowing system distributor 'A= pple', version 10.3.1894
System Description: =C2=A0Mac OS X 10.15.7<= br>
Configured using:
=C2=A0'configure --with-ns '--enable-lo= callisppath=3D/Library/Application
=C2=A0Support/Emacs/${version}/site-l= isp:/Library/Application
=C2=A0Support/Emacs/site-lisp' --with-modul= es'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLI= B TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER

Important s= ettings:
=C2=A0 value of $LANG: en_US.UTF-8
=C2=A0 locale-coding-syst= em: utf-8-unix

Major mode: Lisp Interaction

--0000000000006a5b7805c1d731b5-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 04:05:54 2021 Received: (at 48294) by debbugs.gnu.org; 9 May 2021 08:05:54 +0000 Received: from localhost ([127.0.0.1]:54915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfeRm-0008DR-9H for submit@debbugs.gnu.org; Sun, 09 May 2021 04:05:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60150) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfeRk-0008DE-Ih; Sun, 09 May 2021 04:05:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55662) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfeRf-0003Sz-CD; Sun, 09 May 2021 04:05:47 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2157 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfeRe-0006kO-NY; Sun, 09 May 2021 04:05:47 -0400 Date: Sun, 09 May 2021 11:05:47 +0300 Message-Id: <83k0o88h7o.fsf@gnu.org> From: Eli Zaretskii To: rswgnu@gmail.com In-Reply-To: (message from Robert Weiner on Sat, 8 May 2021 16:14:09 -0400) Subject: Re: bug#48294: Use 'with-current-buffer' byte-compiler warning seems wrong References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 48294 Cc: 48294@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 48294 notabug thanks > From: Robert Weiner > Date: Sat, 8 May 2021 16:14:09 -0400 > > I get a lot of these byte-compile warnings in my Elisp code: > > hbut.el:683:26:Warning: Use ‘with-current-buffer’ rather than > save-excursion+set-buffer > > but since with-current-buffer does not save the value of point, it is > not a valid substitute for save-excursion and should not be suggested. > Evaluate the two samples below and you will see that they are not > equivalent. If I am correct, I'd like this suggestion disabled. Thanks. -- rsw > > (save-excursion > (set-buffer (current-buffer)) > (forward-char 20)) > > (with-current-buffer (current-buffer) > (forward-char 20)) The ELisp manual says about this: Because ‘save-excursion’ only saves point for the buffer that was current at the start of the excursion, any changes made to point in other buffers, during the excursion, will remain in effect afterward. This frequently leads to unintended consequences, so the byte compiler warns if you call ‘set-buffer’ during an excursion: Warning: Use ‘with-current-buffer’ rather than save-excursion+set-buffer To avoid such problems, you should call ‘save-excursion’ only after setting the desired current buffer, as in the following example: (defun append-string-to-buffer (string buffer) "Append STRING to the end of BUFFER." (with-current-buffer buffer (save-excursion (goto-char (point-max)) (insert string)))) I believe this example shows how to solve your problem. From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 06:11:02 2021 Received: (at control) by debbugs.gnu.org; 9 May 2021 10:11:03 +0000 Received: from localhost ([127.0.0.1]:55254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfgOs-0007fa-Ok for submit@debbugs.gnu.org; Sun, 09 May 2021 06:11:02 -0400 Received: from quimby.gnus.org ([95.216.78.240]:52486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfgOr-0007f6-G4 for control@debbugs.gnu.org; Sun, 09 May 2021 06:11:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PzwDYr7G7Sadj/GyDVu1aXtuIg88uhOxyxtXY/EiLX8=; b=OUYr3CirYsF7bKObuh/+LtPVpj TlaxlxUWBi9Qed/DR/lezVqmvq0Yur5e4ZqRlk3bld7aPE8glb3NNR4O0JkSH/Mwj1xthJKl1gOPB 2n5q7vzwgJ7ke5kOcVbnL3b0iVYfjQkPxL+0vjNesTopDINADI+Zm0ni5ygciwISuFQE=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lfgOk-00086p-4b for control@debbugs.gnu.org; Sun, 09 May 2021 12:10:56 +0200 Date: Sun, 09 May 2021 12:10:53 +0200 Message-Id: <87bl9knro2.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #48294 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 48294 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 48294 quit From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 11:58:00 2021 Received: (at 48294) by debbugs.gnu.org; 9 May 2021 15:58:00 +0000 Received: from localhost ([127.0.0.1]:55991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lflod-000114-IP for submit@debbugs.gnu.org; Sun, 09 May 2021 11:57:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfloc-00010h-1G for 48294@debbugs.gnu.org; Sun, 09 May 2021 11:57:59 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36334) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfloW-0005qb-NG for 48294@debbugs.gnu.org; Sun, 09 May 2021 11:57:52 -0400 Received: from mail-lj1-f169.google.com ([209.85.208.169]:35777) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfloW-0005o5-HK for 48294@debbugs.gnu.org; Sun, 09 May 2021 11:57:52 -0400 Received: by mail-lj1-f169.google.com with SMTP id f12so5157201ljp.2 for <48294@debbugs.gnu.org>; Sun, 09 May 2021 08:57:52 -0700 (PDT) X-Gm-Message-State: AOAM5330EJtwyNQVt8X7JNinjqYXFnxPWhpf/OFqXG13f6vsNEWchGTV RAVISHzTyLHHjDWmE6hAOutCmG7hYZrpd49flhw= X-Google-Smtp-Source: ABdhPJwrRZeDI40HtBXaMDTn2R47/Pp/WrFZxZNZ8KjMoJ5p2DC7n2OcNNGhE2aXo78jXr5TnzJQEGzJTjX0oNX0SRM= X-Received: by 2002:a2e:a60c:: with SMTP id v12mr17302049ljp.310.1620575871135; Sun, 09 May 2021 08:57:51 -0700 (PDT) MIME-Version: 1.0 References: <83k0o88h7o.fsf@gnu.org> In-Reply-To: <83k0o88h7o.fsf@gnu.org> From: Robert Weiner Date: Sun, 9 May 2021 11:57:25 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: bug#48294: Use 'with-current-buffer' byte-compiler warning seems wrong To: Eli Zaretskii Content-Type: multipart/alternative; boundary="00000000000021737805c1e7b979" X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 48294 Cc: 48294@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: rswgnu@gmail.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --00000000000021737805c1e7b979 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Eli: Thanks for the feedback. Everything you wrote is very clear. The issue, however, is that I want to save point in the current buffer prior to switching context to the 'with-current-buffer' buffer, just as my (save-excursion (set-buffer ...)) code does. If I move the save-excursion into the with-current-buffer body, then it applies to the new buffer not the original one and if in that same body we change buffers again to the original and move point, then that movement will stay in place. So the question is, what is the appropriate code that the byte-compiler will accept when you want to save your original place before switching buffers. Do I have to just do a (let ((opoint (point))) ...) and then restore it? The issue is that within the with-current-buffer body, there could be a hard to trace sequence of calls any of which could switch back to the original buffer and move point. So how would you protect against that? Thanks, Bob On Sun, May 9, 2021 at 4:05 AM Eli Zaretskii wrote: > tags 48294 notabug > thanks > > > From: Robert Weiner > > Date: Sat, 8 May 2021 16:14:09 -0400 > > > > I get a lot of these byte-compile warnings in my Elisp code: > > > > hbut.el:683:26:Warning: Use =E2=80=98with-current-buffer=E2=80=99 rathe= r than > > save-excursion+set-buffer > > > > but since with-current-buffer does not save the value of point, it is > > not a valid substitute for save-excursion and should not be suggested. > > Evaluate the two samples below and you will see that they are not > > equivalent. If I am correct, I'd like this suggestion disabled. > Thanks. -- rsw > > > > (save-excursion > > (set-buffer (current-buffer)) > > (forward-char 20)) > > > > (with-current-buffer (current-buffer) > > (forward-char 20)) > > The ELisp manual says about this: > > Because =E2=80=98save-excursion=E2=80=99 only saves point for the bu= ffer that was > current at the start of the excursion, any changes made to point in > other buffers, during the excursion, will remain in effect afterward. > This frequently leads to unintended consequences, so the byte compiler > warns if you call =E2=80=98set-buffer=E2=80=99 during an excursion: > > Warning: Use =E2=80=98with-current-buffer=E2=80=99 rather than > save-excursion+set-buffer > > To avoid such problems, you should call =E2=80=98save-excursion=E2=80= =99 only after > setting the desired current buffer, as in the following example: > > (defun append-string-to-buffer (string buffer) > "Append STRING to the end of BUFFER." > (with-current-buffer buffer > (save-excursion > (goto-char (point-max)) > (insert string)))) > > I believe this example shows how to solve your problem. > --00000000000021737805c1e7b979 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Eli:

Thanks for the feedback.=C2=A0 Everything you w= rote is very clear.=C2=A0 The issue, however, is that I want to save point = in the current buffer prior to switching context to the 'with-current-b= uffer' buffer, just as my (save-excursion (set-buffer ...)) code does.= =C2=A0 If I move the save-excursion into the with-current-buffer body, then= it applies to the new buffer not the original one and if in that same body= we change buffers again to the original and move point, then that movement= will stay in place.=C2=A0 So the question is, what is the appropriate code= that the byte-compiler will accept when you want to save your original pla= ce before switching buffers.=C2=A0 Do I have to just do a (let ((opoint (po= int))) ...) and then restore it?=C2=A0 The issue is that within the with-cu= rrent-buffer body, there could be a hard to trace sequence of calls any of = which could switch back to the original buffer and move point.=C2=A0 So how= would you protect against that?

Thanks,

Bob


On S= un, May 9, 2021 at 4:05 AM Eli Zaretskii <eliz@gnu.org> wrote:
tags 48294 notabug
thanks

> From: Robert Weiner <rsw@gnu.org>
> Date: Sat, 8 May 2021 16:14:09 -0400
>
> I get a lot of these byte-compile warnings in my Elisp code:
>
> hbut.el:683:26:Warning: Use =E2=80=98with-current-buffer=E2=80=99 rath= er than
>=C2=A0 =C2=A0 =C2=A0save-excursion+set-buffer
>
> but since with-current-buffer does not save the value of point, it is<= br> > not a valid substitute for save-excursion and should not be suggested.=
> Evaluate the two samples below and you will see that they are not
> equivalent.=C2=A0 If I am correct, I'd like this suggestion disabl= ed.=C2=A0 Thanks.=C2=A0 -- rsw
>
> (save-excursion
>=C2=A0 =C2=A0(set-buffer (current-buffer))
>=C2=A0 =C2=A0(forward-char 20))
>
> (with-current-buffer (current-buffer)
>=C2=A0 =C2=A0(forward-char 20))

The ELisp manual says about this:

=C2=A0 =C2=A0 =C2=A0Because =E2=80=98save-excursion=E2=80=99 only saves poi= nt for the buffer that was
=C2=A0 current at the start of the excursion, any changes made to point in<= br> =C2=A0 other buffers, during the excursion, will remain in effect afterward= .
=C2=A0 This frequently leads to unintended consequences, so the byte compil= er
=C2=A0 warns if you call =E2=80=98set-buffer=E2=80=99 during an excursion:<= br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0Warning: Use =E2=80=98with-current-buffer=E2=80= =99 rather than
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 save-excursion+set-= buffer

=C2=A0 To avoid such problems, you should call =E2=80=98save-excursion=E2= =80=99 only after
=C2=A0 setting the desired current buffer, as in the following example:

=C2=A0 =C2=A0 =C2=A0 =C2=A0(defun append-string-to-buffer (string buffer) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Append STRING to the end of BUFFER.= "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-current-buffer buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-max))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert string))))

I believe this example shows how to solve your problem.
--00000000000021737805c1e7b979-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 12:11:18 2021 Received: (at 48294) by debbugs.gnu.org; 9 May 2021 16:11:18 +0000 Received: from localhost ([127.0.0.1]:56065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfm1V-0001As-UF for submit@debbugs.gnu.org; Sun, 09 May 2021 12:11:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfm1U-0001Am-E8 for 48294@debbugs.gnu.org; Sun, 09 May 2021 12:11:16 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36850) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfm1P-0005A7-9d; Sun, 09 May 2021 12:11:11 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4377 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfm1O-0007oW-Oe; Sun, 09 May 2021 12:11:11 -0400 Date: Sun, 09 May 2021 19:11:13 +0300 Message-Id: <83zgx37uqm.fsf@gnu.org> From: Eli Zaretskii To: rswgnu@gmail.com In-Reply-To: (message from Robert Weiner on Sun, 9 May 2021 11:57:25 -0400) Subject: Re: bug#48294: Use 'with-current-buffer' byte-compiler warning seems wrong References: <83k0o88h7o.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 48294 Cc: 48294@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Robert Weiner > Date: Sun, 9 May 2021 11:57:25 -0400 > Cc: 48294@debbugs.gnu.org > > Thanks for the feedback. Everything you wrote is very clear. The issue, however, is that I want to save > point in the current buffer prior to switching context to the 'with-current-buffer' buffer, just as my > (save-excursion (set-buffer ...)) code does. If I move the save-excursion into the with-current-buffer body, > then it applies to the new buffer not the original one and if in that same body we change buffers again to the > original and move point, then that movement will stay in place. So the question is, what is the appropriate > code that the byte-compiler will accept when you want to save your original place before switching buffers. I don't understand: with-current-buffer doesn't change point of the original buffer, so why do you need to save it? From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 14:09:37 2021 Received: (at 48294) by debbugs.gnu.org; 9 May 2021 18:09:38 +0000 Received: from localhost ([127.0.0.1]:56569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfns1-0007G7-A9 for submit@debbugs.gnu.org; Sun, 09 May 2021 14:09:37 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]:45885) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfnru-0007FX-VP for 48294@debbugs.gnu.org; Sun, 09 May 2021 14:09:34 -0400 Received: by mail-qt1-f182.google.com with SMTP id j11so10379498qtn.12 for <48294@debbugs.gnu.org>; Sun, 09 May 2021 11:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=IJg4df36H0QN5L3w+Sd5LTkL+z2RMzwkCcR4iQsyIIg=; b=bJoNca2rTDnI5MBfArXy3eEvyx3MDzh5FqHLlK2IhQuBCk8WfQoj9WvZFxfpoxfp0c kOFVkv4x8AA9gfZfDosEXpDN/C7tB3iIWKYSjTUbWEJqtLaVKfVtU5P0O1/CDzHeOwiV Jyq8IRXgPY6AzN3TefZ5QFF5WnSyO/kkPhlG6NlD28dHX4aIgoBQuxtLOLJp1WNUg/kz 8c8+fl5REzx3MElbUV+g1Hy/y1gUPtI9fuP3ndrOhawI7pjQ3QtFu631J9zz4rjc/D9K /yKEhp2w6Ofa8WndN9rp+X7NOYAvlLLuK3yPwOwmmnv8qJ3g7x6lq+EbhPpvhbeZlk6P 3JHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=IJg4df36H0QN5L3w+Sd5LTkL+z2RMzwkCcR4iQsyIIg=; b=S2sUJjlTKDktvUAhE2s8XRtNSoF0z5ngocdrBkZ5XK0O8VWfnmSx7lkRnP5ahJAW2W YDnLu/G3xTltR/llwziKTmjVLIBc94Mpax/4+pr/i50FCCJgz/vW24yhJmw3ekdjH8Tc shdlLSRQXGt774CPu0EUi3dQl9XG0XJsNLYI6ZVnHP+FM0tCNngdrwe7NbNqR/5p71Rp SgE3QLqb7QSJ/sSJ4lmpFH05Xa77fsHkx33eLY25tOYQaTlncxd7aBKu36RorGOSIqS9 B+8dqEIdDcMpo+8cqdEDdAUuj0TrIE5Rx5DFSBZEbPTcH9iLvah4rBfVEbRyIl14qHdw xxHQ== X-Gm-Message-State: AOAM533azGivlryxZDvuWb3v/AmQEDYTQZGVy4L13dcBe/g7eRAyKs8+ asG8yiU13WjWNIWQSJ+4rkCLBxfn6Fc= X-Google-Smtp-Source: ABdhPJxEP0flh5SLyL3rH2KDQ9cfxEGNUi/Ghj1X/szClBwBzpM3z18nnenM8Ddw91f2/knIlB8CQw== X-Received: by 2002:a05:622a:88:: with SMTP id o8mr19758956qtw.39.1620583765301; Sun, 09 May 2021 11:09:25 -0700 (PDT) Received: from ?IPv6:2600:1000:b14f:b389:31c9:e8e2:e782:65b5? ([2600:1000:b14f:b389:31c9:e8e2:e782:65b5]) by smtp.gmail.com with ESMTPSA id t128sm9524051qkh.50.2021.05.09.11.09.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 May 2021 11:09:24 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Robert Weiner Mime-Version: 1.0 (1.0) Subject: Re: bug#48294: Use 'with-current-buffer' byte-compiler warning seems wrong Date: Sun, 9 May 2021 14:09:23 -0400 Message-Id: References: <83zgx37uqm.fsf@gnu.org> In-Reply-To: <83zgx37uqm.fsf@gnu.org> To: Eli Zaretskii X-Mailer: iPhone Mail (18D70) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 48294 Cc: 48294@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Somtimes a nested function within the body of the with-current-buffer will c= hange the buffer and move point in the original buffer and this may largely o= nly be known at run-time. -- Bob > On May 9, 2021, at 12:11 PM, Eli Zaretskii wrote: >=20 > =EF=BB=BF >>=20 >> From: Robert Weiner >> Date: Sun, 9 May 2021 11:57:25 -0400 >> Cc: 48294@debbugs.gnu.org >>=20 >> Thanks for the feedback. Everything you wrote is very clear. The issue,= however, is that I want to save >> point in the current buffer prior to switching context to the 'with-curre= nt-buffer' buffer, just as my >> (save-excursion (set-buffer ...)) code does. If I move the save-excursio= n into the with-current-buffer body, >> then it applies to the new buffer not the original one and if in that sam= e body we change buffers again to the >> original and move point, then that movement will stay in place. So the q= uestion is, what is the appropriate >> code that the byte-compiler will accept when you want to save your origin= al place before switching buffers.=20 >=20 > I don't understand: with-current-buffer doesn't change point of the > original buffer, so why do you need to save it? From debbugs-submit-bounces@debbugs.gnu.org Sun May 09 14:24:48 2021 Received: (at 48294) by debbugs.gnu.org; 9 May 2021 18:24:48 +0000 Received: from localhost ([127.0.0.1]:56594 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfo6i-0007d2-0q for submit@debbugs.gnu.org; Sun, 09 May 2021 14:24:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfo6g-0007co-1D for 48294@debbugs.gnu.org; Sun, 09 May 2021 14:24:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39892) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfo6a-0003b9-Rj; Sun, 09 May 2021 14:24:40 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4662 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfo6a-0001Jn-Dp; Sun, 09 May 2021 14:24:40 -0400 Date: Sun, 09 May 2021 21:24:41 +0300 Message-Id: <83im3r7ok6.fsf@gnu.org> From: Eli Zaretskii To: Robert Weiner In-Reply-To: (message from Robert Weiner on Sun, 9 May 2021 14:09:23 -0400) Subject: Re: bug#48294: Use 'with-current-buffer' byte-compiler warning seems wrong References: <83zgx37uqm.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 48294 Cc: 48294@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Robert Weiner > Date: Sun, 9 May 2021 14:09:23 -0400 > Cc: 48294@debbugs.gnu.org > > Somtimes a nested function within the body of the with-current-buffer will change the buffer and move point in the original buffer and this may largely only be known at run-time. Then I'd use save-excursion outside of with-current-buffer. From unknown Fri Aug 15 12:52:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 07 Jun 2021 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator