From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: stardiviner Newsgroups: gmane.emacs.help Subject: [SOLVED] Re: [QUESTION] How to use :filter in `make-process'? Date: Wed, 04 Mar 2020 00:18:26 +0800 Message-ID: <87lfoh76p9.fsf@gmail.com> References: <87r1y97u8v.fsf@gmail.com> <878skhyhok.fsf@fastmail.fm> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="82124"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.3.8; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 03 17:18:59 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9AG3-000LFa-GB for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 17:18:59 +0100 Original-Received: from localhost ([::1]:49636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9AG2-0004iL-Hf for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 11:18:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53959) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9AFj-0004fO-QS for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 11:18:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9AFi-0003wa-I1 for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 11:18:39 -0500 Original-Received: from [183.249.128.110] (port=13007 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j9AFi-0003vb-4y for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 11:18:38 -0500 Original-Received: by dark.localdomain (Postfix, from userid 1000) id E0F45241731; Wed, 4 Mar 2020 00:18:29 +0800 (CST) In-reply-to: <878skhyhok.fsf@fastmail.fm> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 183.249.128.110 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122521 Archived-At: =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Thanks Joost. After reading the Info manual (even though the Info manual is not very frie= ndly.) I have following source code example which works great. #+begin_src emacs-lisp (shell-command "touch /tmp/tail.log") (let ((proc (make-process :name "*tail log*" :command (list "tail" "-f" "/tmp/tail.log") :filter (lambda (proc output) (message "append log captured") (let ((p (get-process "*tail log*"))) (when (buffer-live-p (process-buffer p)) (with-current-buffer (process-buffer p) (let ((moving (=3D (point) (process-mark proc)= ))) (save-excursion ;; Insert the text, advancing the process = marker. (goto-char (process-mark proc)) (insert output) (set-marker (process-mark proc) (point))) (if moving (goto-char (process-mark proc))))= )))) :sentinel (lambda (proc event) (message "done!")) :buffer "*tail log*"))) (display-buffer "*tail log*")) #+end_src #+RESULTS[<2020-03-04 00:15:51> 9c0b6b462a594bd21b9d5579bd9a9254a3279e62]: : # Then execute following command to append content into the log file: #+begin_src sh for N in {0..10}; do echo $N >> /tmp/tail.log done #+end_src =2D --=20 [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5eg1IUHG51bWJjaGls ZEBnbWFpbC5jb20ACgkQG13xyVromsOaCgf+P+aEoz8powv4LhelGuypm71n2AVK Kmx4wNu967+Uz5pCSpKAhFhRp1ZLIOVypQ1lkpoJD/40kK/vr2GCdKAfX4XSUbqb aIasFL6xOZE+4V9fw7BJQAqz9T5deFv46scjXsAvaUAMquP8qAd1X6EMEx2PrQ9t u0NCqTNY4Emob1bkMtDUyfjCYZ1wno+c6mxrpyUTk0AiRLLKA/mqv7p5HdhYZQq5 vsr8Yeg/SwLPoZSQpvXorvhO3chlB1/JL7R65P+cvv+56uaEsWh/PzHRK2FCLzWA 6wI9nGsW05mKzddoNPdU2ZiNuPcwvXPFrHliRyNCR8tHtBvieKEBLqVyzA=3D=3D =3DPwf1 =2D----END PGP SIGNATURE-----