all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to defun body in procedural manner
@ 2009-04-17  1:28 Kiwon Um
  2009-04-17  4:37 ` Barry Margolin
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-17  1:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hello. I wrote a function as follows:

(defun my-update-package (path)
  "Update the package in path from CVS"
  (cvs-update path nil)
  (shell-command (concat "touch `find " path " -name Makefile`"))
  (compile (concat "make -C " path)))

When the function is called, it seems to execute the shell-command and
compile lines before the finishing cvs-update line. How can I make
this functional execution procedurally? Help me, please.

Thanks.


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

* Re: How to defun body in procedural manner
  2009-04-17  1:28 How to defun body in procedural manner Kiwon Um
@ 2009-04-17  4:37 ` Barry Margolin
  2009-04-17  5:29   ` Kiwon Um
  2009-04-17  5:52 ` thierry.volpiatto
       [not found] ` <mailman.5512.1239947972.31690.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 13+ messages in thread
From: Barry Margolin @ 2009-04-17  4:37 UTC (permalink / raw)
  To: help-gnu-emacs

In article 
<54d389f8-ce90-428d-8fa1-a88c971589d5@d2g2000pra.googlegroups.com>,
 Kiwon Um <um.kiwon@gmail.com> wrote:

> Hello. I wrote a function as follows:
> 
> (defun my-update-package (path)
>   "Update the package in path from CVS"
>   (cvs-update path nil)
>   (shell-command (concat "touch `find " path " -name Makefile`"))
>   (compile (concat "make -C " path)))
> 
> When the function is called, it seems to execute the shell-command and
> compile lines before the finishing cvs-update line. How can I make
> this functional execution procedurally? Help me, please.

Lisp does execute procedurally.  The problem is that cvs-update starts a 
background process to do the work, and then returns.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: How to defun body in procedural manner
  2009-04-17  4:37 ` Barry Margolin
@ 2009-04-17  5:29   ` Kiwon Um
  0 siblings, 0 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-17  5:29 UTC (permalink / raw)
  To: help-gnu-emacs

On 4월17일, 오후1시37분, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <54d389f8-ce90-428d-8fa1-a88c97158...@d2g2000pra.googlegroups.com>,
>  Kiwon Um <um.ki...@gmail.com> wrote:
>
> > Hello. I wrote a function as follows:
>
> > (defun my-update-package (path)
> >   "Update the package in path from CVS"
> >   (cvs-update path nil)
> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >   (compile (concat "make -C " path)))
>
> > When the function is called, it seems to execute the shell-command and
> > compile lines before the finishing cvs-update line. How can I make
> > this functional execution procedurally? Help me, please.
>
> Lisp does execute procedurally.  The problem is that cvs-update starts a
> background process to do the work, and then returns.
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

Thanks for your reply. So how can I check the return time of the
background process?


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

* Re: How to defun body in procedural manner
  2009-04-17  1:28 How to defun body in procedural manner Kiwon Um
  2009-04-17  4:37 ` Barry Margolin
@ 2009-04-17  5:52 ` thierry.volpiatto
       [not found] ` <mailman.5512.1239947972.31690.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: thierry.volpiatto @ 2009-04-17  5:52 UTC (permalink / raw)
  To: help-gnu-emacs

Hi, i don't use cvs, but you should have a look at what return:
`cvs-sentinel'.
and:
(when (cvs-sentinel ==> return_what_you_want)
  (shell-command "your_command"))

Kiwon Um <um.kiwon@gmail.com> writes:

> Hello. I wrote a function as follows:
>
> (defun my-update-package (path)
>   "Update the package in path from CVS"
>   (cvs-update path nil)
>   (shell-command (concat "touch `find " path " -name Makefile`"))
>   (compile (concat "make -C " path)))
>
> When the function is called, it seems to execute the shell-command and
> compile lines before the finishing cvs-update line. How can I make
> this functional execution procedurally? Help me, please.
>
> Thanks.
>

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France





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

* Re: How to defun body in procedural manner
       [not found] ` <mailman.5512.1239947972.31690.help-gnu-emacs@gnu.org>
