terminal emacs run a subprocess in foreground - emacs

I am inside terminal emacs.
I'd like to run ranger in foreground.
However, the following code doesn't work:
(call-process "/usr/bin/ranger")
Note, I don't want emacs to simulate a pty (e.g., ansi-term) for ranger. I want the ranger run in my real pty, the one where my emacs resides in.

I'm not sure if what you want is possible. Normally you'd do M-x suspend-frame, which will drop you to the shell, run whatever program, and then fg to bring back Emacs. You might be able to do this with something like tmux or screen, but I'm not very familiar with them.

Related

How do programs like Emacs and Nano get user input while running in terminal without the user having to press enter?

Programs like Emacs and Nano can run in a terminal window and accept real time user input, how might I accomplish this myself? I am looking to use C++ but I can see this could require interfacing with the user's shell, in this case Bash. How can I take input (be it from the mouse or keyboard) from the terminal window without the user having to press enter?
My target platform is Mac OSX Version 10.13.5, but answers on how to do this on other platforms like Windows or Linux are also welcome.
These programs set the terminal to raw mode as opposed to cooked mode. Cooked mode is read a line at a time and is handled by the terminal driver, and raw mode is read a character at a time and is handled by the running program instead.
This Answer has more information.
This Repo is a simple project that implements this mode that you can learn from. man termios will also give you information about manipulating terminal modes.

running multiple "emacs -nw" in different terminals

When I'm coding I'm using multiple "emacs nowindow mode", each one oppened in different terminal. It is really annoying when you have the same file on multiple emacs. Is there a way to synchronize them on save? (to update the other instances of emacs?)
I know that the best solution is not to do this :), but it is hard to break old habbits :)
Cheers,
Stole
p.s I work on Linux systems
It sounds like the ultimate problem you want to solve is working with the common files across Emacs frames. Emacs allows multiple client frames for a single running instance of Emacs. Unless you have technical motivations for entirely isolated instances of Emacs (i.e. isolated global state) I would recommend using this feature. That way you entirely avoid issues arising from concurrent edits to files.
Start the Emacs server from the command line via:
$ emacs --daemon
Alternately you can start the server after emacs has started using M-x server-start.
Then you can create client frames as you need them. Instead of typing emacs -nw, use:
$ emacsclient -nw
Depending on how you work you may need to exit Emacs differently to preserve other clients. Use C-x 5 0 (delete-frame) to close a single client rather than C-x C-c (save-buffers-kill-terminal).
Start your emacs instance in background when your session starts and then use emacsclient -nw to open a new frame in each terminal session. It's not exactly what you're doing but it is the closest I can think of.

Emacs (Multi)Term vs Xterm vs Console & TMUX

I'm an Emacs user trying to learn a software tool that is best run from a terminal. The default set-up to get the most out of that tool is to use xterm for interaction and call Vim for editing. One could simply replace Vim with Emacs in this setup, but then one would spend most of the time working outside of Emacs in an Xterm.
I figured out there is (Multi)Term-mode in Emacs, but it is really hard to find out about its pros and cons. So I have the following questions:
[Without X11]: Why or when would anybody use Emacs (Mutli)Term instead of Console & TMUX (or GNU Screen)?
[With X11] How does Emacs (Multi)Term compare to Xterm?
Obviously speed is one criteria for comparison, but I'm sure there are other.
You'd use Emacs term over tmux/screen if you're more familiar with Emacs and already use it for many other things and/or if you spend more time in Emacs than in the terminal.
Emacs's Term is much less sophisticated and much less reliable than xterm. But it works within Emacs so if you live in Emacs, it might be a good option.
Note that you may also prefer to use Emacs's M-x shell functionality, which gives you a command line without giving you an actual terminal emulator. That means that the commands are edited in Emacs before being sent to the underlying command-line program, so all the usual Emacs editing can be used there (and the history manipulation as well as command completion is performed by Emacs as well, which can be great, or can be disappointing (e.g. if the completion needs info which Emacs does not have)).

Can I run clj file directly on emacs?

I'm using clojure-box on windows.
Because the Emacs is totally new thing for me, I got some trouble with using it.
Can I save the real code(without user>> and result, etc) from Emacs? it seems C-x C-s oversave many things..
how can I run the .clj script directly on Emacs? I'm from python so the way Idle running script is wonderful
(just press F5, then script is excuted, then continue the REPL with having variables, functions in the script)
Is there anyway to do thing easy like that?
yes! emacs has several ways to do this. check out the emacs starter kit
People tend not to save the REPL as a whole.It is more common to paste parts of it into a normal Clojure buffer and then hit control-c control-l to load the buffer into the REPL. This keeps the REPL in synk with the file/buffer and will also print any output your script generates.
there is much more to using emacs with Clojure than I can express in one answer though the emacs starter kit is, well, a good place to start.

How to give names to ssh buffers in emacs

When open an ssh shell through emacs, may keybindings are disabled so I can still use the remote shell bindings. Though, names like ssh, ssh<1>, ssh<2> are not very informative, and thus I'd like to change the title of these buffers.
How am I suposed to do so?
Use rename-buffer.
If you run ssh in (e)shell- or term-mode there are no hooks to do this automatically but you could advise the respective commands bound to RET.
I just discovered that the ssh buffer is in term mode. I middle clicked the term word in the status bar and there was help being displayed. By reading the help I discovered that in order to let the keypresses be intercepted by emacs instead of being directly sent to the terminal I would have to press C-x first. So I just executed C-x M-x rename-buffer and it worked fine.