From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Siyuan Chen Newsgroups: gmane.emacs.bugs Subject: bug#71616: switch-to-buffer behaves inconsistently when switch-to-buffer-obey-display-actions is t and nil . Date: Sun, 23 Jun 2024 13:44:07 +0800 Message-ID: References: <86bk3zxvth.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000bb46ff061b882779" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39344"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71616@debbugs.gnu.org, Juri Linkov To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 23 07:46:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sLG3M-000A46-RA for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Jun 2024 07:46:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLG3D-00064S-88; Sun, 23 Jun 2024 01:46:07 -0400 Original-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 1sLG38-0005za-1T for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2024 01:46:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLG37-0000wb-QG for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2024 01:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sLG37-0001Gv-Us for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2024 01:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Siyuan Chen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jun 2024 05:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71616 X-GNU-PR-Package: emacs Original-Received: via spool by 71616-submit@debbugs.gnu.org id=B71616.171912152331578 (code B ref 71616); Sun, 23 Jun 2024 05:46:01 +0000 Original-Received: (at 71616) by debbugs.gnu.org; 23 Jun 2024 05:45:23 +0000 Original-Received: from localhost ([127.0.0.1]:45612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLG2V-0008Bh-4v for submit@debbugs.gnu.org; Sun, 23 Jun 2024 01:45:23 -0400 Original-Received: from mail-yb1-f179.google.com ([209.85.219.179]:56485) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLG2U-0007tx-4i for 71616@debbugs.gnu.org; Sun, 23 Jun 2024 01:45:22 -0400 Original-Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e02748b2402so3471171276.0 for <71616@debbugs.gnu.org>; Sat, 22 Jun 2024 22:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719121456; x=1719726256; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vsxituNDic4YvrV0IIx/pqCpWayvaa+70oaq0LjKzws=; b=hVFvg90DbJKDtdk2ujdOBEeR0PtG54yrnZpUY2A5J3yHcavMLPaN8+1itB5Vc2AxXp Zv/xInmbJSCq+xHrwLTKee7Xm527QgXRPwaqHQSYtHlX2DAkKYZDhWNJAUaAjyy7qX/f lUU78vELLeckNZQpdkyYhFgApHGRv6Oh75p1d4WRlLdV75x5KYd09mV+ekpdBPYt3+bt RdObw/w4gGC30SDltValPlh7ILbZ8uIWNd9aPCx1Rn4s8LwYRZ8TS5mZjTUzBu/BiMZ7 YtgUP/7aLbZxttuhXN/Wpk9MSZ0EaMD+tKJgJjZ/ZvMX7EDwd93lyMzhg9jCqfRG370t eeiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719121456; x=1719726256; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vsxituNDic4YvrV0IIx/pqCpWayvaa+70oaq0LjKzws=; b=I2lK3en4kx/9KJc5bEmaZvqjB8SPUT4qet7pY0a/2ByhOLybz5EJY3hNzqrIYu7SJ5 KXcwkXxXbXc2ohzaJK0ALZsYDaFKpr6rXTJ89MvMya3UuVmZqP4K+9IRkTmuokDdjenG sT1K1ZiytRuW7eEuZaU8fU9j3oLG5tXBsNEiVkP/r3YYLxfH+EZc23R/1DLAUYahxcCw gmT/FWSIU6zWx3wSbbDHk77CChsw73mLiMwzUxkb1ykIZJdbLpiCcdbcEyFBSXvzd7Ov zO4t7TPeH2yqK+pcdLzvEqznBZUFdHpQYC3JUolpdQiNG+Ql5ZeRbHYlCkPSMKb1oZy4 2qNw== X-Forwarded-Encrypted: i=1; AJvYcCUKKG69OGSh83VCQxp6gnOG+ULe8L+Kl6wZwAwotxmKaNczIAXNh16+y6p4frRimb5u6KJQcEXZG8aKIb/iKKGJ92M8AxA= X-Gm-Message-State: AOJu0YxnRU2QQFJxno/mcNqNI4BxsuiPs+WI0vjz32u2qiNVA+bmyskU XHz6MWzaVSrqs1TWR1ni9KQKg9H4K9Gy8fWjqDxUicaHY32uUsSJ8Wme4MTyk4NURWafoBdpRL8 J8AfoYJEWq091M3pjQ2D7y4+qqQk= X-Google-Smtp-Source: AGHT+IEhPgLhanC3j8dJj61PzshlNueLJ0nDTtU8sv+oyUHtoTFAC+9u/y4By9SckS0u3lJLzHzZ4ve7JCJ+DR9EU5Y= X-Received: by 2002:a05:6902:2486:b0:e02:bf87:7cc7 with SMTP id 3f1490d57ef6-e0304025c08mr1308041276.64.1719121456348; Sat, 22 Jun 2024 22:44:16 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287763 Archived-At: --000000000000bb46ff061b882779 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This patch fixed my original use case, which did not touch 'set-window-buffer'. Thanks. Best regards, Siyuan Chen On Wed, Jun 19, 2024 at 5:37=E2=80=AFPM martin rudalics w= rote: > >> ## Test with switch-to-buffer-obey-display-actions =3D t > >> 1. Emacs -Q > >> 2. M-x eval-expression (setq switch-to-buffer-obey-display-actions t) > >> 2. Open a .el file, e.g. window.el, and keep the cursor location at 1 > >> 3. Click buffers menu -> *scratch* to switch buffer > >> 4. Click buffers menu -> window.el to switch buffer back > >> 5. Move the current location to L24 > >> 6. M-x switch-to-buffer window.el > >> The result is that the current cursor location jumps to location at 1= ! > >> This inconsistent behavior convinced me that this is a bug. > > > > I confirm this in Emacs 30. Maybe Martin could suggest how to fix > >> this. > > A recipe without involving a file is > > 1. M-: (setq switch-to-buffer-obey-display-actions t) > 2. C-x b *Messages* > 3. C-x b *scratch* > 4. Move point > 5. C-x b *scratch* > > In step 2 we record the point of *scratch*. In 5 we go there because > the 'set-window-buffer' called by C-x b decides that the window already > shows buffer and does not record its current position. I attach a patch > that should fix this and the original scenario. It does _not_ fix the > case where instead of C-x b plain 'set-window-buffer' is used. If we > wanted to fix that, we'd have to call 'record-window-buffer' from there > even when the old and the new buffer are the same. I'm not sure whether > we want to do that. > > martin --000000000000bb46ff061b882779 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This patch fixed my original use case, which did not = touch 'set-window-buffer'.

