Subject: Re: bug#39181: 27.0.50; [PATCH] Allow users to store & restore gdb-mi layout

From: Yuan Fu <[email-masked]>
Date: Sat, 7 Mar 2020 14:17:14 -0500

> On Mar 7, 2020, at 2:07 PM, Štěpán Němec <[email-masked]> wrote:
> 
> On Sat, 7 Mar 2020 13:09:53 -0500
> Yuan Fu wrote:
> 
> [...]
> 
>> diff --git a/lisp/window.el b/lisp/window.el
>> index bd825c09e1..229400966a 100644
>> --- a/lisp/window.el
>> +++ b/lisp/window.el
>> @@ -278,6 +278,19 @@ with-displayed-buffer-window
>> 	     (funcall ,vquit-function ,window ,value)
>> 	   ,value)))))
>> 
>> +(defmacro with-selected-window-undedicated (&rest body)
>> +  "Run BODY in the selected window temporarily undedicated."
>> +  (let ((window-dedicated-sym (gensym)))
>> +    `(let ((,window-dedicated-sym (window-dedicated-p)))
>> +       (when ,window-dedicated-sym
>> +         (set-window-dedicated-p nil nil))
>> +       ,@body
>> +       (when ,window-dedicated-sym
>> +         ;; `window-dedicated-p' returns the value set by
>> +         ;; `set-window-dedicated-p', which differentiates
>> +         ;; non-nil and t, so we cannot simply set to t.
>> +         (set-window-dedicated-p nil ,window-dedicated-sym)))))
>> +
>> ;; The following two functions are like `window-next-sibling' and
>> ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so
>> ;; they don't substitute the selected window for nil), and they return
> 
> I'm sorry, I only skimmed through your patch, but shouldn't this use
> 'unwind-protect'? Otherwise the "temporarily" won't hold in case of
> abnormal exit from BODY, unless I'm missing something.
> 
> — 
> Štěpán

Thanks for spotting that. I added the unwind-protext form.

Yuan