From ae272cb5141c5347f205180b8ccf68eb56383ae2 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 16 Dec 2007 22:04:52 +0000 Subject: [PATCH] Successfully indented all of standard lib with domtool-mode --- elisp/domtool-mode.el | 16 +++++++-- lib/apache.dtl | 14 ++++---- lib/easy_domain.dtl | 83 ++++++++++++++++++++++--------------------- lib/mailman.dtl | 8 ++--- 4 files changed, 66 insertions(+), 55 deletions(-) diff --git a/elisp/domtool-mode.el b/elisp/domtool-mode.el index db93b74..17c90c5 100644 --- a/elisp/domtool-mode.el +++ b/elisp/domtool-mode.el @@ -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) @@ -107,6 +107,12 @@ (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)))) @@ -121,7 +127,7 @@ (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))) @@ -131,12 +137,16 @@ '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))))))) diff --git a/lib/apache.dtl b/lib/apache.dtl index 1c3b1ad..f176787 100644 --- a/lib/apache.dtl +++ b/lib/apache.dtl @@ -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 diff --git a/lib/easy_domain.dtl b/lib/easy_domain.dtl index 8491af0..56bc092 100644 --- a/lib/easy_domain.dtl +++ b/lib/easy_domain.dtl @@ -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); diff --git a/lib/mailman.dtl b/lib/mailman.dtl index 31cb02e..f2158b7 100644 --- a/lib/mailman.dtl +++ b/lib/mailman.dtl @@ -22,10 +22,10 @@ extern val mailman_place_to_ip : mailman_place -> ip; {{Analogous to web_place, but based on mailman_nodes}} 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.}} -- 2.20.1