Skip to content

Emacs Configuration

Your instructors use Emacs so they recommend that you use Emacs. However, Emacs is not easy to pick up, but once you use it, you either love it or hate it. So it's your choice.

Read through this page before you start choosing emacs. If you don't find it to your taste, choose other IDE. If you see this as a challenge, go ahead.

Installing Emacs

The current version is Emacs 29.

Emacs has a built-in Tutorial. Try that to know how to use Emacs.

Notation for Emacs Keys

In the following steps, you may need to use some of the commands in Emacs that requires to press certain keys. Here is the notation.

  • C-key: CONTROL key and additional key key. For example, C-s means you press CONTROL key and s key in the keyboard.
  • M-key: ALT key and additional key key. For example, M-x means you press ALT key and x key in the keyboard.
  • RET: ENTER key.

Installing Major Modes

After you install Emacs, you can install Racket Major Mode for Emacs. We recommend Racket-Mode. To install racket-mode, follow the steps below. 1. Add the following to your ~/.emacs.d/init.el:

(require 'package)
(add-to-list 'package-archives
              '("melpa" . "https://melpa.org/packages/")
              t)
(package-initialize)

  1. Restart Emacs.
  2. Type M-x package-initialize RET.
  3. Type M-x package-refresh-contents RET.
  4. Type M-x package-install RET.

Installing Minor Mode

We recommend to install Paredit which is a minor mode in Emacs for pseudo-structurally edit programs in Lisp-like languages. It prevents you from accidentally unbalancing parantheses. To install Paredit, follow the steps below.

  1. Download paraedit.el and put it somewhere in your local computer. For example save it to /path/to/paredit.el.
  2. Add the following to your ~/.emacs.d/init.el.
    (add-to-list 'load-path "/path/to/elisp")
    (autoload 'enable-paredit-mode "paredit"
      "Turn on pseudo-structural editing of Lisp code."
      t)
    

Configuring

Edit your Emacs configuration file under ~/.emacs.d/init.el and add the following:

;; racket-mode
(add-to-list 'auto-mode-alist '("\\.rkt\\'" . racket-mode))
(setq racket-racket-program "/Applications/Racket v8.13/bin/racket")
(add-hook 'racket-mode-hook (lambda () (paredit-mode 1)))

  • The first line is to allow all .rkt files to use racket-mode.
  • The second line is to set the path to the racket program. Change the path to the executable location of racket in your system. In the above example, the path is /Applications/Racket v8.13/bin/racket (An example of MacOS path).
  • The last line is to add the minor mode to use paredit-mode.

Reference