Getting Started with Emacs and Scheme on Windows

Getting Started with Emacs and Scheme on Windows

Saketh Bhamidipati

Contents

1  Who is this article for?
2  What is Emacs?
3  What is Scheme?
4  Getting Emacs
5  Setting up Emacs
6  A Basic Introduction to Emacs and Files
7  Your .emacs file
8  Getting Scheme
9  Beginning Scheme

1  Who is this article for?

This article is for people who are: Don't expect this article to answer all of your questions - you will face problems, and you will learn how to solve them.

2  What is Emacs?

According to the Emacs manual:
Emacs is the extensible, customizable, self-documenting real-time display editor.

If this confuses you, don't worry. Basically, Emacs is a better version of Notepad. They are both text editors, as opposed to word processors such as Microsoft Word. Text editors are good for writing programs, and word processors are good for writing reports and books. However, emacs (which shall remain uncapitalized hereafter) is an application that fits both definitions. It has capabilities of both text editors and word processors. Emacs was written in 1976 by Richard Stallman, Guy Steele, and Dave Moon. It possesses features including, but not limited to:

Emacs is highly customizable - everyone has their own preferences as to how to run it. All the customization is kept in a little `.emacs' file, but that's for later. Emacs is released under the GNU license, which is a license that promotes the freedom of software, and not the oppressive regime of Microsoft.

3  What is Scheme?

Scheme is a programming language that is related to Lisp. Lisp is an ancient programming language (in computer science terms) - it dates back to 1958! It is often used as an introductory programming language, as is Python (http://python.org). However, Scheme promotes certain coding paradigms that are very important to the beginner. Although Scheme code may look like nonsense to the untrained eye, the simplicity becomes apparent after a short period of time.

4  Getting Emacs

It's time to get our hands wet (figuratively, of course). Head over to the emacs download center for Windows (http://ftp.gnu.org/pub/gnu/emacs/windows/). Download the one called emacs-21.3-fullbin-i386.tar.gz, or whichever one is closest to 18.3 megabytes. After you've downloaded it, unzip it (You can use WinRAR http://www.rarlab.com/download.htm for this process). Figure out how to run it. If you can't figure it out, then you're not ready for the rest of this article.

5  Setting up Emacs

Assuming you got emacs to run, you should have a window. Looks confusing, doesn't it? It's simple enough, though. Commands in emacs are just like commands in Microsoft Word - Ctrl - Whatever. However, emacs users list commands differently. Instead of typing Ctrl - Whatever, they type C-Whatever. Not so different. And they also type Meta-x instead of Alt-x. Meta-x can also be written as M-x. So let's compare the `Save' command:

Microsoft Word - Ctrl-S
Emacs - C-x C-s

(Note that commands can be stacked on top of one another in emacs.) Also, emacs calls ``documents'' ``buffers''. ``Buffers'' hold the contents of files.

