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

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

Re: How to defun body in procedural manner


From: thierry . volpiatto
Subject: Re: How to defun body in procedural manner
Date: Mon, 20 Apr 2009 12:43:13 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (gnu/linux)

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





reply via email to

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