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.
- For MacOS users, see Emacs for Mac OS X download page.
- For Linux users, most probably Emacs is already installed. See download page from GNU.
- For Windows users, download emacs-$VERSION-installer.exe.
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 additionalkeykey. For example,C-smeans you press CONTROL key andskey in the keyboard.M-key: ALT key and additionalkeykey. For example,M-xmeans you press ALT key andxkey 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)
- Restart Emacs.
- Type
M-xpackage-initializeRET. - Type
M-xpackage-refresh-contentsRET. - Type
M-xpackage-installRET.
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.
- Download paraedit.el and put it somewhere in your local computer. For example save it to
/path/to/paredit.el. - Add the following to your
~/.emacs.d/init.el.
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
.rktfiles to useracket-mode. - The second line is to set the path to the
racketprogram. Change the path to the executable location ofracketin 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.