Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 1: Introduction to Emacs

Previous HourNext Hour

Sections in this Hour:

 

Using Different Emacs

This book covers both GNU Emacs and XEmacs; furthermore, GNU Emacs is covered for Windows as well. The Emacs version that is focused on is version 20, and incompatibilities with Emacs 19 are pointed out. All in all, this book covers quite a few different combinations. Something special might need to be done for GNU Emacs version 19, whereas other things need to be done for Emacs under Windows.

Throughout this book I will tell you to insert code into your .emacs file, in case you need a given feature in, for example, GNU Emacs. In these cases, you need to make a clause around the lines to ensure that the given line is only interpreted by GNU Emacs. Several predicates are defined in sams-lib.el, which describe the setup that you are using (see Table 1.1).

Table 1.1  Predicates for Setup Testing

Name

Meaning

sams-Emacs-20-p

This predicate is true if your current Emacs is version 20

sams-Emacs-19-p

This predicate is true if your current Emacs is version 19

sams-UNIX-p

This predicate is true if your Emacs is running under UNIX

sams-Windows-p

This predicate is true if your current Emacs is running under Windows

sams-GNU-Emacs-p

This predicate is true if your current Emacs is GNU Emacs

sams-XEmacs-p

This predicate is true if your current Emacs is XEmacs


If I suggest, for example, that you insert the line (require 'customize) in GNU Emacs version 19, you should take one of the following actions:


(if (and sams-Gnu-Emacs-p sams-Emacs-19-p)
    (progn
      (require 'customize)
))

Tip - Even though you only use one flavor and one version of Emacs on one system, you might still consider inserting the text to ensure that everything works correctly, in case you ever try another combination of these parameters (that is, another version: XEmacs instead of GNU Emacs, or Emacs in Windows instead of only in UNIX).


The parentheses say that (and sams-GNU-Emacs-p sams-Emacs-19-p) is the predicate that selects the correct conditions. This is a Lisp expression; because you haven't learned Lisp yet, however, Table 1.2 shows you a few different examples of such predicates (that is, alternatives to (and ...) in the preceding code.)

Table 1.2  A Few Combined Tests

Test

Description

sams-GNU-Emacs-p

If you only test on one thing, you do not need the parentheses around this test.

(or sams-XEmacs-p sams-Windows-p)

This is true if you use either XEmacs or Emacs in Windows.

(and sams-GNU-Emacs-p sams-Emacs-19-p)

This is true if you use GNU Emacs, version 19.

(or sams-GNU-Emacs-p (and sams-XEmacs-p sams-Emacs-20-p))

This is true if you use either GNU Emacs or XEmacs version 20.

(not (and sams- GNU-Emacs-p sams- Emacs-19-p))

This is true if the current Emacs is anything other than GNU Emacs version 19.


Any number of lines can be dropped in place of (require 'customize). Therefore, as a final example, I suggest that you insert the following lines if you use GNU Emacs in UNIX:


(message "Loading bla bla...")
(require 'bla)
(message "Loading bla bla...Done")

In your .emacs file, this would look like:


(if (and sams-GNU-Emacs-p sams-Windows-p)
    (progn
      (message "Loading bla bla...")
      (require 'bla)
      (message "Loading bla bla...Done")
))

Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 1: Introduction to Emacs

Previous HourNext Hour

Sections in this Hour: