开发者

Interactive compilation mode in emacs ? (what if compiler asks a question)

I am looking for either a hack to regular compilation mode, or suggestion on how to create new mode. What i want to achieve, is to 'compile' my code - but the compilator sometimes asks certain questions on the terminal (yes/no, etc etc). Afaik, regular compilation mode can't direct my keyboard input and feed the subprocess with it. Is that possible ?

开发者_运维百科

Thanks


C-u M-x compile RET is all you need.

This is, in fact, documented: typing C-h f compile RET shows

Additionally, with universal prefix arg, compilation buffer will be in comint mode, i.e. interactive.


If you know all of the answers in advance, you might be able to get away with something as easy as:

(setq compile-command "(echo yes; echo no; echo yes) | (old compile command)")


I have switched from using the compile mode to using an async shell command. Here's the lisp:

(defun run-it () "Run it on the current file." (interactive) (save-buffer) (shell-command (format "my_command %s &" (shell-quote-argument (buffer-name))))) (global-set-key "\C-ct" 'run-it)

It saves the buffer first. The & makes it actually interactive so I can enter text in the buffer and the command will get that input. An added benefit is that it colors the command output on the fly, which my compile buffer was not doing.


It seems the only way to achieve what i want, is to use comint package. I'm going to override regular compile mode, to determine (upon file type) whether compiler will or won't ask any questions - if not, use regular compile, otherwise use my custom comint-integrated buffer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