[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sending commands to shell with emacs lisp
From: |
Thierry Volpiatto |
Subject: |
Re: sending commands to shell with emacs lisp |
Date: |
Sun, 13 Sep 2009 08:55:50 +0200 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) |
Hi,
Corey Foote <coreyfoote@hotmail.com> writes:
> I'm trying to send commands to a shell buffer. I'm able to send the command
> "hello world" by calling this:
>
> (defun exec-command ()
> (interactive)
> (set-buffer (get-buffer "*shell*"))
> (insert "hello world"))
You probably want:
,----
| (with-current-buffer "*shell*"
| (goto-char (point-max))
| (insert "echo hello world"))
`----
Or
,----
| (switch-to-buffer "*shell*"
| (goto-char (point-max))
| (insert "echo hello world"))
`----
All that assume shell is started.
If not just run the shell you want from your function before inserting.
If you want a complete mode to send commands to a shell (even an xterm)
from emacs, have a look at eev-mode.
http://www.emacswiki.org/cgi-bin/wiki/EevMode
> But I can't figure out how to send over the "enter key" to actually make it
> execute the shell command. I'm an emacs lisp newbie!
If you use eshell as shell, the command is `eshell-send-input', but i
think it's better to use enter to be sure you really want to send the
command inserted.
But maybe what you only need is instead of all that is:
(shell-command "echo hello world")
Put point at end of this expression and hit C-x C-e.
> Thanks everybody!
>
> - Corey
>
> _________________________________________________________________
> Hotmail: Free, trusted and rich email service.
> http://clk.atdmt.com/GBL/go/171222984/direct/01/
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France