aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.org1
-rw-r--r--compat-28.el16
-rw-r--r--compat-tests.el11
-rw-r--r--compat.texi7
4 files changed, 34 insertions, 1 deletions
diff --git a/NEWS.org b/NEWS.org
index 1b26dcd..e0c03bc 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -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: