unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: Corey Foote <coreyfoote@hotmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: sending commands to shell with emacs lisp
Date: Sun, 13 Sep 2009 07:45:08 +0200	[thread overview]
Message-ID: <20090913054508.GA9149@tomas> (raw)
In-Reply-To: <SNT122-W2785CAD39491BC7BE108A4DAE50@phx.gbl>

-----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	other threads:[~2009-09-13  5:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-13  5:15 sending commands to shell with emacs lisp Corey Foote
2009-09-13  5:45 ` tomas [this message]
2009-09-13  6:43   ` Corey Foote
2009-09-13 10:21     ` tomas
     [not found]   ` <mailman.6560.1252824219.2239.help-gnu-emacs@gnu.org>
2009-09-13 14:39     ` despen
2009-09-13  6:55 ` Thierry Volpiatto
     [not found] ` <mailman.6558.1252820105.2239.help-gnu-emacs@gnu.org>
2009-09-13  7:45   ` Bruno Barbier
     [not found] <mailman.6557.1252818947.2239.help-gnu-emacs@gnu.org>
2009-09-13  7:14 ` Helmut Eller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090913054508.GA9149@tomas \
    --to=tomas@tuxteam.de \
    --cc=coreyfoote@hotmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).