1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00

Yet another fix for 'set-minibuffer-message'

* lisp/minibuffer.el (set-minibuffer-message): Handle the case of
separate minibuffer-only frame.  Suggested by Gregory Heytings
<ghe@sdf.org>.
This commit is contained in:
Eli Zaretskii 2020-10-16 10:17:42 +03:00
parent 72dd911981
commit c37b2a9b42

View file

@ -783,45 +783,50 @@ The text is displayed for `minibuffer-message-clear-timeout' seconds
whichever comes first. whichever comes first.
Unlike `minibuffer-message', this function is called automatically Unlike `minibuffer-message', this function is called automatically
via `set-message-function'." via `set-message-function'."
(when (and (not noninteractive) (let* ((minibuf-window (active-minibuffer-window))
(window-live-p (active-minibuffer-window)) (minibuf-frame (and (window-live-p minibuf-window)
(eq (window-frame) (window-frame (active-minibuffer-window)))) (window-frame minibuf-window))))
(with-current-buffer (window-buffer (active-minibuffer-window)) (when (and (not noninteractive)
(setq message (if (string-match-p "\\` *\\[.+\\]\\'" message) (window-live-p minibuf-window)
;; Make sure we can put-text-property. (or (eq (window-frame) minibuf-frame)
(copy-sequence message) (eq (frame-parameter minibuf-frame 'minibuffer) 'only)))
(concat " [" message "]"))) (with-current-buffer (window-buffer minibuf-window)
(unless (or (null minibuffer-message-properties) (setq message (if (string-match-p "\\` *\\[.+\\]\\'" message)
;; Don't overwrite the face properties the caller has set ;; Make sure we can put-text-property.
(text-properties-at 0 message)) (copy-sequence message)
(setq message (apply #'propertize message minibuffer-message-properties))) (concat " [" message "]")))
(unless (or (null minibuffer-message-properties)
;; Don't overwrite the face properties the caller has set
(text-properties-at 0 message))
(setq message
(apply #'propertize message minibuffer-message-properties)))
(clear-minibuffer-message) (clear-minibuffer-message)
(let ((ovpos (minibuffer--message-overlay-pos))) (let ((ovpos (minibuffer--message-overlay-pos)))
(setq minibuffer-message-overlay (setq minibuffer-message-overlay
(make-overlay ovpos ovpos nil t t))) (make-overlay ovpos ovpos nil t t)))
(unless (zerop (length message)) (unless (zerop (length message))
;; The current C cursor code doesn't know to use the overlay's ;; The current C cursor code doesn't know to use the overlay's
;; marker's stickiness to figure out whether to place the cursor ;; marker's stickiness to figure out whether to place the cursor
;; before or after the string, so let's spoon-feed it the pos. ;; before or after the string, so let's spoon-feed it the pos.
(put-text-property 0 1 'cursor 1 message)) (put-text-property 0 1 'cursor 1 message))
(overlay-put minibuffer-message-overlay 'after-string message) (overlay-put minibuffer-message-overlay 'after-string message)
;; Make sure the overlay with the message is displayed before ;; Make sure the overlay with the message is displayed before
;; any other overlays in that position, in case they have ;; any other overlays in that position, in case they have
;; resize-mini-windows set to nil and the other overlay strings ;; resize-mini-windows set to nil and the other overlay strings
;; are too long for the mini-window width. This makes sure the ;; are too long for the mini-window width. This makes sure the
;; temporary message will always be visible. ;; temporary message will always be visible.
(overlay-put minibuffer-message-overlay 'priority 1100) (overlay-put minibuffer-message-overlay 'priority 1100)
(when (numberp minibuffer-message-clear-timeout) (when (numberp minibuffer-message-clear-timeout)
(setq minibuffer-message-timer (setq minibuffer-message-timer
(run-with-timer minibuffer-message-clear-timeout nil (run-with-timer minibuffer-message-clear-timeout nil
#'clear-minibuffer-message))) #'clear-minibuffer-message)))
;; Return `t' telling the caller that the message ;; Return `t' telling the caller that the message
;; was handled specially by this function. ;; was handled specially by this function.
t))) t))))
(setq set-message-function 'set-minibuffer-message) (setq set-message-function 'set-minibuffer-message)