emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a67d8e0d70 2/2: Add a new display-buffer-full-frame display actio


From: Lars Ingebrigtsen
Subject: master a67d8e0d70 2/2: Add a new display-buffer-full-frame display action
Date: Wed, 18 May 2022 09:34:03 -0400 (EDT)

branch: master
commit a67d8e0d70d5563044f9981795de9ee2876b6463
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a new display-buffer-full-frame display action
    
    * doc/lispref/windows.texi (Buffer Display Action Functions):
    Document it.
    
    * lisp/window.el (display-buffer-full-frame): New display action
    (bug#34169).
    (display-buffer--action-function-custom-type): Add.
    (display-buffer): Mention it.
---
 doc/lispref/windows.texi |  5 +++++
 etc/NEWS                 |  5 +++++
 lisp/window.el           | 19 +++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 4ff71a3575..0bb873f3a9 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -2845,6 +2845,11 @@ the function specified in @code{pop-up-frame-function}
 the newly created frame's parameters.
 @end defun
 
+@defun display-buffer-full-frame buffer alist
+This function displays the buffer on the current frame, deleting all
+other windows so that it takes up the full frame.
+@end defun
+
 @defun display-buffer-in-child-frame buffer alist
 This function tries to display @var{buffer} in a child frame
 (@pxref{Child Frames}) of the selected frame, either reusing an
diff --git a/etc/NEWS b/etc/NEWS
index 7089e3a271..8aa53e62e0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -605,6 +605,11 @@ specifiers can now use ':type webp'.
 
 ** Windows
 
++++
+*** New display action 'display-buffer-full-frame'.
+This action removes other windows on the frame when displaying a
+buffer.
+
 +++
 *** 'display-buffer' now can set up the body size of the chosen window.
 For example, a 'display-buffer-alist' entry of
diff --git a/lisp/window.el b/lisp/window.el
index 8b8940197e..4ad2defdf9 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7435,6 +7435,7 @@ The actual non-nil value of this variable will be copied 
to the
           (const display-buffer-pop-up-window)
           (const display-buffer-same-window)
           (const display-buffer-pop-up-frame)
+          (const display-buffer-full-frame)
           (const display-buffer-in-child-frame)
           (const display-buffer-below-selected)
           (const display-buffer-at-bottom)
@@ -7581,6 +7582,7 @@ to an expression containing one of these \"action\" 
functions:
  `display-buffer-use-least-recent-window' -- Try to avoid re-using
     windows that have recently been switched to.
  `display-buffer-pop-up-window' -- Pop up a new window.
+ `display-buffer-full-frame' -- Delete other windows and use the full frame.
  `display-buffer-below-selected' -- Use or pop up a window below
     the selected one.
  `display-buffer-at-bottom' -- Use or pop up a window at the
@@ -7814,6 +7816,23 @@ indirectly called by the latter."
              (window-dedicated-p))
     (window--display-buffer buffer (selected-window) 'reuse alist)))
 
+(defun display-buffer-full-frame (buffer alist)
+  "Display BUFFER in the current frame, taking the entire frame.
+ALIST is an association list of action symbols and values.  See
+Info node `(elisp) Buffer Display Action Alists' for details of
+such alists.
+
+This is an action function for buffer display, see Info
+node `(elisp) Buffer Display Action Functions'.  It should be
+called only by `display-buffer' or a function directly or
+indirectly called by the latter."
+  (when-let ((window (or (display-buffer-reuse-window buffer alist)
+                         (display-buffer-same-window buffer alist)
+                         (display-buffer-pop-up-window buffer alist)
+                         (display-buffer-use-some-window buffer alist))))
+    (delete-other-windows window)
+    window))
+
 (defun display-buffer--maybe-same-window (buffer alist)
   "Conditionally display BUFFER in the selected window.
 ALIST is an association list of action symbols and values.  See



reply via email to

[Prev in Thread] Current Thread [Next in Thread]