From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: andrea crotti Newsgroups: gmane.emacs.help Subject: Real time output Date: Tue, 15 Feb 2011 15:28:11 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0ce0424a602863049c52f92c X-Trace: dough.gmane.org 1297780143 21993 80.91.229.12 (15 Feb 2011 14:29:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 15 Feb 2011 14:29:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 15 15:28:58 2011 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.69) (envelope-from ) id 1PpLtf-0003dv-W2 for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Feb 2011 15:28:58 +0100 Original-Received: from localhost ([127.0.0.1]:44772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpLtW-0002XI-6X for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Feb 2011 09:28:46 -0500 Original-Received: from [140.186.70.92] (port=41368 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpLt7-0002Vp-D0 for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 09:28:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpLt0-0006tv-4c for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 09:28:14 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:52230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpLsz-0006ta-Sa for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 09:28:14 -0500 Original-Received: by wyj26 with SMTP id 26so224380wyj.0 for ; Tue, 15 Feb 2011 06:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=F7vDXZ8y4JTGIVDoo7fwF2KFC6qQlNiDfCg/dPD8m1I=; b=yDddXhMSoM8LpmjWs0G+Od9FIfkVYZLh5k4lwGB1ny/Bw0qaP04Ke4EKFeg6E2A+CH KHrnINPS9wIli3N8s7t9VjoA0EDuP9yMLVmo33H+b9QrSGxGpDl7BU5atl5kFzRZHcto wTRWf5YE9uDQ+9uNj+OGBCRMDmHVyZhZhiMUY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=fNW6kj15c0cqu5KThkru09lgHnCdJcao7sIYH+EbFhv9RoP83VKn92ckcMXxmNVakO 7xBaO8bf021M5CXo62c5/Swiv5qVIdU1fayPGOf44dsAYooByPGV7jDTdU08+iCTbEHT ztEln++qc+5ld3y7lgrlmXdcAZeWAQYLua3tU= Original-Received: by 10.216.65.16 with SMTP id e16mr4296699wed.73.1297780091919; Tue, 15 Feb 2011 06:28:11 -0800 (PST) Original-Received: by 10.216.164.83 with HTTP; Tue, 15 Feb 2011 06:28:11 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.169 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:79125 Archived-At: --000e0ce0424a602863049c52f92c Content-Type: text/plain; charset=ISO-8859-1 How would that be possible to implement a function which calls a shell command and shows its output in real-time? I tried a few things but didn't succeed yet, I thought about something as below. Where I switch to the buffer and activate auto-revert-mode, but apparently it doesn't work... --8<---------------cut here---------------start------------->8--- (defun pad-show-results () "shows the results of the execution" (interactive) ;; takes a symbol and a number corresponding the conf to analyze (let ((cmd (read-from-minibuffer "command to run: " "cd $PAD_DIR && ./run_sim.py")) (output-buffer "*pad-results*")) (if (buffer-live-p (get-buffer output-buffer)) (kill-buffer (get-buffer output-buffer))) ;; maybe can popup always on the same external frame instead (switch-to-buffer output-buffer) (message (concat "running " cmd)) (auto-revert-mode t) (shell-command cmd output-buffer) (compilation-mode))) --8<---------------cut here---------------end--------------->8--- Thanks, Andrea --000e0ce0424a602863049c52f92c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable How would that be possible to implement a function which calls a shell comm= and and shows its output
in real-time?

I tried a few things but d= idn't succeed yet, I thought about something as below.
Where I switc= h to the buffer and activate auto-revert-mode, but apparently it doesn'= t work...

--8<---------------cut here---------------start------------->8---=
(defun pad-show-results ()
=A0 "shows the results of the execut= ion"
=A0 (interactive)
=A0 ;; takes a symbol and a number corres= ponding the conf to analyze
=A0 (let
=A0=A0=A0=A0=A0 ((cmd (read-from-minibuffer "command to ru= n: " "cd $PAD_DIR && ./run_sim.py"))
=A0=A0=A0=A0= =A0=A0 (output-buffer "*pad-results*"))

=A0=A0=A0 (if (buf= fer-live-p (get-buffer output-buffer))
=A0=A0=A0=A0=A0=A0=A0 (kill-buffer (get-buffer output-buffer)))
=A0=A0= =A0 ;; maybe can popup always on the same external frame instead
=A0=A0= =A0 (switch-to-buffer output-buffer)
=A0=A0=A0 (message (concat "ru= nning " cmd))
=A0=A0=A0 (auto-revert-mode t)
=A0=A0=A0 (shell-command cmd output-buffer)
=A0=A0=A0 (compilation-mode)= ))
--8<---------------cut here---------------end--------------->8-= --


Thanks,
Andrea
--000e0ce0424a602863049c52f92c--