all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Yu,Gang" <wuhanyugang@gmail.com>
To: "Thien-Thi Nguyen" <ttn@gnuvola.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: process communication help
Date: Tue, 29 May 2007 19:57:42 +0800	[thread overview]
Message-ID: <48378d570705290457x68c645fegf56dd1f48558b5e9@mail.gmail.com> (raw)
In-Reply-To: <871wh0kjzg.fsf@ambire.localdomain>


[-- Attachment #1.1: Type: text/plain, Size: 2071 bytes --]

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

thanks

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

(defmacro syn-call (input buffer display command)
   "synchorous process call macro, using call-process"
   `(call-process ,(eval `(car ,command)) ,input ,buffer ,display  ,@(eval
`(cdr ,command))))

(defmacro asyn-call (process-name buff command)
  "aynchorous process call macro, using start process"
  `(start-process ,process-name ,buff ,(eval `(car ,command)) ,@(eval `(cdr
,command))))

(defun startup (check-command wanted start-command)
  "check whether the 'wanted' state satisfied, if not, launch the
start-command"
  (interactive)
  (save-excursion
    (let* ((d-buf (get-buffer-create "diagnose"))
            (process-connection-type nil)
            (process-status (syn-call nil d-buf t check-command)))
      (switch-to-buffer d-buf)
      (if (not (string-match wanted (buffer-string)))
          (progn
             (print (concat "starting command " (stringlist-to-string
start-command " ")) d-buf)
             (asyn-call "start up" d-buf start-command))
        (print
          (concat wanted " matched! no need to start " (stringlist-to-string
start-command " ")) d-buf)
    ))))



On 5/29/07, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
>
> () "Yu,Gang" <wuhanyugang@gmail.com>
> () Tue, 29 May 2007 17:08:27 +0800
>
>    Yes, I add the statement , but result the same. So,
>    I believe it's not the problem of (buffer-string)
>
> the problem is in your understanding of `buffer-string'.
> you need to fix that first.  try using `current-buffer' to
> test your assumptions.  btw, unrelated comment: the form:
>
>   (eval `(func ,(car foo) ... ,@(cdr foo)))
>
> can be replaced by:
>
>   (apply 'func (car foo) ... (cdr foo))
>
> the latter is much more idiomatic and easier for people
> like me (who wish to help you) to read.
>
> thi
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>



-- 
YuGang

[-- Attachment #1.2: Type: text/html, Size: 3264 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

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

  reply	other threads:[~2007-05-29 11:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1377.1180419176.32220.help-gnu-emacs@gnu.org>
2007-05-29  8:00 ` process communication help Thien-Thi Nguyen
2007-05-29  9:08   ` Yu,Gang
2007-05-29 10:19     ` Yu,Gang
     [not found]   ` <mailman.1381.1180429716.32220.help-gnu-emacs@gnu.org>
2007-05-29 10:22     ` Thien-Thi Nguyen
2007-05-29 11:57       ` Yu,Gang [this message]
     [not found]       ` <mailman.1388.1180439874.32220.help-gnu-emacs@gnu.org>
2007-05-29 15:08         ` Thien-Thi Nguyen
2007-05-30  7:53           ` Yu,Gang
2007-05-29  6:12 Yu,Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48378d570705290457x68c645fegf56dd1f48558b5e9@mail.gmail.com \
    --to=wuhanyugang@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=ttn@gnuvola.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.