@ 2009-04-17  9:52   ` Kiwon Um
  2009-04-17 12:51     ` thierry.volpiatto
       [not found]     ` <mailman.5523.1239973116.31690.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-17  9:52 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
> Hi, i don't use cvs, but you should have a look at what return:
> `cvs-sentinel'.
> and:
> (when (cvs-sentinel ==> return_what_you_want)
>   (shell-command "your_command"))
>

I've tried to understand what the cvs-sentinel function does, but I
didn't. Would you write a concrete example code for me, please?

> Kiwon Um <um.ki...@gmail.com> writes:
> > Hello. I wrote a function as follows:
>
> > (defun my-update-package (path)
> >   "Update the package in path from CVS"
> >   (cvs-update path nil)
> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >   (compile (concat "make -C " path)))
>
> > When the function is called, it seems to execute the shell-command and
> > compile lines before the finishing cvs-update line. How can I make
> > this functional execution procedurally? Help me, please.
>
> > Thanks.
>
> --
> A + Thierry Volpiatto
> Location: Saint-Cyr-Sur-Mer - France



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

* Re: How to defun body in procedural manner
  2009-04-17  9:52   ` Kiwon Um
@ 2009-04-17 12:51     ` thierry.volpiatto
       [not found]     ` <mailman.5523.1239973116.31690.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: thierry.volpiatto @ 2009-04-17 12:51 UTC (permalink / raw)
  To: help-gnu-emacs

Kiwon Um <um.kiwon@gmail.com> writes:

> On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
>> Hi, i don't use cvs, but you should have a look at what return:
>> `cvs-sentinel'.
>> and:
>> (when (cvs-sentinel ==> return_what_you_want)
>>   (shell-command "your_command"))
>>
>
> I've tried to understand what the cvs-sentinel function does, but I
> didn't. Would you write a concrete example code for me, please?

