aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2021-06-08 19:51:51 +0300
committerJuri Linkov2021-06-08 19:51:51 +0300
commit15f4237303f304ef4e40cdf692570e1ef1c033b5 (patch)
tree25e4518edcc11758ea95382f4c6fe2afc9ce2b48
parentbef3070ab8dfbb8b68c08f0f0aa03532311f3dd5 (diff)
downloademacs-15f4237303f304ef4e40cdf692570e1ef1c033b5.tar.gz
emacs-15f4237303f304ef4e40cdf692570e1ef1c033b5.zip
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.
-rw-r--r--lisp/minibuffer.el32
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d5a0118b7c0..d09a348211f 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -741,14 +741,16 @@ If ARGS are provided, then pass MESSAGE through `format-message'."
741 ;; Don't overwrite the face properties the caller has set 741 ;; Don't overwrite the face properties the caller has set
742 (text-properties-at 0 message)) 742 (text-properties-at 0 message))
743 (setq message (apply #'propertize message minibuffer-message-properties))) 743 (setq message (apply #'propertize message minibuffer-message-properties)))
744 (let ((ol (make-overlay (point-max) (point-max) nil t t)) 744 ;; Put overlay either on `minibuffer-message' property, or at EOB.
745 ;; A quit during sit-for normally only interrupts the sit-for, 745 (let* ((ovpos (minibuffer--message-overlay-pos))
746 ;; but since minibuffer-message is used at the end of a command, 746 (ol (make-overlay ovpos ovpos nil t t))
747 ;; at a time when the command has virtually finished already, a C-g 747 ;; A quit during sit-for normally only interrupts the sit-for,
748 ;; should really cause an abort-recursive-edit instead (i.e. as if 748 ;; but since minibuffer-message is used at the end of a command,
749 ;; the C-g had been typed at top-level). Binding inhibit-quit here 749 ;; at a time when the command has virtually finished already, a C-g
750 ;; is an attempt to get that behavior. 750 ;; should really cause an abort-recursive-edit instead (i.e. as if
751 (inhibit-quit t)) 751 ;; the C-g had been typed at top-level). Binding inhibit-quit here
752 ;; is an attempt to get that behavior.
753 (inhibit-quit t))
752 (unwind-protect 754 (unwind-protect
753 (progn 755 (progn
754 (unless (zerop (length message)) 756 (unless (zerop (length message))
@@ -757,6 +759,12 @@ If ARGS are provided, then pass MESSAGE through `format-message'."
757 ;; before or after the string, so let's spoon-feed it the pos. 759 ;; before or after the string, so let's spoon-feed it the pos.
758 (put-text-property 0 1 'cursor t message)) 760 (put-text-property 0 1 'cursor t message))
759 (overlay-put ol 'after-string message) 761 (overlay-put ol 'after-string message)
762 ;; Make sure the overlay with the message is displayed before
763 ;; any other overlays in that position, in case they have
764 ;; resize-mini-windows set to nil and the other overlay strings
765 ;; are too long for the mini-window width. This makes sure the
766 ;; temporary message will always be visible.
767 (overlay-put ol 'priority 1100)
760 (sit-for (or minibuffer-message-timeout 1000000))) 768 (sit-for (or minibuffer-message-timeout 1000000)))
761 (delete-overlay ol))))) 769 (delete-overlay ol)))))
762 770
@@ -778,8 +786,10 @@ and `clear-minibuffer-message' called automatically via
778(defvar minibuffer-message-overlay nil) 786(defvar minibuffer-message-overlay nil)
779 787
780(defun minibuffer--message-overlay-pos () 788(defun minibuffer--message-overlay-pos ()
781 "Return position where `set-minibuffer-message' shall put message overlay." 789 "Return position where minibuffer message functions shall put message overlay.
782 ;; Starting from point, look for non-nil 'minibuffer-message' 790The minibuffer message functions include `minibuffer-message' and
791`set-minibuffer-message'."
792 ;; Starting from point, look for non-nil `minibuffer-message'
783 ;; property, and return its position. If none found, return the EOB 793 ;; property, and return its position. If none found, return the EOB
784 ;; position. 794 ;; position.
785 (let* ((pt (point)) 795 (let* ((pt (point))
@@ -824,7 +834,7 @@ via `set-message-function'."
824 ;; The current C cursor code doesn't know to use the overlay's 834 ;; The current C cursor code doesn't know to use the overlay's
825 ;; marker's stickiness to figure out whether to place the cursor 835 ;; marker's stickiness to figure out whether to place the cursor
826 ;; before or after the string, so let's spoon-feed it the pos. 836 ;; before or after the string, so let's spoon-feed it the pos.
827 (put-text-property 0 1 'cursor 1 message)) 837 (put-text-property 0 1 'cursor t message))
828 (overlay-put minibuffer-message-overlay 'after-string message) 838 (overlay-put minibuffer-message-overlay 'after-string message)
829 ;; Make sure the overlay with the message is displayed before 839 ;; Make sure the overlay with the message is displayed before
830 ;; any other overlays in that position, in case they have 840 ;; any other overlays in that position, in case they have