8.6. Summary of Commands by NameThe following Emacs commands are presented alphabetically by command name. Use M-x to access the command name. Tables list command name, keystroke, and description. C- indicates the Ctrl key; M- indicates the Meta key.
8.6.1. Extending EmacsEmacs' many modes come courtesy of elisp files, programs written in Emacs' own LISP-based language and stored in .el and .elc files (the latter for compiled files). Getting into the Elisp language is outside the topic of this book, [*] but be aware that all the modes you're working with are written in elisp .
Darwin's directory for Emacs extensions is /usr/share/emacs/ emacs-version-number/ lisp . Generally speaking, installing Emacs extensions that you download is as simple as moving them into this folder or into the neighboring site-lisp directory. Some .el files need to be compiled in order to work; this involves using the M-x byte-compile-file command from within Emacs. Packages that contain many interdependent files, such as the PSGML extension for editing SGML and XML files (http://www.lysator.liu.se/projects/about_psgml.html), may make this process easier by including standard Unix configure and Makefile files, which often just run Emacs in batch mode to compile the files in the right order. Many modes require you to activate various Emacs variables and settings before they'll work. This usually involves editing your .emacs file (see the next section) in some way and is usually described in the extension's README file, or perhaps in the comment section of the elisp file itself.
8.6.2. The .emacs FileYou can configure Emacs' default behavior by creating and editing a special elisp file called .emacs in your Home folder. (As with all dotfiles, the Finder hides .emacs from sight; see "Hidden files" in Chapter 10.) Emacs executes all the commands in this file whenever you launch the program, so it's a great place to set variables, activate and customize major mode options, and so on. Even if you don't know elisp , it's good to know about .emacs because Emacs extensions often require it. If you use Emacs a lot, you may find your .emacs file growing over time. A well-organized elisp file maintains scalability through grouping similar commands together into well-commented blocks, so that you know what everything does each time you return to add to (or debug) the file. As an example, here's part of the .emacs file on a Mac OS X system: ; First, adjust my loadpath so I can see me own .el files (setq load-path (cons (expand-file-name "/Users/jmac/emacs-lisp/") load- path) ) ; Activate and configure PSGML mode (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t ) (custom-set-variables) (custom-set-faces '(font-lock-comment-face ((((class color) (background dark)) (:foreground "orchid1"))))) ;; required for Emacs 21 (setq after-change-function nil) ;; Activate XSL-editing mode (autoload 'xsl-mode "xslide" "Major mode for XSL stylesheets." t) ;; Turn on font lock when in XSL mode (add-hook 'xsl-mode-hook 'turn-on-font-lock) (setq auto-mode-alist (append (list '("\.xsl" . xsl-mode)) auto-mode-alist)) ;; Activate the 'time-clock' minor mode, which adds time-tracking functionality. (require 'timeclock) ;; Define some keystrokes to trigger timeclock functions quickly. (define-key ctl-x-map "ti" 'timeclock-in) (define-key ctl-x-map "to" 'timeclock-out) (define-key ctl-x-map "tc" 'timeclock-change) (define-key ctl-x-map "tr" 'timeclock-reread-log) (define-key ctl-x-map "tu" 'timeclock-update-modeline) (define-key ctl-x-map "tw" 'timeclock-when-to-leave-string) ;; The M-x-erase-buffer command will warn you about your rash deed unless ;; you have the following variable set: (put 'erase-buffer 'disabled nil) You can find plenty of other .emacs examples online, including a whole repository just for them at http://www.dotfiles.com. Note the path-extending command, (setq load-path ... ) , at the top of the previous example. If you're not a member of the machine's admin group , and thus lack the sudo powers necessary to write to the /usr/share/emacs/21.2/ directory, you can define your own space to place elisp files, just as we have here with the directory /Users/jmac/emacs-lisp . This tells Emacs to add that directory to the paths it scans when it seeks extension files. 8.6.3. GUI EmacsThe Emacs that comes with Mac OS X Tiger is a console application that runs in the Terminal. There's no interaction with the GUI, and so many features such as menus , mouse and scroll wheel support, and syntax coloring are not supported. However, there are currently at least two distributions of Emacs that take advantage of Mac OS X and the Carbon and Aqua frameworks.
Finally, if you're running X Windows on your Macintosh, you can compile Emacs and run it with X support. |