From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: thierry.volpiatto@gmail.com Newsgroups: gmane.emacs.help Subject: Re: How to defun body in procedural manner Date: Mon, 20 Apr 2009 16:18:29 +0200 Message-ID: <87vdoz4de2.fsf@tux.homenetwork> 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=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1240238806 24472 80.91.229.12 (20 Apr 2009 14:46:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Apr 2009 14:46:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 20 16:48:05 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 1Lvumf-00042a-Aa for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Apr 2009 16:47:46 +0200 Original-Received: from localhost ([127.0.0.1]:45021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvulG-0006Cg-GF for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Apr 2009 10:46:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvuRK-00066M-FK for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 10:25:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvuRE-000645-4g for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 10:25:40 -0400 Original-Received: from [199.232.76.173] (port=54973 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvuRD-00063r-Cg for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 10:25:35 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:49130 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LvuRC-0006VY-PA for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 10:25:35 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LvuR9-0007AQ-7B for help-gnu-emacs@gnu.org; Mon, 20 Apr 2009 14:25:31 +0000 Original-Received: from 203.77.197-77.rev.gaoland.net ([77.197.77.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Apr 2009 14:25:31 +0000 Original-Received: from thierry.volpiatto by 203.77.197-77.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 Apr 2009 14:25:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 123 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 203.77.197-77.rev.gaoland.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEUHAwNfJRBVTESlTym0 RB/OwKFivhZqAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAABeElE QVQ4y3VTW47CMAyMwwUyTfYfUvG/wfC/ET4B0t7/KmsHurRgXFVVPRm/xglhsRj2+npW98G3+Amp tS5BXxl3SqzcXGRuEyf7n5lPA9jXetNPRhE7EJkzfz8YWnIgBSwW95TK4H79/t4GINKNADWj4PgA DiJX/ZxFDzDXeb4oYMw7kNUvyMzcaj3ioICG4hCKEShkPpwQ49Q05nnkGAQLDFDdExjm0qpowBYA Wi61bDlFU1GW0WbY2dSJYX5ZD2S0AiZL+rPyE19TpMzP2IvNWly+NkuWNgD4pO2oL73IQXoSyVX2 NHna7tgadWRXoCdvf2guqEcvGHqZwE520iRD0/QCYiiTE+U21w1Qxvg6iSp9fbIiDCnSAelDkCVF Vn+HekqXzRybwJ40xF4DMRG6SWGK9G1lYzHSxLYEm05GWbpJCB6A9tb9A3BGn2XdwJbS/WuInj74 4QNF8sVFdP3vl+5tgYp4Ev7fyrfFMkXgElDgV4uV/w8TWEeLCIGJ/AAAACV0RVh0Y3JlYXRlLWRh dGUAMjAwOC0wNS0zMVQyMDoxNDoyMiswMDowMAS7YjIAAAARdEVYdGpwZWc6Y29sb3JzcGFjZQAy LHVVnwAAACB0RVh0anBlZzpzYW1wbGluZy1mYWN0b3IAMngyLDF4MSwxeDFJ+qa0AAAAJXRFWHRt b2RpZnktZGF0ZQAyMDA3LTEwLTI4VDE2OjA4OjQ4KzAwOjAw44nspgAAAABJRU5ErkJggg== User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (gnu/linux) Cancel-Lock: sha1:vVZY2yN4eIVqfD+ulvVaY1K6Ic8= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:63902 Archived-At: Kiwon Um writes: > On Apr 20, 7:43 pm, thierry.volpia...@gmail.com wrote: >> Hi Kiwon, >> >> >> >> Kiwon Um writes: >> > On Apr 17, 9:51 pm, thierry.volpia...@gmail.com wrote: >> >> Kiwon Um 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 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