Hardware Reference
In-Depth Information
Running commands from Emacs
If you are currently looking at the dired buffer in Emacs, then Emacs is aware that you
are on a remote machine. Certain commands are TRAMP-aware and will execute re-
motely. For example, M-! will execute a shell command. When used over TRAMP, it will
execute the shell command remotely. Try using M-! with touch test.txt . Now press
g to refresh dired . You should now see test.txt . If you edit this file by navigating to
it in dired and then pressing Enter , you will now be editing the file remotely. Technic-
ally, you are editing a local copy of this buffer but when you save it with C-x C-s , it will
send the changes over to the BBB.
There is a benefit to this system. If the SSH connection drops, for whatever reason, the
buffer is still in RAM on your local machine. Once the connection is restored, Emacs will
save the buffer. Emacs acts as a session manager for your remote connections and will
transparently reconnect when needed.
If you open a C file in Emacs, Emacs will apply C-aware syntax highlighting, but it can
also compile and debug over TRAMP. To compile, invoke M-x , type compile , and sup-
ply the compile command. If there is a makefile, then make should suffice; otherwise,
provide the full gcc compilation string. The benefit of using the compile function is that
Emacs will be aware of compilation errors and you can jump to each one with C-x `.
Lastly, if you install gdb on BBB, you debug with gdb from your host computer. Assum-
ing that you compiled your program with debug symbols, if you are looking at the source
file in the current buffer, you can press M-x , and then type gdb .
You'll have to provide the gdb command, which is something such as gdb nameofex-
ec -i=mi . Emacs will remotely launch gdb and open an interactive session. If you set
breakpoints, Emacs will switch over to the code buffer and show you where the instruc-
tion pointer has stopped in the code.
Lastly, you can run a shell inside Emacs on the remote system as well. If you are in a
TRAMP-aware buffer, pressing M-x and then typing shell will open a remote shell. You
can perform all your development actions while never leaving Emacs. Emacs can also act
as your mail reader, calculator, IRC client, and even play Tetris (by pressing M-x , and then
typing Tetris ). Emacs is a cross platform editor, so if you learn how to use Emacs once,
you can use it as your development environment on any machine.
Search WWH ::




Custom Search