From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Yu,Gang" Newsgroups: gmane.emacs.help Subject: Re: process communication help Date: Wed, 30 May 2007 15:53:57 +0800 Message-ID: <48378d570705300053g312524dbx2da09b79657a4806@mail.gmail.com> References: <878xb8kqje.fsf@ambire.localdomain> <871wh0kjzg.fsf@ambire.localdomain> <87tztvk6qg.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0971040087==" X-Trace: sea.gmane.org 1180511689 25531 80.91.229.12 (30 May 2007 07:54:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 May 2007 07:54:49 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Thien-Thi Nguyen" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 30 09:54:47 2007 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 1HtJ0z-0000en-KH for geh-help-gnu-emacs@m.gmane.org; Wed, 30 May 2007 09:54:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtJ0y-0008VG-E6 for geh-help-gnu-emacs@m.gmane.org; Wed, 30 May 2007 03:54:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtJ0V-0008Tl-8W for help-gnu-emacs@gnu.org; Wed, 30 May 2007 03:54:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtJ0S-0008TU-KH for help-gnu-emacs@gnu.org; Wed, 30 May 2007 03:54:09 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtJ0S-0008TR-BZ for help-gnu-emacs@gnu.org; Wed, 30 May 2007 03:54:08 -0400 Original-Received: from nz-out-0506.google.com ([64.233.162.233]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HtJ0P-0003ac-Ic for help-gnu-emacs@gnu.org; Wed, 30 May 2007 03:54:07 -0400 Original-Received: by nz-out-0506.google.com with SMTP id z3so1667601nzf for ; Wed, 30 May 2007 00:53:58 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=gXEgZz2/iE7AiEFOcjbOzZNy4DC4rRr9iA4Q+y01JcgyD8cHHxvk5wMgo9Pv4CT+vl7pn1yJCQJ7fXrPNcCwPrki/7GgSlOK9BpDPIJrxaxjgPWkDJg2zK7CAgFLlZvCkDpgJgQ3fj+XiTKz30dBh525FS3/uMipZo0Lg2VN8lw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=CvDQf7nQrZCuNh3nmL4EPtphgLH1PHzPPFNUUQrECDcuiniNvpvYyKkm5J4bLcyVOhTRhvL+Aft8X+TCEFur+Drr3N5LDE5a61fTzMO4kxFz46nwpYwO8uky3CIXJhOaOSy04Ff9SHtMbe9FhskeXA7z+AQ1fWAK9ZJLg1LnIM0= Original-Received: by 10.115.23.12 with SMTP id a12mr3787261waj.1180511637669; Wed, 30 May 2007 00:53:57 -0700 (PDT) Original-Received: by 10.114.60.1 with HTTP; Wed, 30 May 2007 00:53:57 -0700 (PDT) In-Reply-To: <87tztvk6qg.fsf@ambire.localdomain> X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) 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:44550 Archived-At: --===============0971040087== Content-Type: multipart/alternative; boundary="----=_Part_925_17539654.1180511637618" ------=_Part_925_17539654.1180511637618 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Thien-Thi : thanks!! I get a lot of instances shown in *grep* buffer, just like cd /usr/share/emacs/21.4/lisp/ egrep -nH -e '(start|call)-process' *.el /dev/null arc-mode.el:989: (apply 'call-process arc-mode.el:1011: (apply 'call-process arc-mode.el:1122: (let ((exitcode (apply 'call-process arc-mode.el:1282: (apply 'call-process .... dired-aux.el:411:(defun dired-call-process (praogram discard &rest arguments) dired-aux.el:417: 'dired-call-process))) dired-aux.el:418: (if handler (apply handler 'dired-call-process dired-aux.el:420: (apply 'call-process program nil (not discard) nil arguments)))) dired-aux.el:438: (apply (function dired-call-process) program nil arguments))) .... I try to rewrite the code like this: (defun def-in-dir (dir regexp) "find regexp in elisp source directory" (interactive) (setq dir (if (not (string-equal (substring dir -1) "/")) (concat dir "/") dir)) (setq default-directory dir) (if (file-exists-p default-directory) (progn (setq files (directory-files default-directory nil "\\.el$")) (if files (setq command (concat "egrep -nH -e '" regexp "' " (stringlist-to-string files " "))) (setq command "grep -n -e")) (ignore-errors (grep command)) ))) but I cant' collect all the result in the same "*grep*" buffer, everytime only one command result can be written in this buffer, no append way? I mean things like: (dolist (dir load-path) (def-in-dir dir "(start|call)-process") On 5/29/07, Thien-Thi Nguyen wrote: > > () "Yu,Gang" > () Tue, 29 May 2007 19:57:42 +0800 > > Where can I get resources on elisp's idiomatic programming style? > > one way is to read a lot of elisp. this is particularly easy to do > since emacs itself is distributed with a lot of elisp. > > How about these macros?? I rewrite the function like this, [...] > > these are ugly. i don't even know if they are correct, i could not > force myself to read them. > > why don't you try this: > > (0) make sure your emacs is properly installed, in other words, with > full source code (for each .elc file there should be a corresponding > .el file in the same directory). > > (1) evaluate the forms: > (require 'cl) > (dolist (dir load-path) (ignore-errors (dired dir))) > > (2) in each" dired buffer, evaluate the form: > (grep "egrep -nH -e '(call|start)-process' *.el") > > by "evaluate the form", i mean type `M-:' and then the form and then > RET. for step (2) you can recall previous forms into the minibuffer > by typing `M-p'. > > further exploration is up to you. have fun! > > thi > _______________________________________________ > help-gnu-emacs mailing list > help-gnu-emacs@gnu.org > http://lists.gnu.org/mailman/listinfo/help-gnu-emacs > -- YuGang ------=_Part_925_17539654.1180511637618 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Thien-Thi :

   thanks!!

I get a lot of instances shown in *grep* buffer, just like

cd /usr/share/emacs/21.4/lisp/
egrep -nH -e '(start|call)-process' *.el /dev/null
arc-mode.el:989:      (apply 'call-process
arc-mode.el:1011:  (apply 'call-process
arc-mode.el:1122:          (let ((exitcode (apply 'call-process
arc-mode.el:1282:  (apply 'call-process
....

dired-aux.el:411:(defun dired-call-process (praogram discard &rest arguments)
dired-aux.el:417:                 'dired-call-process)))
dired-aux.el:418:    (if handler (apply handler 'dired-call-process
dired-aux.el:420:      (apply 'call-process program nil (not discard) nil arguments))))
dired-aux.el:438:         (apply (function dired-call-process) program nil arguments)))
....

I try to rewrite the code like this:
     
(defun def-in-dir (dir regexp)
  "find regexp in elisp source directory"
  (interactive)
  (setq dir (if (not (string-equal (substring dir -1) "/"))
                  (concat dir "/")
                dir))
  (setq default-directory dir)
  (if (file-exists-p default-directory)
      (progn (setq files (directory-files default-directory nil "\\.el$"))
         (if files
            (setq command
               (concat "egrep -nH -e '" regexp "' "  (stringlist-to-string files " ")))
           (setq command "grep -n -e"))
         (ignore-errors (grep command))
         )))

but I cant' collect all the result in the same "*grep*" buffer, everytime only one command result can be written in this buffer, no append way?

I mean things like:

(dolist (dir load-path)
   (def-in-dir dir "(start|call)-process")


On 5/29/07, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
() "Yu,Gang" <wuhanyugang@gmail.com >
() Tue, 29 May 2007 19:57:42 +0800

   Where can I get resources on elisp's idiomatic programming style?

one way is to read a lot of elisp.  this is particularly easy to do
since emacs itself is distributed with a lot of elisp.

   How about these macros?? I rewrite the function like this, [...]

these are ugly.  i don't even know if they are correct, i could not
force myself to read them.

why don't you try this:

(0) make sure your emacs is properly installed, in other words, with
    full source code (for each .elc file there should be a corresponding
    .el file in the same directory).

(1) evaluate the forms:
    (require 'cl)
    (dolist (dir load-path) (ignore-errors (dired dir)))

(2) in each" dired buffer, evaluate the form:
    (grep "egrep -nH -e '(call|start)-process' *.el")

by "evaluate the form", i mean type `M-:' and then the form and then
RET.  for step (2) you can recall previous forms into the minibuffer
by typing `M-p'.

further exploration is up to you.  have fun!

thi
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs



--
YuGang ------=_Part_925_17539654.1180511637618-- --===============0971040087== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0971040087==--