diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-17 18:25:59 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-17 18:27:06 +0100 |
| commit | 66fc73a53519907c6efc332705ed650888952bdb (patch) | |
| tree | fae1b23a6f11761fe87cb192e378347e6d60eb1f | |
| parent | 2993addafd3fe33dd106483fcbc69d655e0e0ce7 (diff) | |
compat-28: Add with-window-non-dedicated
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-28.el | 16 | ||||
| -rw-r--r-- | compat-tests.el | 11 | ||||
| -rw-r--r-- | compat.texi | 7 |
4 files changed, 34 insertions, 1 deletions
@@ -6,6 +6,7 @@ - compat-27: Add ~date-ordinal-to-time~. - compat-27: Add ~make-decoded-time~. - compat-28: Add ~color-dark-p~. +- compat-28: Add ~with-window-non-dedicated~. * Release of "Compat" Version 29.1.2.0 diff --git a/compat-28.el b/compat-28.el index 55e0b75..6149106 100644 --- a/compat-28.el +++ b/compat-28.el @@ -666,7 +666,21 @@ contrast color with RGB as background and as foreground." (y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722)))) (< y color-luminance-dark-limit))) -;;;; Defined in windows.el +;;;; Defined in window.el + +(compat-defmacro with-window-non-dedicated (window &rest body) + "Evaluate BODY with WINDOW temporarily made non-dedicated. +If WINDOW is nil, use the selected window. Return the value of +the last form in BODY." + (declare (indent 1) (debug t)) + (let ((window-dedicated-sym (gensym)) + (window-sym (gensym))) + `(let* ((,window-sym (window-normalize-window ,window t)) + (,window-dedicated-sym (window-dedicated-p ,window-sym))) + (set-window-dedicated-p ,window-sym nil) + (unwind-protect + (progn ,@body) + (set-window-dedicated-p ,window-sym ,window-dedicated-sym))))) (compat-defun count-windows (&optional minibuf all-frames) ;; <compat-tests:count-windows> "Handle optional argument ALL-FRAMES. diff --git a/compat-tests.el b/compat-tests.el index 2ae8fc6..26389d4 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -330,6 +330,17 @@ (should-equal (getenv A) B)) (should-not (getenv A)))) +(ert-deftest with-window-non-dedicated () + (unwind-protect + (progn + (should-not (window-dedicated-p)) + (set-window-dedicated-p nil t) + (should (window-dedicated-p)) + (with-window-non-dedicated nil + (should-not (window-dedicated-p))) + (should (window-dedicated-p))) + (set-window-dedicated-p nil nil))) + (ert-deftest count-windows () (should (fixnump (compat-call count-windows))) (should (fixnump (compat-call count-windows t))) diff --git a/compat.texi b/compat.texi index 94a9ce1..fe1c89c 100644 --- a/compat.texi +++ b/compat.texi @@ -1922,6 +1922,13 @@ This compatibility version handles the optional argument @var{all-frames}. @end defun +@c copied from on lisp/window.el +@defmac with-window-non-dedicated window &rest body +Evaluate @var{body} with @var{window} temporarily made non-dedicated. +If @var{window} is nil, use the selected window. Return the value of +the last form in @var{body}. +@end defmac + @subsection Missing Definitions Compat does not provide support for the following Lisp features implemented in 28.1: |
