The .emacs File
You 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" ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access