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 331, Sat Jun 12 15:04:53 1999 UTC revision 332, Tue Jun 15 00:51:38 1999 UTC
# Line 104  Line 104 
104    
105  ;;; VERSION STRING  ;;; VERSION STRING
106    
107  (defconst sml-mode-version-string  (defconst sml-mode-version-string "sml-mode, version 3.9.1")
   "sml-mode, version 3.3")  
108    
109  (require 'cl)  (require 'cl)
110  (require 'sml-util)  (require 'sml-util)
# Line 123  Line 122 
122  (defvar sml-pipe-indent -2  (defvar sml-pipe-indent -2
123    "*Extra (usually negative) indentation for lines beginning with `|'.")    "*Extra (usually negative) indentation for lines beginning with `|'.")
124    
 (defvar sml-indent-case-arm 0  
   "*Indentation of case arms.")  
   
125  (defvar sml-indent-case-of 2  (defvar sml-indent-case-of 2
126    "*Indentation of an `of' on its own line.")    "*Indentation of an `of' on its own line.")
127    
 (defvar sml-indent-equal -2  
   "*Extra (usually negative) indenting for lines beginning with `='.")  
   
 (defvar sml-indent-fn -3  
   "*Extra (usually negative) indenting for lines beginning with `fn'.")  
   
 ;;(defvar sml-indent-paren -1  
 ;;  "*Extra (usually negative) indenting for lines beginning with `('.")  
   
