Commits

Anonymous committed aaf286a

Partial (mostly DSSSL) sync with GNU Emacs 21.3 <1067190397.3092.64.camel@bobcat.mine.nu>.

Comments (0)

Files changed (2)

+2003-10-26  Ville Skyttä  <scop@xemacs.org>
+
+	* scheme.el: Partial sync with GNU Emacs 21.3 (mostly DSSSL).
+	Add auto-mode-alist autoload cookie for *.dsl, *.dsssl.
+
 2003-03-09  Ben Wing  <ben@xemacs.org>
 
 	* Makefile:
-;;; scheme.el --- Scheme (and DSSSL) editing mode.
+;;; scheme.el --- Scheme (and DSSSL) editing mode
 
-;; Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 87, 88, 97, 1998 Free Software Foundation, Inc.
 
 ;; Author: Bill Rozas <jinx@martigny.ai.mit.edu>
+;; Adapted-by: Dave Love <d.love@dl.ac.uk>
 ;; Keywords: languages, lisp
 
 ;; This file is part of XEmacs.
 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ;; 02111-1307, USA.
 
-;;; Synched up with: FSF 20.2
+;;; Synched up with: GNU Emacs 20.2, partially 21.3.
 
 ;;; Commentary:
 
 ;; the `cmuscheme' package and also the implementation-specific
 ;; `xscheme' package.
 