Yes, as i told you i am not a cvs user, so...
it seem cvs-sentinel return only a message :-(
So try that, i just write it and it worked to update emacs-w3m and compile
it:

(defun update-cvs-dir-and-compile ()
  (interactive)
  (let ((dir default-directory))
    (cvs-update dir nil)
    (while (not (equal cvs-mode-line-process "exit"))
      (sit-for 1))
    (shell-command "make")))

Modify for your need (make args ...etc..)

>> Kiwon Um <um.ki...@gmail.com> writes:
>> > Hello. I wrote a function as follows:
>>
>> > (defun my-update-package (path)
>> >   "Update the package in path from CVS"
>> >   (cvs-update path nil)
>> >   (shell-command (concat "touch `find " path " -name Makefile`"))
>> >   (compile (concat "make -C " path)))
>>
>> > When the function is called, it seems to execute the shell-command and
>> > compile lines before the finishing cvs-update line. How can I make
>> > this functional execution procedurally? Help me, please.
>>
>> > Thanks.
>>
>> --
>> A + Thierry Volpiatto
>> Location: Saint-Cyr-Sur-Mer - France
>
>

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France





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

* Re: How to defun body in procedural manner
       [not found]     ` <mailman.5523.1239973116.31690.help-gnu-emacs@gnu.org>
@ 2009-04-18  6:58       ` Kiwon Um
  2009-04-20  7:44       ` Kiwon Um
  1 sibling, 0 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-18  6:58 UTC (permalink / raw)
  To: help-gnu-emacs

On 4월17일, 오후9시51분, thierry.volpia...@gmail.com wrote:
> Kiwon Um <um.ki...@gmail.com> writes:
> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
> >> Hi, i don't use cvs, but you should have a look at what return:
> >> `cvs-sentinel'.
> >> and:
> >> (when (cvs-sentinel ==> return_what_you_want)
> >>   (shell-command "your_command"))
>
> > I've tried to understand what the cvs-sentinel function does, but I
> > didn't. Would you write a concrete example code for me, please?
>
> Yes, as i told you i am not a cvs user, so...
> it seem cvs-sentinel return only a message :-(
> So try that, i just write it and it worked to update emacs-w3m and compile
> it:
>
> (defun update-cvs-dir-and-compile ()
>   (interactive)
>   (let ((dir default-directory))
>     (cvs-update dir nil)
>     (while (not (equal cvs-mode-line-process "exit"))
>       (sit-for 1))
>     (shell-command "make")))
>
> Modify for your need (make args ...etc..)
>

These codes work very well. Thanks. :)

>
>
> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> > Hello. I wrote a function as follows:
>
> >> > (defun my-update-package (path)
> >> >   "Update the package in path from CVS"
> >> >   (cvs-update path nil)
> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >> >   (compile (concat "make -C " path)))
>
> >> > When the function is called, it seems to execute the shell-command and
> >> > compile lines before the finishing cvs-update line. How can I make
> >> > this functional execution procedurally? Help me, please.
>
> >> > Thanks.
>
> >> --
> >> A + Thierry Volpiatto
> >> Location: Saint-Cyr-Sur-Mer - France
>
> --
> A + Thierry Volpiatto
> Location: Saint-Cyr-Sur-Mer - France



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

* Re: How to defun body in procedural manner
       [not found]     ` <mailman.5523.1239973116.31690.help-gnu-emacs@gnu.org>
  2009-04-18  6:58       ` Kiwon Um
@ 2009-04-20  7:44       ` Kiwon Um
  2009-04-20 10:43         ` thierry.volpiatto
       [not found]         ` <mailman.5725.1240224622.31690.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-20  7:44 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote:
> Kiwon Um <um.ki...@gmail.com> writes:
> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
> >> Hi, i don't use cvs, but you should have a look at what return:
> >> `cvs-sentinel'.
> >> and:
> >> (when (cvs-sentinel ==> return_what_you_want)
> >>   (shell-command "your_command"))
>
> > I've tried to understand what the cvs-sentinel function does, but I
> > didn't. Would you write a concrete example code for me, please?
>
> Yes, as i told you i am not a cvs user, so...
> it seem cvs-sentinel return only a message :-(
> So try that, i just write it and it worked to update emacs-w3m and compile
> it:
>
> (defun update-cvs-dir-and-compile ()
>   (interactive)
>   (let ((dir default-directory))
>     (cvs-update dir nil)
>     (while (not (equal cvs-mode-line-process "exit"))
>       (sit-for 1))
>     (shell-command "make")))
>
> Modify for your need (make args ...etc..)
>

Then, how can I check the end of the compile process as similar manner
as above? I tried (compile-mode-line-process "exit"), but it didn't
work. And I tried as follows:
(while (not (equal (process-status  "compilation") 'exit)) (sit-for
1))
This didn't work, either.
Any advice?

>
>
> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> > Hello. I wrote a function as follows:
>
> >> > (defun my-update-package (path)
> >> >   "Update the package in path from CVS"
> >> >   (cvs-update path nil)
> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >> >   (compile (concat "make -C " path)))
>
> >> > When the function is called, it seems to execute the shell-command and
> >> > compile lines before the finishing cvs-update line. How can I make
> >> > this functional execution procedurally? Help me, please.
>
> >> > Thanks.
>
> >> --
> >> A + Thierry Volpiatto
> >> Location: Saint-Cyr-Sur-Mer - France
>
> --
> A + Thierry Volpiatto
> Location: Saint-Cyr-Sur-Mer - France



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

* Re: How to defun body in procedural manner
  2009-04-20  7:44       ` Kiwon Um
@ 2009-04-20 10:43         ` thierry.volpiatto
  2009-04-21  0:57           ` Kevin Rodgers
       [not found]         ` <mailman.5725.1240224622.31690.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 13+ messages in thread
From: thierry.volpiatto @ 2009-04-20 10:43 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Kiwon,
Kiwon Um <um.kiwon@gmail.com> writes:

> On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote:
>> Kiwon Um <um.ki...@gmail.com> writes:
>> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
>> >> Hi, i don't use cvs, but you should have a look at what return:
>> >> `cvs-sentinel'.
>> >> and:
>> >> (when (cvs-sentinel ==> return_what_you_want)
>> >>   (shell-command "your_command"))
>>
>> > I've tried to understand what the cvs-sentinel function does, but I
>> > didn't. Would you write a concrete example code for me, please?
>>
>> Yes, as i told you i am not a cvs user, so...
>> it seem cvs-sentinel return only a message :-(
>> So try that, i just write it and it worked to update emacs-w3m and compile
>> it:
>>
>> (defun update-cvs-dir-and-compile ()
>>   (interactive)
>>   (let ((dir default-directory))
>>     (cvs-update dir nil)
>>     (while (not (equal cvs-mode-line-process "exit"))
>>       (sit-for 1))
>>     (shell-command "make")))
>>
>> Modify for your need (make args ...etc..)
>>
>
> Then, how can I check the end of the compile process as similar manner
> as above? I tried (compile-mode-line-process "exit"), but it didn't
> work. And I tried as follows:
> (while (not (equal (process-status  "compilation") 'exit)) (sit-for
> 1))
> This didn't work, either.
> Any advice?

`shell-command' is a synchronous process, so you have just to wait it
finish.May be just add a message to tell you that the compile process is
started:

(defun update-cvs-dir-and-compile ()
  "Cvs update current dir and compile it."
  (interactive)
  (let ((dir default-directory))
    (cvs-update dir nil)
    (while (not (equal cvs-mode-line-process "exit"))
      (sit-for 1))
    (message "Wait compiling %s..." dir)
    (shell-command "make")))

But if you want to run the compile process asynchronous,
you have to use `start-process' instead of `shell-command' and set a
sentinel on this process like this:

(progn
  (start-process "my-compil" nil "sleep"
               "12")
  (set-process-sentinel (get-process "my-compil")
                        #'(lambda (process event)
                            (message "Process:%s State:%s" process event))))

Replace "sleep" with "make" and "12" with make args ;-)

NOTE:If you have more than one arg to the make command, it's may be
convenient to use apply on start-process.


>> >> Kiwon Um <um.ki...@gmail.com> writes:
>> >> > Hello. I wrote a function as follows:
>>
>> >> > (defun my-update-package (path)
>> >> >   "Update the package in path from CVS"
>> >> >   (cvs-update path nil)
>> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
>> >> >   (compile (concat "make -C " path)))
>>
>> >> > When the function is called, it seems to execute the shell-command and
>> >> > compile lines before the finishing cvs-update line. How can I make
>> >> > this functional execution procedurally? Help me, please.
>>
>> >> > Thanks.
>>
>> >> --
>> >> A + Thierry Volpiatto
>> >> Location: Saint-Cyr-Sur-Mer - France
>>
>> --
>> A + Thierry Volpiatto
>> Location: Saint-Cyr-Sur-Mer - France
>
>

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France





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

* Re: How to defun body in procedural manner
       [not found]         ` <mailman.5725.1240224622.31690.help-gnu-emacs@gnu.org>
@ 2009-04-20 13:28           ` Kiwon Um
  2009-04-20 14:18             ` thierry.volpiatto
       [not found]             ` <mailman.5730.1240237545.31690.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-20 13:28 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 20, 7:43 pm, thierry.volpia...@gmail.com wrote:
> Hi Kiwon,
>
>
>
> Kiwon Um <um.ki...@gmail.com> writes:
> > On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote:
> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
> >> >> Hi, i don't use cvs, but you should have a look at what return:
> >> >> `cvs-sentinel'.
> >> >> and:
> >> >> (when (cvs-sentinel ==> return_what_you_want)
> >> >>   (shell-command "your_command"))
>
> >> > I've tried to understand what the cvs-sentinel function does, but I
> >> > didn't. Would you write a concrete example code for me, please?
>
> >> Yes, as i told you i am not a cvs user, so...
> >> it seem cvs-sentinel return only a message :-(
> >> So try that, i just write it and it worked to update emacs-w3m and compile
> >> it:
>
> >> (defun update-cvs-dir-and-compile ()
> >>   (interactive)
> >>   (let ((dir default-directory))
> >>     (cvs-update dir nil)
> >>     (while (not (equal cvs-mode-line-process "exit"))
> >>       (sit-for 1))
> >>     (shell-command "make")))
>
> >> Modify for your need (make args ...etc..)
>
> > Then, how can I check the end of the compile process as similar manner
> > as above? I tried (compile-mode-line-process "exit"), but it didn't
> > work. And I tried as follows:
> > (while (not (equal (process-status  "compilation") 'exit)) (sit-for
> > 1))
> > This didn't work, either.
> > Any advice?
>
> `shell-command' is a synchronous process, so you have just to wait it
> finish.May be just add a message to tell you that the compile process is
> started:
>

Ah! I missed my point. Actually, I've changed shell-command to compile
so that
(compile "make -C ...some_path") not (shell-command ...).
The function 'compile' doesn't seem to be synchronous, huh? So I'm
wondering how to check it.
Thanks for your kind replies :)

