[Top][All Lists]

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

RE: canonical verbose?

From: Drew Adams
Subject: RE: canonical verbose?
Date: Sat, 21 Sep 2013 07:03:40 -0700 (PDT)

> > writing quite often commands which should give some reports when being
> > successful, like that:
> >
> > (defun ar-up-list ()
> >    "Returns position reached when successful, nil otherwise"
> >    (interactive)...
> >    (when (interactive-p) (message "%s" erg))
> >    erg))
> >
> > However, binding the message at interactive-usage alone seems not optimal.
> > Does Emacs provide some variable setting verbosity?
> Another option is to have two functions: one that does all the work, and
> a command that calls the first function and then displays a message.

I do not know of a general, global approach.  You could perhaps, for your own 
code, use a macro or even add a global variable etc.  But there is nothing 
built in, AFAIK.

But I did want to mention, for those who might not be aware of it (not Barry or 
Andreas, no doubt), what the Elisp manual (node `Distinguish Interactive') 
recommends for an individual command:

  Sometimes a command should display additional visual feedback (such as
  an informative message in the echo area) for interactive calls only.
  There are three ways to do this.  The recommended way to test whether
  the function was called using `call-interactively' is to give it an
  optional argument `print-message' and use the `interactive' spec to
  make it non-`nil' in interactive calls.  Here's an example:

     (defun foo (&optional print-message)
       (interactive "p")
       (when print-message
         (message "foo")))

  We use `"p"' because the numeric prefix argument is never `nil'.
  Defined in this way, the function does display the message when called
  from a keyboard macro.

  The above method with the additional argument is usually best,
  because it allows callers to say "treat this call as interactive".

reply via email to

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