There's a way to launch a process(continuously) in emacs?
For example, imagine ruby REPL, I expect launch the command "irb" in emacs and it should be in some some kinda of separated tab or buffer.
For the specific case of REPLs in Spacemacs you can start one for any supported language with SPC m s i then explore SPC m s prefix command for all the commands to interact with the REPL.
M-x shell
irb
This will cover simple use cases. To get previous commands, type M-p and M-n instead of up and down.
You can get a fancier version from #legoscia's link.
Can also do M-! to execute a single shell command and output to a new buffer.
Related
It's nice to run M-x man foo for command foo within Emacs. It's then possible to navigate easily within the man page and to find details quickly.
When the help of a command (such as git) produces limited output, one can just use a terminal instead of emacs.
But occasionally, a command (such as aws help—run in a terminal) produces extensive output. Yet the output is not compatible with the emacs Man mode. An option is to use M-x shell within emacs, but that will not display the page at once. It will report "WARNING: terminal is not fully functional" and require pressing a key endlessly until the complete help appears, or, for Emacs 25, "Could not find executable named 'groff'".
What is a good way to read long manual pages produced by commands within emacs?
I just ran into this exact problem a few days ago.
Type escape + ! then type (for example) “aws ec2 help”. This brings the help text into a new buffer called Shell Command Output, with all of the control-h characters, etc.
Switch to the new buffer with control-x then lowercase ‘o’ (for other buffer)
Type escape + lowercase ‘x’ to run an emacs function, then type ‘man’ and hit Enter. It will prompt for man page entry and default to EC2, just hit Enter. In my case, it displays an error in the status line, “error in process sentinel: Can’t find the EC2 manpage”.
However, the “man page” functions are now available, so now (in that buffer)you can type escape + x and run the function Man-fontify-manpage. The page should now look like a nice man page with bold, etc.
You can then rename the buffer (escape + x then something like ec2) so the buffer isn’t replaced if you run another shell command.
I you just want the output in a buffer, you can simply use:
M-! aws help RET
If you want the output in a shell buffer, you can do git help commit | cat (so no more "terminal is not fully functional").
Probably you can do M-! aws help | cat RET also. I do not have aws, but hopefully the piping will remove the escape characters if aws output formatting is done right. You should try also TERM=dumb aws help. Any command should know better than using fancy output when TERM is set to dumb. If aws is dumb that way itself, you could pipe its output to something that filters out control characters -- try this
For forcing man mode in an arbitrary buffer, M-x Man-mode (yes, uppercase). I am not sure if that will play nice with aws's output.
By the way, for git I suppose you know you can do man git-commit (or man git-any_git_command, in general), so you have a nice alternative to git help when using emacs (output of help and man page is the same).
I have a Python program which uses rlcompleter to provide custom Tab-completion. The completion works when it is run under a bash terminal. However, it does not work under emacs, in shell mode, nor in eshell mode.
I noticed that Tab is really bound to completion-at-point, eshell-pcomplete, and so on, so I tried an (insert "\t"), supposing that this would trigger the completion, which I understand happens when the child process reads a "\t" character. But this does not work either. Perhaps input is buffered until a "RET"?
Completion for commands like service, which define their own candidates, does not work as expected either.
How can I access these candidates within Emacs?
Try using M-x ansi-term. I find it behaves a bit more like what I have come to expect from a *nix terminal.
Every time I start the interpreter for a programming language (lets consider python in this case) emacs opens the interpreter in the window which is not current. Note that I have two windows open, so the interpreter is always opening in the opposite window that I am currently in. This is annoying because then I always have to switch windows after I open an interpreter...
How can I get the python interpreter to open in the current window inside emacs?
Can I solve this problem generally for other programs/shells/buffers that do not open in the current window?
I note that this also happens frequently with other emacs commands (such as C-h v and the description of the variable opens in the window that is not current)
All help is greatly appreciated!
Interpreter-buffers connect with a process. If not already there, it must be a different one than the buffer called from - otherwise the current buffers contents is lost.
You might be interested in org-mode, org-babel, which provides a way to insert results in current buffer when executing source-code.
With python-mode.el, set py-switch-buffers-on-execute-p to non-nil. After M-x py-shell, cursor is in new shell.
If py-split-windows-on-execute-p is nil, M-x py-shell should switch to Python shell without splitting the window. See more options if re-using an existing py-shell etc.
With python.el, M-x run-python switches into the Python-shell.
See also customizable variable pop-up-windows.
I learn to use emacs. When I enter M-x shell , I enter the shell mode, but I don't know how to exit shell mode. I want to be back to fundamental mode to continue to my editing work. I search this question Emacs switching out of terminal, but when I press C-c o , the input will be treated as a command, so how to exit ?
The shell will be running in a buffer. You can switch back to the buffer where you were doing your work using C-x b.
You can try shell-toggle.el for quick jump back and forth between your current buffer and a shell buffer.
You can also try my hacked version of shell-toggle, which let you open a shell in the path of your current buffer (file). See the following link:
http://zhangda.wordpress.com/2009/04/08/my-hack-on-shell-toggle/
I have some processes that run from functions, i.e.:
M-x run-proc1
M-x run-proc2
I would like to know what command to issue from the command line to run emacs with run-proc1 running in the upper window and run-proc2 running in the lower window.
Thanks!
You might get better answers later, but appending this to your ~/.emacs.d/init.el might work.
(split-window-vertically)
(run-proc1)
(other-window)
(run-proc2)
(other-window)
Alternatively (for another approach), see this link.