From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Floyd Davidson Newsgroups: gmane.emacs.help Subject: Re: Emacs-Lisp question about "shell-command" Date: Thu, 19 Feb 2004 07:01:01 -0900 Organization: __________ Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87ad3f12ki.fld@barrow.com> References: <6wsmh7l2z3.fsf@pino.iskp.uni-bonn.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1077207480 6578 80.91.224.253 (19 Feb 2004 16:18:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 Feb 2004 16:18:00 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 19 17:17:53 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Atqs5-0001Ss-00 for ; Thu, 19 Feb 2004 17:17:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Atqqw-0005U7-Kz for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Feb 2004 11:16:42 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!HSNX.atgi.net!falcon.america.net!eagle.america.net.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.0 Cancel-Lock: sha1:zFy9C8ahUWuhlyS33FtFSyvHMrc= Original-Lines: 57 Original-NNTP-Posting-Host: 209.124.156.246 Original-X-Trace: eagle.america.net 1077206503 209.124.156.246 (Thu, 19 Feb 2004 11:01:43 EST) Original-NNTP-Posting-Date: Thu, 19 Feb 2004 11:01:43 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:121048 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:16998 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16998 Kay Ulbrich wrote: >Hello! > >Under Linux (version information see end of message) I am using a >simple emacs-lisp function (the actual function is more complex, but >this question is just about "shell-command"): > >;; __________________________________________________ >(defun my-command () > (interactive) > (let (command) > (setq command ("some-shell-command-generating-output &")) > (shell-command command "buffername") > )) >;; __________________________________________________ > >When executing the function from an unsplit emacs-frame, the window is >split and the output of the shell is written into the newly appeared >window, which containins the buffer "buffername". This obviously is >the default behaviour of "shell-command". > >Is there an easy way to run the command without a new window >appearing, i.e., having the buffer created but not shown >automatically, so that my visible windows are not changed? I do not >want to open a new frame to run the function in. You can wrap the portion that changes the frame with save-window-excursion and possibily also with save-excursion. Using save-excursion will restore the cursor position in your current buffer, if you do anything that would move it, such as if the rest of your actual function collects some text generated in the new buffer and uses it to modify the original current buffer. Your code might look like this, (defun my-command () (interactive) (let (command) (setq command ("some-shell-command-generating-output &")) (save-window-excursion (save-excursion (shell-command command "buffername"))))) >Using (replace-buffer-in-windows "buffername") as the last command >in the function just did this, when I had the frame split into two >halves right away. > >Output of "M-x emacs-version": GNU Emacs 21.3.1 (i686-pc-linux-gnu, X >toolkit, Xaw3d scroll bars) of 2004-01-19 on HOSTNAME > >Thank you for advice! >Kay -- Floyd L. Davidson Ukpeagvik (Barrow, Alaska) floyd@barrow.com