emacs-devel
[Top][All Lists]
Advanced

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

Re: Potential problem of minibuffer-message


From: Stefan Monnier
Subject: Re: Potential problem of minibuffer-message
Date: Thu, 10 Apr 2003 09:44:22 -0400

> I'd like to install the attached change.
> 
> Currently, minibuffer-message calls temp_echo_area_glyphs
> with the arg SDATA (string), and temp_echo_area_glyphs
> inserts it by insert_string function.  But insert_string
> should not be used for the contents of Lisp string.  My fix
> changes the arg of temp_echo_area_glyphs to Lisp string, and
> use insert_from_string to insert it.
> 
> I also want to add the optional arg TIMEOUT to
> minibuffer-message and temp_echo_area_glyphs.  It is to
> specify how long to display the text instead of the defualt
> two seconds.
> 
> I need TIMEOUT because I'm going to change quail to use just
> `message' (normal case) or `minibuffer-message' (the case of
> inputting in a minibuffer) to display the guidance string.
> In the latter case, the two seconds is too short.
> 
> By the way, minibuffer-message is not described in Elisp
> info nor in NEWS.

As part of my still-in-progress rewrite of completion in elisp,
I use the following (partly taken from complete.el where it is
called PC-temp-minibuffer-message or somesuch).

Note how it already works in both case: from the minibuffer or
from some other buffer.  And actually pcomplete needs to be patched
to use this function in place of `message' so as to be more usable
for minibuffer-completion.


        Stefan


(defun minibuffer-message (message &rest args)
  "Temporarily display STRING at the end of the minibuffer.
The text is displayed for `minibuffer-message-timeout' seconds,
or until the next input event arrives, whichever comes first."
  (cond ((not (minibuffer-p (current-buffer)))
         (apply 'message message args)
         (sit-for (or minibuffer-message-timeout 1000000))
         (message nil))
        (t
         (let ((point-max (point-max)))
           (message nil)
           (save-excursion
             (goto-char point-max)
             (insert (apply 'format (if (string-match "\\[.*\\]" message)
                                        message
                                      (concat " [" message "]"))
                            args))
             (let ((inhibit-quit t))
               (sit-for (or minibuffer-message-timeout 1000000))
               (delete-region point-max (point))
               (when quit-flag
                 (setq quit-flag nil
                       unread-command-events '(7)))))))))





reply via email to

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