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-mode/trunk/sml-mode.el
ViewVC logotype

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

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

revision 340, Fri Jun 18 05:32:46 1999 UTC revision 341, Fri Jun 18 19:10:12 1999 UTC
# Line 116  Line 116 
116  (defvar sml-indent-level 4  (defvar sml-indent-level 4
117    "*Indentation of blocks in ML (see also `sml-structure-indent').")    "*Indentation of blocks in ML (see also `sml-structure-indent').")
118    
119  (defvar sml-structure-indent 4          ; Not currently an option.  (defvar sml-indent-args sml-indent-level
   "*Indentation of signature/structure/functor declarations.")  
   
 (defvar sml-pipe-indent -2  
   "*Extra (usually negative) indentation for lines beginning with `|'.")  
   
 (defvar sml-indent-args 4  
120    "*Indentation of args placed on a separate line.")    "*Indentation of args placed on a separate line.")
121    
122  (defvar sml-indent-align-args t  ;; (defvar sml-indent-align-args t
123    "*Whether the arguments should be aligned.")  ;;   "*Whether the arguments should be aligned.")
124    
125  (defvar sml-nested-if-indent t  ;; (defvar sml-case-indent nil
126    "*Determine how nested if-then-else will be formatted:  ;;   "*How to indent case-of expressions.
127      If t: if exp1 then exp2               If nil:   if exp1 then exp2  ;;     If t:   case expr                     If nil:   case expr of
128            else if exp3 then exp4                    else if exp3 then exp4  ;;               of exp1 => ...                            exp1 => ...
129            else if exp5 then exp6                         else if exp5 then exp6  ;;                | exp2 => ...                          | exp2 => ...
           else exp7                                           else exp7")  
   
 (defvar sml-case-indent nil  
   "*How to indent case-of expressions.  
     If t:   case expr                     If nil:   case expr of  
               of exp1 => ...                            exp1 => ...  
                | exp2 => ...                          | exp2 => ...  
130    
131  The first seems to be the standard in SML/NJ, but the second  ;; The first seems to be the standard in SML/NJ, but the second
132  seems nicer...")  ;; seems nicer...")
133    
134  (defvar sml-electric-semi-mode nil  (defvar sml-electric-semi-mode nil
135    "*If t, `\;' will self insert, reindent the line, and do a newline.    "*If t, `\;' will self insert, reindent the line, and do a newline.
# Line 313  Line 300 
300  sml-indent-level (default 4)  sml-indent-level (default 4)
301      The indentation of a block of code.      The indentation of a block of code.
302    
 sml-pipe-indent (default -2)  
     Extra indentation of a line starting with \"|\".  
   
 sml-case-indent (default nil)  
     Determine the way to indent case-of expression.  
   
303  sml-electric-semi-mode (default nil)  sml-electric-semi-mode (default nil)
304      If t, a `\;' will reindent line, and perform a newline.      If t, a `\;' will reindent line, and perform a newline.
305    
# Line 529  Line 510 
510                                     (sml-op-prec "|" 'back))                                     (sml-op-prec "|" 'back))
511      (if (looking-at "|")      (if (looking-at "|")
512          (if (sml-bolp) (current-column) (sml-indent-pipe))          (if (sml-bolp) (current-column) (sml-indent-pipe))
513          (let ((pipe-indent (or (cdr (assoc "|" sml-symbol-indent)) -2)))
514        (when (looking-at "\\(data\\|abs\\)type\\>")        (when (looking-at "\\(data\\|abs\\)type\\>")
515          (re-search-forward "="))          (re-search-forward "="))
516        (sml-forward-sym)        (sml-forward-sym)
517        (sml-forward-spaces)        (sml-forward-spaces)
518        (+ sml-pipe-indent (current-column)))))          (+ pipe-indent (current-column))))))
519    
520  (defun sml-find-forward (re)  (defun sml-find-forward (re)
521    (sml-forward-spaces)    (sml-forward-spaces)
# Line 579  Line 561 
561    (if (sml-dangling-sym)    (if (sml-dangling-sym)
562        (sml-indent-default 'noindent)        (sml-indent-default 'noindent)
563      (sml-move-if (backward-word 1)      (sml-move-if (backward-word 1)
564                   (and sml-nested-if-indent                   (looking-at sml-agglomerate-re))
                       (looking-at sml-agglomerate-re)))  
565      (current-column)))      (current-column)))
566    
567  (defun sml-get-sym-indent (sym &optional style)  (defun sml-get-sym-indent (sym &optional style)
# Line 698  Line 679 
679         (define-skeleton ,fsym         (define-skeleton ,fsym
680           ,(format "SML-mode skeleton for `%s..' expressions" name)           ,(format "SML-mode skeleton for `%s..' expressions" name)
681           ,interactor           ,interactor
682           ,(concat " " name " ") >           ,(concat name " ") >
683           ,@elements))))           ,@elements))))
684  (put 'sml-def-skeleton 'lisp-indent-function 2)  (put 'sml-def-skeleton 'lisp-indent-function 2)
685    
# Line 712  Line 693 
693    _ "\nin" > "\nend" >)    _ "\nin" > "\nend" >)
694    
695  (sml-def-skeleton "case" "Case expr: "  (sml-def-skeleton "case" "Case expr: "
696    str (if sml-case-indent "\nof " " of\n") > _ " => ")    str "\nof " > _ " => ")
697    
698  (sml-def-skeleton "signature" "Signature name: "  (sml-def-skeleton "signature" "Signature name: "
699    str " =\nsig" > "\n" > _ "\nend" >)    str " =\nsig" > "\n" > _ "\nend" >)
# Line 742  Line 723 
723    
724  (defvar sml-last-form "let")  (defvar sml-last-form "let")
725    
726    (defun sml-electric-space ()
727      "Expand a symbol into an SML form, or just insert a space.
728    If the point directly precedes a symbol for which an SML form exists,
729    the corresponding form is inserted."
730      (interactive)
731      (let* ((point (point))
732             (sym (sml-backward-sym)))
733        (if (not (and sym (assoc sym sml-forms-alist)))
734            (progn (goto-char point) (insert " "))
735          (delete-region (point) point)
736          (sml-insert-form sym nil))))
737    
738  (defun sml-insert-form (name newline)  (defun sml-insert-form (name newline)
739    "Interactive short-cut to insert a common ML form.    "Interactive short-cut to insert a common ML form.
740  If a perfix argument is given insert a newline and indent first, or  If a perfix argument is given insert a newline and indent first, or
# Line 761  Line 754 
754    (unless (or (not newline)    (unless (or (not newline)
755                (save-excursion (beginning-of-line) (looking-at "\\s-*$")))                (save-excursion (beginning-of-line) (looking-at "\\s-*$")))
756      (insert "\n"))      (insert "\n"))
757      (unless (/= ?w (char-syntax (char-before))) (insert " "))
758    (let ((f (cdr (assoc name sml-forms-alist))))    (let ((f (cdr (assoc name sml-forms-alist))))
759      (cond      (cond
760       ((commandp f) (command-execute f))       ((commandp f) (command-execute f))

Legend:
Removed from v.340  
changed lines
  Added in v.341

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