> (defun update-cvs-dir-and-compile ()
>   "Cvs update current dir and compile it."
>   (interactive)
>   (let ((dir default-directory))
>     (cvs-update dir nil)
>     (while (not (equal cvs-mode-line-process "exit"))
>       (sit-for 1))
>     (message "Wait compiling %s..." dir)
>     (shell-command "make")))
>
> But if you want to run the compile process asynchronous,
> you have to use `start-process' instead of `shell-command' and set a
> sentinel on this process like this:
>
> (progn
>   (start-process "my-compil" nil "sleep"
>                "12")
>   (set-process-sentinel (get-process "my-compil")
>                         #'(lambda (process event)
>                             (message "Process:%s State:%s" process event))))
>
> Replace "sleep" with "make" and "12" with make args ;-)
>
> NOTE:If you have more than one arg to the make command, it's may be
> convenient to use apply on start-process.
>
>
>
> >> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> >> > Hello. I wrote a function as follows:
>
> >> >> > (defun my-update-package (path)
> >> >> >   "Update the package in path from CVS"
> >> >> >   (cvs-update path nil)
> >> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >> >> >   (compile (concat "make -C " path)))
>
> >> >> > When the function is called, it seems to execute the shell-command and
> >> >> > compile lines before the finishing cvs-update line. How can I make
> >> >> > this functional execution procedurally? Help me, please.
>
> >> >> > Thanks.
>
> >> >> --
> >> >> A + Thierry Volpiatto
> >> >> Location: Saint-Cyr-Sur-Mer - France
>
> >> --
> >> A + Thierry Volpiatto
> >> Location: Saint-Cyr-Sur-Mer - France
>
> --
> A + Thierry Volpiatto
> Location: Saint-Cyr-Sur-Mer - France



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

