all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `call-interactively' only the first time
@ 2006-08-15 13:48 augukarl
  2006-08-16  2:13 ` wenbinye
  0 siblings, 1 reply; 8+ messages in thread
From: augukarl @ 2006-08-15 13:48 UTC (permalink / raw)


Hi everyone,

Is it possible to write a function that first calls a function, f,
interactively and then invokes f with the same parameters
non-interactively?


Regards,

August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-15 13:48 `call-interactively' only the first time augukarl
@ 2006-08-16  2:13 ` wenbinye
  2006-08-16  9:58   ` augukarl
  0 siblings, 1 reply; 8+ messages in thread
From: wenbinye @ 2006-08-16  2:13 UTC (permalink / raw)


If use (call-interactively 'f), the function is interactively.
if provide parameters to the function, such (f 1), the function f is
like other functions.
Is this the answer?
augukarl@yahoo.se wrote:
> Hi everyone,
>
> Is it possible to write a function that first calls a function, f,
> interactively and then invokes f with the same parameters
> non-interactively?
> 
> 
> Regards,
> 
> August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-16  2:13 ` wenbinye
@ 2006-08-16  9:58   ` augukarl
  2006-08-16 15:20     ` wenbinye
  0 siblings, 1 reply; 8+ messages in thread
From: augukarl @ 2006-08-16  9:58 UTC (permalink / raw)


wenbinye@gmail.com skrev:

> If use (call-interactively 'f), the function is interactively.
> if provide parameters to the function, such (f 1), the function f is
> like other functions.
> Is this the answer?

Unfortunately, no.

I first want to call a function interactively and then I want to call
the same function non-interactively. In the non-interactive call I want
to pass the same parameters used with the preceding interactive call.


August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-16  9:58   ` augukarl
@ 2006-08-16 15:20     ` wenbinye
  2006-08-17  9:05       ` augukarl
  0 siblings, 1 reply; 8+ messages in thread
From: wenbinye @ 2006-08-16 15:20 UTC (permalink / raw)


Can you give the definition of the function?
augukarl@yahoo.se wrote:
> wenbinye@gmail.com skrev:
>
> > If use (call-interactively 'f), the function is interactively.
> > if provide parameters to the function, such (f 1), the function f is
> > like other functions.
> > Is this the answer?
>
> Unfortunately, no.
>
> I first want to call a function interactively and then I want to call
> the same function non-interactively. In the non-interactive call I want
> to pass the same parameters used with the preceding interactive call.
> 
> 
> August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-16 15:20     ` wenbinye
@ 2006-08-17  9:05       ` augukarl
  2006-08-17 12:02         ` wenbinye
  0 siblings, 1 reply; 8+ messages in thread
From: augukarl @ 2006-08-17  9:05 UTC (permalink / raw)


wenbinye@gmail.com skrev:
> Can you give the definition of the function?

Here is the pseudo code for the function I want to define:

(defun f (g)  ;; g is an interactive function.
  ;; Call g interactively.
  ;; Call g non-interactively with the parameters (specified by
  ;; the user) in the command above.
  )

Is this clear enough?


Thanks,

August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-17  9:05       ` augukarl
@ 2006-08-17 12:02         ` wenbinye
  2006-08-17 13:19           ` augukarl
  0 siblings, 1 reply; 8+ messages in thread
From: wenbinye @ 2006-08-17 12:02 UTC (permalink / raw)


You didn't provide the real code, 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.
Another question is how do you restore the argument when called
interactively first time?

(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)

augukarl@yahoo.se wrote:
> wenbinye@gmail.com skrev:
> > Can you give the definition of the function?
>
> Here is the pseudo code for the function I want to define:
>
> (defun f (g)  ;; g is an interactive function.
>   ;; Call g interactively.
>   ;; Call g non-interactively with the parameters (specified by
>   ;; the user) in the command above.
>   )
> 
> Is this clear enough?
> 
> 
> Thanks,
> 
> August

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-17 12:02         ` wenbinye
@ 2006-08-17 13:19           ` augukarl
  2006-08-17 13:35             ` wenbinye
  0 siblings, 1 reply; 8+ messages in thread
From: augukarl @ 2006-08-17 13:19 UTC (permalink / raw)


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.

> (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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: `call-interactively' only the first time
  2006-08-17 13:19           ` augukarl
@ 2006-08-17 13:35             ` wenbinye
  0 siblings, 0 replies; 8+ messages in thread
From: wenbinye @ 2006-08-17 13:35 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-08-17 13:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-15 13:48 `call-interactively' only the first time augukarl
2006-08-16  2:13 ` wenbinye
2006-08-16  9:58   ` augukarl
2006-08-16 15:20     ` wenbinye
2006-08-17  9:05       ` augukarl
2006-08-17 12:02         ` wenbinye
2006-08-17 13:19           ` augukarl
2006-08-17 13:35             ` wenbinye

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.