help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Prefix Argument and optional argument


From: Bruno Barbier
Subject: Re: Prefix Argument and optional argument
Date: Tue, 05 Jul 2022 08:52:05 +0200

carlmarcos--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> I am having difficulty figuring out any problems associated with the 
> following two functions.
>
> Can one safely call "M-x name", "C-u M-x name", "C-u 2 M-x name", where name 
> is either
> `poke' or `poke-opt'.
>
> (defun poke (prefix)
>   "TODO."
>   (interactive "P")
> ...)

You should compile your code; Emacs will say:

    Warning: misplaced interactive spec: ‘(interactive P)’


>
> (defun poke-opt (&optional prefix)
>   "TODO."
>   (interactive "P")
> ...)

This version is OK. You can call it "M-x name", "C-u M-x name", "C-u 2
M-x name"; wether it's safe or not depends on its body though ;-)

Bruno




reply via email to

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