help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: sending commands to shell with emacs lisp


From: tomas
Subject: Re: sending commands to shell with emacs lisp
Date: Sun, 13 Sep 2009 07:45:08 +0200
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Sep 13, 2009 at 01:15:38AM -0400, Corey Foote wrote:
> 
> 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"))
> 
> 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!

I think what you are looking for is "call-process" and "start-process".

Evaluating

  (call-process "ls" nil t t "-l")

for example, you get the current directory listing in long form inserted
at point into the current buffer.

(call-process waits for the process to terminate, while start-process
just lets the process run while Emacs goes on with its other tasks).

There are so many options and variants that I'll stop here and refer you
to the documentation -- but do ask here if you get stuck.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFKrIbkBcgs9XrR2kYRAvHvAJ4iqHDOcRWoJz+861efBHlUMn9qBACfRUgI
pjtfndJKqUQ6W7HTCkmtGgg=
=V2HY
-----END PGP SIGNATURE-----




reply via email to

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