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: Tue, 29 May 2007 18:19:59 +0800 Message-ID: <48378d570705290319u1bb080b6l53975dc25c8c8ca@mail.gmail.com> References: <878xb8kqje.fsf@ambire.localdomain> <48378d570705290208m5b13d036v3121d8e3679777e3@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0822551409==" X-Trace: sea.gmane.org 1180434040 11884 80.91.229.12 (29 May 2007 10:20:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 29 May 2007 10:20:40 +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 Tue May 29 12:20:38 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 1Hsyod-0005ba-C4 for geh-help-gnu-emacs@m.gmane.org; Tue, 29 May 2007 12:20:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hsyoc-0002jl-PE for geh-help-gnu-emacs@m.gmane.org; Tue, 29 May 2007 06:20:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HsyoC-0002Z2-0c for help-gnu-emacs@gnu.org; Tue, 29 May 2007 06:20:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HsyoA-0002X9-79 for help-gnu-emacs@gnu.org; Tue, 29 May 2007 06:20:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hsyo9-0002Wt-V3 for help-gnu-emacs@gnu.org; Tue, 29 May 2007 06:20:06 -0400 Original-Received: from wa-out-1112.google.com ([209.85.146.176]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hsyo9-0006ri-Cm for help-gnu-emacs@gnu.org; Tue, 29 May 2007 06:20:05 -0400 Original-Received: by wa-out-1112.google.com with SMTP id j4so861861wah for ; Tue, 29 May 2007 03:20:04 -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=Z2YqOKDJFPy1EH+Vr88dD8b+6Jmxz8YBZsyJ62NxIaeLlBc+VqGMQgY5y/mpDzGt7Sg+TAdEomKeZdsaTCo3c0f1oYIyqruzypbkV7x7oqaXYCAL6uGmwSA3ePNAkuXNn6klkG9+PFQ1WD1YZ4bPxIGgxq7GTaX92K9+PYeSld8= 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=E4A2oNfaxalusbqdakn2Mlh3khmLtYlMwAKDUZ6l3oLGtMkrxxG92oJGzqzb3xY6jN2rUCX7Uj5NsJ3sryZrVNwk44hBwXwxNLZ8Sdc4g+O3W32lBV+v2uhRxK4Oj+6UK2hgYUH+nGcxD1q3wCtrJHoBYZ328iyblQBTutCZiYs= Original-Received: by 10.115.111.1 with SMTP id o1mr3349511wam.1180434004237; Tue, 29 May 2007 03:20:04 -0700 (PDT) Original-Received: by 10.114.60.1 with HTTP; Tue, 29 May 2007 03:19:59 -0700 (PDT) In-Reply-To: <48378d570705290208m5b13d036v3121d8e3679777e3@mail.gmail.com> X-detected-kernel: Linux 2.6 (newer, 2) 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:44523 Archived-At: --===============0822551409== Content-Type: multipart/alternative; boundary="----=_Part_4436_23741584.1180433999188" ------=_Part_4436_23741584.1180433999188 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Surprisely, this time, after I add (switch-to-buffer d-buf) it works now!! thanks On 5/29/07, Yu,Gang wrote: > > Thanks! > > Yes, I add the statement , but result the same. So, I believe it's not the > problem of (buffer-string) > > ------------------------------- > (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 (eval `(call-process (car check-command) nil d-buf > t ,@(cdr check-command))))) > (switch-to-buffer d-buf) > (print `(,(buffer-modified-p) ,(buffer-size) ,(point-min) ,(point) > ,(point-max)) d-buf) > ;;(debug) > (if (not (string-match wanted (buffer-string))) > (progn > (print (concat "starting command " (stringlist-to-string > start-command " ")) d-buf) > (eval `(start-process "start up" d-buf (car start-command) ,@(cdr > start-command))) > ) > (print > (concat wanted " matched! no need to start " (stringlist-to-string > start-command " ")) d-buf) > )))) > > and aux function > > (defun stringlist-to-string (list connector) > "translate string list to string , cons using connector" > (let ((result "")) > (mapcar (lambda (string) > (setq result (concat result string connector)) > ) list) > (substring result 0 -1))) > > On 5/29/07, Thien-Thi Nguyen < ttn@gnuvola.org> wrote: > > > > () "Yu,Gang" < wuhanyugang@gmail.com> > > () Tue, 29 May 2007 14:12:46 +0800 > > > > How can I solve the problem? thanks > > > > determine the current buffer at the moment `(buffer-string)' is > > evaluated. if it is not as you expect, learn how to make it so. > > > > thi > > _______________________________________________ > > help-gnu-emacs mailing list > > help-gnu-emacs@gnu.org > > http://lists.gnu.org/mailman/listinfo/help-gnu-emacs > > > > > > -- > YuGang -- YuGang ------=_Part_4436_23741584.1180433999188 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Surprisely, this time, after I add

(switch-to-buffer d-buf)

it works now!!

thanks

On 5/29/07, Yu,Gang < wuhanyugang@gmail.com> wrote:
Thanks!

Yes, I add the statement , but result the same. So, I believe it's not the problem of (buffer-string)

-------------------------------
(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 (eval `(call-process (car check-command) nil d-buf t ,@(cdr check-command)))))
      (switch-to-buffer d-buf)
      (print `(,(buffer-modified-p) ,(buffer-size) ,(point-min) ,(point) ,(point-max)) d-buf)
      ;;(debug)
      (if (not (string-match wanted (buffer-string)))
      (progn
        (print (concat "starting command " (stringlist-to-string start-command " ")) d-buf)
        (eval `(start-process "start up" d-buf (car start-command) ,@(cdr start-command)))
        )
    (print
     (concat wanted " matched! no need to start " (stringlist-to-string start-command " ")) d-buf)
    ))))
 
and aux function

(defun stringlist-to-string (list connector)
  "translate string list to string , cons using connector"
  (let ((result ""))
    (mapcar (lambda (string)
          (setq result (concat result string connector))
          ) list)
    (substring result 0 -1)))


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

   How can I solve the problem? thanks

determine the current buffer at the moment `(buffer-string)' is
evaluated.  if it is not as you expect, learn how to make it so.

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



--
YuGang



--
YuGang ------=_Part_4436_23741584.1180433999188-- --===============0822551409== 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 --===============0822551409==--