Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

read user input in compilation buffer

11 views
Skip to first unread message

hemant

unread,
Dec 19, 2012, 11:47:41 AM12/19/12
to help-gn...@gnu.org
Hello Folks,

I often run my tests (RSpec if you will) from Emacs using a customized version of compile command. It works beautifully and all that.

But sometimes some special line in my code triggers something that reads from user input. If you have heard of this Ruby gem Pry. When I run the tests from Emacs and code being run contains binding.pry() it opens pry prompt at the point, the method is encountered.

Now I understand that, there are some emacs-pry integrations out there, but I want something simple, something that will simply let me type things in the buffer when user input is required, in compile buffer.

Is it possible at all?



--
Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals.

http://gnufied.org
http://twitter.com/gnufied

William Gardella

unread,
Dec 19, 2012, 12:27:46 PM12/19/12
to
Hi,

hemant <geth...@gmail.com> writes:

> Hello Folks,
>
> I often run my tests (RSpec if you will) from Emacs using a
> customized version of compile command. It works beautifully and all
> that.
>
> But sometimes some special line in my code triggers something that
> reads from user input. If you have heard of this Ruby gem Pry. When I
> run the tests from Emacs and code being run contains binding.pry() it
> opens pry prompt at the point, the method is encountered.
>
> Now I understand that, there are some emacs-pry integrations out
> there, but I want something simple, something that will simply let me
> type things in the buffer when user input is required, in compile
> buffer.
>
> Is it possible at all?

A lazy way would be to consider using async-shell-command instead of
compilation-mode. `async-shell-command' does prompt for user input via
the minibuffer if it detects that the command is waiting for user
input. Generally works well, and you can even get nice colorized output
if `ansi-color-for-comint-mode' is non-nil.

--
WGG
I use grml (http://grml.org/)

Stefan Monnier

unread,
Dec 19, 2012, 2:16:07 PM12/19/12
to help-gn...@gnu.org
> Now I understand that, there are some emacs-pry integrations out there, but
> I want something simple, something that will simply let me type things in
> the buffer when user input is required, in compile buffer.

You can ask compile to run the process in a comint buffer.
And you can also write a little function that lets you send text to
the process. Such as:

(defun my-send-string-to-process (string)
(interactive (list (read-string "Input: ")))
(process-send-string (get-buffer-process) (concat string "\n")))

If such user-input is only needed occasionally, it may be simpler to M-x
my-send-string-to-process RET then to configure your compilation command to
always use comint.


Stefan


Peter Dyballa

unread,
Dec 19, 2012, 4:10:30 PM12/19/12
to Stefan Monnier, hemant, help-gn...@gnu.org

Am 19.12.2012 um 20:16 schrieb Stefan Monnier:

> You can ask compile to run the process in a comint buffer.
> And you can also write a little function that lets you send text to
> the process.

I'm just using send-invisible… (which is OK for short strings while larger ones could be inserted from registers in which these "texts" were saved before)

--
Greetings

Pete

I consider religion godesque.



hemant

unread,
Dec 20, 2012, 12:04:07 AM12/20/12
to Stefan Monnier, help-gn...@gnu.org
Hi,

On Thu, Dec 20, 2012 at 12:46 AM, Stefan Monnier <mon...@iro.umontreal.ca> wrote:
> Now I understand that, there are some emacs-pry integrations out there, but
> I want something simple, something that will simply let me type things in
> the buffer when user input is required, in compile buffer.

You can ask compile to run the process in a comint buffer.

That did the trick. Thanks. 


0 new messages