[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Prefix Argument and optional argument
From: |
carlmarcos |
Subject: |
Re: Prefix Argument and optional argument |
Date: |
Tue, 5 Jul 2022 22:26:03 +0200 (CEST) |
Jul 5, 2022, 06:52 by brubar.cs@gmail.com:
> 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)’
>
I did call `M-x byte-compile-file file' but did not get the warning you
desrcibe.
>>
>> (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
>
Have done as follows
(defun poke (&optional prefix)
"TODO"
(interactive "P")
(cond
((equal current-prefix-arg nil) ; no C-u
(setq poke-name-mode 1))
((equal current-prefix-arg '(4)) ; C-u
(setq poke-name-mode 0)
(arktika-workbench))
((equal current-prefix-arg 1) ; C-u 1
(setq poke-name-mode 0)
(let* ( (name (read-from-minibuffer " Name: ")) )
(arktika-workbench name))) ) ))
- Prefix Argument and optional argument, carlmarcos, 2022/07/04
- Message not available
- Message not available
- Re: Prefix Argument and optional argument, carlmarcos, 2022/07/06
- Re: Prefix Argument and optional argument, Michael Heerdegen, 2022/07/07
- Re: Prefix Argument and optional argument, Emanuel Berg, 2022/07/07
- Re: Prefix Argument and optional argument, Emanuel Berg, 2022/07/07
- Re: Prefix Argument and optional argument, Michael Heerdegen, 2022/07/07
- Re: Prefix Argument and optional argument, Christopher Dimech, 2022/07/07
- Re: Prefix Argument and optional argument, Michael Heerdegen, 2022/07/07