[Top][All Lists]

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

Re: Emacs 25.0.04: Feature Request: Make called-interactively-p's argume

From: Noam Postavsky
Subject: Re: Emacs 25.0.04: Feature Request: Make called-interactively-p's argument optional
Date: Tue, 5 Jul 2016 20:24:52 -0400

On Tue, Jul 5, 2016 at 8:09 PM, John Wiegley <address@hidden> wrote:
> Simple and common patterns should be simple, because they are common.

The simplest way to do this if you don't care about the
distinction between (called-interactively 'any)
and (called-interactively 'interactive) is to add an argument
that is set to non-nil by the interactive spec, as described in
the manual:

    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]