* Re: How to defun body in procedural manner
  2009-04-20 13:28           ` Kiwon Um
@ 2009-04-20 14:18             ` thierry.volpiatto
       [not found]             ` <mailman.5730.1240237545.31690.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: thierry.volpiatto @ 2009-04-20 14:18 UTC (permalink / raw)
  To: help-gnu-emacs

Kiwon Um <um.kiwon@gmail.com> writes:

> On Apr 20, 7:43 pm, thierry.volpia...@gmail.com wrote:
>> Hi Kiwon,
>>
>>
>>
>> Kiwon Um <um.ki...@gmail.com> writes:
>> > On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote:
>> >> Kiwon Um <um.ki...@gmail.com> writes:
>> >> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
>> >> >> Hi, i don't use cvs, but you should have a look at what return:
>> >> >> `cvs-sentinel'.
>> >> >> and:
>> >> >> (when (cvs-sentinel ==> return_what_you_want)
>> >> >>   (shell-command "your_command"))
>>
>> >> > I've tried to understand what the cvs-sentinel function does, but I
>> >> > didn't. Would you write a concrete example code for me, please?
>>
>> >> Yes, as i told you i am not a cvs user, so...
>> >> it seem cvs-sentinel return only a message :-(
>> >> So try that, i just write it and it worked to update emacs-w3m and compile
>> >> it:
>>
>> >> (defun update-cvs-dir-and-compile ()
>> >>   (interactive)
>> >>   (let ((dir default-directory))
>> >>     (cvs-update dir nil)
>> >>     (while (not (equal cvs-mode-line-process "exit"))
>> >>       (sit-for 1))
>> >>     (shell-command "make")))
>>
>> >> Modify for your need (make args ...etc..)
>>
>> > Then, how can I check the end of the compile process as similar manner
>> > as above? I tried (compile-mode-line-process "exit"), but it didn't
>> > work. And I tried as follows:
>> > (while (not (equal (process-status  "compilation") 'exit)) (sit-for
>> > 1))
>> > This didn't work, either.
>> > Any advice?
>>
>> `shell-command' is a synchronous process, so you have just to wait it
>> finish.May be just add a message to tell you that the compile process is
>> started:
>>
>
> Ah! I missed my point. Actually, I've changed shell-command to compile
> so that
> (compile "make -C ...some_path") not (shell-command ...).
> The function 'compile' doesn't seem to be synchronous, huh? So I'm
> wondering how to check it.

compile is asynchronous, and it will warn you when finish.
Have a look at C-h f compile RET.

Unless you have to run another command after the compile process, there
is no need to catch the end of the process, just wait it warn you in the
mode-line or the compile buffer.

> Thanks for your kind replies :)
>
>> (defun update-cvs-dir-and-compile ()
>>   "Cvs update current dir and compile it."
>>   (interactive)
>>   (let ((dir default-directory))
>>     (cvs-update dir nil)
>>     (while (not (equal cvs-mode-line-process "exit"))
>>       (sit-for 1))
>>     (message "Wait compiling %s..." dir)
>>     (shell-command "make")))
>>
>> But if you want to run the compile process asynchronous,
>> you have to use `start-process' instead of `shell-command' and set a
>> sentinel on this process like this:
>>
>> (progn
>>   (start-process "my-compil" nil "sleep"
>>                "12")
>>   (set-process-sentinel (get-process "my-compil")
>>                         #'(lambda (process event)
>>                             (message "Process:%s State:%s" process event))))
>>
>> Replace "sleep" with "make" and "12" with make args ;-)
>>
>> NOTE:If you have more than one arg to the make command, it's may be
>> convenient to use apply on start-process.
>>
>>
>>
>> >> >> Kiwon Um <um.ki...@gmail.com> writes:
>> >> >> > Hello. I wrote a function as follows:
>>
>> >> >> > (defun my-update-package (path)
>> >> >> >   "Update the package in path from CVS"
>> >> >> >   (cvs-update path nil)
>> >> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
>> >> >> >   (compile (concat "make -C " path)))
>>
>> >> >> > When the function is called, it seems to execute the shell-command and
>> >> >> > compile lines before the finishing cvs-update line. How can I make
>> >> >> > this functional execution procedurally? Help me, please.
>>
>> >> >> > Thanks.
>>
>> >> >> --
>> >> >> A + Thierry Volpiatto
>> >> >> Location: Saint-Cyr-Sur-Mer - France
>>
>> >> --
>> >> A + Thierry Volpiatto
>> >> Location: Saint-Cyr-Sur-Mer - France
>>
>> --
>> A + Thierry Volpiatto
>> Location: Saint-Cyr-Sur-Mer - France
>
>

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France





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

