From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#64619: [PATCH] Add toggle-window-dedicated command Date: Tue, 18 Jul 2023 11:34:10 -0400 Message-ID: References: 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="2410"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: martin rudalics , Eli Zaretskii , Philip Kaludercic , Drew Adams To: 64619@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 18 17:35:19 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 1qLmjP-0000OH-NB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Jul 2023 17:35:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLmjA-0008Ia-Tm; Tue, 18 Jul 2023 11:35:04 -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 1qLmj9-0008I2-0t for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2023 11:35: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 1qLmj8-0004r9-NA for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2023 11:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qLmj8-00089g-GN for bug-gnu-emacs@gnu.org; Tue, 18 Jul 2023 11:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jul 2023 15:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64619 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64619-submit@debbugs.gnu.org id=B64619.168969445731285 (code B ref 64619); Tue, 18 Jul 2023 15:35:02 +0000 Original-Received: (at 64619) by debbugs.gnu.org; 18 Jul 2023 15:34:17 +0000 Original-Received: from localhost ([127.0.0.1]:54002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLmiP-00088X-Ai for submit@debbugs.gnu.org; Tue, 18 Jul 2023 11:34:17 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:59059) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLmiN-00088J-GM for 64619@debbugs.gnu.org; Tue, 18 Jul 2023 11:34:16 -0400 In-Reply-To: (Spencer Baugh's message of "Fri, 14 Jul 2023 11:38:59 -0400") 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:265468 Archived-At: --=-=-= Content-Type: text/plain OK, this patch adds support for making the buffer strongly dedicated with a prefix argument, and also adds an indicator to the mode line of whether the current window is dedicated (which seems useful even if we don't apply the toggle part of this patch). I wonder if we should support clicking on the mode line indicator to turn off dedicated status? The tricky thing is that the mode line indicator disappears when the window isn't dedicated, so there's no way to turn it back *on* using the mouse. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-toggle-window-dedicated-command-and-mode-line-wi.patch >From 6346388d0992ad78b42e79590db60f2f337b0b88 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 14 Jul 2023 11:38:24 -0400 Subject: [PATCH] Add toggle-window-dedicated command and mode-line-window-dedicated It's sometimes useful to interactively make certain windows dedicated. This allows a level of interactive control over which window display-buffer uses. Additionally, when a window is dedicated (even without this new command) it can affect display-buffer behavior in ways which may be unexpected for users. Let's display the window dedicated status in the mode-line to help indicate what's going on. * lisp/window.el (toggle-window-dedicated): Add. (window-prefix-map): Add C-x w d binding. * lisp/bindings.el (mode-line-window-control): Add. (mode-line-window-dedicated): Add. (standard-mode-line-format): Insert mode-line-window-dedicated. --- lisp/bindings.el | 22 ++++++++++++++++++++++ lisp/window.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/lisp/bindings.el b/lisp/bindings.el index 0a0fef1b564..a570b5d6a7b 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -298,6 +298,27 @@ mode-line-frame-identification ;;;###autoload (put 'mode-line-frame-identification 'risky-local-variable t) +(defun mode-line-window-control () + "Compute mode line construct for window dedicated state. +Value is used for `mode-line-window-dedicated', which see." + (cond + ((eq (window-dedicated-p) t) + '(:propertize + " D" + help-echo "Window is strongly dedicated to current buffer" + mouse-face 'mode-line-highlight)) + ((window-dedicated-p) + '(:propertize + " d" + help-echo "Window is dedicated to current buffer" + mouse-face 'mode-line-highlight)) + (t ""))) + +(defvar mode-line-window-dedicated '(:eval (mode-line-window-control)) + "Mode line construct to describe the current window.") +;;;###autoload +(put 'mode-line-window-dedicated 'risky-local-variable t) + (defvar-local mode-line-process nil "Mode line construct for displaying info on process status. Normally nil in most modes, since there is no process to display.") @@ -678,6 +699,7 @@ mode-line-end-spaces 'mode-line-modified 'mode-line-remote) 'display '(min-width (5.0))) + 'mode-line-window-dedicated 'mode-line-frame-identification 'mode-line-buffer-identification " " diff --git a/lisp/window.el b/lisp/window.el index d91bbabc010..259c1e679ac 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7463,6 +7463,33 @@ display-buffer-mark-dedicated The actual non-nil value of this variable will be copied to the `window-dedicated-p' flag.") +(defun toggle-window-dedicated (&optional window flag interactive) + "Toggle whether WINDOW is dedicated. + +See `set-window-dedicated-p' for more details. WINDOW defaults +to the currently selected window. FLAG defaults to +`dedicated' (weak dedication) or `t' (strong dedication) with a +prefix argument. If INTERACTIVE is non-nil, will print a message +about the dedication status of the window afterwards." + (interactive "i\nP\np") + (setq window (window-normalize-window window)) + (setq flag (cond + ((consp flag) t) + ((null flag) 'dedicated) + (t flag))) + (if (window-dedicated-p window) + (set-window-dedicated-p window nil) + (set-window-dedicated-p window flag)) + (when interactive + (message "Window is %s dedicated to buffer %s" + (let ((status (window-dedicated-p window))) + (cond + ((null status) "no longer") + ((eq status t) "now strongly") + (t "now"))) + (current-buffer)) + (force-mode-line-update))) + (defconst display-buffer--action-function-custom-type '(choice :tag "Function" (const :tag "--" ignore) ; default for insertion @@ -10746,6 +10773,7 @@ window-prefix-map "2" #'split-root-window-below "3" #'split-root-window-right "s" #'window-toggle-side-windows + "d" #'toggle-window-dedicated "^ f" #'tear-off-window "^ t" #'tab-window-detach "-" #'fit-window-to-buffer -- 2.39.3 --=-=-=--