Export new procedure C-COMPUTE-INDENTATION for use by Java mode.
authorChris Hanson <org/chris-hanson/cph>
Sun, 28 Jun 1998 20:24:15 +0000 (20:24 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sun, 28 Jun 1998 20:24:15 +0000 (20:24 +0000)
v7/src/edwin/cinden.scm
v7/src/edwin/edwin.pkg

index f6970f4127bee8f85d869fea330d58ede6b7ad9a..09f28eabce82326e49e1991b4759e348b965c07e 100644 (file)
@@ -1,8 +1,8 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Id: cinden.scm,v 1.16 1997/02/08 07:08:43 cph Exp $
+;;;    $Id: cinden.scm,v 1.17 1998/06/28 20:23:53 cph Exp $
 ;;;
-;;;    Copyright (c) 1986, 1989-97 Massachusetts Institute of Technology
+;;;    Copyright (c) 1986, 1989-98 Massachusetts Institute of Technology
 ;;;
 ;;;    This material was developed by the Scheme project at the
 ;;;    Massachusetts Institute of Technology, Department of
@@ -83,38 +83,40 @@ This is in addition to c-continued-statement-offset."
   exact-integer?)
 \f
 (define (c-indent-line start)
-  (let* ((start (line-start start 0))
-        (old-indentation (mark-indentation start))
-        (new-indentation
-         (let ((indentation (calculate-indentation start false)))
-           (cond ((not indentation)
-                  old-indentation)
-                 ((eq? indentation true)
-                  ;; Inside a comment.
-                  (mark-column
-                   (let* ((star?
-                           (char-match-forward #\* (indentation-end start)))
-                          (pend (whitespace-start start (group-start start)))
-                          (pstart (indentation-end pend))
-                          (comment-start
-                           (and (mark< pstart pend)
-                                (re-search-forward "/\\*[ \t]*" pstart pend
-                                                   false))))
-                     (cond ((not comment-start)
-                            pstart)
-                           (star?
-                            (mark1+ (re-match-start 0)))
-                           (else
-                            comment-start)))))
-                 ((char-match-forward #\# start)
-                  0)
-                 (else
-                  (indent-line:adjust-indentation (horizontal-space-end start)
-                                                  indentation))))))
-    (if (not (= new-indentation old-indentation))
+  (let ((old-indentation (mark-indentation start))
+       (new-indentation (c-compute-indentation start)))
+    (if (not (fix:= new-indentation old-indentation))
        (change-indentation new-indentation start))
     (- new-indentation old-indentation)))
 
+(define (c-compute-indentation start)
+  (let ((start (line-start start 0)))
+    (let ((old-indentation (mark-indentation start)))
+      (let ((indentation (calculate-indentation start #f)))
+       (cond ((not indentation)
+              old-indentation)
+             ((eq? indentation true)
+              ;; Inside a comment.
+              (mark-column
+               (let* ((star?
+                       (char-match-forward #\* (indentation-end start)))
+                      (pend (whitespace-start start (group-start start)))
+                      (pstart (indentation-end pend))
+                      (comment-start
+                       (and (mark< pstart pend)
+                            (re-search-forward "/\\*[ \t]*" pstart pend #f))))
+                 (cond ((not comment-start)
+                        pstart)
+                       (star?
+                        (mark1+ (re-match-start 0)))
+                       (else
+                        comment-start)))))
+             ((char-match-forward #\# start)
+              0)
+             (else
+              (indent-line:adjust-indentation (horizontal-space-end start)
+                                              indentation)))))))
+
 (define (indent-line:adjust-indentation start indentation)
   (cond ((or (looking-at-keyword? "case" start)
             (and (re-match-forward "[A-Za-z]" start)
index 7b800477c68b6fcfe66f32e92a7e65b49b06a842..aebfe2961bfcca219c11c351f786baf016bb0238 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: edwin.pkg,v 1.222 1998/03/08 07:26:25 cph Exp $
+$Id: edwin.pkg,v 1.223 1998/06/28 20:24:15 cph Exp $
 
 Copyright (c) 1989-98 Massachusetts Institute of Technology
 
@@ -626,6 +626,7 @@ MIT in each case. |#
   (files "cinden")
   (parent (edwin))
   (export (edwin)
+         c-compute-indentation
          c-indent-expression
          c-indent-line
          edwin-variable$c-argdecl-indent