* Re: How to defun body in procedural manner
  2009-04-20 10:43         ` thierry.volpiatto
@ 2009-04-21  0:57           ` Kevin Rodgers
  0 siblings, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2009-04-21  0:57 UTC (permalink / raw)
  To: help-gnu-emacs

thierry.volpiatto@gmail.com wrote:
> `shell-command' is a synchronous process, so you have just to wait it
> finish.May be just add a message to tell you that the compile process is
> started:
> 
> (defun update-cvs-dir-and-compile ()
>   "Cvs update current dir and compile it."
>   (interactive)
>   (let ((dir default-directory))
>     (cvs-update dir nil)
>     (while (not (equal cvs-mode-line-process "exit"))
>       (sit-for 1))
>     (message "Wait compiling %s..." dir)
>     (shell-command "make")))
> 
> But if you want to run the compile process asynchronous,
> you have to use `start-process' instead of `shell-command' and set a
> sentinel on this process like this:
> 
> (progn
>   (start-process "my-compil" nil "sleep"
>                "12")
>   (set-process-sentinel (get-process "my-compil")
>                         #'(lambda (process event)
>                             (message "Process:%s State:%s" process event))))
> 
> Replace "sleep" with "make" and "12" with make args ;-)
> 
> NOTE:If you have more than one arg to the make command, it's may be
> convenient to use apply on start-process.

