setsa: enable spam checking on admin mail nodes
[hcoop/domtool2.git] / elisp / domtool-mode.el
index 039db8d..17c90c5 100644 (file)
 
 (defun domtool-syms-re (&rest syms)
   (concat "\\<" (regexp-opt syms t) "\\>"))
-(defconst domtool-types-regexp
-  (domtool-syms-re "proxy_target" "proxy_port" "mod_rewrite_cond_flag" "mod_rewrite_flag" "rewrite_arg" "redirect_code" "autoindex_option" "autoindex_width" "homedir_path" "dnsRecord" "apache_option" "authType" "location" "ssl" "ssl_cert_path" "suexec_flag" "web_node" "aliasTarget" "aliasSource" "email" "emailUser" "mail_node" "dnsKind" "master" "dns_node" "soa" "serial" "your_path" "your_group" "your_user" "group" "user" "node" "your_domain_host" "your_domain" "domain" "host" "ip" "no_newlines" "no_spaces" "bool" "string" "int")
-  "A regexp that matches Domtool types from the standard library.")
 
-(defconst domtool-contexts-regexp
-  (domtool-syms-re "Location" "Vhost" "Domain")
-  "A regexp that matches Domtool contexts from the standard library.")
-
-(defconst domtool-actions-regexp
-  (domtool-syms-re "errorDocument" "scriptAlias" "alias" "proxyPassReverse" "proxyPass" "rewriteLogLevel" "localProxyRewrite" "rewriteBase" "rewriteCond" "rewriteRule" "setEnv" "davFilesystem" "readmeName" "headerName" "unset_indexOptions" "set_indexOptions" "indexOptions" "addDescription" "mailmanWebHost" "dnsDefault" "dnsAlias" "dnsMail" "dnsIP" "nameserver" "dom" "web" "webAt" "relayMail" "handleMail" "dns" "addDefaultCharset" "action" "forceTypeOff" "forceType" "directoryIndex" "unset_options" "set_options" "options" "satisfyAny" "satisfyAll" "denyFrom" "denyFromAll" "allowFrom" "allowFromAll" "orderDenyAllow" "orderAllowDeny" "requireGroup" "requireUser" "requireValidUser" "authUserFile" "authName" "authType" "serverAliasDefault" "serverAlias" "serverAliasHost" "directory" "location" "vhost" "defaultAlias" "aliasDrop" "aliasMulti" "emailAlias" "aliasPrim" "domain")
-  "A regexp that matches Domtool actions from the standard library.")
-
-(defconst domtool-vals-regexp
-  (domtool-syms-re "ornext" "cond_nocase" "env" "skip" "redirectWith" "mimeType" "passthrough" "noescape" "qsappend" "nocase" "nosubreq" "chain" "last" "gone" "forbidden" "redirect" "redir307" "redir305" "redir304" "redir303" "redir302" "redir301" "redir300" "seeother" "permanent" "temp" "xhtml" "versionSort" "trackModified" "suppressSize" "suppressRules" "suppressLastModified" "suppressIcon" "suppressHtmlPreamble" "suppressDescription" "suppressColumnSorting" "scanHtmlTitles" "nameWidth" "ignoreClient" "ignoreCase" "iconWidth" "iconHeight" "iconsAreLinks" "htmlTable" "foldersFirst" "fancyIndexing" "descriptionWidth" "characters" "autofit" "home" "web_node" "default_node" "dnsDefaultA" "dnsNS" "dnsMX" "dnsCNAME" "dnsA" "indexes" "includesNOEXEC" "execCGI" "kerberos" "digest" "basic" "use_cert" "no_ssl" "web_node_to_node" "dropTarget" "addressesTarget" "addressTarget" "catchAllSource" "defaultSource" "userSource" "mail_node_to_node" "noDns" "useDns" "internalMaster" "externalMaster" "dns_node_to_node" "defaultSoa" "soa" "serialConst" "serialAuto" "ip_of_node" "true" "false")
-  "A regexp that matches Domtool vals from the standard library.")
-
-(defconst domtool-env-vars-regexp
-  (domtool-syms-re "Aliases" "DNS" "DocumentRoot" "Group" "MailNodes" "Mailbox" "SSL" "ServerAdmin" "SuExec" "TTL" "User" "WWW" "WebNodes")
-  "A regexp that matches Domtool env-vars from the standard library.")
+(require 'domtool-tables)
 
 (defvar domtool-font-lock-keywords
   `(,(concat
       "\\_<"
       (regexp-opt '("let" "in" "begin" "end" "with" "where" "extern" "type"
-                    "val" "context" "Root")
+                    "val" "context" "Root" "if" "then" "else")
                   t)
       "\\_>")
 
           . domtool-font-lock-syntactic-keywords)
          (font-lock-syntactic-face-function
           . domtool-font-lock-syntactic-face-function)))
-  (set (make-local-variable 'indent-line-function) 'sml-indent-line)
-  (set (make-local-variable 'comment-start) "(* ")
-  (set (make-local-variable 'comment-end) " *)")
-  (set (make-local-variable 'comment-nested) t))
+  (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)
+       (concat "domtool -tc " (file-relative-name buffer-file-name))))
 
 (defun domtool-indent-line ()
   (let ((savep (> (current-column) (current-indentation)))
 
 (defun until-closed-helper (level)
   (if
-      (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>"
+      (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\|let\\|val\\|type\\|if\\)\\_>"
                          nil t)
       (cond
        ((string= (match-string 0) "end")
        (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))))
 
     0))
 
-(defun until-closed (is-with)
+(defun until-closed ()
   (save-excursion
-    (if is-with
-       (until-closed-helper 1)
-      (until-closed-helper 0))))
+    (until-closed-helper 0)))
 
 (defun domtool-calculate-indent ()
   (save-excursion
     (back-to-indentation)
     (multiple-value-bind (previous-keyword base-indent)
         (save-excursion
-          (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>"
+          (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 "\\_<\\(with\\)\\_>")
-          (until-closed t))
-         ((looking-at "\\_<\\(end\\)\\_>")
-          (until-closed nil))
+        ((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)))))))
 
                    (incf depth)
                  (decf depth)))
              (+ (current-indentation) depth)))))
+
+(provide 'domtool-mode)