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: Helmut Eller
Subject: Re: sending commands to shell with emacs lisp
Date: Sun, 13 Sep 2009 09:14:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

* Corey Foote [2009-09-13 07:15+0200] 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"))
>
> 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!

comint-send-input sends the region (and a newline) to the subprocess.
So:

(defun exec-command ()
  (interactive)
  (set-buffer (get-buffer "*shell*"))
  (insert "hello world")
  (comint-send-input))

should work.

Helmut


reply via email to

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