If you want be able to run more than 1 process (after all, it is
asynchronous):

(let ((this-process (start-process "my-compil" nil "sleep"
				   "12")))
   (set-process-sentinel this-process
                         #'(lambda (process event)
                             (message "Process:%s State:%s" process 
event))))

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: How to defun body in procedural manner
       [not found]             ` <mailman.5730.1240237545.31690.help-gnu-emacs@gnu.org>
@ 2009-04-21  1:46               ` Kiwon Um
  0 siblings, 0 replies; 13+ messages in thread
From: Kiwon Um @ 2009-04-21  1:46 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 20, 11:18 pm, thierry.volpia...@gmail.com wrote:
> Kiwon Um <um.ki...@gmail.com> writes:
> > On Apr 20, 7:43 pm, thierry.volpia...@gmail.com wrote:
> >> Hi Kiwon,
>
> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> > On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote:
> >> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> >> > On Apr 17, 2:52 pm, thierry.volpia...@gmail.com wrote:
> >> >> >> Hi, i don't use cvs, but you should have a look at what return:
> >> >> >> `cvs-sentinel'.
> >> >> >> and:
> >> >> >> (when (cvs-sentinel ==> return_what_you_want)
> >> >> >>   (shell-command "your_command"))
>
> >> >> > I've tried to understand what the cvs-sentinel function does, but I
> >> >> > didn't. Would you write a concrete example code for me, please?
>
> >> >> Yes, as i told you i am not a cvs user, so...
> >> >> it seem cvs-sentinel return only a message :-(
> >> >> So try that, i just write it and it worked to update emacs-w3m and compile
> >> >> it:
>
> >> >> (defun update-cvs-dir-and-compile ()
> >> >>   (interactive)
> >> >>   (let ((dir default-directory))
> >> >>     (cvs-update dir nil)
> >> >>     (while (not (equal cvs-mode-line-process "exit"))
> >> >>       (sit-for 1))
> >> >>     (shell-command "make")))
>
> >> >> Modify for your need (make args ...etc..)
>
> >> > Then, how can I check the end of the compile process as similar manner
> >> > as above? I tried (compile-mode-line-process "exit"), but it didn't
> >> > work. And I tried as follows:
> >> > (while (not (equal (process-status  "compilation") 'exit)) (sit-for
> >> > 1))
> >> > This didn't work, either.
> >> > Any advice?
>
> >> `shell-command' is a synchronous process, so you have just to wait it
> >> finish.May be just add a message to tell you that the compile process is
> >> started:
>
> > Ah! I missed my point. Actually, I've changed shell-command to compile
> > so that
> > (compile "make -C ...some_path") not (shell-command ...).
> > The function 'compile' doesn't seem to be synchronous, huh? So I'm
> > wondering how to check it.
>
> compile is asynchronous, and it will warn you when finish.
> Have a look at C-h f compile RET.
>
> Unless you have to run another command after the compile process, there
> is no need to catch the end of the process, just wait it warn you in the
> mode-line or the compile buffer.
>

