unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Barry Margolin <barmar@alum.mit.edu>, help-gnu-emacs@gnu.org
Subject: RE: canonical verbose?
Date: Sat, 21 Sep 2013 07:03:40 -0700 (PDT)	[thread overview]
Message-ID: <6d1a31f3-98ce-40c6-b416-97134021b5ae@default> (raw)
In-Reply-To: <<barmar-9D6D59.07331121092013@news.eternal-september.org>>

> > 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	other threads:[~2013-09-21 14:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<mailman.2626.1379749488.10748.help-gnu-emacs@gnu.org>
     [not found] ` <<barmar-9D6D59.07331121092013@news.eternal-september.org>
2013-09-21 14:03   ` Drew Adams [this message]
2013-09-21 14:31     ` canonical verbose? Andreas Röhler
     [not found] <mailman.2626.1379749488.10748.help-gnu-emacs@gnu.org>
2013-09-21 11:33 ` Barry Margolin
2013-09-21  7:46 Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d1a31f3-98ce-40c6-b416-97134021b5ae@default \
    --to=drew.adams@oracle.com \
    --cc=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).