aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-01-28 18:57:45 +0000
committerStefan Monnier2005-01-28 18:57:45 +0000
commit150bbae7a4e01c02d3daba544083c10e95494b0b (patch)
treef7df8512a355a26716ac8eb4035cd687bcc9506d
parente4105348b2aa19be95a5cc98405b00ce967c34dd (diff)
downloademacs-150bbae7a4e01c02d3daba544083c10e95494b0b.tar.gz
emacs-150bbae7a4e01c02d3daba544083c10e95494b0b.zip
(scheme-mode-variables): Set comment-add.
(dsssl-mode): Use define-derived-mode. (scheme-mode-initialize): Remove. (scheme-mode): Use run-mode-hooks.
-rw-r--r--lisp/progmodes/scheme.el48
1 files changed, 19 insertions, 29 deletions
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 13dd790b6a0..bf0f18d5bba 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -1,6 +1,7 @@
1;;; scheme.el --- Scheme (and DSSSL) editing mode 1;;; scheme.el --- Scheme (and DSSSL) editing mode
2 2
3;; Copyright (C) 1986, 87, 88, 97, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 1987, 1988, 1997, 1998, 2005
4;; Free Software Foundation, Inc.
4 5
5;; Author: Bill Rozas <jinx@martigny.ai.mit.edu> 6;; Author: Bill Rozas <jinx@martigny.ai.mit.edu>
6;; Adapted-by: Dave Love <d.love@dl.ac.uk> 7;; Adapted-by: Dave Love <d.love@dl.ac.uk>
@@ -144,6 +145,7 @@
144 (setq outline-regexp ";;; \\|(....") 145 (setq outline-regexp ";;; \\|(....")
145 (make-local-variable 'comment-start) 146 (make-local-variable 'comment-start)
146 (setq comment-start ";") 147 (setq comment-start ";")
148 (set (make-local-variable 'comment-add) 1)
147 (make-local-variable 'comment-start-skip) 149 (make-local-variable 'comment-start-skip)
148 ;; Look within the line for a ; following an even number of backslashes 150 ;; Look within the line for a ; following an even number of backslashes
149 ;; after either a non-backslash or the line beginning. 151 ;; after either a non-backslash or the line beginning.
@@ -171,17 +173,11 @@
171 173
172(defvar scheme-mode-line-process "") 174(defvar scheme-mode-line-process "")
173 175
174(defvar scheme-mode-map nil 176(defvar scheme-mode-map
175 "Keymap for Scheme mode. 177 (let ((smap (make-sparse-keymap))
176All commands in `lisp-mode-shared-map' are inherited by this map.") 178 (map (make-sparse-keymap "Scheme")))
177 179 (set-keymap-parent smap lisp-mode-shared-map)
178(unless scheme-mode-map 180 (define-key smap [menu-bar scheme] (cons "Scheme" map))
179 (let ((map (make-sparse-keymap "Scheme")))
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)) 181 (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme))
186 (define-key map [uncomment-region] 182 (define-key map [uncomment-region]
187 '("Uncomment Out Region" . (lambda (beg end) 183 '("Uncomment Out Region" . (lambda (beg end)
@@ -192,7 +188,10 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
192 (define-key map [indent-line] '("Indent Line" . lisp-indent-line)) 188 (define-key map [indent-line] '("Indent Line" . lisp-indent-line))
193 (put 'comment-region 'menu-enable 'mark-active) 189 (put 'comment-region 'menu-enable 'mark-active)
194 (put 'uncomment-region 'menu-enable 'mark-active) 190 (put 'uncomment-region 'menu-enable 'mark-active)
195 (put 'indent-region 'menu-enable 'mark-active))) 191 (put 'indent-region 'menu-enable 'mark-active)
192 smap)
193 "Keymap for Scheme mode.
194All commands in `lisp-mode-shared-map' are inherited by this map.")
196 195
197;; Used by cmuscheme 196;; Used by cmuscheme
198(defun scheme-mode-commands (map) 197(defun scheme-mode-commands (map)
@@ -222,14 +221,11 @@ Entry to this mode calls the value of `scheme-mode-hook'
222if that value is non-nil." 221if that value is non-nil."
223 (interactive) 222 (interactive)
224 (kill-all-local-variables) 223 (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) 224 (use-local-map scheme-mode-map)
231 (setq major-mode 'scheme-mode) 225 (setq major-mode 'scheme-mode)
232 (setq mode-name "Scheme")) 226 (setq mode-name "Scheme")
227 (scheme-mode-variables)
228 (run-mode-hooks 'scheme-mode-hook))
233 229
234(defgroup scheme nil 230(defgroup scheme nil
235 "Editing Scheme code" 231 "Editing Scheme code"
@@ -346,7 +342,7 @@ See `run-hooks'."
346 "Default expressions to highlight in Scheme modes.") 342 "Default expressions to highlight in Scheme modes.")
347 343
348;;;###autoload 344;;;###autoload
349(defun dsssl-mode () 345(define-derived-mode dsssl-mode scheme-mode "DSSSL"
350 "Major mode for editing DSSSL code. 346 "Major mode for editing DSSSL code.
351Editing commands are similar to those of `lisp-mode'. 347Editing commands are similar to those of `lisp-mode'.
352 348
@@ -357,20 +353,16 @@ Blank lines separate paragraphs. Semicolons start comments.
357Entering this mode runs the hooks `scheme-mode-hook' and then 353Entering this mode runs the hooks `scheme-mode-hook' and then
358`dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if 354`dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if
359that variable's value is a string." 355that variable's value is a string."
360 (interactive)
361 (kill-all-local-variables)
362 (use-local-map scheme-mode-map)
363 (scheme-mode-initialize)
364 (make-local-variable 'page-delimiter) 356 (make-local-variable 'page-delimiter)
365 (setq page-delimiter "^;;;" ; ^L not valid SGML char 357 (setq page-delimiter "^;;;" ; ^L not valid SGML char
366 major-mode 'dsssl-mode 358 major-mode 'dsssl-mode
367 mode-name "DSSSL") 359 mode-name "DSSSL")
368 ;; Insert a suitable SGML declaration into an empty buffer. 360 ;; Insert a suitable SGML declaration into an empty buffer.
361 ;; FIXME: This should use `auto-insert-alist' instead.
369 (and (zerop (buffer-size)) 362 (and (zerop (buffer-size))
370 (stringp dsssl-sgml-declaration) 363 (stringp dsssl-sgml-declaration)
371 (not buffer-read-only) 364 (not buffer-read-only)
372 (insert dsssl-sgml-declaration)) 365 (insert dsssl-sgml-declaration))
373 (scheme-mode-variables)
374 (setq font-lock-defaults '(dsssl-font-lock-keywords 366 (setq font-lock-defaults '(dsssl-font-lock-keywords
375 nil t (("+-*/.<>=?$%_&~^:" . "w")) 367 nil t (("+-*/.<>=?$%_&~^:" . "w"))
376 beginning-of-defun 368 beginning-of-defun
@@ -378,9 +370,7 @@ that variable's value is a string."
378 (set (make-local-variable 'imenu-case-fold-search) nil) 370 (set (make-local-variable 'imenu-case-fold-search) nil)
379 (setq imenu-generic-expression dsssl-imenu-generic-expression) 371 (setq imenu-generic-expression dsssl-imenu-generic-expression)
380 (set (make-local-variable 'imenu-syntax-alist) 372 (set (make-local-variable 'imenu-syntax-alist)
381 '(("+-*/.<>=?$%_&~^:" . "w"))) 373 '(("+-*/.<>=?$%_&~^:" . "w"))))
382 (run-hooks 'scheme-mode-hook)
383 (run-hooks 'dsssl-mode-hook))
384 374
385;; Extra syntax for DSSSL. This isn't separated from Scheme, but 375;; Extra syntax for DSSSL. This isn't separated from Scheme, but
386;; shouldn't cause much trouble in scheme-mode. 376;; shouldn't cause much trouble in scheme-mode.
@@ -558,5 +548,5 @@ that variable's value is a string."
558 548
559(provide 'scheme) 549(provide 'scheme)
560 550
561;;; arch-tag: a8f06bc1-ad11-42d2-9e36-ce651df37a90 551;; arch-tag: a8f06bc1-ad11-42d2-9e36-ce651df37a90
562;;; scheme.el ends here 552;;; scheme.el ends here