From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TheFlyingDutchman Newsgroups: gmane.emacs.help Subject: Re: Enter Date: Tue, 4 Nov 2008 11:22:05 -0800 (PST) Organization: http://groups.google.com Message-ID: <8a30f5a5-b82d-4a79-b4ba-d8e5e23130a3@u29g2000pro.googlegroups.com> References: <87iqr34xl6.fsf@kobe.laptop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1225828144 30159 80.91.229.12 (4 Nov 2008 19:49:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Nov 2008 19:49:04 +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 Nov 04 20:50:07 2008 connect(): Connection refused 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 1KxRug-00036T-E8 for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Nov 2008 20:50:07 +0100 Original-Received: from localhost ([127.0.0.1]:41332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KxRtY-0003sS-JQ for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Nov 2008 14:48:56 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!u29g2000pro.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: 192.91.147.34 Original-X-Trace: posting.google.com 1225826525 779 127.0.0.1 (4 Nov 2008 19:22:05 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 4 Nov 2008 19:22:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u29g2000pro.googlegroups.com; posting-host=192.91.147.34; posting-account=9bWHAAoAAAAxSFC_2O_ssTETNW9NhMbW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164108 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:59444 Archived-At: On Nov 4, 2:03=A0am, Giorgos Keramidas wrote: > On Tue, 4 Nov 2008 00:46:11 -0800 (PST), TheFlyingDutchman wrote: > > I want to start a shell buffer and then run a command via an Emacs > > Lisp function. If I do this: > > > (shell) > > (insert "ls\n") > > You don't need the extra "\n" at the end of the command, but you may > find the function `comint-send-input' useful. > > =A0 =A0 (shell) > =A0 =A0 (insert "ls") > =A0 =A0 (comint-send-input) > > If you don't really need the command to support interactive input, you > can also call `shell-command' with the full command string: > > =A0 =A0 (shell-command "ls") > > With an optional second argument, you can send the output to a specific > buffer, i.e.: > > =A0 =A0 (with-temp-buffer > =A0 =A0 =A0 (shell-command "ls" (current-buffer)) > > =A0 =A0 =A0 ;; More stuff that processes parts of (current-buffer). > =A0 =A0 =A0 ...) Thanks Giorgos. shell-command is probably what I should be using in most cases instead of shell. Didn't know about with-temp-buffer either.