[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to exit function from inside its `interactive' call?
From: |
Thorsten Jolitz |
Subject: |
How to exit function from inside its `interactive' call? |
Date: |
Wed, 06 Aug 2014 21:38:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Hi List,
how can I use catch/throw (or whatever) to exit function foo from inside
its 'interactive call? All combinations I tried so far only exit
'interactive and still execute the function body.
#+begin_src emacs-lisp
(defun foo (&optional arg)
(catch 'exit
(interactive
(let ((bar (if current-prefix-arg
(prefix-numeric-value)
(throw 'exit nil))))
(list (+ 2 bar)))))
(message "Arg: %s" arg))
#+end_src
#+results:
: Arg: nil
#+begin_src emacs-lisp
(foo)
#+end_src
#+results:
: Arg: nil
#+begin_src emacs-lisp
(foo '(4))
#+end_src
#+results:
: Arg: (4)
Thanks for any hint.
--
cheers,
Thorsten
- How to exit function from inside its `interactive' call?,
Thorsten Jolitz <=