Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/sml-mode/sml-mode.el
ViewVC logotype

Diff of /sml/trunk/sml-mode/sml-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 543, Sat Feb 19 14:17:52 2000 UTC revision 544, Tue Feb 22 22:56:38 2000 UTC
# Line 191  Line 191 
191      ("\\<\\(\\(data\\|abs\\|with\\|eq\\)?type\\)\\s-+\\('\\sw+\\s-+\\)*\\(\\sw+\\)"      ("\\<\\(\\(data\\|abs\\|with\\|eq\\)?type\\)\\s-+\\('\\sw+\\s-+\\)*\\(\\sw+\\)"
192       (1 font-lock-keyword-face)       (1 font-lock-keyword-face)
193       (4 font-lock-type-def-face))       (4 font-lock-type-def-face))
194      ("\\<\\(val\\)\\s-+\\(\\sw+\\>\\s-*\\)?\\(\\sw+\\)\\s-*="      ("\\<\\(val\\)\\s-+\\(\\sw+\\>\\s-*\\)?\\(\\sw+\\)\\s-*[=:]"
195       (1 font-lock-keyword-face)       (1 font-lock-keyword-face)
196       ;;(6 font-lock-variable-def-face nil t)       ;;(6 font-lock-variable-def-face nil t)
197       (3 font-lock-variable-name-face))       (3 font-lock-variable-name-face))
# Line 305  Line 305 
305     (let ((text     (let ((text
306            (save-excursion            (save-excursion
307              (backward-char 2)           ;back over the just inserted "| "              (backward-char 2)           ;back over the just inserted "| "
308              (sml-find-matching-starter sml-pipehead-re              (let ((sym (sml-find-matching-starter sml-pipeheads
309                                         (sml-op-prec "|" 'back))                                                    (sml-op-prec "|" 'back))))
310              (let ((sym (sml-forward-sym)))                (sml-forward-sym)
311                (sml-forward-spaces)                (sml-forward-spaces)
312                (cond                (cond
313                 ((string= sym "|")                 ((string= sym "|")
# Line 334  Line 334 
334                    (sml-forward-spaces))                    (sml-forward-spaces))
335                  (concat sym "  = "))                  (concat sym "  = "))
336                 ((member sym '("case" "handle" "fn" "of")) " => ")                 ((member sym '("case" "handle" "fn" "of")) " => ")
337                 ((member sym '("abstype" "datatype")) "")                 ;;((member sym '("abstype" "datatype")) "")
338                 (t (error "Wow, now, there's a bug")))))))                 (t ""))))))
339    
340       (insert text)       (insert text)
341       (indent-according-to-mode)       (indent-according-to-mode)
# Line 378  Line 378 
378  (defun sml-indent-line ()  (defun sml-indent-line ()
379    "Indent current line of ML code."    "Indent current line of ML code."
380    (interactive)    (interactive)
381    (indent-line-to (sml-calculate-indentation)))    (let ((savep (> (current-column) (current-indentation)))
382            (indent (or (ignore-errors (sml-calculate-indentation)) 0)))
383        (if savep
384            (save-excursion (indent-line-to indent))
385          (indent-line-to indent))))
386    
387  (defun sml-back-to-outer-indent ()  (defun sml-back-to-outer-indent ()
388    "Unindents to the next outer level of indentation."    "Unindents to the next outer level of indentation."
# Line 444  Line 448 
448          (and (setq data (assoc sym sml-close-paren))          (and (setq data (assoc sym sml-close-paren))
449               (sml-indent-relative sym data))               (sml-indent-relative sym data))
450    
451          (and (looking-at sml-starters-re)          (and (member (save-excursion (sml-forward-sym)) sml-starters-syms)
452               (let ((sym (unless (save-excursion (sml-backward-arg))               (let ((sym (unless (save-excursion (sml-backward-arg))
453                            (sml-backward-spaces)                            (sml-backward-spaces)
454                            (sml-backward-sym))))                            (sml-backward-sym))))
455                 (if sym (sml-get-sym-indent sym)                 (if sym (sml-get-sym-indent sym)
456                   ;; FIXME: this can take a *long* time !!                   ;; FIXME: this can take a *long* time !!
457                   (sml-find-matching-starter sml-starters-re)                   (sml-find-matching-starter sml-starters-syms)
458                   (current-column))))                   (current-column))))
459    
460          (and (string= sym "|") (sml-indent-pipe))          (and (string= sym "|") (sml-indent-pipe))
# Line 466  Line 470 
470         (sml-delegated-indent))))         (sml-delegated-indent))))
471    
472  (defun sml-indent-pipe ()  (defun sml-indent-pipe ()
473    (when (sml-find-matching-starter sml-pipehead-re    (let ((sym (sml-find-matching-starter sml-pipeheads
474                                     (sml-op-prec "|" 'back))                                          (sml-op-prec "|" 'back))))
475      (if (looking-at "|")      (when sym
476          (if (string= sym "|")
477          (if (sml-bolp) (current-column) (sml-indent-pipe))          (if (sml-bolp) (current-column) (sml-indent-pipe))
478        (let ((pipe-indent (or (cdr (assoc "|" sml-symbol-indent)) -2)))        (let ((pipe-indent (or (cdr (assoc "|" sml-symbol-indent)) -2)))
479          (when (looking-at "\\(data\\|abs\\)type\\>")            (when (member sym '("datatype" "abstype"))
480            (re-search-forward "="))            (re-search-forward "="))
481          (sml-forward-sym)          (sml-forward-sym)
482          (sml-forward-spaces)          (sml-forward-spaces)
483          (+ pipe-indent (current-column))))))            (+ pipe-indent (current-column)))))))
484    
485  (defun sml-find-forward (re)  (defun sml-find-forward (re)
486    (sml-forward-spaces)    (sml-forward-spaces)
# Line 567  Line 572 
572      (if sym-indent      (if sym-indent
573          ;; the previous sym is an indentation introducer: follow the rule          ;; the previous sym is an indentation introducer: follow the rule
574          (let ((indent-after (or (cdr (assoc sym-after sml-symbol-indent)) 0)))          (let ((indent-after (or (cdr (assoc sym-after sml-symbol-indent)) 0)))
575            (if noindent (current-column) (+ sym-indent indent-after)))            (if noindent
576                  ;;(current-column)
577                  sym-indent
578                (+ sym-indent indent-after)))
579        ;; default-default        ;; default-default
580        (let* ((prec-after (sml-op-prec sym-after 'back))        (let* ((prec-after (sml-op-prec sym-after 'back))
581               (prec (or (sml-op-prec sym-before 'back) prec-after 100)))               (prec (or (sml-op-prec sym-before 'back) prec-after 100)))
# Line 583  Line 591 
591          (when noindent          (when noindent
592            (sml-move-if            (sml-move-if
593             (sml-backward-spaces)             (sml-backward-spaces)
594             (string-match sml-starters-re (or (sml-backward-sym) ""))))             (member (sml-backward-sym) sml-starters-syms)))
595          (current-column)))))          (current-column)))))
596    
597    
# Line 600  Line 608 
608      (current-column)))      (current-column)))
609    
610    
611  (defun sml-find-matching-starter (regexp &optional prec)  (defun sml-find-matching-starter (syms &optional prec)
612      (let (sym)
613    (ignore-errors    (ignore-errors
614      (sml-backward-sexp prec)        (while
615      (while (not (or (looking-at regexp) (bobp)))            (progn (sml-backward-sexp prec)
616        (sml-backward-sexp prec))                   (setq sym (save-excursion (sml-forward-sym)))
617      (not (bobp))))                   (not (or (member sym syms) (bobp)))))
618          (unless (bobp) sym))))
619    
620  (defun sml-comment-indent ()  (defun sml-comment-indent ()
621    (if (looking-at "^(\\*")              ; Existing comment at beginning    (if (looking-at "^(\\*")              ; Existing comment at beginning

Legend:
Removed from v.543  
changed lines
  Added in v.544

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0