128  (defvar sml-indent-args 4  (defvar sml-indent-args 4
129    "*Indentation of args placed on a separate line.")    "*Indentation of args placed on a separate line.")
130    
# Line 153  Line 140 
140  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
141  seems nicer...")  seems nicer...")
142    
 (defvar sml-nested-if-indent nil  
   "*Determine how nested if-then-else will be formatted:  
     If t: if exp1 then exp2               If nil:   if exp1 then exp2  
           else if exp3 then exp4                    else if exp3 then exp4  
           else if exp5 then exp6                         else if exp5 then exp6  
           else exp7                                           else exp7")  
   
 (defvar sml-type-of-indent nil  
   "*How to indent `let' `struct' etc.  
     If t:  fun foo bar = let              If nil:  fun foo bar = let  
                              val p = 4                 val p = 4  
                          in                        in  
                              bar + p                   bar + p  
                          end                       end  
   
 Will not have any effect if the starting keyword is first on the line.")  
   
143  (defvar sml-electric-semi-mode nil  (defvar sml-electric-semi-mode nil
144    "*If t, `\;' will self insert, reindent the line, and do a newline.    "*If t, `\;' will self insert, reindent the line, and do a newline.
145  If nil, just insert a `\;'. (To insert while t, do: C-q \;).")  If nil, just insert a `\;'. (To insert while t, do: C-q \;).")
146    
 (defvar sml-paren-lookback 1000  
   "*How far back (in chars) the indentation algorithm should look  
 for open parenthesis. High value means slow indentation algorithm. A  
 value of 1000 (being the equivalent of 20-30 lines) should suffice  
 most uses. (A value of nil, means do not look at all)")  
   
147  ;;; OTHER GENERIC MODE VARIABLES  ;;; OTHER GENERIC MODE VARIABLES
148    
149  (defvar sml-mode-info "sml-mode"  (defvar sml-mode-info "sml-mode"
# Line 203  Line 167 
167    
168  (defvar sml-mode-abbrev-table nil "*SML mode abbrev table (default nil)")  (defvar sml-mode-abbrev-table nil "*SML mode abbrev table (default nil)")
169    
 (defvar sml-error-overlay t  
   "*Non-nil means use an overlay to highlight errorful code in the buffer.  
   
 This gets set when `sml-mode' is invoked\; if you don't like/want SML  
 source errors to be highlighted in this way, do something like  
   
   \(setq-default sml-error-overlay nil\)  
   
 in your `sml-load-hook', say.")  
   
 (make-variable-buffer-local 'sml-error-overlay)  
   
170  ;;; CODE FOR SML-MODE  ;;; CODE FOR SML-MODE
171    
172  (defun sml-mode-info ()  (defun sml-mode-info ()
# Line 236  Line 188 
188  Full documentation will be available after autoloading the function."))  Full documentation will be available after autoloading the function."))
189    
190    (autoload 'run-sml       "sml-proc"   sml-no-doc t)    (autoload 'run-sml       "sml-proc"   sml-no-doc t)
191    (autoload 'sml-make      "sml-proc"   sml-no-doc t)    (autoload 'sml-compile        "sml-proc"   sml-no-doc t)
192    (autoload 'sml-load-file   "sml-proc"   sml-no-doc t)    (autoload 'sml-load-file   "sml-proc"   sml-no-doc t)
   
193    (autoload 'switch-to-sml   "sml-proc"   sml-no-doc t)    (autoload 'switch-to-sml   "sml-proc"   sml-no-doc t)
194    (autoload 'sml-send-region "sml-proc"   sml-no-doc t)    (autoload 'sml-send-region "sml-proc"   sml-no-doc t)
195    (autoload 'sml-send-buffer "sml-proc"   sml-no-doc t)    (autoload 'sml-send-buffer    "sml-proc"   sml-no-doc t))
   (autoload 'sml-next-error  "sml-proc"   sml-no-doc t))  
196    
197  ;; font-lock setup  ;; font-lock setup
198    
# Line 297  Line 247 
247      (modify-syntax-entry ?l "(d" st)      (modify-syntax-entry ?l "(d" st)
248      (modify-syntax-entry ?s "(d" st)      (modify-syntax-entry ?s "(d" st)
249      (modify-syntax-entry ?d ")l" st)      (modify-syntax-entry ?d ")l" st)
250        (modify-syntax-entry ?\\ "." st)
251      (modify-syntax-entry ?* "." st)      (modify-syntax-entry ?* "." st)
252      st))      st))
253    
# Line 322  Line 273 
273    `(;;("\\<\\(l\\)\\(et\\|ocal\\)\\>" (1 ',sml-syntax-prop-table))    `(;;("\\<\\(l\\)\\(et\\|ocal\\)\\>" (1 ',sml-syntax-prop-table))
274      ;;("\\<\\(s\\)\\(ig\\truct\\)\\>" (1 ',sml-syntax-prop-table))      ;;("\\<\\(s\\)\\(ig\\truct\\)\\>" (1 ',sml-syntax-prop-table))
275      ;;("\\<en\\(d\\)\\>" (1 ',sml-syntax-prop-table))      ;;("\\<en\\(d\\)\\>" (1 ',sml-syntax-prop-table))
276        ("^\\s-*\\(\\\\\\)" (1 ',sml-syntax-prop-table))
277      ("(?\\(\\*\\))?" (1 (sml-get-depth-st)))))      ("(?\\(\\*\\))?" (1 (sml-get-depth-st)))))
278    
279  (defconst sml-font-lock-defaults  (defconst sml-font-lock-defaults
280    '(sml-font-lock-keywords nil nil ((?_ . "w") (?' . "w")) nil    '(sml-font-lock-keywords nil nil ((?_ . "w") (?' . "w")) nil
281                             (font-lock-syntactic-keywords . sml-font-lock-syntactic-keywords)))                             (font-lock-syntactic-keywords . sml-font-lock-syntactic-keywords)))
282    
 ;; code to get comment fontification working in the face of recursive  
 ;; comments.  It's lots more work than it should be.    -- stefan  
 ;; (defvar sml-font-cache '((0 . normal))  
 ;;   "List of (POSITION . STATE) pairs for an SML buffer.  
 ;; The STATE is either `normal', `comment', or `string'.  The POSITION is  
 ;; immediately after the token that caused the state change.")  
 ;; (make-variable-buffer-local 'sml-font-cache)  
   
 ;; (defun sml-font-comments-and-strings (limit)  
 ;;   "Fontify SML comments and strings up to LIMIT.  
 ;; Handles nested comments and SML's escapes for breaking a string over lines.  
 ;; Uses sml-font-cache to maintain the fontification state over the buffer."  
 ;;   (let ((beg (point))  
 ;;      last class)  
 ;;     (while (< beg limit)  
 ;;       (while (and sml-font-cache  
 ;;                (> (caar sml-font-cache) beg))  
 ;;      (pop sml-font-cache))  
 ;;       (setq last (caar sml-font-cache))  
 ;;       (setq class (cdar sml-font-cache))  
 ;;       (goto-char last)  
 ;;       (cond  
 ;;        ((eq class 'normal)  
 ;;      (cond  
 ;;       ((not (re-search-forward "\\((\\*\\)\\|\\(\"\\)" limit t))  
 ;;        (goto-char limit))  
 ;;       ((match-beginning 1)  
 ;;        (push (cons (point) 'comment) sml-font-cache))  
 ;;       ((match-beginning 2)  
 ;;        (push (cons (point) 'string) sml-font-cache))))  
 ;;        ((eq class 'comment)  
 ;;      (cond  
 ;;       ((let ((nest 1))  
 ;;          (while (and (> nest 0)  
 ;;                      (re-search-forward "\\((\\*\\)\\|\\(\\*)\\)" limit t))  
 ;;            (cond  
 ;;             ((match-beginning 1) (incf nest))  
 ;;             ((match-beginning 2) (decf nest))))  
 ;;          (> nest 0))  
 ;;        (goto-char limit))  
 ;;       (t  
 ;;        (push (cons (point) 'normal) sml-font-cache)))  
 ;;      (put-text-property (- last 2) (point) 'face 'font-lock-comment-face))  
 ;;        ((eq class 'string)  
 ;;      (while (and (re-search-forward  
 ;;                   "\\(\"\\)\\|\\(\\\\\\s-*\\\\\\)\\|\\(\\\\\"\\)" limit t)  
 ;;                   (not (match-beginning 1))))  
 ;;      (cond  
 ;;       ((match-beginning 1)  
 ;;        (push (cons (point) 'normal) sml-font-cache))  
 ;;       (t  
 ;;        (goto-char limit)))  
 ;;      (put-text-property (- last 1) (point) 'face 'font-lock-string-face)))  
 ;;       (setq beg (point)))))  
   
 ;;; H A C K   A T T A C K !   X E M A C S   V E R S U S   E M A C S  
   
 ;; (cond ((fboundp 'make-extent)  
 ;;        ;; suppose this is XEmacs  
   
 ;;        (defun sml-make-overlay ()  
 ;;          "Create a new text overlay (extent) for the SML buffer."  
 ;;          (let ((ex (make-extent 1 1)))  
 ;;            (set-extent-property ex 'face 'zmacs-region) ex))  
   
 ;;        (defalias 'sml-is-overlay 'extentp)  
   
 ;;        (defun sml-overlay-active-p ()  
 ;;          "Determine whether the current buffer's error overlay is visible."  
 ;;          (and (sml-is-overlay sml-error-overlay)  
 ;;               (not (zerop (extent-length sml-error-overlay)))))  
   
 ;;        (defalias 'sml-move-overlay 'set-extent-endpoints))  
   
 ;;       ((fboundp 'make-overlay)  
        ;; otherwise assume it's Emacs  
   
        (defun sml-make-overlay ()  
          "Create a new text overlay (extent) for the SML buffer."  
          (let ((ex (make-overlay 0 0)))  
            (overlay-put ex 'face 'region) ex))  
   
        (defalias 'sml-is-overlay 'overlayp)  
   
        (defun sml-overlay-active-p ()  
          "Determine whether the current buffer's error overlay is visible."  
          (and (sml-is-overlay sml-error-overlay)  
               (not (equal (overlay-start sml-error-overlay)  
                           (overlay-end sml-error-overlay)))))  
   
        (defalias 'sml-move-overlay 'move-overlay);;)  
 ;;       (t  
 ;;        ;; what *is* this!?  
 ;;        (defalias 'sml-is-overlay 'ignore)  
 ;;        (defalias 'sml-overlay-active-p 'ignore)  
 ;;        (defalias 'sml-make-overlay 'ignore)  
 ;;        (defalias 'sml-move-overlay 'ignore)))  
283    
284  ;;; MORE CODE FOR SML-MODE  ;;; MORE CODE FOR SML-MODE
285    
# Line 460  Line 315 
315  sml-case-indent (default nil)  sml-case-indent (default nil)
316      Determine the way to indent case-of expression.      Determine the way to indent case-of expression.
317    
 sml-nested-if-indent (default nil)  
     Determine how nested if-then-else expressions are formatted.  
   
 sml-type-of-indent (default nil)  
     How to indent let, struct, local, etc.  
     Will not have any effect if the starting keyword is first on the line.  
   
318  sml-electric-semi-mode (default nil)  sml-electric-semi-mode (default nil)
319      If t, a `\;' will reindent line, and perform a newline.      If t, a `\;' will reindent line, and perform a newline.
320    
 sml-paren-lookback (default 1000)  
     Determines how far back (in chars) the indentation algorithm should  
     look to match parenthesis. A value of nil, means do not look at all.  
   
321  Mode map  Mode map
322  ========  ========
323  \\{sml-mode-map}"  \\{sml-mode-map}"
# Line 501  Line 345 
345    (set (make-local-variable 'comment-column) 40)    (set (make-local-variable 'comment-column) 40)
346    (set (make-local-variable 'comment-start-skip) "(\\*+[ \t]?")    (set (make-local-variable 'comment-start-skip) "(\\*+[ \t]?")
347    (set (make-local-variable 'comment-indent-function) 'sml-comment-indent)    (set (make-local-variable 'comment-indent-function) 'sml-comment-indent)
348    (set (make-local-variable 'font-lock-defaults) sml-font-lock-defaults)    (set (make-local-variable 'font-lock-defaults) sml-font-lock-defaults))
   ;;(set (make-local-variable 'parse-sexp-lookup-properties) t)  
   ;;(set (make-local-variable 'parse-sexp-ignore-comments) t)  
   (setq sml-error-overlay (and sml-error-overlay (sml-make-overlay))))  
   
 (defun sml-error-overlay (undo &optional beg end buffer)  
   "Move `sml-error-overlay' so it surrounds the text region in the  
 current buffer. If the buffer-local variable `sml-error-overlay' is  
 non-nil it should be an overlay \(or extent, in XEmacs speak\)\; this  
 function moves the overlay over the current region. If the optional  
 BUFFER argument is given, move the overlay in that buffer instead of  
 the current buffer.  
   
 Called interactively, the optional prefix argument UNDO indicates that  
 the overlay should simply be removed: \\[universal-argument] \  
 \\[sml-error-overlay]."  
   (interactive "P")  
   (save-excursion  
     (set-buffer (or buffer (current-buffer)))  
     (if (sml-is-overlay sml-error-overlay)  
         (if undo  
             (sml-move-overlay sml-error-overlay 1 1)  
           ;; if active regions, signals mark not active if no region set  
           (let ((beg (or beg (region-beginning)))  
                 (end (or end (region-end))))  
             (sml-move-overlay sml-error-overlay beg end))))))  
349    
350  (defun sml-electric-pipe ()  (defun sml-electric-pipe ()
351    "Insert a \"|\".    "Insert a \"|\".
# Line 661  Line 480 
480                                     (looking-at "[\t ]*\\\\"))                                     (looking-at "[\t ]*\\\\"))
481                     (progn (previous-line 1) (current-indentation))                     (progn (previous-line 1) (current-indentation))
482                   (if (re-search-backward "[^\\\\]\"" nil t)                   (if (re-search-backward "[^\\\\]\"" nil t)
483                       (1+ (current-indentation))                       (1+ (current-column))
484                     0))))                     0))))
485    
486          (and (looking-at "in\\>")       ; Match the beginning let/local          (and (looking-at "in\\>")       ; Match the beginning let/local
# Line 674  Line 493 
493          (and (looking-at "else\\>")     ; Match the if          (and (looking-at "else\\>")     ; Match the if
494               (progn               (progn
495                 (sml-find-match-backward "\\<else\\>" "\\<if\\>")                 (sml-find-match-backward "\\<else\\>" "\\<if\\>")
496                 (sml-move-if (backward-word 1)                 ;;(sml-move-if (backward-word 1)
497                              (and sml-nested-if-indent                 ;;           (and sml-nested-if-indent
498                                   (looking-at "else[ \t]+if\\>")))                 ;;                (looking-at "else[ \t]+if\\>")))
499                 (current-column)))                 (if (sml-dangling-sym)
500                         (sml-indent-default 'noindent)
501                     (current-column))))
502    
503          (and (looking-at "then\\>")     ; Match the if + extra indentation          (and (looking-at "then\\>")     ; Match the if + extra indentation
504               (sml-find-match-indent "\\<then\\>" "\\<if\\>" t))               (sml-find-match-indent "\\<then\\>" "\\<if\\>" t))
# Line 698  Line 519 
519          (sml-indent-arg)          (sml-indent-arg)
520          (sml-indent-default))))))          (sml-indent-default))))))
521    
 ;;        (let ((indent (current-column)))  
 ;;          ;;(skip-chars-forward "\t (")  
 ;;          (cond  
 ;;           ;; a "let fun" or "let val"  
 ;;           ((looking-at "let \\(fun\\|val\\)\\>")  
 ;;            (+ (current-column) 4 sml-indent-level))  
 ;;           ;; Started val/fun/structure...  
 ;;           ;; Indent after "=>" pattern, but only if its not an fn _ =>  
 ;;           ;; (890726)  
 ;;           ((looking-at ".*=>")  
 ;;            (if (looking-at ".*\\<fn\\>.*=>")  
 ;;                indent  
 ;;              (+ indent sml-indent-case-arm)))  
 ;;           ;; else keep the same indentation as previous line  
 ;;           (t indent)))))))))  
   
   
         ;;(and (setq indent (sml-get-indent)) nil)  
   
         ;;(and (looking-at "=[^>]") (+ indent sml-indent-equal))  
         ;;(and (looking-at "fn\\>") (+ indent sml-indent-fn))  
         ;;       (and (looking-at "(") (+ indent sml-indent-paren))  
   
         ;;(and sml-paren-lookback    ; Look for open parenthesis ?  
         ;;    (max indent (sml-get-paren-indent)))  
         ;;indent)))))  
   
522  (defun sml-indent-pipe ()  (defun sml-indent-pipe ()
523    (when (sml-find-matching-starter (concat "|\\|\\<of\\>\\|" sml-pipehead-re)    (when (sml-find-matching-starter (concat "|\\|\\<of\\>\\|" sml-pipehead-re)
524                                     (sml-op-prec "|" 'back))                                     (sml-op-prec "|" 'back))
# Line 764  Line 558 
558    (when sym    (when sym
559      (cdr (assoc* sym al      (cdr (assoc* sym al
560                   :test (lambda (x y) (string-match y x))))))                   :test (lambda (x y) (string-match y x))))))
561    
562  (defun sml-get-indent (data n &optional strict)  (defun sml-get-indent (data n &optional strict)
563    (eval (if (listp data)    (eval (if (listp data)
564              (nth n data)              (nth n data)
# Line 777  Line 572 
572                               (sml-forward-spaces))))))                               (sml-forward-spaces))))))
573    
574  (defun sml-get-sym-indent (sym &optional style)  (defun sml-get-sym-indent (sym &optional style)
575    "expects to be looking-at SYM."    "expects to be looking-at SYM.
576    If indentation is delegated, the point will be at the start of
577    the parent at the end of this function."
578    (let ((indent-data (sml-re-assoc sml-indent-starters sym))    (let ((indent-data (sml-re-assoc sml-indent-starters sym))
579          (delegate (eval (sml-re-assoc sml-delegate sym))))          (delegate (eval (sml-re-assoc sml-delegate sym))))
580      (or (when indent-data      (or (when indent-data
# Line 794  Line 591 
591              (let* ((parent-sym (save-excursion (sml-move-read (sml-forward-sym))))              (let* ((parent-sym (save-excursion (sml-move-read (sml-forward-sym))))
592                     (parent-indent (sml-re-assoc sml-indent-starters parent-sym)))                     (parent-indent (sml-re-assoc sml-indent-starters parent-sym)))
593                ;; check the special rules                ;; check the special rules
594                (sml-move-if (backward-word 1)                ;;(sml-move-if (backward-word 1)
595                             (looking-at "\\<else[ \t]+if\\>"))                  ;;         (looking-at "\\<else[ \t]+if\\>"))
596                (+ (if (sml-dangling-sym)                (+ (if (sml-dangling-sym)
597                       (sml-indent-default 'noindent)                       (sml-indent-default 'noindent)
598                     (current-column))                     (current-column))
# Line 816  Line 613 
613           (_ (sml-backward-spaces))           (_ (sml-backward-spaces))
614           (sym-before (sml-move-read (sml-backward-sym)))           (sym-before (sml-move-read (sml-backward-sym)))
615           (prec (or (sml-op-prec sym-before 'back) prec-after 100))           (prec (or (sml-op-prec sym-before 'back) prec-after 100))
616           sexp)           (sym-indent (and sym-before (sml-get-sym-indent sym-before))))
617      (or (and sym-before (sml-get-sym-indent sym-before))      (or (and sym-indent (if noindent (current-column) sym-indent))
618          (progn          (progn
619            ;;(sml-forward-sym)            ;;(sml-forward-sym)
620            (while (and (not (sml-bolp))            (while (and (not (sml-bolp))
# Line 825  Line 622 
622                        (not (sml-bolp)))                        (not (sml-bolp)))
623              (while (sml-move-if (sml-backward-sexp prec))))              (while (sml-move-if (sml-backward-sexp prec))))
624            (or (and (not (sml-bolp))            (or (and (not (sml-bolp))
625                     (= prec 65) (string-equal "=" sym-before) ;Yuck!!                     ;; If we backed over an equal char which was not the
626                       ;; polymorphic equality, then we did what amounts to
627                       ;; delegate indent from `=' to the corresponding head, so we
628                       ;; need to look at the preceding symbol and follow its
629                       ;; intentation instructions.
630                       (= prec 65) (string-equal "=" sym-before)
631                     (save-excursion                     (save-excursion
632                       (sml-backward-spaces)                       (sml-backward-spaces)
633                       (let* ((sym (sml-move-read (sml-backward-sym)))                       (let* ((sym (sml-move-read (sml-backward-sym)))
# Line 841  Line 643 
643    (save-excursion    (save-excursion
644      (skip-chars-backward " \t|") (bolp)))      (skip-chars-backward " \t|") (bolp)))
645    
 ;; (defun sml-goto-first-subexp ()  
 ;;   (let ((initpoint (point)))  
   
 ;;     (let ((argp (and (looking-at "[[({a-zA-Z0-9_'#~]\\|$")  
 ;;                   (not (looking-at (concat "[ \t]*" sml-not-arg-regexp))))))  
 ;;       (while (and argp (not (bobp)))  
 ;;      (let* ((endpoint (point))  
 ;;             (startpoint endpoint))  
 ;;        (setq argp  
 ;;              (ignore-errors  
 ;;               (sml-backward-sexp t)  
 ;;               (setq startpoint (point))  
 ;;               (and (not (looking-at (concat "[[(]\\|" sml-keywords-regexp)))  
 ;;                    (progn (sml-forward-sexp)  
 ;;                           (sml-skip-spaces)  
 ;;                           (>= (point) endpoint)))))  
 ;;        (goto-char (if argp startpoint endpoint))))  
 ;;       (let ((res (point)))  
 ;;      (sml-backward-spaces) (skip-syntax-backward "^ ")  
 ;;      (if (looking-at "*\\|:[^=]\\|->\\|of\\>")  
 ;;          (goto-char initpoint)  
 ;;        (goto-char res)  
 ;;        (sml-skip-spaces))))))  
646    
647  ;; maybe `|' should be set to word-syntax in our temp syntax table ?  ;; maybe `|' should be set to word-syntax in our temp syntax table ?
648  (defun sml-current-indentation ()  (defun sml-current-indentation ()
# Line 872  Line 651 
651      (skip-chars-forward " \t|")      (skip-chars-forward " \t|")
652      (current-column)))      (current-column)))
653    
 ;; (defun sml-get-indent ()  
 ;;   (save-excursion  
 ;;     ;;(let ((endpoint (point)))  
   
 ;;       ;; let's try to see whether we are inside an `f a1 a2 ..' expression  
 ;;       ;;(sml-goto-first-subexp)  
 ;;       ;;(setq rover (current-column))  
 ;;       ;;(sml-skip-spaces)  
 ;;       (cond  
 ;; ;;        ((< (point) endpoint)  
 ;; ;;   ;; we're not the first subexp  
 ;; ;;   (sml-forward-sexp)  
 ;; ;;   (if (and sml-indent-align-args  
 ;; ;;            (progn (sml-skip-spaces) (< (point) endpoint)))  
 ;; ;;       ;; we're not the second subexp  
 ;; ;;       (current-column)  
 ;; ;;     (+ rover sml-indent-args)))  
   
 ;;        ;; we're not inside an `f a1 a2 ..' expr  
 ;;        ((progn ;;(goto-char endpoint)  
 ;;             (sml-backward-spaces)  
 ;;             (/= (skip-chars-backward ";,") 0))  
 ;;      (sml-backward-sexps (concat "[[(]\\'\\|" sml-user-begin-symbols-re))  
 ;;      (current-column))  
   
 ;;        (t  
 ;;      (while (/= (current-column) (current-indentation))  
 ;;        (sml-backward-sexp t))  
 ;;      (when (looking-at "\\<of\\>") (forward-word 1))  
 ;;      (skip-chars-forward "\t |")  
 ;;      (let ((indent (current-column)))  
 ;;        ;;(skip-chars-forward "\t (")  
 ;;        (cond  
 ;;         ;; a "let fun" or "let val"  
 ;;         ((looking-at "let \\(fun\\|val\\)\\>")  
 ;;          (+ (current-column) 4 sml-indent-level))  
 ;;         ;; Started val/fun/structure...  
 ;;         ((looking-at sml-indent-starters-reg)  
 ;;          (+ (current-column) sml-indent-level))  
 ;;         ;; Indent after "=>" pattern, but only if its not an fn _ =>  
 ;;         ;; (890726)  
 ;;         ((looking-at ".*=>")  
 ;;          (if (looking-at ".*\\<fn\\>.*=>")  
 ;;              indent  
 ;;            (+ indent sml-indent-case-arm)))  
 ;;         ;; else keep the same indentation as previous line  
 ;;         (t indent)))))))  
   
 ;; (defun sml-get-paren-indent ()  
 ;;   (save-excursion  
 ;;     (condition-case ()  
 ;;      (progn  
 ;;        (up-list -1)  
 ;;        (if (save-excursion  
 ;;              (forward-char 1)  
 ;;              (looking-at sml-indent-starters-reg))  
 ;;            (1+ (+ (current-column) sml-indent-level))  
 ;;          (1+ (current-column))))  
 ;;       (error 0))))  
   
 ;; (defun sml-inside-comment-or-string-p ()  
 ;;   (let ((start (point)))  
 ;;     (if (save-excursion  
 ;;           (condition-case ()  
 ;;               (progn  
 ;;                 (search-backward "(*")  
 ;;                 (search-forward "*)")  
 ;;                 (forward-char -1)       ; A "*)" is not inside the comment  
 ;;                 (> (point) start))  
 ;;             (error nil)))  
 ;;         t  
 ;;       (let ((numb 0))  
 ;;         (save-excursion  
 ;;           (save-restriction  
 ;;             (narrow-to-region (progn (beginning-of-line) (point)) start)  
 ;;             (condition-case ()  
 ;;                 (while t  
 ;;                   (search-forward "\"")  
 ;;                   (setq numb (1+ numb)))  
 ;;               (error (if (and (not (zerop numb))  
 ;;                               (not (zerop (% numb 2))))  
 ;;                          t nil)))))))))  
   
 ;; (defun sml-find-match-backward (unquoted-this this match)  
 ;;   (let ((case-fold-search nil)  
 ;;      (level 1)  
 ;;      (pattern (concat this "\\|" match)))  
 ;;     (while (not (zerop level))  
 ;;       (if (sml-re-search-backward pattern)  
 ;;        (setq level (cond  
 ;;                     ((looking-at this) (1+ level))  
 ;;                     ((looking-at match) (1- level))))  
 ;;      ;; The right match couldn't be found  
 ;;      (error (concat "Unbalanced: " unquoted-this))))))  
654    
655  (defun sml-find-match-indent (this match &optional indented)  (defun sml-find-match-indent (this match &optional indented)
656    (save-excursion    (save-excursion
# Line 980  Line 665 
665      (sml-backward-sexp prec))      (sml-backward-sexp prec))
666    (not (bobp)))    (not (bobp)))
667    
 ;; (defun sml-re-search-backward (regexpr)  
 ;;   (let ((case-fold-search nil) (found t))  
 ;;     (if (re-search-backward regexpr nil t)  
 ;;         (progn  
 ;;           (condition-case ()  
 ;;               (while (sml-inside-comment-or-string-p)  
 ;;                 (re-search-backward regexpr))  
 ;;             (error (setq found nil)))  
 ;;           found)  
 ;;       nil)))  
   
668  (defun sml-comment-indent ()  (defun sml-comment-indent ()
669    (if (looking-at "^(\\*")              ; Existing comment at beginning    (if (looking-at "^(\\*")              ; Existing comment at beginning
670        0                                 ; of line stays there.        0                                 ; of line stays there.
# Line 1211  Line 885 
885        (indent-to indent)        (indent-to indent)
886        (insert "end"))))        (insert "end"))))
887    
 ;;; Load the menus, if they can be found on the load-path  
   
 (condition-case nil  
     (require 'sml-menus)  
   (error (message "Sorry, not able to load SML mode menus.")))  
   
888  ;;; & do the user's customisation  ;;; & do the user's customisation
   
 (add-hook 'sml-load-hook 'sml-mode-version t)  
   
889  (run-hooks 'sml-load-hook)  (run-hooks 'sml-load-hook)
890    
891  ;;; sml-mode.el has just finished.  ;;; sml-mode.el has just finished.

Legend:
Removed from v.331  
changed lines
  Added in v.332

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