From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 12:39:26 2025 Received: (at submit) by debbugs.gnu.org; 23 Mar 2025 16:39:26 +0000 Received: from localhost ([127.0.0.1]:52230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twOM9-0007Ty-Cw for submit@debbugs.gnu.org; Sun, 23 Mar 2025 12:39:26 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33904) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twOM6-0007TR-7W for submit@debbugs.gnu.org; Sun, 23 Mar 2025 12:39:23 -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 1twOM0-0005iQ-SW for bug-gnu-emacs@gnu.org; Sun, 23 Mar 2025 12:39:16 -0400 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1] helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1twOLy-0004Ss-7V for bug-gnu-emacs@gnu.org; Sun, 23 Mar 2025 12:39:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc: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=EGFMRRmoG90F3fImMqlIq2+jyrPSW7VS81BQrzBTbgM=; b=kK2TM41R6kec9x6RXA3LvU3oiF ujBozYC7conOyVz4QHjlIcbU7hVUc4V0OmkHBYKC3TP+bwKC6PbzTFbMoy7try5tvFIWaT0ZSU5Oz ejy1EKxfr8NK3EmKF4az8A0+VEDzzmQ+fiZ3bUU7YpEfpvYvA2Ip5rlcxIB3/uobJl7U=; From: Daniel Mendler To: bug-gnu-emacs@gnu.org Subject: 30.1.50; ibuffer - preserve window position when updating X-Debbugs-Cc: Date: Sun, 23 Mar 2025 17:38:53 +0100 Message-ID: <87r02nu2g2.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a01:4f8:c012:9177::1; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Ibuffer updates its buffer content after actions on the buffers, when the buffer list changes if `ibuffer-auto-mode' is enabled, or when pressing "g", which invokes `ibuffer-update'. The buffer update leads to movement of the window point and window start position. In particular if the buffer list has many buffers, such that the list does not fit into the window, the Ibuffer content jumps after an update. Right now I use the following advice which tries to preserve the window position and tries to prevent the jumping during an update: (advice-add #'ibuffer-redisplay-engine :around #'ibuffer-preserve-position) (defun ibuffer-preserve-position (&rest app) (if-let ((buf (get-buffer "*Ibuffer*"))) (let (restore) (dolist (win (get-buffer-window-list buf)) (let ((pt (window-point win)) (start (window-start win))) (push (lambda () (when (eq buf (window-buffer win)) (set-window-buffer-start-and-point win buf start pt))) restore))) (let ((pt (with-current-buffer buf (point)))) (push (lambda () (with-current-buffer buf (goto-char pt))) restore)) (prog1 (apply app) (mapc #'funcall restore))) (apply app))) The advice works in most cases, for example when killing buffers from inside Ibuffer or from somewhere else. When selecting a buffer the Ibuffer window content still moves. Is there a better way to preserve the content position of Ibuffer than the given advice? I would like to provide a patch to `ibuffer-redisplay-engine' (or to `ibuffer-update' or `ibuffer-redisplay') which improves the update such that the window content does not move. Any suggestions welcome. Thank you! In GNU Emacs 30.1.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.4) of 2025-03-20 Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --with-tree-sitter --with-native-compilation --with-x-toolkit=athena --with-dbus --without-toolkit-scroll-bars --without-selinux --without-threads --without-gsettings --without-gpm --with-cairo --with-cairo-xcb --disable-gc-mark-trace --with-xinput2' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 TIFF TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM LUCID ZLIB