Thanks.

Best regards,
Siyuan Chen

On Wed, Jun = 19, 2024 at 5:37=E2=80=AFPM martin rudalics <rudalics@gmx.at> wrote:
=C2=A0>> ## Test with switch-to-buffer-obey-di= splay-actions =3D t
=C2=A0>> 1. Emacs -Q
=C2=A0>> 2. M-x eval-expression (setq switch-to-buffer-obey-display-a= ctions t)
=C2=A0>> 2. Open a .el file, e.g. window.el, and keep the cursor loca= tion at 1
=C2=A0>> 3. Click buffers menu -> *scratch* to switch buffer
=C2=A0>> 4. Click buffers menu -> window.el to switch buffer back<= br> =C2=A0>> 5. Move the current location to L24
=C2=A0>> 6. M-x switch-to-buffer window.el
=C2=A0>> The result is that the current cursor location jumps to loca= tion at 1!
=C2=A0>> This inconsistent behavior convinced me that this is a bug.<= br> =C2=A0>
=C2=A0> I confirm this in Emacs 30.=C2=A0 Maybe Martin could suggest how= to fix
=C2=A0>> this.

A recipe without involving a file is

1. M-: (setq switch-to-buffer-obey-display-actions t)
2. C-x b *Messages*
3. C-x b *scratch*
4. Move point
5. C-x b *scratch*

In step 2 we record the point of *scratch*.=C2=A0 In 5 we go there because<= br> the 'set-window-buffer' called by C-x b decides that the window alr= eady
shows buffer and does not record its current position.=C2=A0 I attach a pat= ch
that should fix this and the original scenario.=C2=A0 It does _not_ fix the=
case where instead of C-x b plain 'set-window-buffer' is used.=C2= =A0 If we
wanted to fix that, we'd have to call 'record-window-buffer' fr= om there
even when the old and the new buffer are the same.=C2=A0 I'm not sure w= hether
we want to do that.

martin
--000000000000bb46ff061b882779--