From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#64911: 30.0.50; switch-to-buffer-preserve-window-point not respected by switch-to-(next|prev)-buffer Date: Fri, 28 Jul 2023 17:24:36 +1200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26231"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: Adam Porter To: 64911@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 28 07:36:34 2023 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 1qPG9S-0006bZ-2N for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 28 Jul 2023 07:36:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPFzN-0001Hq-Mz; Fri, 28 Jul 2023 01:26:09 -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 1qPFzI-0001Hi-8S for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 01:26:04 -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 1qPFzG-0002ZQ-Dq for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 01:26:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qPFzG-0004fV-0l for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 01:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Jul 2023 05:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64911 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169052190417878 (code B ref -1); Fri, 28 Jul 2023 05:26:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Jul 2023 05:25:04 +0000 Original-Received: from localhost ([127.0.0.1]:43479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qPFyJ-0004eG-J0 for submit@debbugs.gnu.org; Fri, 28 Jul 2023 01:25:04 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:42720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qPFyE-0004de-Um for submit@debbugs.gnu.org; Fri, 28 Jul 2023 01:25:02 -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 1qPFy8-00019X-K7 for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 01:24:52 -0400 Original-Received: from smtp-2.orcon.net.nz ([60.234.4.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qPFy6-0000Yx-HU for bug-gnu-emacs@gnu.org; Fri, 28 Jul 2023 01:24:52 -0400 Original-Received: from [10.253.37.70] (port=29455 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1qPFxs-0004F2-Fc; Fri, 28 Jul 2023 17:24:41 +1200 Original-Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Fri, 28 Jul 2023 17:24:36 +1200 X-Sender: psainty@orcon.net.nz X-GeoIP: -- Received-SPF: pass client-ip=60.234.4.43; envelope-from=psainty@orcon.net.nz; helo=smtp-2.orcon.net.nz X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:266227 Archived-At: The `switch-to-buffer-preserve-window-point' variable determines whether the (BUFFER WINDOW-START POS) data returned by `window-prev-buffers' will be used by `switch-to-buffer' to set the window's start and point positions. I think this variable should additionally be respected by both: - `switch-to-prev-buffer' - `switch-to-next-buffer' (If not others? These are the cases I'm presently aware of.) Each of the latter functions has two calls like this: (set-window-buffer-start-and-point window new-buffer (nth 1 entry) (nth 2 entry)) where `entry' comes from a call to `window-prev-buffers', and the `switch-to-buffer-preserve-window-point' value is not checked in any of those cases. In practice this is a problem because the position stored in the `window-prev-buffers' data is a marker (or at least that is the case in the scenario I am dealing with), and the buffer in question is periodically erased and regenerated. Erasing the buffer causes all its markers to be moved to position 1, so the end result is that the user loses their place. (The buffer contents are rebuilt, but the new content is typically similar if not identical to the old content, and so maintaining the original position is desirable). Tangentially there is a similar case with `quit-window' where an internal marker is set in (window-parameter WIN 'quit-restore) and subject to the above issue whenever the buffer is erased. In that instance, `display-buffer-record-window' does this: (set-window-parameter window 'quit-restore (list 'other ;; A quadruple of WINDOW's buffer, start, point and height. (list (current-buffer) (window-start window) ;; Preserve window-point-insertion-type (Bug#12855). (copy-marker (window-point window) window-point-insertion-type) (if (window-combined-p window) (window-total-height window) (window-total-width window))) (selected-window) buffer))) And `quit-restore-window' does this: ;; Restore WINDOW's previous buffer, start and point position. (set-window-buffer-start-and-point window (nth 0 quad) (nth 1 quad) (nth 2 quad)) This also doesn't test `switch-to-buffer-preserve-window-point' (or anything similar), so the only way of circumventing this behaviour that I can see is to clobber the marker with its own marker position after it's been set. I note that the cases above comprise the *only* standard calls to `set-window-buffer-start-and-point'. Maybe `set-window-buffer-start-and-point' itself should be testing `switch-to-buffer-preserve-window-point' ? -Phil In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2023-04-30 built on phil-lp Repository revision: e03cfec0a455dd8c496d33c422c8edb9ac5a4005 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Ubuntu 22.04.2 LTS Configured using: 'configure --prefix=/home/phil/emacs/trunk/usr/local --with-x-toolkit=lucid --without-sound '--program-transform-name=s/^ctags$/ctags_emacs/'' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LC_MONETARY: en_NZ.UTF-8 value of $LC_NUMERIC: en_NZ.UTF-8 value of $LC_TIME: en_NZ.UTF-8 value of $LANG: en_GB.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Help Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t isearch-fold-quotes-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t buffer-read-only: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra cl-print byte-opt gv bytecomp byte-compile help-fns radix-tree help-mode misearch multi-isearch vc-git diff-mode easy-mmode vc-dispatcher jka-compr thingatpt cl-loaddefs cl-lib find-func rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo x-toolkit xinput2 x multi-tty make-network-process emacs) Memory information: ((conses 16 61926 21737) (symbols 48 6728 0) (strings 32 21712 1476) (string-bytes 1 576559) (vectors 16 12858) (vector-slots 8 183318 15975) (floats 8 32 45) (intervals 56 1270 0) (buffers 976 14))