aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/scheme.el92
1 files changed, 76 insertions, 16 deletions
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 302f634362f..ff4d2b381a9 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -1,6 +1,6 @@
1;;; scheme.el --- Scheme (and DSSSL) editing mode. 1;;; scheme.el --- Scheme (and DSSSL) editing mode.
2 2
3;; Copyright (C) 1986, 87, 88, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 87, 88, 97, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Bill Rozas <jinx@martigny.ai.mit.edu> 5;; Author: Bill Rozas <jinx@martigny.ai.mit.edu>
6;; Adapted-by: Dave Love <d.love@dl.ac.uk> 6;; Adapted-by: Dave Love <d.love@dl.ac.uk>
@@ -163,7 +163,13 @@
163 (make-local-variable 'imenu-generic-expression) 163 (make-local-variable 'imenu-generic-expression)
164 (setq imenu-generic-expression scheme-imenu-generic-expression) 164 (setq imenu-generic-expression scheme-imenu-generic-expression)
165 (make-local-variable 'imenu-syntax-alist) 165 (make-local-variable 'imenu-syntax-alist)
166 (setq imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w")))) 166 (setq imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w")))
167 (make-local-variable 'font-lock-defaults)
168 (setq font-lock-defaults
169 '((scheme-font-lock-keywords
170 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
171 nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
172 (font-lock-mark-block-function . mark-defun))))
167 173
168(defvar scheme-mode-line-process "") 174(defvar scheme-mode-line-process "")
169 175
@@ -248,13 +254,13 @@ doctype, as required for Jade."
248 :group 'scheme) 254 :group 'scheme)
249 255
250(defcustom scheme-mode-hook nil 256(defcustom scheme-mode-hook nil
251 "*Normal hook (list of functions) run when entering scheme-mode. 257 "Normal hook (list of functions) run when entering scheme-mode.
252See `run-hooks'." 258See `run-hooks'."
253 :type 'hook 259 :type 'hook
254 :group 'scheme) 260 :group 'scheme)
255 261
256(defcustom dsssl-mode-hook nil 262(defcustom dsssl-mode-hook nil
257 "*Normal hook (list of functions) run when entering dsssl-mode. 263 "Normal hook (list of functions) run when entering dsssl-mode.
258See `run-hooks'." 264See `run-hooks'."
259 :type 'hook 265 :type 'hook
260 :group 'scheme) 266 :group 'scheme)
@@ -276,6 +282,62 @@ See `run-hooks'."
276 "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\sw+\\)" 2)) 282 "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\sw+\\)" 2))
277 "Imenu generic expression for DSSSL mode. See `imenu-generic-expression'.") 283 "Imenu generic expression for DSSSL mode. See `imenu-generic-expression'.")
278 284
285(defconst scheme-font-lock-keywords-1
286 (eval-when-compile
287 (list
288 ;;
289 ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says
290 ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS.
291 (list (concat "(\\(define\\("
292 ;; Function names.
293 "\\(\\|-method\\|-generic\\(-procedure\\)?\\)\\|"
294 ;; Macro names, as variable names. A bit dubious, this.
295 "\\(-syntax\\)\\|"
296 ;; Class names.
297 "-class"
298 "\\)\\)\\>"
299 ;; Any whitespace and declared object.
300 "[ \t]*(?"
301 "\\(\\sw+\\)?")
302 '(1 font-lock-keyword-face)
303 '(6 (cond ((match-beginning 3) font-lock-function-name-face)
304 ((match-beginning 5) font-lock-variable-name-face)
305 (t font-lock-type-face))
306 nil t))
307 ))
308 "Subdued expressions to highlight in Scheme modes.")
309
310(defconst scheme-font-lock-keywords-2
311 (append scheme-font-lock-keywords-1
312 (eval-when-compile
313 (list
314 ;;
315 ;; Control structures.
316 (cons
317 (concat
318 "(" (regexp-opt
319 '("begin" "call-with-current-continuation" "call/cc"
320 "call-with-input-file" "call-with-output-file" "case" "cond"
321 "do" "else" "for-each" "if" "lambda"
322 "let" "let*" "let-syntax" "letrec" "letrec-syntax"
323 ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants:
324 "and" "or" "delay"
325 ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother:
326 ;;"quasiquote" "quote" "unquote" "unquote-splicing"
327 "map" "syntax" "syntax-rules") t)
328 "\\>") 1)
329 ;;
330 ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers.
331 '("\\<<\\sw+>\\>" . font-lock-type-face)
332 ;;
333 ;; Scheme `:' keywords as builtins.
334 '("\\<:\\sw+\\>" . font-lock-builtin-face)
335 )))
336 "Gaudy expressions to highlight in Scheme modes.")
337
338(defvar scheme-font-lock-keywords scheme-font-lock-keywords-1
339 "Default expressions to highlight in Scheme modes.")
340
279;;;###autoload 341;;;###autoload
280(defun dsssl-mode () 342(defun dsssl-mode ()
281 "Major mode for editing DSSSL code. 343 "Major mode for editing DSSSL code.
@@ -285,19 +347,13 @@ Commands:
285Delete converts tabs to spaces as it moves back. 347Delete converts tabs to spaces as it moves back.
286Blank lines separate paragraphs. Semicolons start comments. 348Blank lines separate paragraphs. Semicolons start comments.
287\\{scheme-mode-map} 349\\{scheme-mode-map}
288Entry to this mode calls the value of dsssl-mode-hook 350Entering this mode runs the hooks `scheme-mode-hook' and then
289if that value is non-nil and inserts the value of 351`dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if
290`dsssl-sgml-declaration' if that variable's value is a string." 352that variable's value is a string."
291 (interactive) 353 (interactive)
292 (kill-all-local-variables) 354 (kill-all-local-variables)
293 (use-local-map scheme-mode-map) 355 (use-local-map scheme-mode-map)
294 (scheme-mode-initialize) 356 (scheme-mode-initialize)
295 (make-local-variable 'font-lock-defaults)
296 (setq font-lock-defaults '(dsssl-font-lock-keywords
297 nil t (("+-*/.<>=?$%_&~^:" . "w"))
298 beginning-of-defun
299 (font-lock-comment-start-regexp . ";")
300 (font-lock-mark-block-function . mark-defun)))
301 (make-local-variable 'page-delimiter) 357 (make-local-variable 'page-delimiter)
302 (setq page-delimiter "^;;;" ; ^L not valid SGML char 358 (setq page-delimiter "^;;;" ; ^L not valid SGML char
303 major-mode 'dsssl-mode 359 major-mode 'dsssl-mode
@@ -307,12 +363,16 @@ if that value is non-nil and inserts the value of
307 (stringp dsssl-sgml-declaration) 363 (stringp dsssl-sgml-declaration)
308 (not buffer-read-only) 364 (not buffer-read-only)
309 (insert dsssl-sgml-declaration)) 365 (insert dsssl-sgml-declaration))
310 (run-hooks 'scheme-mode-hook)
311 (run-hooks 'dsssl-mode-hook)
312 (scheme-mode-variables) 366 (scheme-mode-variables)
367 (setq font-lock-defaults '(dsssl-font-lock-keywords
368 nil t (("+-*/.<>=?$%_&~^:" . "w"))
369 beginning-of-defun
370 (font-lock-mark-block-function . mark-defun)))
313 (setq imenu-case-fold-search nil) 371 (setq imenu-case-fold-search nil)
314 (setq imenu-generic-expression dsssl-imenu-generic-expression) 372 (setq imenu-generic-expression dsssl-imenu-generic-expression)
315 (setq imenu-syntax-alist '(("+-*/.<>=?$%_&~^:" . "w")))) 373 (setq imenu-syntax-alist '(("+-*/.<>=?$%_&~^:" . "w")))
374 (run-hooks 'scheme-mode-hook)
375 (run-hooks 'dsssl-mode-hook))
316 376
317;; Extra syntax for DSSSL. This isn't separated from Scheme, but 377;; Extra syntax for DSSSL. This isn't separated from Scheme, but
318;; shouldn't cause much trouble in scheme-mode. 378;; shouldn't cause much trouble in scheme-mode.