Subject: Re: bug#48674: Frames and minibuffer bug

From: martin rudalics <[email-masked]>
Date: Fri, 28 May 2021 10:25:31 +0200

>> The only difference is the add-hook, this time using
 >> window-state-change-hook instead of minibuffer-...
 >> This leads to the same bug.

It's still the same bug.  No matter what happens, evaluating

(let ((window (selected-window)))
   (dolist (frame (frame-list))
     (with-selected-frame frame))
   (eq window (selected-window)))

must always yield t.

Note, however, that the `with-selected-frame' in your function is not
needed.  `modify-frame-parameters' works without selecting the frame
whose parameter you want to modify.  Also I do not understand why you
want to modify the cursor in all windows when you enter the minibuffer.

Consider the following snippet to set the background of the minibuffer
window when it is active (hopefully `active-minibuffer-window' always
returns the right value when exiting the minibuffer).

(defun foo ()
   (with-current-buffer (window-buffer (active-minibuffer-window))
     (set (make-local-variable 'face-remapping-alist)
	 '((default (:background "yellow") default)))))

(defun bar ()
   (with-current-buffer (window-buffer (active-minibuffer-window))
     (set (make-local-variable 'face-remapping-alist) nil)))

(add-hook 'minibuffer-setup-hook #'foo)
(add-hook 'minibuffer-exit-hook #'bar)

I never tried to remap the cursor color in a buffer-local way, but I
think you can figure out how to do that in a similar fashion.

martin