+;; Here's a recipe to generate a TAGS file for DSSSL, by the way:
+;; etags --lang=scheme --regex='/[ \t]*(\(mode\|element\)[ \t
+;; ]+\([^ \t(
+;; ]+\)/\2/' --regex='/[ \t]*(element[ \t
+;; ]*([^)]+[ \t
+;; ]+\([^)]+\)[ \t
+;; ]*)/\1/' --regex='/(declare[^ \t
+;; ]*[ \t
+;; ]+\([^ \t
+;; ]+\)/\1/' "$@"
+
 ;;; Code:
 
 (require 'lisp-mode)
 
-(defvar scheme-mode-syntax-table nil "")
+(defvar scheme-mode-syntax-table nil)
 (if (not scheme-mode-syntax-table)
     (let ((i 0))
       (setq scheme-mode-syntax-table (make-syntax-table))
       (modify-syntax-entry ?# "_ p14")
       (modify-syntax-entry ?\\ "\\   ")))
 
-(defvar scheme-mode-abbrev-table nil "")
+(defvar scheme-mode-abbrev-table nil)
 (define-abbrev-table 'scheme-mode-abbrev-table ())
 
 (defvar scheme-imenu-generic-expression
-      '((nil 
-	 "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 4)
-	(" Types" 
-	 "^(define-class\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 1)
-	(" Macros"
-	 "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 2))
+      '((nil
+	 "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\sw+\\)" 4)
+	("Types"
+	 "^(define-class\\s-+(?\\(\\sw+\\)" 1)
+	("Macros"
+	 "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\sw+\\)" 2))
   "Imenu generic expression for Scheme mode.  See `imenu-generic-expression'.")
 
 (defun scheme-mode-variables ()
 ;; Used by cmuscheme
 (defun scheme-mode-commands (map)
   (define-key map "\e\C-q" 'indent-sexp))
-
 
 ;;;###autoload
 (defun scheme-mode ()
   "Major mode for editing Scheme code.
-Editing commands are similar to those of lisp-mode.
+Editing commands are similar to those of `lisp-mode'.
 
 In addition, if an inferior Scheme process is running, some additional
 commands will be defined, for evaluating expressions and controlling
 Delete converts tabs to spaces as it moves back.
 Blank lines separate paragraphs.  Semicolons start comments.
 \\{scheme-mode-map}
-Entry to this mode calls the value of scheme-mode-hook
+Entry to this mode calls the value of `scheme-mode-hook'
 if that value is non-nil."
   (interactive)
   (kill-all-local-variables)
 
 (defgroup scheme nil
   "Editing Scheme code"
+  ;; XEmacs change
   :group 'languages)
 
 (defcustom scheme-mit-dialect t
   "<!DOCTYPE style-sheet PUBLIC \"-//James Clark//DTD DSSSL Style Sheet//EN\">
 "
   "*An SGML declaration for the DSSSL file.
-This will be inserted into an empty buffer in dsssl-mode if it is
-defined as a string.  It is typically James Clark's style-sheet
+If it is defined as a string this will be inserted into an empty buffer
+which is in `dsssl-mode'.  It is typically James Clark's style-sheet
 doctype, as required for Jade."
+  :type '(choice (string :tag "Specified string")
+                 (const :tag "None" :value nil))
+  :group 'scheme)
+
+(defcustom scheme-mode-hook nil
+  "Normal hook run when entering `scheme-mode'.
+See `run-hooks'."
+  :type 'hook
+  :group 'scheme)
+
+(defcustom dsssl-mode-hook nil
+  "Normal hook run when entering `dsssl-mode'.
+See `run-hooks'."
+  :type 'hook
   :group 'scheme)
 
 (defvar dsssl-imenu-generic-expression
   ;; not sure it's the best way to organize it; perhaps one type
   ;; should be at the first level, though you don't see this anyhow if
   ;; it gets split up.
-  '((" Defines" 
-     "^(define\\s-+(?\\(\\(\\sw\\|\\s_\\)+\\)" 1)
-    (" Modes"
-     "^\\s-*(mode\\s-+\\(\\(\\sw\\|\\s-\\|\\s_\\)+\\)" 1)
-    (" Elements"
+  '(("Defines"
+     "^(define\\s-+(?\\(\\sw+\\)" 1)
+    ("Modes"
+     "^\\s-*(mode\\s-+\\(\\(\\sw\\|\\s-\\)+\\)" 1)
+    ("Elements"
      ;; (element foo ...) or (element (foo bar ...) ...)
      ;; Fixme: Perhaps it should do `root'.
-     "^\\s-*(element\\s-+(?\\(\\(\\sw\\|\\s-\\|\\s_\\)+\\))?" 1)
-    (" Declarations" 
-     "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 2))
+     "^\\s-*(element\\s-+(?\\(\\(\\sw\\|\\s-\\)+\\))?" 1)
+    ("Declarations"
+     "^(declare\\(-\\sw+\\)+\\>\\s-+\\(\\sw+\\)" 2))
   "Imenu generic expression for DSSSL mode.  See `imenu-generic-expression'.")
 
 ;;;###autoload
 (defun dsssl-mode ()
   "Major mode for editing DSSSL code.
-Editing commands are similar to those of lisp-mode.
+Editing commands are similar to those of `lisp-mode'.
 
 Commands:
 Delete converts tabs to spaces as it moves back.
 Blank lines separate paragraphs.  Semicolons start comments.
 \\{scheme-mode-map}
-Entry to this mode calls the value of dsssl-mode-hook
-if that value is non-nil and inserts the value of
-`dsssl-sgml-declaration' if that variable's value is a string."
+Entering this mode runs the hooks `scheme-mode-hook' and then
+`dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if
+that variable's value is a string."
   (interactive)
   (kill-all-local-variables)
   (use-local-map scheme-mode-map)
   (scheme-mode-initialize)
-  (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults '(dsssl-font-lock-keywords
-			     nil t (("+-*/.<>=!?$%_&~^:" . "w"))
-			     beginning-of-defun
-			     (font-lock-comment-start-regexp . ";")
-			     (font-lock-mark-block-function . mark-defun)))
   (make-local-variable 'page-delimiter)
   (setq page-delimiter "^;;;" ; ^L not valid SGML char
 	major-mode 'dsssl-mode
        (stringp dsssl-sgml-declaration)
        (not buffer-read-only)
        (insert dsssl-sgml-declaration))
+  (scheme-mode-variables)
+  (setq font-lock-defaults '(dsssl-font-lock-keywords
+			     nil t
+			     ;; XEmacs change
+			     ((?+ . "w") (?- . "w") (?* . "w") (?/ . "w")
+			      (?. . "w") (?< . "w") (?> . "w") (?= . "w")
+			      (?? . "w") (?$ . "w") (?% . "w") (?_ . "w")
+			      (?& . "w") (?~ . "w") (?^ . "w") (?: . "w"))
+			     beginning-of-defun
+			     (font-lock-mark-block-function . mark-defun)))
+  (set (make-local-variable 'imenu-case-fold-search) nil)
+  (setq imenu-generic-expression dsssl-imenu-generic-expression)
+  (set (make-local-variable 'imenu-syntax-alist)
+       '(("+-*/.<>=?$%_&~^:" . "w")))
   (run-hooks 'scheme-mode-hook)
-  (run-hooks 'dsssl-mode-hook)
-  (scheme-mode-variables)
-  (setq imenu-generic-expression dsssl-imenu-generic-expression))
+  (run-hooks 'dsssl-mode-hook))
 
 ;; Extra syntax for DSSSL.  This isn't separated from Scheme, but
 ;; shouldn't cause much trouble in scheme-mode.
     (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
     (if (and (elt state 2)
              (not (looking-at "\\sw\\|\\s_")))
-        ;; car of form doesn't seem to be a a symbol
+        ;; car of form doesn't seem to be a symbol
         (progn
           (if (not (> (save-excursion (forward-line 1) (point))
                       calculate-lisp-indent-last-sexp))
   (not (string-equal (substring string 0 1) "(")))
 
 (defun next-sexp-as-string ()
-  ;; Assumes that protected by a save-excursion
+  ;; Assumes that it is protected by a save-excursion
   (forward-sexp 1)
   (let ((the-end (point)))
     (backward-sexp 1)
   (skip-chars-forward " \t")
   (if (looking-at "[-a-zA-Z0-9+*/?!@$%^&_:~]")
       (lisp-indent-specform 2 state indent-point normal-indent)
-      (lisp-indent-specform 1 state indent-point normal-indent)))
+    (lisp-indent-specform 1 state indent-point normal-indent)))
 
 ;; (put 'begin 'scheme-indent-function 0), say, causes begin to be indented
 ;; like defun if the first form is placed on the next line, otherwise
 (put 'let 'scheme-indent-function 'scheme-let-indent)
 (put 'let* 'scheme-indent-function 1)
 (put 'letrec 'scheme-indent-function 1)
-(put 'sequence 'scheme-indent-function 0)
+(put 'sequence 'scheme-indent-function 0) ; SICP, not r4rs
+(put 'let-syntax 'scheme-indent-function 1)
+(put 'letrec-syntax 'scheme-indent-function 1)
+(put 'syntax-rules 'scheme-indent-function 1)
+
 
 (put 'call-with-input-file 'scheme-indent-function 1)
 (put 'with-input-from-file 'scheme-indent-function 1)
 (put 'call-with-output-file 'scheme-indent-function 1)
 (put 'with-output-to-file 'scheme-indent-function 1)
 (put 'with-output-to-port 'scheme-indent-function 1)
+(put 'call-with-values 'scheme-indent-function 1) ; r5rs?
+(put 'dynamic-wind 'scheme-indent-function 3) ; r5rs?
 
 ;;;; MIT Scheme specific indentation.
 
 ;;;###autoload(add-to-list 'auto-mode-alist '("\\.scm?\\(?:\\.[0-9]*\\)?\\'" . scheme-mode))
 ;;;###autoload(add-to-list 'auto-mode-alist '("\\.oak\\'" . scheme-mode))
 ;;;###autoload(add-to-list 'interpreter-mode-alist '("scm\\|guile" . scheme-mode))
+;;;###autoload(add-to-list 'auto-mode-alist '("\\.ds\\(?:ss\\)?l\\'" . dsssl-mode))
 
 (provide 'scheme)