aboutsummaryrefslogtreecommitdiff
path: root/compat-28.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-01-17 18:25:59 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-01-17 18:27:06 +0100
commit66fc73a53519907c6efc332705ed650888952bdb (patch)
treefae1b23a6f11761fe87cb192e378347e6d60eb1f /compat-28.el
parent2993addafd3fe33dd106483fcbc69d655e0e0ce7 (diff)
compat-28: Add with-window-non-dedicated
Diffstat (limited to 'compat-28.el')
-rw-r--r--compat-28.el16
1 files changed, 15 insertions, 1 deletions
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.