16 Highlighting ELisp source code

Highlighting ELisp code is similar to highlighting Scheme code. You have to set the type option of the '\sourcebegin' or '\sourceinput' commands to el. For a comment in order to be recognized as valid label, the same rules apply as stated for Scheme code. Following we show how a highlighted '.el' file will look like. (The base font used for the listing is OT1pcrmnCourier. It was specified with the option ``fontname=pcr''.)

Listing 15: version.el
;;; version.el --- record version number of Emacs.
;;; Copyright (C) 1985, 1992, 1994, 1995 Free Software Foundation, Inc.

(defconst emacs-version "20.5" "\
Version numbers of this version of Emacs.")

(defconst emacs-major-version
  (progn (string-match "^[0-9]+" emacs-version)
         (string-to-int (match-string 0 emacs-version)))
  "Major version number of this version of Emacs.
This variable first existed in version 19.23.")

(defconst emacs-minor-version
  (progn (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
         (string-to-int (match-string 1 emacs-version)))
  "Minor version number of this version of Emacs.
This variable first existed in version 19.23.")

(defconst emacs-build-time (current-time) "\
Time at which Emacs was dumped out.")

(defconst emacs-build-system (system-name))

(defun emacs-version  (&optional here) "\
Return string describing the version of Emacs that is running.
If optional argument HERE is non-nil, insert string at point.
Don't use this function in programs to choose actions according
to the system configuration; look at `system-configuration' instead."
  (interactive "P")
  (let ((version-string 
         (format (if (not (interactive-p))
                     "GNU Emacs %s (%s%s)\n of %s on %s"
                   "GNU Emacs %s (%s%s) of %s on %s")
                 emacs-version
                 system-configuration
                 (cond ((featurep 'motif) ", Motif")
                       ((featurep 'x-toolkit) ", X toolkit")
                       (t ""))
                 (format-time-string "%a %b %e %Y" emacs-build-time)
                 emacs-build-system)))
    (if here 
        (insert version-string)
      (if (interactive-p)
          (message "%s" version-string)
        version-string))))
        ...



Volker Simonis 2003-03-05