From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evgeny Zajcev Newsgroups: gmane.emacs.devel Subject: Buffer local `switch-to-buffer-preserve-window-point' Date: Mon, 30 Nov 2020 11:03:30 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cbedee05b54e72cf" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38803"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 30 09:05:34 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kjeBi-0009zG-9l for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Nov 2020 09:05:34 +0100 Original-Received: from localhost ([::1]:56028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjeBh-0007GU-CL for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Nov 2020 03:05:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjeA1-0006lp-RA for emacs-devel@gnu.org; Mon, 30 Nov 2020 03:03:49 -0500 Original-Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:40513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kje9w-00063A-IZ for emacs-devel@gnu.org; Mon, 30 Nov 2020 03:03:49 -0500 Original-Received: by mail-lj1-x22c.google.com with SMTP id y10so16337426ljc.7 for ; Mon, 30 Nov 2020 00:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=CV3i8q3lK0ZbvsY+QRuY0F+1YQmTdJTdMgPcCb7GOL0=; b=jMlDXId3CIKkDKDGRm90bs3XleYijAqsDuS4vVNBo8TRZVuhI8KDCLkxy8p2bdEFEp lC/LdMR/4YMsmvsyCMwWEDu8FOpUttVq0EjoZ7wn/HrZYPcmNi8wtAIaBXY/UDfCuyoH VsvGvZYW2GBC4aIV3Z1JFAPmQI+DnNDiwnZFAZ9+OzMUZqRCNh+we9XGpZOgiwabnwq9 QKdkAz3Q+kczLEkdQ2XpWGSCHCO5jTf6IJha9RU8HLoBD/5//y0esKWmgN90TlJcDT9D lh1K0yvdMYPpk1A6ClffDXnxWVndqJF9t0RizbRd5iXaUIf6a60OFsiAoFwcsrOKSAwP CPOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CV3i8q3lK0ZbvsY+QRuY0F+1YQmTdJTdMgPcCb7GOL0=; b=fbQApnOz2Z0Hb4X3X6SiGy2EhWGkDJq1C/Pr5cYmw8YkfsS6MxUqbNPsbHhgy43S1W LQyU5uVr969wbweGlERucNH5ihYu/94sNYkaYawle4zNmg/10ZIekhbVfKvSloYmx9gR TuMDp+bmzBHjZCH+IqwbvVAaaCKRXyAcSpLs7AcYqLEr3d44q7e94BG91L7KyY1U4K0e Zc5V0ae7RhLbmeKKDMGDZkdyaPn2mkZd+b6MZCT7+yKR/ZcTvINu1MhNiZAENJyB4rQP Keth+XVoWy713SES3mBZhxK5FgEjWaiuUPzXK/9/rqg1V28Tv4JBKusBI4pSQFWJAgc9 CmUw== X-Gm-Message-State: AOAM531p3tqZ0yFOE3P1nmX1JsP1vzbP5L1ieudiSbxkBIonYpKzTXa1 j07g/OG6/nF3JGPqmvI2MLfUx1msd1APS7XDF0ZGpBXytJg= X-Google-Smtp-Source: ABdhPJwMF7C4dY7kNs7hYjen4tRIRQmEhZFHjP3tHC2nd+dzMpjFv70sQhLLLaKvWCQsu+rcDA3THrcmkorQK80HQ7g= X-Received: by 2002:a2e:b013:: with SMTP id y19mr8876510ljk.50.1606723421595; Mon, 30 Nov 2020 00:03:41 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=lg.zevlg@gmail.com; helo=mail-lj1-x22c.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, HTML_MESSAGE=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-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:260054 Archived-At: --000000000000cbedee05b54e72cf Content-Type: text/plain; charset="UTF-8" I think we should add to the documentation that buffer local values for `switch-to-buffer-obey-display-actions' and `switch-to-buffer-preserve-window-point' won't work as user would expect. The problem with their buffer local values is that they are used for buffer logic *before* buffer is set as current, see `switch-to-buffer'. We should either use `(buffer-local-value NAME buffer)' to get their values in `switch-to-buffer', or add to the documentation that they should not have buffer local values. Here is code snippet to trigger unexpected behaviour: ;; Switch to scratch and eval (progn (setq switch-to-buffer-preserve-window-point t) (with-current-buffer (get-buffer-create "pwp") (setq-local switch-to-buffer-preserve-window-point nil) (insert "asnoteh asoensnaot heusnatoeh usanotehu aeosntuhaoe") (point)) (switch-to-buffer "pwp") (switch-to-other-buffer 1) (with-current-buffer "pwp" (goto-char 10) (point)) (switch-to-buffer "pwp") ;; Expecting point to be at 10 position, but it remains at the end ;; of the line ) What do you think? Thanks -- lg --000000000000cbedee05b54e72cf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think we should add to the documentation that buffe= r local values for `switch-to-buffer-obey-display-actions' and `switch-= to-buffer-preserve-window-point' won't work as user would expect.

The problem with their buffer local values is that = they are used for buffer logic *before* buffer is set as current, see `swit= ch-to-buffer'.=C2=A0 We should either use `(buffer-local-value NAME buf= fer)' to get their values in `switch-to-buffer', or add to the docu= mentation that they should not have buffer local values.

Here is code snippet to trigger unexpected behaviour:

=
=C2=A0 ;; Switch to scratch and eval
=C2=A0 (progn
=C2=A0 = =C2=A0 (setq switch-to-buffer-preserve-window-point t)
=C2=A0 =C2=A0 (wi= th-current-buffer (get-buffer-create "pwp")
=C2=A0 =C2=A0 =C2= =A0(setq-local switch-to-buffer-preserve-window-point nil)
=C2=A0 =C2=A0= =C2=A0(insert "asnoteh asoensnaot heusnatoeh usanotehu aeosntuhaoe&qu= ot;)
=C2=A0 =C2=A0 =C2=A0(point))
=C2=A0 =C2=A0 (switch-to-buffer &qu= ot;pwp")
=C2=A0 =C2=A0 (switch-to-other-buffer 1)
=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 (with-current-buffer "pwp"
=C2=A0 =C2=A0 =C2= =A0(goto-char 10)
=C2=A0 =C2=A0 =C2=A0(point))
=C2=A0 =C2=A0 (switch-= to-buffer "pwp")
=C2=A0 =C2=A0 ;; Expecting point to be at 10 = position, but it remains at the end
=C2=A0 =C2=A0 ;; of the line
=C2= =A0 =C2=A0 )

What do you think?

Thanks

--
lg
--000000000000cbedee05b54e72cf--