emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 15f4237 1/2: Sync overlay code in minibuffer-message and set-mini


From: Juri Linkov
Subject: master 15f4237 1/2: Sync overlay code in minibuffer-message and set-minibuffer-message (bug#48669)
Date: Tue, 8 Jun 2021 12:54:50 -0400 (EDT)

branch: master
commit 15f4237303f304ef4e40cdf692570e1ef1c033b5
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    Sync overlay code in minibuffer-message and set-minibuffer-message 
(bug#48669)
    
    * lisp/minibuffer.el (minibuffer-message): Copy more overlay positioning 
code
    from set-minibuffer-message.
    (minibuffer--message-overlay-pos): Mention both minibuffer-message and
    set-minibuffer-message in the docstring.
    (set-minibuffer-message): Use 'cursor t' instead of 1.
---
 lisp/minibuffer.el | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d5a0118..d09a348 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -741,14 +741,16 @@ If ARGS are provided, then pass MESSAGE through 
`format-message'."
                 ;; Don't overwrite the face properties the caller has set
                 (text-properties-at 0 message))
       (setq message (apply #'propertize message 
minibuffer-message-properties)))
-    (let ((ol (make-overlay (point-max) (point-max) nil t t))
-          ;; A quit during sit-for normally only interrupts the sit-for,
-          ;; but since minibuffer-message is used at the end of a command,
-          ;; at a time when the command has virtually finished already, a C-g
-          ;; should really cause an abort-recursive-edit instead (i.e. as if
-          ;; the C-g had been typed at top-level).  Binding inhibit-quit here
-          ;; is an attempt to get that behavior.
-          (inhibit-quit t))
+    ;; Put overlay either on `minibuffer-message' property, or at EOB.
+    (let* ((ovpos (minibuffer--message-overlay-pos))
+           (ol (make-overlay ovpos ovpos nil t t))
+           ;; A quit during sit-for normally only interrupts the sit-for,
+           ;; but since minibuffer-message is used at the end of a command,
+           ;; at a time when the command has virtually finished already, a C-g
+           ;; should really cause an abort-recursive-edit instead (i.e. as if
+           ;; the C-g had been typed at top-level).  Binding inhibit-quit here
+           ;; is an attempt to get that behavior.
+           (inhibit-quit t))
       (unwind-protect
           (progn
             (unless (zerop (length message))
@@ -757,6 +759,12 @@ If ARGS are provided, then pass MESSAGE through 
`format-message'."
               ;; before or after the string, so let's spoon-feed it the pos.
               (put-text-property 0 1 'cursor t message))
             (overlay-put ol 'after-string message)
+            ;; Make sure the overlay with the message is displayed before
+            ;; any other overlays in that position, in case they have
+            ;; resize-mini-windows set to nil and the other overlay strings
+            ;; are too long for the mini-window width.  This makes sure the
+            ;; temporary message will always be visible.
+            (overlay-put ol 'priority 1100)
             (sit-for (or minibuffer-message-timeout 1000000)))
         (delete-overlay ol)))))
 
@@ -778,8 +786,10 @@ and `clear-minibuffer-message' called automatically via
 (defvar minibuffer-message-overlay nil)
 
 (defun minibuffer--message-overlay-pos ()
-  "Return position where `set-minibuffer-message' shall put message overlay."
-  ;; Starting from point, look for non-nil 'minibuffer-message'
+  "Return position where minibuffer message functions shall put message 
overlay.
+The minibuffer message functions include `minibuffer-message' and
+`set-minibuffer-message'."
+  ;; Starting from point, look for non-nil `minibuffer-message'
   ;; property, and return its position.  If none found, return the EOB
   ;; position.
   (let* ((pt (point))
@@ -824,7 +834,7 @@ via `set-message-function'."
           ;; The current C cursor code doesn't know to use the overlay's
           ;; marker's stickiness to figure out whether to place the cursor
           ;; 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 t message))
         (overlay-put minibuffer-message-overlay 'after-string message)
         ;; Make sure the overlay with the message is displayed before
         ;; any other overlays in that position, in case they have



reply via email to

[Prev in Thread] Current Thread [Next in Thread]