emacs-devel
[Top][All Lists]
Advanced

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

RE: wrapper fn for message and minibuffer-message?


From: Drew Adams
Subject: RE: wrapper fn for message and minibuffer-message?
Date: Wed, 5 Oct 2005 09:23:10 -0700

    > (defun msg-maybe-in-minibuffer (string &rest args)
    >   "Display STRING with `message' or `minibuffer-message', as
    appropriate."
    >   (if (active-minibuffer-window)
    >       (minibuffer-message (format "  [%s]" string))
    >     (message string)))

    I agree 100% with the intention.  Typical such messages are the
    completion messages, for completion functions that can be used
    both in the minibuffer and in normal buffers.

Yes, that's what I had in mind.

    Of course I'd define it more like

    (defun msg-maybe-in-minibuffer (format &rest args)
      "Display STRING with `message' or `minibuffer-message', as
appropriate."
      (if (minibufferp)
          (minibuffer-message (apply 'format (concat "  [" format "]")
args))
        (apply 'message format args)))

Yes. I use (active-minibuffer-window) because I want the code to work on
Emacs 20 also (where there is no `minibufferp').

Suggestion: Name the argument FORMAT-STRING, not FORMAT, for less confusion
with the function. (And use that name in the doc string, instead of STRING.)

(defun display-message (format-string &rest args)
  "Display FORMAT-STRING as a message.
If called with the minibuffer active, this is done using `message'.
Otherwise, it is done using `minibuffer-message'."
  (if (minibufferp)
      (minibuffer-message
        (apply 'format (concat "  [" format-string "]") args))
    (apply 'message format-string args)))


    I'd even argue that this function should be called "minibuffer-message",
    since currently minibuffer-message is only used when (minibufferp) is
    non-nil.

I'm confused here. If used outside of the minibuffer, it is not a
"minibuffer-message" at all, is it? Wouldn't the name `minibuffer-message'
be misleading, in that case?

The best name for the function would really be "message", with today's
`message' being called something like `log-message' (since it logs to
*Messages*).

Otherwise, if it's a no-no to co-opt the standard `message' name, a name
like "display-message" might be OK for this.

WDOT?






reply via email to

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