From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kiwon Um Newsgroups: gmane.emacs.help Subject: Re: How to defun body in procedural manner Date: Mon, 20 Apr 2009 18:46:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <195d4c26-e977-4ce6-80fc-10f868199f44@s38g2000prg.googlegroups.com> References: <54d389f8-ce90-428d-8fa1-a88c971589d5@d2g2000pra.googlegroups.com> <640bf9e6-2694-4334-9781-c31254c36c33@k19g2000prh.googlegroups.com> <3d87cfcb-eb0c-4dbf-b8cb-da5010b1d5b0@z16g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1240281649 19737 80.91.229.12 (21 Apr 2009 02:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Apr 2009 02:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 21 04:42:08 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lw5vv-000868-Mw for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Apr 2009 04:42:04 +0200 Original-Received: from localhost ([127.0.0.1]:44391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lw5uW-0006L5-Si for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Apr 2009 22:40:36 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!s38g2000prg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 135 Original-NNTP-Posting-Host: 163.152.71.53 Original-X-Trace: posting.google.com 1240278362 3585 127.0.0.1 (21 Apr 2009 01:46:02 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 21 Apr 2009 01:46:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s38g2000prg.googlegroups.com; posting-host=163.152.71.53; posting-account=6v9_LQoAAACIrmHTUxB_-iw-j364OtYr User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; ko-KR; rv:1.9.0.8) Gecko/2009032600 SUSE/3.0.8-1.1 Firefox/3.0.8,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:168642 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:63915 Archived-At: On Apr 20, 11:18=A0pm, thierry.volpia...@gmail.com wrote: > Kiwon Um writes: > > On Apr 20, 7:43=A0pm, thierry.volpia...@gmail.com wrote: > >> Hi Kiwon, > > >> Kiwon Um writes: > >> > On Apr 17, 9:51=A0pm, thierry.volpia...@gmail.com wrote: > >> >> Kiwon Um writes: > >> >> > On Apr 17, 2:52=A0pm, 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 =3D=3D> return_what_you_want) > >> >> >> =A0 (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 () > >> >> =A0 (interactive) > >> >> =A0 (let ((dir default-directory)) > >> >> =A0 =A0 (cvs-update dir nil) > >> >> =A0 =A0 (while (not (equal cvs-mode-line-process "exit")) > >> >> =A0 =A0 =A0 (sit-for 1)) > >> >> =A0 =A0 (shell-command "make"))) > > >> >> Modify for your need (make args ...etc..) > > >> > Then, how can I check the end of the compile process as similar mann= er > >> > as above? I tried (compile-mode-line-process "exit"), but it didn't > >> > work. And I tried as follows: > >> > (while (not (equal (process-status =A0"compilation") 'exit)) (sit-fo= r > >> > 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 () > >> =A0 "Cvs update current dir and compile it." > >> =A0 (interactive) > >> =A0 (let ((dir default-directory)) > >> =A0 =A0 (cvs-update dir nil) > >> =A0 =A0 (while (not (equal cvs-mode-line-process "exit")) > >> =A0 =A0 =A0 (sit-for 1)) > >> =A0 =A0 (message "Wait compiling %s..." dir) > >> =A0 =A0 (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 > >> =A0 (start-process "my-compil" nil "sleep" > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"12") > >> =A0 (set-process-sentinel (get-process "my-compil") > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #'(lambda (process eve= nt) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message "Proc= ess:%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 writes: > >> >> >> > Hello. I wrote a function as follows: > > >> >> >> > (defun my-update-package (path) > >> >> >> > =A0 "Update the package in path from CVS" > >> >> >> > =A0 (cvs-update path nil) > >> >> >> > =A0 (shell-command (concat "touch `find " path " -name Makefil= e`")) > >> >> >> > =A0 (compile (concat "make -C " path))) > > >> >> >> > When the function is called, it seems to execute the shell-com= mand 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