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

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

Re: `call-interactively' only the first time


From: wenbinye
Subject: Re: `call-interactively' only the first time
Date: 17 Aug 2006 06:35:00 -0700
User-agent: G2/0.2

Maybe I misunderstand you question. You should tell you real problem at
the beginning.

(defun foo (arg1 arg2)
  (interactive "nNumber: \nsString: \n")
  (message "foo: %S, %S" arg1 arg2)
  (setq my-global-arg (list arg1 arg2)))

(defun bar (func)
  (let (arg)
    (message "first call: ")
    (call-interactively func)
    (message "call again: ")
    (apply func my-global-arg)))

(bar 'foo)

augukarl@yahoo.se wrote:
> wenbinye@gmail.com skrev:
> > You didn't provide the real code,
>
> Of course not. My question is how to write it.
>
> > I assume you may make mistake when use
> > the function in parameter, which is named g in you pseudo code. You
> > should use funcall function.
>
> How can it be a misstake? I haven't written any (real) function-call
> statements.
>
> > Another question is how do you restore the argument when called
> > interactively first time?
>
> Exactly, that's the essence of my question.
Global variable may help.
>
> > (defun foo (arg)
> >   (interactive "sGive me a string: ")
> >   (message "foo: %S" arg))
> >
> > (defun bar (func)
> >     (message "first call: ")
> >     (call-interactively func)
> >     (message "call again: ")
> >     (funcall func "efg"))
> >
> > ;; use like this:
> > (bar 'foo)
>
> This is only a special case. In my pseudo code I put no restrictions on
> the command g (it can take any number of parameters).
> 
> 
> August



reply via email to

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