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#70949: display-buffer-choose-some-window Date: Wed, 15 May 2024 19:49:28 +0300 Organization: LINKOV.NET Message-ID: <86r0e32fnj.fsf@mail.linkov.net> References: <86jzjwqqmd.fsf@mail.linkov.net> <8d1947c7-a4d1-4920-8638-f8ae17acfe65@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28957"; 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: 70949@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 15 19:16:42 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 1s7IF8-0007Kp-3O for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 May 2024 19:16:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7IEX-0002pq-4E; Wed, 15 May 2024 13:16:05 -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 1s7IEU-0002oA-Cv for bug-gnu-emacs@gnu.org; Wed, 15 May 2024 13:16:03 -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 1s7IES-0004Wm-TE for bug-gnu-emacs@gnu.org; Wed, 15 May 2024 13:16:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s7IEU-0007PW-19 for bug-gnu-emacs@gnu.org; Wed, 15 May 2024 13:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 May 2024 17:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70949 X-GNU-PR-Package: emacs Original-Received: via spool by 70949-submit@debbugs.gnu.org id=B70949.171579331728475 (code B ref 70949); Wed, 15 May 2024 17:16:01 +0000 Original-Received: (at 70949) by debbugs.gnu.org; 15 May 2024 17:15:17 +0000 Original-Received: from localhost ([127.0.0.1]:43303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7IDk-0007PD-JS for submit@debbugs.gnu.org; Wed, 15 May 2024 13:15:16 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:39709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7IDT-0007OI-Sw for 70949@debbugs.gnu.org; Wed, 15 May 2024 13:15:15 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id E639BC0008; Wed, 15 May 2024 17:14:50 +0000 (UTC) In-Reply-To: <8d1947c7-a4d1-4920-8638-f8ae17acfe65@gmx.at> (martin rudalics's message of "Wed, 15 May 2024 10:06:39 +0200") 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:285100 Archived-At: --=-=-= Content-Type: text/plain >> +(defcustom display-buffer-choose-some-window 'lru >> + "How to choose an existing window. >> +This defines a strategy of choosing some window >> +by `display-buffer-use-some-window'. >> + >> +The possible choices are `lru' (the default) to select the least recently >> +used window on that frame, and `mru' to select the most recently used >> +window on that frame. When a function, it takes two arguments: a buffer >> +and an alist, and should return the window where to display the buffer." > > I'd call the option 'display-buffer-use-some-window-method' so it's more > clear that it pertains to 'display-buffer-use-some-window'. As for the > first line of the doc-string I'd write > > "Which window `display-buffer-use-some-window' should choose." Ok, done in this patch. > Also, we should mention the constraints used for 'lru' and that 'mru' > avoids the selected window here. Sorry, I don't understand what constraints. The docstring of 'display-buffer-use-some-window' doesn't mention any 'lru' constraints. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=display-buffer-use-some-window-method.patch diff --git a/lisp/window.el b/lisp/window.el index 3935908fdb4..01c8429500d 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8726,6 +8726,20 @@ display-buffer--lru-window (setq best-window window)))))) (or best-window second-best-window))) +(defcustom display-buffer-use-some-window-method 'lru + "Which window `display-buffer-use-some-window' should choose. +The possible choices are `lru' (the default) to select the least +recently used window, and `mru' to select the most recently used +window (not taking into account the selected window). When a function, +it takes two arguments: a buffer and an alist, and should return the +window where to display the buffer." + :type '(choice (const :tag "Least recently used" lru) + (const :tag "Most recently used" mru) + (function :tag "Custom function")) + :group 'windows + :group 'frames + :version "30.1") + (defun display-buffer-use-some-window (buffer alist) "Display BUFFER in an existing window. Search for a usable window, set that window to the buffer, and @@ -8748,11 +8762,17 @@ display-buffer-use-some-window (window--frame-usable-p (last-nonminibuffer-frame)))) (window ;; Reuse an existing window. - (or (display-buffer--lru-window - ;; If ALIST specifies 'lru-frames' or 'window-min-width' - ;; let them prevail. - (append alist `((lru-frames . ,frame) - (window-min-width . full-width)))) + (or (cond + ((eq display-buffer-use-some-window-method 'lru) + (display-buffer--lru-window + ;; If ALIST specifies 'lru-frames' or 'window-min-width' + ;; let them prevail. + (append alist `((lru-frames . ,frame) + (window-min-width . full-width))))) + ((eq display-buffer-use-some-window-method 'mru) + (get-mru-window t t t)) + ((functionp display-buffer-use-some-window-method) + (funcall display-buffer-use-some-window-method buffer alist))) (let ((window (get-buffer-window buffer 'visible))) (unless (and not-this-window (eq window (selected-window))) --=-=-=--