That's my case. The compile command is for clear-all things, so the
next processes must check it. Actually, shell-command is fine to do
it. I just wondered how to generally check the status of an
asynchronous function process. Always thanks for your advice. :)

>
>
> > Thanks for your kind replies :)
>
> >> (defun update-cvs-dir-and-compile ()
> >>   "Cvs update current dir and compile it."
> >>   (interactive)
> >>   (let ((dir default-directory))
> >>     (cvs-update dir nil)
> >>     (while (not (equal cvs-mode-line-process "exit"))
> >>       (sit-for 1))
> >>     (message "Wait compiling %s..." dir)
> >>     (shell-command "make")))
>
> >> But if you want to run the compile process asynchronous,
> >> you have to use `start-process' instead of `shell-command' and set a
> >> sentinel on this process like this:
>
> >> (progn
> >>   (start-process "my-compil" nil "sleep"
> >>                "12")
> >>   (set-process-sentinel (get-process "my-compil")
> >>                         #'(lambda (process event)
> >>                             (message "Process:%s State:%s" process event))))
>
> >> Replace "sleep" with "make" and "12" with make args ;-)
>
> >> NOTE:If you have more than one arg to the make command, it's may be
> >> convenient to use apply on start-process.
>
> >> >> >> Kiwon Um <um.ki...@gmail.com> writes:
> >> >> >> > Hello. I wrote a function as follows:
>
> >> >> >> > (defun my-update-package (path)
> >> >> >> >   "Update the package in path from CVS"
> >> >> >> >   (cvs-update path nil)
> >> >> >> >   (shell-command (concat "touch `find " path " -name Makefile`"))
> >> >> >> >   (compile (concat "make -C " path)))
>
> >> >> >> > When the function is called, it seems to execute the shell-command and
> >> >> >> > compile lines before the finishing cvs-update line. How can I make
> >> >> >> > this functional execution procedurally? Help me, please.
>
> >> >> >> > Thanks.
>
> >> >> >> --
> >> >> >> A + Thierry Volpiatto
> >> >> >> Location: Saint-Cyr-Sur-Mer - France
>
> >> >> --
> >> >> A + Thierry Volpiatto
> >> >> Location: Saint-Cyr-Sur-Mer - France
>
> >> --
> >> A + Thierry Volpiatto
> >> Location: Saint-Cyr-Sur-Mer - France
>
> --
> A + Thierry Volpiatto
> Location: Saint-Cyr-Sur-Mer - France



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

end of thread, other threads:[~2009-04-21  1:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-17  1:28 How to defun body in procedural manner Kiwon Um
2009-04-17  4:37 ` Barry Margolin
2009-04-17  5:29   ` Kiwon Um
2009-04-17  5:52 ` thierry.volpiatto
     [not found] ` <mailman.5512.1239947972.31690.help-gnu-emacs@gnu.org>
2009-04-17  9:52   ` Kiwon Um
2009-04-17 12:51     ` thierry.volpiatto
     [not found]     ` <mailman.5523.1239973116.31690.help-gnu-emacs@gnu.org>
2009-04-18  6:58       ` Kiwon Um
2009-04-20  7:44       ` Kiwon Um
2009-04-20 10:43         ` thierry.volpiatto
2009-04-21  0:57           ` Kevin Rodgers
     [not found]         ` <mailman.5725.1240224622.31690.help-gnu-emacs@gnu.org>
2009-04-20 13:28           ` Kiwon Um
2009-04-20 14:18             ` thierry.volpiatto
     [not found]             ` <mailman.5730.1240237545.31690.help-gnu-emacs@gnu.org>
2009-04-21  1:46               ` Kiwon Um

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.