[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using called-interactively-p
From: |
Marcin Borkowski |
Subject: |
Re: Using called-interactively-p |
Date: |
Wed, 05 Jul 2023 17:25:18 +0200 |
User-agent: |
mu4e 1.1.0; emacs 30.0.50 |
On 2023-07-05, at 15:35, uzibalqa <uzibalqa@proton.me> wrote:
> I have the following function that executes the command (do-this) when
> the function skatpad is called interactively by the user, but executes
> (do-that) if the function is called from elisp code.
>
> The documentation suggests to use "called-interactively-p" instead of
> (interactive-p).
>
> Looking at the documentation, it is not quite clear whether KIND should be
> a symbol or a string. This problem of distinguishing between a symbol and
> a string, is something that occurs frequently in the documentation. A source
> of constant deliberation for me.
I would definitely bet on symbol. Using strings for things like this
seems highly unusual for me (in Elisp, as opposed to e.g. JavaScript).
OTOH, you can check if you want to (do-this) or (do-that) using a simple
trick with an optional parameter -- see
https://www.gnu.org/software/emacs/manual/html_node/elisp/Distinguish-Interactive.html
Hth,
--
Marcin Borkowski
http://mbork.pl