From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: Redirecting the output of a commend in "shell" into a buffer Date: Sat, 06 Sep 2014 00:02:40 +0100 Message-ID: <87fvg58ycv.fsf@robertthorpeconsulting.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1409958199 772 80.91.229.3 (5 Sep 2014 23:03:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Sep 2014 23:03:19 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: C K Kashyap Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 06 01:03:12 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XQ2X9-00022a-QY for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Sep 2014 01:03:11 +0200 Original-Received: from localhost ([::1]:60514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQ2X9-0000xq-2q for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Sep 2014 19:03:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQ2Wq-0000xe-D4 for help-gnu-emacs@gnu.org; Fri, 05 Sep 2014 19:03:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQ2Wi-0001Ez-69 for help-gnu-emacs@gnu.org; Fri, 05 Sep 2014 19:02:52 -0400 Original-Received: from outbound-smtp04.blacknight.com ([81.17.249.35]:33908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQ2Wi-0001Du-0S for help-gnu-emacs@gnu.org; Fri, 05 Sep 2014 19:02:44 -0400 Original-Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp04.blacknight.com (Postfix) with ESMTP id 1B32D985B3 for ; Fri, 5 Sep 2014 23:01:21 +0000 (UTC) Original-Received: (qmail 16128 invoked from network); 5 Sep 2014 23:02:42 -0000 Original-Received: from unknown (HELO RTLaptop) (rt@robertthorpeconsulting.com@[109.76.87.95]) by 81.17.254.9 with ESMTPSA (DHE-RSA-AES128-SHA encrypted, authenticated); 5 Sep 2014 23:02:41 -0000 In-Reply-To: (message from C K Kashyap on Wed, 3 Sep 2014 14:10:58 +0530) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 81.17.249.35 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99665 Archived-At: C K Kashyap writes: > Hi, > While using shell, is it possible to redirect output of commands into a > buffer? > Ofcourse, the shell buffer itself is editable and all but it would be nice > if I could directly pipe the output of a command into a new buffer. Emanuel gave one solution, here's another. There's a hook called "comint-filter-functions" and a command called "comint-send-input". Together these control what gets sent to the external process in things like shell buffers. You could modify these or advice them. Or you could rebind RET. For example, suppose you create a new "pseudo-command" called "buf". You write: "buf ls RET" in the shell buffer. Your function finds the "buf" at the beginning of the command string. It then cuts out the rest and sends it to shell-command which puts it in a separate buffer. If it doesn't find "buf" at the start then it calls comint-send-input as usual. I've thought about doing this myself but I've never got around to it. BR, Robert Thorpe