User Tools

Site Tools


ease:fallschool_cpo

This is an old revision of the document!


Emacs in the CRAM environment

Using Emacs with CRAM is not all too different from using Emacs in any other LISP programming context. Here are some basic techniques to make your life easier when working with it.

Definitions

An Emacs buffer is the equivalent of window / tab in other editors. It can have a file associated with it that you can (or cannot depending on the privileges) edit, or it can be running a process (e.g. when you open the shell: M-x shell). The minibuffer is usually a one-line part of the screen at the bottom of the Emacs window.

The cursor in Emacs is called the point. Dired is the directory explorer mode of Emacs. When in the following we talk about “closing” a buffer it's not generally meant as really clsoing it, but only the window for it. The buffer is then still active in the background and can be switched to. To really close a buffer you need to “kill” it.

Key Bindings

Textual representation of Emacs key bindings has a number of conventions:

Short way of writing Ctrl, Alt and Shift is: C, M and S respectively.
RET stands for the Enter or Return key
If a key is supposed to be pressed together with another key, they're connected with a dash, e.g. C-h
C-h b means first press Ctrl and h together and then b separately (in contrast to C-h C-b)
Commands like M-x shell mean: press Alt and x together and then type shell into the minibuffer on the bottom of the screen.

Now some of the most important commands:

Going back in history (when in the REPL buffer):

  • C-Up: Step through previously executed commands in the REPL buffer
  • C-Down: Step back forward thorugh the previously executed commands
  • M-R: regex-search in the previously executed commands (can step through with C-Up and C-Down)

Handling multiple buffers:

  • C-x 2: Splits the currently selected buffer horizontally
  • C-x 3: Splits the currently selected buffer vertically
  • C-x 0: Closes the currently selected buffer (the other buffer in the split is scaled back to it's full size)
  • C-x 1: Close any buffer other than the currently selected

Opening files, switching and killing buffers:

  • C-x f: Open a new buffer with the contents of a file (specified by its path)
  • C-x b: Change the buffer of the current frame (specified by its name, in most cases that's the filename)
  • C-x k: Kill the currently active buffer. (Emacs will ask you if you want to save any changes beforehand.)

Note: When changing buffers, you can use C-Up and C-Down to step through the currently open buffers.

Lisp/(Slime)-specific (while in a .lisp-file-buffer):

  • M-. (M-,): Jump in (out) of function definition
  • C-c M-p: set the package from the selected lisp file as the package in the REPL
  • C-c C-c: Compile the code block at the point (usually a function)
  • C-c C-k: Compile the whole file (Emacs will ask you to save if there are unsaved changes)

In REPL:

  • C-RET: close all unmatched parenthesis and evaluate
  • C-c C-c: interrupt evaluation
  • M-r (M-s): Regexp search backwards (forward) through history
  • , : Opens mini-buffer to use shortcuts (see ,help), one important example is ,ros-load-system to load ROS package LISP systems.

General Tips

When starting out with using Emacs, it can be useful to have a fixed window configuration to not get overwhelmed with having to constantly open and close new buffer windows. When opening Emacs, use the C-x 2 command to split the window in two and just leave the bottom one as the REPL and use the top one for viewing files (C-x f and C-x b).

Further Reading

There is a much more in-depth overview of Emacs (and everything else surrounding CRAM) here: http://cram-system.org/doc/ide

For an example of how to setup the Emacs initilization file with very useful extensions and such, take a look at: http://cram-system.org/doc/emacs-config

ease/fallschool_cpo.1593433968.txt.gz · Last modified: 2020/06/29 12:32 by cpollok

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki