diff options
| author | Eli Zaretskii | 2020-02-12 21:39:44 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2020-02-12 21:39:44 +0200 |
| commit | 027da652a4fc643a086a880aec30618b2bccb487 (patch) | |
| tree | e4c94bb3ad04b794e1873e16b8f357de3ee4a77f | |
| parent | 5a21aaff468ec3f0337117707cda4254cbef8de7 (diff) | |
| download | emacs-027da652a4fc643a086a880aec30618b2bccb487.tar.gz emacs-027da652a4fc643a086a880aec30618b2bccb487.zip | |
Fix display of minibuffer prompt in ido.el
* lisp/minibuffer.el (minibuffer--message-overlay-pos): New
function.
(set-minibuffer-message): Use it to determine where to show the
overlay with the temporary message.
* lisp/ido.el (ido-exhibit): Revert "Render Ido suggestions using
an overlay"; this restores the original code which inserted the
match-status information into the minibuffer, instead of
displaying it in an overlay with an after-string. Put the special
'minibuffer-message' text property at the beginning of the
inserted text. (Bug#39379)
* etc/NEWS:
* doc/lispref/display.texi (Displaying Messages):
* doc/lispref/text.texi (Special Properties): Document the
'minibuffer-message' text property and its effect.
| -rw-r--r-- | doc/lispref/display.texi | 9 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/ido.el | 19 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 18 |
5 files changed, 45 insertions, 17 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index e4980fe4c36..2b25d6023cd 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -319,7 +319,10 @@ the echo area. See also @code{clear-message-function} that can be | |||
| 319 | used to clear the message displayed by this function. | 319 | used to clear the message displayed by this function. |
| 320 | 320 | ||
| 321 | The default value is the function that displays the message at the end | 321 | The default value is the function that displays the message at the end |
| 322 | of the minibuffer when the minibuffer is active. | 322 | of the minibuffer when the minibuffer is active. However, if the text |
| 323 | shown in the active minibuffer has the @code{minibuffer-message} text | ||
| 324 | property (@pxref{Special Properties}) on some character, the message | ||
| 325 | will be displayed before the first character having that property. | ||
| 323 | @end defvar | 326 | @end defvar |
| 324 | 327 | ||
| 325 | @defvar clear-message-function | 328 | @defvar clear-message-function |
| @@ -332,8 +335,8 @@ after displaying an echo-area message. The function is expected to | |||
| 332 | clear the message displayed by its counterpart function specified by | 335 | clear the message displayed by its counterpart function specified by |
| 333 | @code{set-message-function}. | 336 | @code{set-message-function}. |
| 334 | 337 | ||
| 335 | The default value is the function that clears the message displayed at | 338 | The default value is the function that clears the message displayed in |
| 336 | the end of the minibuffer when the minibuffer is active. | 339 | an active minibuffer. |
| 337 | @end defvar | 340 | @end defvar |
| 338 | 341 | ||
| 339 | @defvar inhibit-message | 342 | @defvar inhibit-message |
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 527057eed59..f027cdf8ede 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -3741,6 +3741,16 @@ single glyph composed from components. But the value of the property | |||
| 3741 | itself is completely internal to Emacs and should not be manipulated | 3741 | itself is completely internal to Emacs and should not be manipulated |
| 3742 | directly by, for instance, @code{put-text-property}. | 3742 | directly by, for instance, @code{put-text-property}. |
| 3743 | 3743 | ||
| 3744 | @item minibuffer-message | ||
| 3745 | @kindex minibuffer-message @r{(text property)} | ||
| 3746 | This text property tells where to display temporary messages in an | ||
| 3747 | active minibuffer. Specifically, the first character of the | ||
| 3748 | minibuffer text which has this property will have the temporary | ||
| 3749 | message displayed before it. The default is to display temporary | ||
| 3750 | messages at the end of the minibuffer text. This text property is | ||
| 3751 | used by the function that is the default value of | ||
| 3752 | @code{set-message-function} (@pxref{Displaying Messages}). | ||
| 3753 | |||
| 3744 | @end table | 3754 | @end table |
| 3745 | 3755 | ||
| 3746 | @defvar inhibit-point-motion-hooks | 3756 | @defvar inhibit-point-motion-hooks |
| @@ -3591,6 +3591,12 @@ Setting this on the first character of a help string disables | |||
| 3591 | conversions via 'substitute-command-keys'. | 3591 | conversions via 'substitute-command-keys'. |
| 3592 | 3592 | ||
| 3593 | +++ | 3593 | +++ |
| 3594 | ** New text property 'minibuffer-message'. | ||
| 3595 | Setting this on a character of the minibuffer text will display the | ||
| 3596 | temporary echo messages before that character, when messages need to | ||
| 3597 | be displayed while minibuffer is active. | ||
| 3598 | |||
| 3599 | +++ | ||
| 3594 | ** 'undo' can be made to ignore the active region for a command | 3600 | ** 'undo' can be made to ignore the active region for a command |
| 3595 | by setting 'undo-inhibit-region' symbol property of that command to | 3601 | by setting 'undo-inhibit-region' symbol property of that command to |
| 3596 | non-nil. This is used by 'mouse-drag-region' to make the effect | 3602 | non-nil. This is used by 'mouse-drag-region' to make the effect |
diff --git a/lisp/ido.el b/lisp/ido.el index 6707d814077..7198649e5a5 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -4492,8 +4492,6 @@ For details of keybindings, see `ido-find-file'." | |||
| 4492 | (ido-tidy)) | 4492 | (ido-tidy)) |
| 4493 | (throw 'ido contents)))) | 4493 | (throw 'ido contents)))) |
| 4494 | 4494 | ||
| 4495 | (defvar ido--overlay nil) | ||
| 4496 | |||
| 4497 | (defun ido-exhibit () | 4495 | (defun ido-exhibit () |
| 4498 | "Post command hook for Ido." | 4496 | "Post command hook for Ido." |
| 4499 | ;; Find matching files and display a list in the minibuffer. | 4497 | ;; Find matching files and display a list in the minibuffer. |
| @@ -4728,16 +4726,13 @@ For details of keybindings, see `ido-find-file'." | |||
| 4728 | (let ((inf (ido-completions contents))) | 4726 | (let ((inf (ido-completions contents))) |
| 4729 | (setq ido-show-confirm-message nil) | 4727 | (setq ido-show-confirm-message nil) |
| 4730 | (ido-trace "inf" inf) | 4728 | (ido-trace "inf" inf) |
| 4731 | (when ido--overlay | 4729 | (let ((pos (point))) |
| 4732 | (delete-overlay ido--overlay)) | 4730 | (insert inf) |
| 4733 | (let ((o (make-overlay (point-max) (point-max) nil t t))) | 4731 | (if (< pos (point-max)) |
| 4734 | (when (> (length inf) 0) | 4732 | ;; Tell set-minibuffer-message where to display the |
| 4735 | ;; For hacks that redefine ido-completions function (bug#39379) | 4733 | ;; overlay with temporary messages. |
| 4736 | (when (eq (aref inf 0) ?\n) | 4734 | (put-text-property pos (1+ pos) 'minibuffer-message t))) |
| 4737 | (setq inf (concat " " inf))) | 4735 | ) |
| 4738 | (put-text-property 0 1 'cursor t inf)) | ||
| 4739 | (overlay-put o 'after-string inf) | ||
| 4740 | (setq ido--overlay o))) | ||
| 4741 | )))) | 4736 | )))) |
| 4742 | 4737 | ||
| 4743 | (defun ido-completions (name) | 4738 | (defun ido-completions (name) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 0589211877a..49daabc44e3 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -763,8 +763,21 @@ and `clear-minibuffer-message' called automatically via | |||
| 763 | (defvar minibuffer-message-timer nil) | 763 | (defvar minibuffer-message-timer nil) |
| 764 | (defvar minibuffer-message-overlay nil) | 764 | (defvar minibuffer-message-overlay nil) |
| 765 | 765 | ||
| 766 | (defun minibuffer--message-overlay-pos () | ||
| 767 | "Return position where `set-minibuffer-message' shall put message overlay." | ||
| 768 | ;; Starting from point, look for non-nil 'minibuffer-message' | ||
| 769 | ;; property, and return its position. If none found, return the EOB | ||
| 770 | ;; position. | ||
| 771 | (let* ((pt (point)) | ||
| 772 | (propval (get-text-property pt 'minibuffer-message))) | ||
| 773 | (if propval pt | ||
| 774 | (next-single-property-change pt 'minibuffer-message nil (point-max))))) | ||
| 775 | |||
| 766 | (defun set-minibuffer-message (message) | 776 | (defun set-minibuffer-message (message) |
| 767 | "Temporarily display MESSAGE at the end of the minibuffer. | 777 | "Temporarily display MESSAGE at the end of the minibuffer. |
| 778 | If some part of the minibuffer text has the `minibuffer-message' property, | ||
| 779 | the message will be displayed before the first such character, instead of | ||
| 780 | at the end of the minibuffer. | ||
| 768 | The text is displayed for `minibuffer-message-clear-timeout' seconds | 781 | The text is displayed for `minibuffer-message-clear-timeout' seconds |
| 769 | \(if the value is a number), or until the next input event arrives, | 782 | \(if the value is a number), or until the next input event arrives, |
| 770 | whichever comes first. | 783 | whichever comes first. |
| @@ -784,8 +797,9 @@ via `set-message-function'." | |||
| 784 | 797 | ||
| 785 | (clear-minibuffer-message) | 798 | (clear-minibuffer-message) |
| 786 | 799 | ||
| 787 | (setq minibuffer-message-overlay | 800 | (let ((ovpos (minibuffer--message-overlay-pos))) |
| 788 | (make-overlay (point-max) (point-max) nil t t)) | 801 | (setq minibuffer-message-overlay |
| 802 | (make-overlay ovpos ovpos nil t t))) | ||
| 789 | (unless (zerop (length message)) | 803 | (unless (zerop (length message)) |
| 790 | ;; The current C cursor code doesn't know to use the overlay's | 804 | ;; The current C cursor code doesn't know to use the overlay's |
| 791 | ;; marker's stickiness to figure out whether to place the cursor | 805 | ;; marker's stickiness to figure out whether to place the cursor |