If you want an extremely good introduction to emacs, run emacs and type in C-h t (that means type in Ctrl-H, and then the letter `t'). You'll get the official emacs tutorial. If you want to quit emacs, use the command C-x C-c.

6  A Basic Introduction to Emacs and Files

A confusing topic for new emacs users is files. Although you can go to File-Open File, emacs users use the command C-x C-f far more often. What does the command do? It ``visits'' a file. By visiting, it can either create or open the file. If the file doesn't exist, it is created, and if the file exists, it is loaded into the buffer. If you understand what I'm saying, good. If you don't, then take a look at that emacs tutorial.

Let's put the newfound knowledge to some good use - visit a file called ``.emacs'' without using the menu bar. Put the following contents into your file:

;;<name>'s .emacs file.
Change name to whatever your name is. Save it again. Congratulations - you can now open files, and save them!

7  Your .emacs file

Now that you have a file called .emacs, let's see what we can do with it. But first, we have to set the home directory. Right-click on My Computer, and click on Properties. Go to the Advanced tab, then Environment Variables. Click on New, and create a variable called HOME, with the value of the path to your emacs bin directory.

After you've done that, start up emacs again. Visit the .emacs file. Your .emacs file is your customization file, and there are some changes that we need to make to it in order to make working more efficient. I'll post my .emacs file here - I would suggest that you copy it to yours (in emacs, pasting is done by the middle-mouse-button).

;;Saketh's .emacs file ;; April 3, 2005

;;;;;;;;;;;;; ;;April 4th;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;TODO: Replace the startup message with a better one;; ;;Goal: Get a dictionary to work with Emacs ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Turn off that annoying startup message;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq inhibit-startup-message t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Set the beginning window size to 35x80;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set-frame-height (selected-frame) 35) (set-frame-width (selected-frame) 80)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set the text and background colors ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Set cursor color (set-cursor-color "white")

;; Set mouse color (set-mouse-color "white")

;; Set foreground and background (set-foreground-color "white") (set-background-color "darkblue")

;;; Set highlighting colors for isearch and drag (set-face-foreground 'highlight "white") (set-face-background 'highlight "blue")

(set-face-foreground 'region "cyan") (set-face-background 'region "blue")

(set-face-foreground 'secondary-selection ßkyblue") (set-face-background 'secondary-selection "darkblue")

;; Set calendar highlighting colors (setq calendar-load-hook '(lambda () (set-face-foreground 'diary-face ßkyblue") (set-face-background 'holiday-face ßlate blue") (set-face-foreground 'holiday-face "white")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Make the delete key delete the point ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-set-key [delete] 'delete-char)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TeX related stuff...PDF etc. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq tex-output-extension ".pdf") (setq tex-dvi-view-command ßtart \"C:/Program Files/Adobe/Acrobat 6.0/Reader/AcroRd32.exe\" *")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The next three lines put Emacs into ;; ;; Text mode and Auto Fill mode, and are;; ;; for writers who want to start writing;; ;; prose rather than code. ;; ;; -Thanks to Robert J. Chassell! ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'text-mode-hook-identify) (add-hook 'text-mode-hook 'turn-on-auto-fill)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set a Mode Line that tells me which machine, which directory,;; ;; and which line I am on, plus the other customary information.;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq default-mode-line-format (quote (#("-" 0 1 (help-echo "mouse-1: select window, mouse-2: delete others ...")) mode-line-mule-info mode-line-modified mode-line-frame-identification " " mode-line-buffer-identification " " (:eval (substring (system-name) 0 (string-match "
..+" (system-name)))) ":" default-directory #(" " 0 1 (help-echo "mouse-1: select window, mouse-2: delete others ...")) (line-number-mode " Line global-mode-string #(" (help-echo "mouse-1: select window, mouse-2: delete others ...")) (:eval (mode-line-mode-name)) mode-line-process minor-mode-alist #(" ") (-3 . " ;; "- )))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; KEYBINDINGS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-set-key "-z" 'undo) (global-set-key "-s" 'save-buffer) (global-set-key "-f" 'isearch-forward) (global-set-key "-xs" 'isearch-from-top)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SCHEME ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set-variable (quote scheme-program-name) "mzscheme")

The last part, about Scheme, you can ignore. We haven't set up scheme yet. However, that is what we are about to do. For now, figure out the .emacs file, and see what changes you can make to it.

8  Getting Scheme

You can find Scheme (specifically MzScheme) at http://download.plt-scheme.org/mzscheme/. Download it, and install it. After you've done that, access the Environment Variables window again. Find where it says ``path'' in the variables list. Click on Edit, and you will be presented with a dialog box. Add a semi-colon at the end of the value, and paste the directory to MzScheme (traditionally C:\Program Files\MzScheme).

9  Beginning Scheme

Let's see if it worked. Visit a file called ``helloworld.scm''. You should see messages at the bottom that say ``loading scheme mode'', or something similar. If you do not, try typing M-x run-scheme. The second command should invoke the scheme interpreter, which is interactive.

Let's write a very simple program to test out Scheme.

;Our first program

(begin (display "Hello, World!") (newline))

To test it out, invoke the scheme interpreter (M-x run-scheme). Type in (load ``helloworld.scm''). Then hit enter. It should reply saying ``Hello, World!''

If you want to learn more scheme programming, you're out of luck. This article is meant teach setting up scheme and emacs.

Home


File translated from TEX by TTH, version 2.89.
On 9 Apr 2005, 22:53.
Hosted by www.Geocities.ws

1