Mercurial > emacs
annotate lisp/progmodes/scheme.el @ 89547:73bdeb6f6968
(adjust_frame_glyphs_for_frame_redisplay)
(adjust_frame_glyphs_for_window_redisplay): Remove unused ch_dim.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 29 Sep 2003 18:01:37 +0000 |
parents | 375f2633d815 |
children | 68c22ea6027c |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33487
diff
changeset
|
1 ;;; scheme.el --- Scheme (and DSSSL) editing mode |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
3 ;; Copyright (C) 1986, 87, 88, 97, 1998 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
4 |
17976 | 5 ;; Author: Bill Rozas <jinx@martigny.ai.mit.edu> |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
6 ;; Adapted-by: Dave Love <d.love@dl.ac.uk> |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: languages, lisp |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
8 |
65 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
65 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
65 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
26 ;;; Commentary: |
65 | 27 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
28 ;; The major mode for editing Scheme-type Lisp code, very similar to |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
29 ;; the Lisp mode documented in the Emacs manual. `dsssl-mode' is a |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
30 ;; variant of scheme-mode for editing DSSSL specifications for SGML |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
31 ;; documents. [As of Apr 1997, some pointers for DSSSL may be found, |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
32 ;; for instance, at <URL:http://www.sil.org/sgml/related.html#dsssl>.] |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
33 ;; All these Lisp-ish modes vary basically in details of the language |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
34 ;; syntax they highlight/indent/index, but dsssl-mode uses "^;;;" as |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
35 ;; the page-delimiter since ^L isn't normally a legal SGML character. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
36 ;; |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
37 ;; For interacting with a Scheme interpreter See also `run-scheme' in |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
38 ;; the `cmuscheme' package and also the implementation-specific |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
39 ;; `xscheme' package. |
65 | 40 |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
41 ;; Here's a recipe to generate a TAGS file for DSSSL, by the way: |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
42 ;; etags --lang=scheme --regex='/[ \t]*(\(mode\|element\)[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
43 ;; ]+\([^ \t( |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
44 ;; ]+\)/\2/' --regex='/[ \t]*(element[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
45 ;; ]*([^)]+[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
46 ;; ]+\([^)]+\)[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
47 ;; ]*)/\1/' --regex='/(declare[^ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
48 ;; ]*[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
49 ;; ]+\([^ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
50 ;; ]+\)/\1/' "$@" |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
51 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
52 ;;; Code: |
65 | 53 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
54 (require 'lisp-mode) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
55 |
49732
ada6655eb465
(scheme-mode-syntax-table): Don't switch the current buffer's syntax-table.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48074
diff
changeset
|
56 (defvar scheme-mode-syntax-table |
ada6655eb465
(scheme-mode-syntax-table): Don't switch the current buffer's syntax-table.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48074
diff
changeset
|
57 (let ((st (make-syntax-table)) |
ada6655eb465
(scheme-mode-syntax-table): Don't switch the current buffer's syntax-table.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48074
diff
changeset
|
58 (i 0)) |
65 | 59 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
60 ;; Default is atom-constituent. |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
61 (while (< i 256) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
62 (modify-syntax-entry i "_ " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
63 (setq i (1+ i))) |
65 | 64 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
65 ;; Word components. |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
66 (setq i ?0) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
67 (while (<= i ?9) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
68 (modify-syntax-entry i "w " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
69 (setq i (1+ i))) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
70 (setq i ?A) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
71 (while (<= i ?Z) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
72 (modify-syntax-entry i "w " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
73 (setq i (1+ i))) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
74 (setq i ?a) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
75 (while (<= i ?z) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
76 (modify-syntax-entry i "w " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
77 (setq i (1+ i))) |
65 | 78 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
79 ;; Whitespace |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
80 (modify-syntax-entry ?\t " " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
81 (modify-syntax-entry ?\n "> " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
82 (modify-syntax-entry ?\f " " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
83 (modify-syntax-entry ?\r " " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
84 (modify-syntax-entry ? " " st) |
65 | 85 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
86 ;; These characters are delimiters but otherwise undefined. |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
87 ;; Brackets and braces balance for editing convenience. |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
88 (modify-syntax-entry ?\[ "(] " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
89 (modify-syntax-entry ?\] ")[ " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
90 (modify-syntax-entry ?{ "(} " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
91 (modify-syntax-entry ?} "){ " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
92 (modify-syntax-entry ?\| " 23" st) |
65 | 93 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
94 ;; Other atom delimiters |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
95 (modify-syntax-entry ?\( "() " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
96 (modify-syntax-entry ?\) ")( " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
97 (modify-syntax-entry ?\; "< " st) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
98 (modify-syntax-entry ?\" "\" " st) |
50678
106688eb08d8
(scheme-mode-syntax-table): Use prefix syntax for ', `, comma, @ and #.
Richard M. Stallman <rms@gnu.org>
parents:
50070
diff
changeset
|
99 (modify-syntax-entry ?' "' " st) |
106688eb08d8
(scheme-mode-syntax-table): Use prefix syntax for ', `, comma, @ and #.
Richard M. Stallman <rms@gnu.org>
parents:
50070
diff
changeset
|
100 (modify-syntax-entry ?` "' " st) |
65 | 101 |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
102 ;; Special characters |
50678
106688eb08d8
(scheme-mode-syntax-table): Use prefix syntax for ', `, comma, @ and #.
Richard M. Stallman <rms@gnu.org>
parents:
50070
diff
changeset
|
103 (modify-syntax-entry ?, "' " st) |
106688eb08d8
(scheme-mode-syntax-table): Use prefix syntax for ', `, comma, @ and #.
Richard M. Stallman <rms@gnu.org>
parents:
50070
diff
changeset
|
104 (modify-syntax-entry ?@ "' " st) |
106688eb08d8
(scheme-mode-syntax-table): Use prefix syntax for ', `, comma, @ and #.
Richard M. Stallman <rms@gnu.org>
parents:
50070
diff
changeset
|
105 (modify-syntax-entry ?# "' 14" st) |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
106 (modify-syntax-entry ?\\ "\\ " st) |
49732
ada6655eb465
(scheme-mode-syntax-table): Don't switch the current buffer's syntax-table.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48074
diff
changeset
|
107 st)) |
65 | 108 |
26938 | 109 (defvar scheme-mode-abbrev-table nil) |
65 | 110 (define-abbrev-table 'scheme-mode-abbrev-table ()) |
111 | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
112 (defvar scheme-imenu-generic-expression |
26938 | 113 '((nil |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
114 "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\sw+\\)" 4) |
26938 | 115 ("Types" |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
116 "^(define-class\\s-+(?\\(\\sw+\\)" 1) |
21632 | 117 ("Macros" |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
118 "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\sw+\\)" 2)) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
119 "Imenu generic expression for Scheme mode. See `imenu-generic-expression'.") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
120 |
65 | 121 (defun scheme-mode-variables () |
122 (set-syntax-table scheme-mode-syntax-table) | |
123 (setq local-abbrev-table scheme-mode-abbrev-table) | |
124 (make-local-variable 'paragraph-start) | |
10892
0e6ae3605c92
(scheme-mode-variables): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9912
diff
changeset
|
125 (setq paragraph-start (concat "$\\|" page-delimiter)) |
65 | 126 (make-local-variable 'paragraph-separate) |
127 (setq paragraph-separate paragraph-start) | |
128 (make-local-variable 'paragraph-ignore-fill-prefix) | |
129 (setq paragraph-ignore-fill-prefix t) | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
130 (make-local-variable 'fill-paragraph-function) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
131 (setq fill-paragraph-function 'lisp-fill-paragraph) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
132 ;; Adaptive fill mode gets in the way of auto-fill, |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
133 ;; and should make no difference for explicit fill |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
134 ;; because lisp-fill-paragraph should do the job. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
135 (make-local-variable 'adaptive-fill-mode) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
136 (setq adaptive-fill-mode nil) |
20334
98744f3de8ed
(scheme-mode-variables): Bind normal-auto-fill-function.
Richard M. Stallman <rms@gnu.org>
parents:
20067
diff
changeset
|
137 (make-local-variable 'normal-auto-fill-function) |
98744f3de8ed
(scheme-mode-variables): Bind normal-auto-fill-function.
Richard M. Stallman <rms@gnu.org>
parents:
20067
diff
changeset
|
138 (setq normal-auto-fill-function 'lisp-mode-auto-fill) |
65 | 139 (make-local-variable 'indent-line-function) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
140 (setq indent-line-function 'lisp-indent-line) |
9912
08d268f33d66
(scheme-mode-variables): Set parse-sexp-ignore-comments to t.
Karl Heuer <kwzh@gnu.org>
parents:
9179
diff
changeset
|
141 (make-local-variable 'parse-sexp-ignore-comments) |
08d268f33d66
(scheme-mode-variables): Set parse-sexp-ignore-comments to t.
Karl Heuer <kwzh@gnu.org>
parents:
9179
diff
changeset
|
142 (setq parse-sexp-ignore-comments t) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
143 (make-local-variable 'outline-regexp) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
144 (setq outline-regexp ";;; \\|(....") |
65 | 145 (make-local-variable 'comment-start) |
146 (setq comment-start ";") | |
147 (make-local-variable 'comment-start-skip) | |
15598
c5f04e0724ec
(scheme-mode-variables): Set comment-start-skip to ignore backslash-quoted
Miles Bader <miles@gnu.org>
parents:
14169
diff
changeset
|
148 ;; Look within the line for a ; following an even number of backslashes |
c5f04e0724ec
(scheme-mode-variables): Set comment-start-skip to ignore backslash-quoted
Miles Bader <miles@gnu.org>
parents:
14169
diff
changeset
|
149 ;; after either a non-backslash or the line beginning. |
c5f04e0724ec
(scheme-mode-variables): Set comment-start-skip to ignore backslash-quoted
Miles Bader <miles@gnu.org>
parents:
14169
diff
changeset
|
150 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+[ \t]*") |
65 | 151 (make-local-variable 'comment-column) |
152 (setq comment-column 40) | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
851
diff
changeset
|
153 (make-local-variable 'comment-indent-function) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
154 (setq comment-indent-function 'lisp-comment-indent) |
9179
c8ef8dc59108
(scheme-mode-variables): Make parse-sexp-ignore-comments t.
Richard M. Stallman <rms@gnu.org>
parents:
6310
diff
changeset
|
155 (make-local-variable 'parse-sexp-ignore-comments) |
c8ef8dc59108
(scheme-mode-variables): Make parse-sexp-ignore-comments t.
Richard M. Stallman <rms@gnu.org>
parents:
6310
diff
changeset
|
156 (setq parse-sexp-ignore-comments t) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
157 (make-local-variable 'lisp-indent-function) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
158 (set lisp-indent-function 'scheme-indent-function) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
159 (setq mode-line-process '("" scheme-mode-line-process)) |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
160 (set (make-local-variable 'imenu-case-fold-search) t) |
20459 | 161 (setq imenu-generic-expression scheme-imenu-generic-expression) |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
162 (set (make-local-variable 'imenu-syntax-alist) |
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
163 '(("+-*/.<>=?!$%_&~^:" . "w"))) |
26938 | 164 (make-local-variable 'font-lock-defaults) |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
165 (setq font-lock-defaults |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
166 '((scheme-font-lock-keywords |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
167 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
168 nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun |
50070
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
169 (font-lock-mark-block-function . mark-defun) |
25c2d7555a11
(scheme-mode-syntax-table): Construct
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49732
diff
changeset
|
170 (font-lock-syntactic-face-function . lisp-font-lock-syntactic-face-function)))) |
65 | 171 |
172 (defvar scheme-mode-line-process "") | |
173 | |
33483 | 174 (defvar scheme-mode-map nil |
175 "Keymap for Scheme mode. | |
176 All commands in `lisp-mode-shared-map' are inherited by this map.") | |
177 | |
178 (unless scheme-mode-map | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
179 (let ((map (make-sparse-keymap "Scheme"))) |
33483 | 180 (setq scheme-mode-map (make-sparse-keymap)) |
181 (set-keymap-parent scheme-mode-map lisp-mode-shared-map) | |
182 (define-key scheme-mode-map [menu-bar] (make-sparse-keymap)) | |
183 (define-key scheme-mode-map [menu-bar scheme] | |
184 (cons "Scheme" map)) | |
185 (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme)) | |
186 (define-key map [uncomment-region] | |
187 '("Uncomment Out Region" . (lambda (beg end) | |
188 (interactive "r") | |
189 (comment-region beg end '(4))))) | |
190 (define-key map [comment-region] '("Comment Out Region" . comment-region)) | |
191 (define-key map [indent-region] '("Indent Region" . indent-region)) | |
192 (define-key map [indent-line] '("Indent Line" . lisp-indent-line)) | |
193 (put 'comment-region 'menu-enable 'mark-active) | |
194 (put 'uncomment-region 'menu-enable 'mark-active) | |
195 (put 'indent-region 'menu-enable 'mark-active))) | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
196 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
197 ;; Used by cmuscheme |
65 | 198 (defun scheme-mode-commands (map) |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
199 ;;(define-key map "\t" 'indent-for-tab-command) ; default |
65 | 200 (define-key map "\177" 'backward-delete-char-untabify) |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
201 (define-key map "\e\C-q" 'indent-sexp)) |
65 | 202 |
266 | 203 ;;;###autoload |
65 | 204 (defun scheme-mode () |
205 "Major mode for editing Scheme code. | |
26938 | 206 Editing commands are similar to those of `lisp-mode'. |
65 | 207 |
208 In addition, if an inferior Scheme process is running, some additional | |
209 commands will be defined, for evaluating expressions and controlling | |
210 the interpreter, and the state of the process will be displayed in the | |
211 modeline of all Scheme buffers. The names of commands that interact | |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
212 with the Scheme process start with \"xscheme-\" if you use the MIT |
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
213 Scheme-specific `xscheme' package; for more information see the |
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
214 documentation for `xscheme-interaction-mode'. Use \\[run-scheme] to |
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
215 start an inferior Scheme using the more general `cmuscheme' package. |
65 | 216 |
217 Commands: | |
218 Delete converts tabs to spaces as it moves back. | |
219 Blank lines separate paragraphs. Semicolons start comments. | |
220 \\{scheme-mode-map} | |
26938 | 221 Entry to this mode calls the value of `scheme-mode-hook' |
65 | 222 if that value is non-nil." |
223 (interactive) | |
224 (kill-all-local-variables) | |
225 (scheme-mode-initialize) | |
226 (scheme-mode-variables) | |
227 (run-hooks 'scheme-mode-hook)) | |
228 | |
229 (defun scheme-mode-initialize () | |
230 (use-local-map scheme-mode-map) | |
231 (setq major-mode 'scheme-mode) | |
232 (setq mode-name "Scheme")) | |
233 | |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
234 (defgroup scheme nil |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
235 "Editing Scheme code" |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
236 :group 'lisp) |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
237 |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
238 (defcustom scheme-mit-dialect t |
65 | 239 "If non-nil, scheme mode is specialized for MIT Scheme. |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
240 Set this to nil if you normally use another dialect." |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
241 :type 'boolean |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
242 :group 'scheme) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
243 |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
244 (defcustom dsssl-sgml-declaration |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
245 "<!DOCTYPE style-sheet PUBLIC \"-//James Clark//DTD DSSSL Style Sheet//EN\"> |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
246 " |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
247 "*An SGML declaration for the DSSSL file. |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
248 If it is defined as a string this will be inserted into an empty buffer |
26938 | 249 which is in `dsssl-mode'. It is typically James Clark's style-sheet |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
250 doctype, as required for Jade." |
26938 | 251 :type '(choice (string :tag "Specified string") |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
252 (const :tag "None" :value nil)) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
253 :group 'scheme) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
254 |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
255 (defcustom scheme-mode-hook nil |
26938 | 256 "Normal hook run when entering `scheme-mode'. |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
257 See `run-hooks'." |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
258 :type 'hook |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
259 :group 'scheme) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
260 |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
261 (defcustom dsssl-mode-hook nil |
26938 | 262 "Normal hook run when entering `dsssl-mode'. |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
263 See `run-hooks'." |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
264 :type 'hook |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
265 :group 'scheme) |
65 | 266 |
33487 | 267 ;; This is shared by cmuscheme and xscheme. |
268 (defcustom scheme-program-name "scheme" | |
269 "*Program invoked by the `run-scheme' command." | |
270 :type 'string | |
271 :group 'scheme) | |
272 | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
273 (defvar dsssl-imenu-generic-expression |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
274 ;; Perhaps this should also look for the style-sheet DTD tags. I'm |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
275 ;; not sure it's the best way to organize it; perhaps one type |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
276 ;; should be at the first level, though you don't see this anyhow if |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
277 ;; it gets split up. |
26938 | 278 '(("Defines" |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
279 "^(define\\s-+(?\\(\\sw+\\)" 1) |
21632 | 280 ("Modes" |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
281 "^\\s-*(mode\\s-+\\(\\(\\sw\\|\\s-\\)+\\)" 1) |
21632 | 282 ("Elements" |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
283 ;; (element foo ...) or (element (foo bar ...) ...) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
284 ;; Fixme: Perhaps it should do `root'. |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
285 "^\\s-*(element\\s-+(?\\(\\(\\sw\\|\\s-\\)+\\))?" 1) |
26938 | 286 ("Declarations" |
20891
0b58035a48ca
(scheme-imenu-generic-expression): Simplify regexps.
Dave Love <fx@gnu.org>
parents:
20461
diff
changeset
|
287 "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\sw+\\)" 2)) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
288 "Imenu generic expression for DSSSL mode. See `imenu-generic-expression'.") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
289 |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
290 (defconst scheme-font-lock-keywords-1 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
291 (eval-when-compile |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
292 (list |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
293 ;; |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
294 ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
295 ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. |
22709
5fc9fd384c5c
(scheme-font-lock-keywords-1): Fontify SCWM/Guile
Richard M. Stallman <rms@gnu.org>
parents:
21632
diff
changeset
|
296 (list (concat "(\\(define\\*?\\(" |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
297 ;; Function names. |
22709
5fc9fd384c5c
(scheme-font-lock-keywords-1): Fontify SCWM/Guile
Richard M. Stallman <rms@gnu.org>
parents:
21632
diff
changeset
|
298 "\\(\\|-public\\|-method\\|-generic\\(-procedure\\)?\\)\\|" |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
299 ;; Macro names, as variable names. A bit dubious, this. |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
300 "\\(-syntax\\|-macro\\)\\|" |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
301 ;; Class names. |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
302 "-class" |
22709
5fc9fd384c5c
(scheme-font-lock-keywords-1): Fontify SCWM/Guile
Richard M. Stallman <rms@gnu.org>
parents:
21632
diff
changeset
|
303 ;; Guile modules. |
5fc9fd384c5c
(scheme-font-lock-keywords-1): Fontify SCWM/Guile
Richard M. Stallman <rms@gnu.org>
parents:
21632
diff
changeset
|
304 "\\|-module" |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
305 "\\)\\)\\>" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
306 ;; Any whitespace and declared object. |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
307 "[ \t]*(?" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
308 "\\(\\sw+\\)?") |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
309 '(1 font-lock-keyword-face) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
310 '(6 (cond ((match-beginning 3) font-lock-function-name-face) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
311 ((match-beginning 5) font-lock-variable-name-face) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
312 (t font-lock-type-face)) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
313 nil t)) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
314 )) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
315 "Subdued expressions to highlight in Scheme modes.") |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
316 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
317 (defconst scheme-font-lock-keywords-2 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
318 (append scheme-font-lock-keywords-1 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
319 (eval-when-compile |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
320 (list |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
321 ;; |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
322 ;; Control structures. |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
323 (cons |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
324 (concat |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
325 "(" (regexp-opt |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
326 '("begin" "call-with-current-continuation" "call/cc" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
327 "call-with-input-file" "call-with-output-file" "case" "cond" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
328 "do" "else" "for-each" "if" "lambda" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
329 "let" "let*" "let-syntax" "letrec" "letrec-syntax" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
330 ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
331 "and" "or" "delay" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
332 ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
333 ;;"quasiquote" "quote" "unquote" "unquote-splicing" |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
334 "map" "syntax" "syntax-rules") t) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
335 "\\>") 1) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
336 ;; |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
337 ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
338 '("\\<<\\sw+>\\>" . font-lock-type-face) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
339 ;; |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
340 ;; Scheme `:' keywords as builtins. |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
341 '("\\<:\\sw+\\>" . font-lock-builtin-face) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
342 ))) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
343 "Gaudy expressions to highlight in Scheme modes.") |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
344 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
345 (defvar scheme-font-lock-keywords scheme-font-lock-keywords-1 |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
346 "Default expressions to highlight in Scheme modes.") |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
347 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
348 ;;;###autoload |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
349 (defun dsssl-mode () |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
350 "Major mode for editing DSSSL code. |
26938 | 351 Editing commands are similar to those of `lisp-mode'. |
65 | 352 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
353 Commands: |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
354 Delete converts tabs to spaces as it moves back. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
355 Blank lines separate paragraphs. Semicolons start comments. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
356 \\{scheme-mode-map} |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
357 Entering this mode runs the hooks `scheme-mode-hook' and then |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
358 `dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
359 that variable's value is a string." |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
360 (interactive) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
361 (kill-all-local-variables) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
362 (use-local-map scheme-mode-map) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
363 (scheme-mode-initialize) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
364 (make-local-variable 'page-delimiter) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
365 (setq page-delimiter "^;;;" ; ^L not valid SGML char |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
366 major-mode 'dsssl-mode |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
367 mode-name "DSSSL") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
368 ;; Insert a suitable SGML declaration into an empty buffer. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
369 (and (zerop (buffer-size)) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
370 (stringp dsssl-sgml-declaration) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
371 (not buffer-read-only) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
372 (insert dsssl-sgml-declaration)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
373 (scheme-mode-variables) |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
374 (setq font-lock-defaults '(dsssl-font-lock-keywords |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
375 nil t (("+-*/.<>=?$%_&~^:" . "w")) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
376 beginning-of-defun |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
377 (font-lock-mark-block-function . mark-defun))) |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
378 (set (make-local-variable 'imenu-case-fold-search) nil) |
20459 | 379 (setq imenu-generic-expression dsssl-imenu-generic-expression) |
32375
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
380 (set (make-local-variable 'imenu-syntax-alist) |
b9b7ecbf8925
(scheme-mode-variables, dsssl-mode): Avoid
Dave Love <fx@gnu.org>
parents:
32367
diff
changeset
|
381 '(("+-*/.<>=?$%_&~^:" . "w"))) |
21133
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
382 (run-hooks 'scheme-mode-hook) |
ea8428070d53
(scheme-mode-variables): Set font-lock-defaults locally.
Dave Love <fx@gnu.org>
parents:
20953
diff
changeset
|
383 (run-hooks 'dsssl-mode-hook)) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
384 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
385 ;; Extra syntax for DSSSL. This isn't separated from Scheme, but |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
386 ;; shouldn't cause much trouble in scheme-mode. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
387 (put 'element 'scheme-indent-function 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
388 (put 'mode 'scheme-indent-function 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
389 (put 'with-mode 'scheme-indent-function 1) |
17402
1c01c986afc9
(make): Add scheme-indent-function property.
Richard M. Stallman <rms@gnu.org>
parents:
17359
diff
changeset
|
390 (put 'make 'scheme-indent-function 1) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
391 (put 'style 'scheme-indent-function 1) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
392 (put 'root 'scheme-indent-function 1) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
393 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
394 (defvar dsssl-font-lock-keywords |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
395 (eval-when-compile |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
396 (list |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
397 ;; Similar to Scheme |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
398 (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\\((?\\)\\(\\sw+\\)\\>" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
399 '(1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
400 '(4 font-lock-function-name-face)) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
401 (cons |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
402 (concat "(\\(" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
403 ;; (make-regexp '("case" "cond" "else" "if" "lambda" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
404 ;; "let" "let*" "letrec" "and" "or" "map" "with-mode")) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
405 "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
406 "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
407 "\\)\\>") |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
408 1) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
409 ;; DSSSL syntax |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
410 '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
411 (1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
412 (2 font-lock-type-face)) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
413 '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
414 (1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
415 (2 font-lock-type-face)) |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
20891
diff
changeset
|
416 '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. scheme |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
417 ;; SGML markup (from sgml-mode) : |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
418 '("<\\([!?][-a-z0-9]+\\)" 1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
419 '("<\\(/?[-a-z0-9]+\\)" 1 font-lock-function-name-face))) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
420 "Default expressions to highlight in DSSSL mode.") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
421 |
65 | 422 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
423 (defvar calculate-lisp-indent-last-sexp) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
424 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
425 ;; Copied from lisp-indent-function, but with gets of |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
426 ;; scheme-indent-{function,hook}. |
65 | 427 (defun scheme-indent-function (indent-point state) |
428 (let ((normal-indent (current-column))) | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
429 (goto-char (1+ (elt state 1))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
430 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
431 (if (and (elt state 2) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
432 (not (looking-at "\\sw\\|\\s_"))) |
46159 | 433 ;; car of form doesn't seem to be a symbol |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
434 (progn |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
435 (if (not (> (save-excursion (forward-line 1) (point)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
436 calculate-lisp-indent-last-sexp)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
437 (progn (goto-char calculate-lisp-indent-last-sexp) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
438 (beginning-of-line) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
439 (parse-partial-sexp (point) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
440 calculate-lisp-indent-last-sexp 0 t))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
441 ;; Indent under the list or under the first sexp on the same |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
442 ;; line as calculate-lisp-indent-last-sexp. Note that first |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
443 ;; thing on that line has to be complete sexp since we are |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
444 ;; inside the innermost containing sexp. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
445 (backward-prefix-chars) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
446 (current-column)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
447 (let ((function (buffer-substring (point) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
448 (progn (forward-sexp 1) (point)))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
449 method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
450 (setq method (or (get (intern-soft function) 'scheme-indent-function) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
451 (get (intern-soft function) 'scheme-indent-hook))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
452 (cond ((or (eq method 'defun) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
453 (and (null method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
454 (> (length function) 3) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
455 (string-match "\\`def" function))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
456 (lisp-indent-defform state indent-point)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
457 ((integerp method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
458 (lisp-indent-specform method state |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
459 indent-point normal-indent)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
460 (method |
20067
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
461 (funcall method state indent-point normal-indent))))))) |
65 | 462 |
463 | |
464 ;;; Let is different in Scheme | |
465 | |
466 (defun would-be-symbol (string) | |
467 (not (string-equal (substring string 0 1) "("))) | |
468 | |
469 (defun next-sexp-as-string () | |
26938 | 470 ;; Assumes that it is protected by a save-excursion |
65 | 471 (forward-sexp 1) |
472 (let ((the-end (point))) | |
473 (backward-sexp 1) | |
474 (buffer-substring (point) the-end))) | |
475 | |
476 ;; This is correct but too slow. | |
477 ;; The one below works almost always. | |
478 ;;(defun scheme-let-indent (state indent-point) | |
479 ;; (if (would-be-symbol (next-sexp-as-string)) | |
480 ;; (scheme-indent-specform 2 state indent-point) | |
481 ;; (scheme-indent-specform 1 state indent-point))) | |
482 | |
20067
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
483 (defun scheme-let-indent (state indent-point normal-indent) |
65 | 484 (skip-chars-forward " \t") |
6310
c40e283c262b
Put hyphen in a safer place in the character class.
Karl Heuer <kwzh@gnu.org>
parents:
3591
diff
changeset
|
485 (if (looking-at "[-a-zA-Z0-9+*/?!@$%^&_:~]") |
20067
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
486 (lisp-indent-specform 2 state indent-point normal-indent) |
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
487 (lisp-indent-specform 1 state indent-point normal-indent))) |
65 | 488 |
489 ;; (put 'begin 'scheme-indent-function 0), say, causes begin to be indented | |
490 ;; like defun if the first form is placed on the next line, otherwise | |
491 ;; it is indented like any other form (i.e. forms line up under first). | |
492 | |
493 (put 'begin 'scheme-indent-function 0) | |
494 (put 'case 'scheme-indent-function 1) | |
495 (put 'delay 'scheme-indent-function 0) | |
496 (put 'do 'scheme-indent-function 2) | |
497 (put 'lambda 'scheme-indent-function 1) | |
498 (put 'let 'scheme-indent-function 'scheme-let-indent) | |
499 (put 'let* 'scheme-indent-function 1) | |
500 (put 'letrec 'scheme-indent-function 1) | |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
501 (put 'sequence 'scheme-indent-function 0) ; SICP, not r4rs |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
502 (put 'let-syntax 'scheme-indent-function 1) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
503 (put 'letrec-syntax 'scheme-indent-function 1) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
504 (put 'syntax-rules 'scheme-indent-function 1) |
48074 | 505 (put 'syntax-case 'scheme-indent-function 2) ; not r5rs |
65 | 506 |
507 (put 'call-with-input-file 'scheme-indent-function 1) | |
508 (put 'with-input-from-file 'scheme-indent-function 1) | |
509 (put 'with-input-from-port 'scheme-indent-function 1) | |
510 (put 'call-with-output-file 'scheme-indent-function 1) | |
511 (put 'with-output-to-file 'scheme-indent-function 1) | |
512 (put 'with-output-to-port 'scheme-indent-function 1) | |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
513 (put 'call-with-values 'scheme-indent-function 1) ; r5rs? |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
514 (put 'dynamic-wind 'scheme-indent-function 3) ; r5rs? |
65 | 515 |
516 ;;;; MIT Scheme specific indentation. | |
517 | |
518 (if scheme-mit-dialect | |
519 (progn | |
520 (put 'fluid-let 'scheme-indent-function 1) | |
521 (put 'in-package 'scheme-indent-function 1) | |
522 (put 'local-declare 'scheme-indent-function 1) | |
523 (put 'macro 'scheme-indent-function 1) | |
524 (put 'make-environment 'scheme-indent-function 0) | |
525 (put 'named-lambda 'scheme-indent-function 1) | |
526 (put 'using-syntax 'scheme-indent-function 1) | |
527 | |
528 (put 'with-input-from-string 'scheme-indent-function 1) | |
529 (put 'with-output-to-string 'scheme-indent-function 0) | |
530 (put 'with-values 'scheme-indent-function 1) | |
531 | |
532 (put 'syntax-table-define 'scheme-indent-function 2) | |
533 (put 'list-transform-positive 'scheme-indent-function 1) | |
534 (put 'list-transform-negative 'scheme-indent-function 1) | |
535 (put 'list-search-positive 'scheme-indent-function 1) | |
536 (put 'list-search-negative 'scheme-indent-function 1) | |
537 | |
538 (put 'access-components 'scheme-indent-function 1) | |
539 (put 'assignment-components 'scheme-indent-function 1) | |
540 (put 'combination-components 'scheme-indent-function 1) | |
541 (put 'comment-components 'scheme-indent-function 1) | |
542 (put 'conditional-components 'scheme-indent-function 1) | |
543 (put 'disjunction-components 'scheme-indent-function 1) | |
544 (put 'declaration-components 'scheme-indent-function 1) | |
545 (put 'definition-components 'scheme-indent-function 1) | |
546 (put 'delay-components 'scheme-indent-function 1) | |
547 (put 'in-package-components 'scheme-indent-function 1) | |
548 (put 'lambda-components 'scheme-indent-function 1) | |
549 (put 'lambda-components* 'scheme-indent-function 1) | |
550 (put 'lambda-components** 'scheme-indent-function 1) | |
551 (put 'open-block-components 'scheme-indent-function 1) | |
552 (put 'pathname-components 'scheme-indent-function 1) | |
553 (put 'procedure-components 'scheme-indent-function 1) | |
554 (put 'sequence-components 'scheme-indent-function 1) | |
555 (put 'unassigned\?-components 'scheme-indent-function 1) | |
556 (put 'unbound\?-components 'scheme-indent-function 1) | |
557 (put 'variable-components 'scheme-indent-function 1))) | |
584 | 558 |
559 (provide 'scheme) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
560 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
561 ;;; scheme.el ends here |