X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/ef18a74197873c2b319c57ff5dacb2a09e234d76..3b37f60fedd3b91d2781c5ac852617860ec01e9d:/elisp/domtool-mode.el diff --git a/elisp/domtool-mode.el b/elisp/domtool-mode.el index 3f8d193..8e77d7d 100644 --- a/elisp/domtool-mode.el +++ b/elisp/domtool-mode.el @@ -39,7 +39,6 @@ (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.") @@ -57,7 +56,7 @@ "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" "WebNodes") + (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.") (defvar domtool-font-lock-keywords @@ -110,12 +109,32 @@ (savep (save-excursion (indent-line-to indent))) (t (indent-line-to indent))))) +(defun until-closed-helper (level) + (if + (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>" + nil t) + (cond + ((string= (match-string 0) "end") + (until-closed-helper (+ level 1))) + ((= level 0) + (current-indentation)) + (t + (until-closed-helper (- level 1)))) + + 0)) + +(defun until-closed (is-with) + (save-excursion + (if is-with + (until-closed-helper 1) + (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\\|end\\)\\_>" + (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>" nil t) (values (match-string 0) (current-indentation)) (values nil 0))) @@ -125,11 +144,10 @@ 'noindent) ((nth 4 state) (domtool-calculate-comment-indent state)) - ((and (looking-at "\\_") - (string= previous-keyword "end")) - (- base-indent domtool-indent)) - ((looking-at "\\_<\\(with\\|end\\)\\_>") - base-indent) + ((looking-at "\\_<\\(with\\)\\_>") + (until-closed t)) + ((looking-at "\\_<\\(end\\)\\_>") + (until-closed nil)) ((not previous-keyword) base-indent) ((string= previous-keyword "end")