 ;; it is indented like any other form (i.e. forms line up under first).
 
 (put 'begin 'yin-indent-function 0)
-(put 'case 'yin-indent-function 1)
-(put 'delay 'yin-indent-function 0)
-(put 'do 'yin-indent-function 2)
 (put 'lambda 'yin-indent-function 1)
 (put 'let 'yin-indent-function 'yin-let-indent)
-(put 'let* 'yin-indent-function 1)
-(put 'letrec 'yin-indent-function 1)
-(put 'let-values 'yin-indent-function 1) ; SRFI 11
-(put 'let*-values 'yin-indent-function 1) ; SRFI 11
-(put 'sequence 'yin-indent-function 0) ; SICP, not r4rs
-(put 'let-syntax 'yin-indent-function 1)
-(put 'letrec-syntax 'yin-indent-function 1)
-(put 'syntax-rules 'yin-indent-function 1)
-(put 'syntax-case 'yin-indent-function 2) ; not r5rs
-
-(put 'call-with-input-file 'yin-indent-function 1)
-(put 'with-input-from-file 'yin-indent-function 1)
-(put 'with-input-from-port 'yin-indent-function 1)
-(put 'call-with-output-file 'yin-indent-function 1)
-(put 'with-output-to-file 'yin-indent-function 1)
-(put 'with-output-to-port 'yin-indent-function 1)
-(put 'call-with-values 'yin-indent-function 1) ; r5rs?
-(put 'dynamic-wind 'yin-indent-function 3) ; r5rs?
--
-;;;; MIT Yin specific indentation.
-
-(if yin-mit-dialect
-    (progn
-      (put 'fluid-let 'yin-indent-function 1)
-      (put 'in-package 'yin-indent-function 1)
-      (put 'local-declare 'yin-indent-function 1)
-      (put 'macro 'yin-indent-function 1)
-      (put 'make-environment 'yin-indent-function 0)
-      (put 'named-lambda 'yin-indent-function 1)
-      (put 'using-syntax 'yin-indent-function 1)
-
-      (put 'with-input-from-string 'yin-indent-function 1)
-      (put 'with-output-to-string 'yin-indent-function 0)
-      (put 'with-values 'yin-indent-function 1)
-
-      (put 'syntax-table-define 'yin-indent-function 2)
-      (put 'list-transform-positive 'yin-indent-function 1)
-      (put 'list-transform-negative 'yin-indent-function 1)
-      (put 'list-search-positive 'yin-indent-function 1)
-      (put 'list-search-negative 'yin-indent-function 1)
-
-      (put 'access-components 'yin-indent-function 1)
-      (put 'assignment-components 'yin-indent-function 1)
-      (put 'combination-components 'yin-indent-function 1)
-      (put 'comment-components 'yin-indent-function 1)
-      (put 'conditional-components 'yin-indent-function 1)
-      (put 'disjunction-components 'yin-indent-function 1)
-      (put 'declaration-components 'yin-indent-function 1)
-      (put 'definition-components 'yin-indent-function 1)
-      (put 'delay-components 'yin-indent-function 1)
-      (put 'in-package-components 'yin-indent-function 1)
-      (put 'lambda-components 'yin-indent-function 1)
-      (put 'lambda-components* 'yin-indent-function 1)
-      (put 'lambda-components** 'yin-indent-function 1)
-      (put 'open-block-components 'yin-indent-function 1)
-      (put 'pathname-components 'yin-indent-function 1)
-      (put 'procedure-components 'yin-indent-function 1)
-      (put 'sequence-components 'yin-indent-function 1)
-      (put 'unassigned\?-components 'yin-indent-function 1)
-      (put 'unbound\?-components 'yin-indent-function 1)
-      (put 'variable-components 'yin-indent-function 1)))
 
 (provide 'yin-mode)
 

       ;; The function is called with point right after "define".
       (forward-comment (point-max))
       (if (eq (char-after) ?\() 2 0)))

(defun yin-font-lock-syntactic-face-function (state)
  (when (and (null (nth 3 state))
             (eq (char-after (nth 8 state)) ?#)
             (eq (char-after (1+ (nth 8 state))) ?\;))
    ;; It's a sexp-comment.  Tell parse-partial-sexp where it ends.
    (save-excursion
      (let ((pos (point))
            (end
             (condition-case err
                 (let ((parse-sexp-lookup-properties nil))
                   (goto-char (+ 2 (nth 8 state)))
                   ;; FIXME: this doesn't handle the case where the sexp
                   ;; itself contains a #; comment.
                   (forward-sexp 1)
                   (point))
               (scan-error (nth 2 err)))))
        (when (< pos (- end 2))
          (put-text-property pos (- end 2)
                             'syntax-table yin-sexp-comment-syntax-table))
        (put-text-property (- end 1) end 'syntax-table '(12)))))
  ;; Choose the face to use.
  (lisp-font-lock-syntactic-face-function state))

;;;###autoload
(define-derived-mode dsssl-mode yin-mode "DSSSL"
  "Major mode for editing DSSSL code.
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.
\\{yin-mode-map}
Entering this mode runs the hooks `yin-mode-hook' and then
`dsssl-mode-hook' and inserts the value of `dsssl-sgml-declaration' if
that variable's value is a string."
  (set (make-local-variable 'page-delimiter) "^;;;") ; ^L not valid SGML char
  ;; Insert a suitable SGML declaration into an empty buffer.
  ;; FIXME: This should use `auto-insert-alist' instead.
  (and (zerop (buffer-size))
       (stringp dsssl-sgml-declaration)
       (not buffer-read-only)
       (insert dsssl-sgml-declaration))
  (setq font-lock-defaults '(dsssl-font-lock-keywords
			     nil t (("+-*/.<>=?$%_&~^:" . "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"))))

;; Extra syntax for DSSSL.  This isn't separated from Yin, but
;; shouldn't cause much trouble in yin-mode.
(put 'element 'yin-indent-function 1)
(put 'mode 'yin-indent-function 1)
(put 'with-mode 'yin-indent-function 1)
(put 'make 'yin-indent-function 1)
(put 'style 'yin-indent-function 1)
(put 'root 'yin-indent-function 1)

(defvar dsssl-font-lock-keywords
  (eval-when-compile
    (list
     ;; Similar to Yin
     (list "(\\(define\\(-\\w+\\)?\\)\\>[ 	]*\\\((?\\)\\(\\sw+\\)\\>"
	   '(1 font-lock-keyword-face)
	   '(4 font-lock-function-name-face))
     (cons
      (concat "(\\("
	      ;; (make-regexp '("case" "cond" "else" "if" "lambda"
	      ;; "let" "let*" "letrec" "and" "or" "map" "with-mode"))
	      "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|"
	      "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode"
	      "\\)\\>")
      1)
     ;; DSSSL syntax
     '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ 	]*\\(\\sw+\\)"
       (1 font-lock-keyword-face)
       (2 font-lock-type-face))
     '("(\\(element\\)\\>[ 	]*(\\(\\S)+\\))"
       (1 font-lock-keyword-face)
       (2 font-lock-type-face))
     '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. yin
     ;; SGML markup (from sgml-mode) :
     '("<\\([!?][-a-z0-9]+\\)" 1 font-lock-keyword-face)
     '("<\\(/?[-a-z0-9]+\\)" 1 font-lock-function-name-face)))
  "Default expressions to highlight in DSSSL mode.")


(defvar calculate-lisp-indent-last-sexp)


  :type 'hook
  :group 'yin)


(defcustom yin-program-name "yin"
  "Program invoked by the `run-yin' command."
  :type 'string
  :group 'yin)


(defconst yin-sexp-comment-syntax-table
  (let ((st (make-syntax-table yin-mode-syntax-table)))
