From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#69993: Wrap window buffers while cycling Date: Tue, 16 Apr 2024 09:38:14 +0300 Organization: LINKOV.NET Message-ID: <867cgxn7lx.fsf@mail.linkov.net> References: <86h6gug41x.fsf@mail.linkov.net> <0d2fdebf-2149-4f92-89b8-45a8b6a7d272@gmx.at> <86plv8hz2v.fsf@mail.linkov.net> <8a131d8b-1330-4d82-92f6-309f499e9c15@gmx.at> <86h6gi49zw.fsf@mail.linkov.net> <1e50bd70-8cbb-46f9-9078-dd0e6226da63@gmx.at> <861q7k8gms.fsf@mail.linkov.net> <2d3f0d14-e39b-4399-be30-03f11725c505@gmx.at> <86ttkf6a8r.fsf@mail.linkov.net> <86jzlajpqq.fsf@mail.linkov.net> <85109880-3370-47e0-b7c9-6c5a32cfaafa@gmx.at> <86le5nhwqy.fsf@mail.linkov.net> <864jcajzxi.fsf@mail.linkov.net> <86o7ahglre.fsf@mail.linkov.net> <28a8149b-283a-4b08-9df5-f1139a0fccbe@gmx.at> <86ttk7m7ir.fsf@mail.linkov.net> <1b38c78c-6697-4c6b-81cf-5a72fdd3ba8d@gmx.at> <868r1i8si0.fsf@mail.linkov.net> <867ch09bx6.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23171"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 69993@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 16 08:43:22 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 1rwcXH-0005on-6l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Apr 2024 08:43:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwcWv-0001SC-HP; Tue, 16 Apr 2024 02:42:57 -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 1rwcWs-0001IK-P1 for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 02:42:54 -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 1rwcWn-0006uL-RD for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 02:42:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwcWz-0003zz-NX for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 02:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Apr 2024 06:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69993 X-GNU-PR-Package: emacs Original-Received: via spool by 69993-submit@debbugs.gnu.org id=B69993.171324975315175 (code B ref 69993); Tue, 16 Apr 2024 06:43:01 +0000 Original-Received: (at 69993) by debbugs.gnu.org; 16 Apr 2024 06:42:33 +0000 Original-Received: from localhost ([127.0.0.1]:41975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwcWV-0003wQ-Vu for submit@debbugs.gnu.org; Tue, 16 Apr 2024 02:42:33 -0400 Original-Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]:41445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwcWS-0003v8-PD for 69993@debbugs.gnu.org; Tue, 16 Apr 2024 02:42:30 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 7D2F1FF807; Tue, 16 Apr 2024 06:42:10 +0000 (UTC) In-Reply-To: <867ch09bx6.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 14 Apr 2024 19:15:17 +0300") X-GND-Sasl: juri@linkov.net 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:283409 Archived-At: >>>> So keeping the stable order of window prev/next buffers after C-x b >>>> with a hook should be implemented in tab-line.el, not in window.el? >>> >>> I don't know how you currently handle C-x , C-x b or >>> 'rename-buffer' or whether a buffer is modified on the tab line so I >>> can't tell whether you would need a hook for these. But this issue is >>> IMHO not connected to whether getting the previous or next buffer should >>> wrap or be restricted to buffers previously shown in a window. >> >> Handling 'C-x b' and 'rename-buffer' is not yet implemented. >> Probably need to add a new window parameter to keep a list >> of tab buffers and sync it with window prev/next buffers. > > Now handling 'C-x b' is completely implemented here: > > + (set-window-prev-buffers > ... > + (add-hook 'window-buffer-change-functions #'tab-line-buffer-change nil t) Actually using hooks as well as advices in core packages is not a nice thing to do. Neither tab-bar.el nor tab-line.el uses hooks and advices. Also better not to mess with set-window-prev-buffers. And this is perfectly possible with the following small patch that supports everything: wrapping, C-x , C-x b, 'rename-buffer' with buffers restricted to those that were displayed in the window while keeping them in the fixed order: diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 54e9ee16243..b2f0cbf13ed 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -345,6 +345,8 @@ tab-line-tabs-function grouped by `tab-line-tabs-buffer-group-function'." :type '(choice (const :tag "Window buffers" tab-line-tabs-window-buffers) + (const :tag "Window buffers with fixed order" + tab-line-tabs-fixed-window-buffers) (const :tag "Same mode buffers" tab-line-tabs-mode-buffers) (const :tag "Grouped buffers" @@ -515,6 +524,17 @@ tab-line-tabs-window-buffers (list buffer) next-buffers))) +(defun tab-line-tabs-fixed-window-buffers () + "Like `tab-line-tabs-window-buffers' but keep stable sorting order." + (let ((old-buffers (window-parameter nil 'tab-line-fixed-window-buffers)) + (new-buffers (tab-line-tabs-window-buffers))) + (setq new-buffers (sort new-buffers + (lambda (a b) + (> (length (memq a old-buffers)) + (length (memq b old-buffers)))))) + (set-window-parameter nil 'tab-line-fixed-window-buffers new-buffers) + new-buffers))