[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs-Lisp question about "shell-command"

From: Floyd Davidson
Subject: Re: Emacs-Lisp question about "shell-command"
Date: Thu, 19 Feb 2004 07:01:01 -0900
User-agent: gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.0

Kay Ulbrich <address@hidden> wrote:
>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 ()
  (let (command)
    (setq command ("some-shell-command-generating-output &"))
        (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!

Floyd L. Davidson           <>
Ukpeagvik (Barrow, Alaska)                         address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]