Successfully indented all of standard lib with domtool-mode
authorAdam Chlipala <adamc@hcoop.net>
Sun, 16 Dec 2007 22:04:52 +0000 (22:04 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sun, 16 Dec 2007 22:04:52 +0000 (22:04 +0000)
elisp/domtool-mode.el
lib/apache.dtl
lib/easy_domain.dtl
lib/mailman.dtl

index db93b74..17c90c5 100644 (file)
@@ -83,8 +83,8 @@
           . domtool-font-lock-syntactic-keywords)
          (font-lock-syntactic-face-function
           . domtool-font-lock-syntactic-face-function)))
-  (set (make-local-variable 'comment-start) "(* ")
-  (set (make-local-variable 'comment-end) " *)")
+  (set (make-local-variable 'comment-start-regexp) "(\\*\\|{{")
+  (set (make-local-variable 'comment-end-regexp) "\\*)\\|}}")
   (set (make-local-variable 'comment-nested) t)
 
   (set (make-local-variable 'compile-command)
        (until-closed-helper (+ level 1)))
        ((= level 0)
        (current-indentation))
+       ((and
+        (string= (match-string 0) "with")
+        (save-excursion
+          (backward-char)
+          (looking-at "\\s-")))
+       (until-closed-helper level))
        (t
        (until-closed-helper (- level 1))))
 
     (back-to-indentation)
     (multiple-value-bind (previous-keyword base-indent)
         (save-excursion
-          (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\|let\\|in\\|val\\|type\\|if\\)\\_>"
+          (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\|let\\|in\\|val\\|type\\|if\\)\\_>\\|}}\\|{{"
                                   nil t)
               (values (match-string 0) (current-indentation))
             (values nil 0)))
           'noindent)
          ((nth 4 state)
           (domtool-calculate-comment-indent state))
+        ((looking-at "{{\\|\\_<\\(extern\\|val\\|type\\|context\\)\\_>")
+         0)
          ((looking-at "\\_<\\(with\\|end\\|in\\|else\\)\\_>")
           (until-closed))
          ((not previous-keyword)
           base-indent)
          ((string= previous-keyword "end")
           base-indent)
+         ((looking-at "\\_<\\(val\\|extern\\|context\\)\\_>")
+          base-indent)
          (t
           (+ base-indent domtool-indent)))))))
 
index 1c3b1ad..f176787 100644 (file)
@@ -31,13 +31,13 @@ extern val no_ssl : ssl;
 extern val use_cert : ssl_cert_path -> ssl;
 
 extern val vhost : host -> Vhost => [Domain]
-       {WebPlaces : [web_place],
-        SSL : ssl,
-        User : your_user,
-        Group : your_group,
-        DocumentRoot : your_path,
-        ServerAdmin : email,
-        SuExec : suexec_flag};
+  {WebPlaces : [web_place],
+  SSL : ssl,
+  User : your_user,
+  Group : your_group,
+  DocumentRoot : your_path,
+  ServerAdmin : email,
+  SuExec : suexec_flag};
 {{Add a new named Apache virtual host, specifying which nodes' Apache servers
   should answer requests for this host, whether it should use SSL, what UNIX
   user and group dynamic content generators should be run as, the filesystem
index 8491af0..56bc092 100644 (file)
@@ -4,31 +4,32 @@ val default_node : (node) = "mire";
 val web_node : (web_node) = "mire";
 
 val webAt =
-       \ n : (web_node) ->
-       \ host : (host) ->
-       \\ config : Vhost ->
-               (dns (dnsA host (ip_of_node (web_node_to_node n)));
+  \ n : (web_node) ->
+  \ host : (host) ->
+  \\ config : Vhost -> begin
+    dns (dnsA host (ip_of_node (web_node_to_node n)));
 
-               vhost host where
-                       WebPlaces = [web_place_default n]
-               with
-                       config
-               end);
+    vhost host where
+      WebPlaces = [web_place_default n]
+    with
+      config
+    end
+  end;
 
 val web = webAt web_node;
 
 val webAtIp =
-       \ ip : (your_ip) ->
-       \ host : (host) ->
-       \\ config : Vhost -> begin
-         dns (dnsA host (your_ip_to_ip ip));
+  \ ip : (your_ip) ->
+  \ host : (host) ->
+  \\ config : Vhost -> begin
+    dns (dnsA host (your_ip_to_ip ip));
 
-         vhost host where
-           WebPlaces = [web_place web_node ip]
-         with
-           config
-         end
-       end;
+    vhost host where
+      WebPlaces = [web_place web_node ip]
+    with
+      config
+    end
+  end;
 
 val addDefaultAlias = begin
   mailbox <- Mailbox;
@@ -44,33 +45,33 @@ val addWww = begin
 end;
 
 val dom =
-       \ d : (your_domain) ->
-       \\ config : Domain ->
-               domain d with
-                       dns (dnsNS "ns1.hcoop.net");
-                       dns (dnsNS "ns3.hcoop.net");
+  \ d : (your_domain) ->
+  \\ config : Domain ->
+  domain d with
+    dns (dnsNS "ns1.hcoop.net");
+    dns (dnsNS "ns3.hcoop.net");
 
-                       dns (dnsDefaultA (ip_of_node (web_node_to_node web_node)));
+    dns (dnsDefaultA (ip_of_node (web_node_to_node web_node)));
 
-                       handleMail;
-                       dns (dnsMX 1 "deleuze.hcoop.net");
+    handleMail;
+    dns (dnsMX 1 "deleuze.hcoop.net");
 
-                       createWWW : bool <- CreateWWW;
-                       if createWWW then
-                         addWww
-                       else
-                         Skip
-                       end;
+    createWWW : bool <- CreateWWW;
+    if createWWW then
+      addWww
+    else
+      Skip
+    end;
 
-                       defAl : bool <- DefaultAlias;
-                       if defAl then
-                         addDefaultAlias
-                       else
-                         Skip
-                       end;
+    defAl : bool <- DefaultAlias;
+    if defAl then
+      addDefaultAlias
+    else
+      Skip
+    end;
 
-                       config
-               end;
+    config
+  end;
 
 val nameserver = \host -> dns (dnsNS host);
 val dnsIP = \from -> \to -> dns (dnsA from to);
index 31cb02e..f2158b7 100644 (file)
@@ -22,10 +22,10 @@ extern val mailman_place_to_ip : mailman_place -> ip;
 {{Analogous to <tt>web_place</tt>, but based on <tt>mailman_node</tt>s}}
 
 extern val mailmanVhost : host -> [Domain]
-       {MailmanPlaces : [mailman_place],
-        SSL : ssl,
-        User : your_user,
-         ServerAdmin : email};
+  {MailmanPlaces : [mailman_place],
+  SSL : ssl,
+  User : your_user,
+  ServerAdmin : email};
 {{Create an Apache virtual host to serve as the web interface for some Mailman
   lists.}}