Mercurial > emacs
annotate lisp/progmodes/scheme.el @ 20844:d69034fe59c2
(vc-ignore-vc-files): New variable.
(vc-file-hook, vc-file-not-found-hook): Use it.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 04 Feb 1998 14:20:15 +0000 |
parents | 3965832648d3 |
children | 0b58035a48ca |
rev | line source |
---|---|
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
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 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
3 ;; Copyright (C) 1986, 87, 88, 1997 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> |
20334
98744f3de8ed
(scheme-mode-variables): Bind normal-auto-fill-function.
Richard M. Stallman <rms@gnu.org>
parents:
20067
diff
changeset
|
6 ;; Maintainer: FSF |
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 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
26 ;; Originally adapted from Lisp mode by Bill Rozas, jinx@prep with a |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
27 ;; comment that the code should be merged back. Merging done by |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
28 ;; d.love@dl.ac.uk when DSSSL features added. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
30 ;;; Commentary: |
65 | 31 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
32 ;; 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
|
33 ;; 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
|
34 ;; 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
|
35 ;; 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
|
36 ;; 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
|
37 ;; 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
|
38 ;; 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
|
39 ;; 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
|
40 ;; |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
41 ;; 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
|
42 ;; 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
|
43 ;; `xscheme' package. |
65 | 44 |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
45 ;; 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
|
46 ;; 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
|
47 ;; ]+\([^ \t( |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
48 ;; ]+\)/\2/' --regex='/[ \t]*(element[ \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 ;; ]+\([^)]+\)[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
51 ;; ]*)/\1/' --regex='/(declare[^ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
52 ;; ]*[ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
53 ;; ]+\([^ \t |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
54 ;; ]+\)/\1/' "$@" |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
55 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
56 ;;; Code: |
65 | 57 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
58 (require 'lisp-mode) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
59 |
65 | 60 (defvar scheme-mode-syntax-table nil "") |
61 (if (not scheme-mode-syntax-table) | |
62 (let ((i 0)) | |
63 (setq scheme-mode-syntax-table (make-syntax-table)) | |
64 (set-syntax-table scheme-mode-syntax-table) | |
65 | |
66 ;; Default is atom-constituent. | |
67 (while (< i 256) | |
68 (modify-syntax-entry i "_ ") | |
69 (setq i (1+ i))) | |
70 | |
71 ;; Word components. | |
72 (setq i ?0) | |
73 (while (<= i ?9) | |
74 (modify-syntax-entry i "w ") | |
75 (setq i (1+ i))) | |
76 (setq i ?A) | |
77 (while (<= i ?Z) | |
78 (modify-syntax-entry i "w ") | |
79 (setq i (1+ i))) | |
80 (setq i ?a) | |
81 (while (<= i ?z) | |
82 (modify-syntax-entry i "w ") | |
83 (setq i (1+ i))) | |
84 | |
85 ;; Whitespace | |
86 (modify-syntax-entry ?\t " ") | |
87 (modify-syntax-entry ?\n "> ") | |
88 (modify-syntax-entry ?\f " ") | |
89 (modify-syntax-entry ?\r " ") | |
90 (modify-syntax-entry ? " ") | |
91 | |
92 ;; These characters are delimiters but otherwise undefined. | |
93 ;; Brackets and braces balance for editing convenience. | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
94 (modify-syntax-entry ?\[ "(] ") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
95 (modify-syntax-entry ?\] ")[ ") |
65 | 96 (modify-syntax-entry ?{ "(} ") |
97 (modify-syntax-entry ?} "){ ") | |
98 (modify-syntax-entry ?\| " 23") | |
99 | |
100 ;; Other atom delimiters | |
101 (modify-syntax-entry ?\( "() ") | |
102 (modify-syntax-entry ?\) ")( ") | |
103 (modify-syntax-entry ?\; "< ") | |
104 (modify-syntax-entry ?\" "\" ") | |
105 (modify-syntax-entry ?' " p") | |
106 (modify-syntax-entry ?` " p") | |
107 | |
108 ;; Special characters | |
109 (modify-syntax-entry ?, "_ p") | |
110 (modify-syntax-entry ?@ "_ p") | |
111 (modify-syntax-entry ?# "_ p14") | |
112 (modify-syntax-entry ?\\ "\\ "))) | |
113 | |
114 (defvar scheme-mode-abbrev-table nil "") | |
115 (define-abbrev-table 'scheme-mode-abbrev-table ()) | |
116 | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
117 (defvar scheme-imenu-generic-expression |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
118 '((nil |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
119 "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 4) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
120 (" Types" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
121 "^(define-class\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
122 (" Macros" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
123 "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 2)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
124 "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
|
125 |
65 | 126 (defun scheme-mode-variables () |
127 (set-syntax-table scheme-mode-syntax-table) | |
128 (setq local-abbrev-table scheme-mode-abbrev-table) | |
129 (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
|
130 (setq paragraph-start (concat "$\\|" page-delimiter)) |
65 | 131 (make-local-variable 'paragraph-separate) |
132 (setq paragraph-separate paragraph-start) | |
133 (make-local-variable 'paragraph-ignore-fill-prefix) | |
134 (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
|
135 (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
|
136 (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
|
137 ;; 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
|
138 ;; 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
|
139 ;; 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
|
140 (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
|
141 (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
|
142 (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
|
143 (setq normal-auto-fill-function 'lisp-mode-auto-fill) |
65 | 144 (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
|
145 (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
|
146 (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
|
147 (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
|
148 (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
|
149 (setq outline-regexp ";;; \\|(....") |
65 | 150 (make-local-variable 'comment-start) |
151 (setq comment-start ";") | |
152 (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
|
153 ;; 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
|
154 ;; 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
|
155 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+[ \t]*") |
65 | 156 (make-local-variable 'comment-column) |
157 (setq comment-column 40) | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
851
diff
changeset
|
158 (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
|
159 (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
|
160 (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
|
161 (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
|
162 (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
|
163 (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
|
164 (setq mode-line-process '("" scheme-mode-line-process)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
165 (make-local-variable 'imenu-generic-expression) |
20459 | 166 (setq imenu-generic-expression scheme-imenu-generic-expression) |
167 (setq imenu-case-fold-search t)) | |
65 | 168 |
169 (defvar scheme-mode-line-process "") | |
170 | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
171 (defvar scheme-mode-map nil |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
172 "Keymap for Scheme mode. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
173 All commands in `shared-lisp-mode-map' are inherited by this map.") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
174 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
175 (if scheme-mode-map |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
176 () |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
177 (let ((map (make-sparse-keymap "Scheme"))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
178 (setq scheme-mode-map |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
179 (nconc (make-sparse-keymap) shared-lisp-mode-map)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
180 (define-key scheme-mode-map [menu-bar] (make-sparse-keymap)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
181 (define-key scheme-mode-map [menu-bar scheme] |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
182 (cons "Scheme" map)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
183 (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme)) |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
184 (define-key map [uncomment-region] |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
185 '("Uncomment Out Region" . (lambda (beg end) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
186 (interactive "r") |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
187 (comment-region beg end '(4))))) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
188 (define-key map [comment-region] '("Comment Out Region" . comment-region)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
189 (define-key map [indent-region] '("Indent Region" . indent-region)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
190 (define-key map [indent-line] '("Indent Line" . lisp-indent-line)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
191 (put 'comment-region 'menu-enable 'mark-active) |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
192 (put 'uncomment-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
|
193 (put 'indent-region 'menu-enable 'mark-active))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
194 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
195 ;; Used by cmuscheme |
65 | 196 (defun scheme-mode-commands (map) |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
197 ;;(define-key map "\t" 'indent-for-tab-command) ; default |
65 | 198 (define-key map "\177" 'backward-delete-char-untabify) |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
199 (define-key map "\e\C-q" 'indent-sexp)) |
65 | 200 |
266 | 201 ;;;###autoload |
65 | 202 (defun scheme-mode () |
203 "Major mode for editing Scheme code. | |
204 Editing commands are similar to those of lisp-mode. | |
205 | |
206 In addition, if an inferior Scheme process is running, some additional | |
207 commands will be defined, for evaluating expressions and controlling | |
208 the interpreter, and the state of the process will be displayed in the | |
209 modeline of all Scheme buffers. The names of commands that interact | |
210 with the Scheme process start with \"xscheme-\". For more information | |
211 see the documentation for xscheme-interaction-mode. | |
212 | |
213 Commands: | |
214 Delete converts tabs to spaces as it moves back. | |
215 Blank lines separate paragraphs. Semicolons start comments. | |
216 \\{scheme-mode-map} | |
217 Entry to this mode calls the value of scheme-mode-hook | |
218 if that value is non-nil." | |
219 (interactive) | |
220 (kill-all-local-variables) | |
221 (scheme-mode-initialize) | |
222 (scheme-mode-variables) | |
223 (run-hooks 'scheme-mode-hook)) | |
224 | |
225 (defun scheme-mode-initialize () | |
226 (use-local-map scheme-mode-map) | |
227 (setq major-mode 'scheme-mode) | |
228 (setq mode-name "Scheme")) | |
229 | |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
230 (defgroup scheme nil |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
231 "Editing Scheme code" |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
232 :group 'lisp) |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
233 |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
234 (defcustom scheme-mit-dialect t |
65 | 235 "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
|
236 Set this to nil if you normally use another dialect." |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
237 :type 'boolean |
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
238 :group 'scheme) |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
239 |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
240 (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
|
241 "<!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
|
242 " |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
243 "*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
|
244 If it is defined as a string this will be inserted into an empty buffer |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
245 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
|
246 doctype, as required for Jade." |
20461
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
247 :type '(choice (string :tag "Specified string") |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
248 (const :tag "None" :value nil)) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
249 :group 'scheme) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
250 |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
251 (defcustom scheme-mode-hook nil |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
252 "*Normal hook (list of functions) run when entering scheme-mode. |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
253 See `run-hooks'." |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
254 :type 'hook |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
255 :group 'scheme) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
256 |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
257 (defcustom dsssl-mode-hook nil |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
258 "*Normal hook (list of functions) run when entering dsssl-mode. |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
259 See `run-hooks'." |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
260 :type 'hook |
18285
d38d2b26bd52
(scheme): Add defgroup.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
261 :group 'scheme) |
65 | 262 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
263 (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
|
264 ;; 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
|
265 ;; 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
|
266 ;; 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
|
267 ;; it gets split up. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
268 '((" Defines" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
269 "^(define\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
270 (" Modes" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
271 "^\\s-*(mode\\s-+\\(\\(\\sw\\|\\s-\\|\\s_\\)+\\)" 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
272 (" Elements" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
273 ;; (element foo ...) or (element (foo bar ...) ...) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
274 ;; Fixme: Perhaps it should do `root'. |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
275 "^\\s-*(element\\s-+(?\\(\\(\\sw\\|\\s-\\|\\s_\\)+\\))?" 1) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
276 (" Declarations" |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
277 "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 2)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
278 "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
|
279 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
280 ;;;###autoload |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
281 (defun dsssl-mode () |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
282 "Major mode for editing DSSSL code. |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
283 Editing commands are similar to those of lisp-mode. |
65 | 284 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
285 Commands: |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
286 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
|
287 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
|
288 \\{scheme-mode-map} |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
289 Entry to this mode calls the value of dsssl-mode-hook |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
290 if that value is non-nil and inserts the value of |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
291 `dsssl-sgml-declaration' if 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
|
292 (interactive) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
293 (kill-all-local-variables) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
294 (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
|
295 (scheme-mode-initialize) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
296 (make-local-variable 'font-lock-defaults) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
297 (setq font-lock-defaults '(dsssl-font-lock-keywords |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
298 nil t (("+-*/.<>=!?$%_&~^:" . "w")) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
299 beginning-of-defun |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
300 (font-lock-comment-start-regexp . ";") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
301 (font-lock-mark-block-function . mark-defun))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
302 (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
|
303 (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
|
304 major-mode 'dsssl-mode |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
305 mode-name "DSSSL") |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
306 ;; 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
|
307 (and (zerop (buffer-size)) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
308 (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
|
309 (not buffer-read-only) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
310 (insert dsssl-sgml-declaration)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
311 (run-hooks 'scheme-mode-hook) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
312 (run-hooks 'dsssl-mode-hook) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
313 (scheme-mode-variables) |
20459 | 314 (setq imenu-generic-expression dsssl-imenu-generic-expression) |
315 (setq imenu-case-fold-search nil)) | |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
316 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
317 ;; 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
|
318 ;; 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
|
319 (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
|
320 (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
|
321 (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
|
322 (put 'make 'scheme-indent-function 1) |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
323 (put 'style 'scheme-indent-function 1) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
324 (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
|
325 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
326 (defvar dsssl-font-lock-keywords |
17578
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
327 (eval-when-compile |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
328 (list |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
329 ;; Similar to Scheme |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
330 (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\\((?\\)\\(\\sw+\\)\\>" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
331 '(1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
332 '(4 font-lock-function-name-face)) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
333 (cons |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
334 (concat "(\\(" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
335 ;; (make-regexp '("case" "cond" "else" "if" "lambda" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
336 ;; "let" "let*" "letrec" "and" "or" "map" "with-mode")) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
337 "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
338 "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
339 "\\)\\>") |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
340 1) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
341 ;; DSSSL syntax |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
342 '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
343 (1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
344 (2 font-lock-type-face)) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
345 '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))" |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
346 (1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
347 (2 font-lock-type-face)) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
348 '("\\<\\sw+:\\>" . font-lock-reference-face) ; trailing `:' c.f. scheme |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
349 ;; SGML markup (from sgml-mode) : |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
350 '("<\\([!?][-a-z0-9]+\\)" 1 font-lock-keyword-face) |
86a3f6bf749a
(dsssl-sgml-declaration): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17402
diff
changeset
|
351 '("<\\(/?[-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
|
352 "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
|
353 |
65 | 354 |
17359
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
355 (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
|
356 |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
357 ;; 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
|
358 ;; scheme-indent-{function,hook}. |
65 | 359 (defun scheme-indent-function (indent-point state) |
360 (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
|
361 (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
|
362 (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
|
363 (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
|
364 (not (looking-at "\\sw\\|\\s_"))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
365 ;; car of form doesn't seem to be a a symbol |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
366 (progn |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
367 (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
|
368 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
|
369 (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
|
370 (beginning-of-line) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
371 (parse-partial-sexp (point) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
372 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
|
373 ;; 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
|
374 ;; 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
|
375 ;; 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
|
376 ;; 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
|
377 (backward-prefix-chars) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
378 (current-column)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
379 (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
|
380 (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
|
381 method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
382 (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
|
383 (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
|
384 (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
|
385 (and (null method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
386 (> (length function) 3) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
387 (string-match "\\`def" function))) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
388 (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
|
389 ((integerp method) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
390 (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
|
391 indent-point normal-indent)) |
13ebd090612a
Add DSSSL mode and share code with newly required
Richard M. Stallman <rms@gnu.org>
parents:
15598
diff
changeset
|
392 (method |
20067
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
393 (funcall method state indent-point normal-indent))))))) |
65 | 394 |
395 | |
396 ;;; Let is different in Scheme | |
397 | |
398 (defun would-be-symbol (string) | |
399 (not (string-equal (substring string 0 1) "("))) | |
400 | |
401 (defun next-sexp-as-string () | |
402 ;; Assumes that protected by a save-excursion | |
403 (forward-sexp 1) | |
404 (let ((the-end (point))) | |
405 (backward-sexp 1) | |
406 (buffer-substring (point) the-end))) | |
407 | |
408 ;; This is correct but too slow. | |
409 ;; The one below works almost always. | |
410 ;;(defun scheme-let-indent (state indent-point) | |
411 ;; (if (would-be-symbol (next-sexp-as-string)) | |
412 ;; (scheme-indent-specform 2 state indent-point) | |
413 ;; (scheme-indent-specform 1 state indent-point))) | |
414 | |
20067
694a165b5b0d
(scheme-let-indent): New arg NORMAL-INDENT.
Karl Heuer <kwzh@gnu.org>
parents:
18285
diff
changeset
|
415 (defun scheme-let-indent (state indent-point normal-indent) |
65 | 416 (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
|
417 (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
|
418 (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
|
419 (lisp-indent-specform 1 state indent-point normal-indent))) |
65 | 420 |
421 ;; (put 'begin 'scheme-indent-function 0), say, causes begin to be indented | |
422 ;; like defun if the first form is placed on the next line, otherwise | |
423 ;; it is indented like any other form (i.e. forms line up under first). | |
424 | |
425 (put 'begin 'scheme-indent-function 0) | |
426 (put 'case 'scheme-indent-function 1) | |
427 (put 'delay 'scheme-indent-function 0) | |
428 (put 'do 'scheme-indent-function 2) | |
429 (put 'lambda 'scheme-indent-function 1) | |
430 (put 'let 'scheme-indent-function 'scheme-let-indent) | |
431 (put 'let* 'scheme-indent-function 1) | |
432 (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
|
433 (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
|
434 (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
|
435 (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
|
436 (put 'syntax-rules 'scheme-indent-function 1) |
3965832648d3
Define indentation in normal dialect for let-syntax,
Dave Love <fx@gnu.org>
parents:
20459
diff
changeset
|
437 |
65 | 438 |
439 (put 'call-with-input-file 'scheme-indent-function 1) | |
440 (put 'with-input-from-file 'scheme-indent-function 1) | |
441 (put 'with-input-from-port 'scheme-indent-function 1) | |
442 (put 'call-with-output-file 'scheme-indent-function 1) | |
443 (put 'with-output-to-file 'scheme-indent-function 1) | |
444 (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
|
445 (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
|
446 (put 'dynamic-wind 'scheme-indent-function 3) ; r5rs? |
65 | 447 |
448 ;;;; MIT Scheme specific indentation. | |
449 | |
450 (if scheme-mit-dialect | |
451 (progn | |
452 (put 'fluid-let 'scheme-indent-function 1) | |
453 (put 'in-package 'scheme-indent-function 1) | |
454 (put 'local-declare 'scheme-indent-function 1) | |
455 (put 'macro 'scheme-indent-function 1) | |
456 (put 'make-environment 'scheme-indent-function 0) | |
457 (put 'named-lambda 'scheme-indent-function 1) | |
458 (put 'using-syntax 'scheme-indent-function 1) | |
459 | |
460 (put 'with-input-from-string 'scheme-indent-function 1) | |
461 (put 'with-output-to-string 'scheme-indent-function 0) | |
462 (put 'with-values 'scheme-indent-function 1) | |
463 | |
464 (put 'syntax-table-define 'scheme-indent-function 2) | |
465 (put 'list-transform-positive 'scheme-indent-function 1) | |
466 (put 'list-transform-negative 'scheme-indent-function 1) | |
467 (put 'list-search-positive 'scheme-indent-function 1) | |
468 (put 'list-search-negative 'scheme-indent-function 1) | |
469 | |
470 (put 'access-components 'scheme-indent-function 1) | |
471 (put 'assignment-components 'scheme-indent-function 1) | |
472 (put 'combination-components 'scheme-indent-function 1) | |
473 (put 'comment-components 'scheme-indent-function 1) | |
474 (put 'conditional-components 'scheme-indent-function 1) | |
475 (put 'disjunction-components 'scheme-indent-function 1) | |
476 (put 'declaration-components 'scheme-indent-function 1) | |
477 (put 'definition-components 'scheme-indent-function 1) | |
478 (put 'delay-components 'scheme-indent-function 1) | |
479 (put 'in-package-components 'scheme-indent-function 1) | |
480 (put 'lambda-components 'scheme-indent-function 1) | |
481 (put 'lambda-components* 'scheme-indent-function 1) | |
482 (put 'lambda-components** 'scheme-indent-function 1) | |
483 (put 'open-block-components 'scheme-indent-function 1) | |
484 (put 'pathname-components 'scheme-indent-function 1) | |
485 (put 'procedure-components 'scheme-indent-function 1) | |
486 (put 'sequence-components 'scheme-indent-function 1) | |
487 (put 'unassigned\?-components 'scheme-indent-function 1) | |
488 (put 'unbound\?-components 'scheme-indent-function 1) | |
489 (put 'variable-components 'scheme-indent-function 1))) | |
584 | 490 |
491 (provide 'scheme) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
492 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
493 ;;; scheme.el ends here |