X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/4542571e02a2517e6ca9c342d433343293b06be8..6b71895409837ee7ebea2a66f62d98dbee8b97e7:/elisp/domtool-mode.el diff --git a/elisp/domtool-mode.el b/elisp/domtool-mode.el index d1a4a98..4b23e76 100644 --- a/elisp/domtool-mode.el +++ b/elisp/domtool-mode.el @@ -37,16 +37,25 @@ )) table)) +(defun domtool-syms-re (&rest syms) + (concat "\\<" (regexp-opt syms t) "\\>")) + +(load-file "/usr/local/share/emacs/site-lisp/domtool-mode/domtool-tables.el") + (defvar domtool-font-lock-keywords `(,(concat "\\_<" (regexp-opt '("let" "in" "begin" "end" "with" "where" "extern" "type" - "val" "context" "Root" - ;; Actions - "vhost" "location" "directory" "domain" "dom" - "webAt" "web") + "val" "context" "Root") t) "\\_>") + + (,domtool-actions-regexp . font-lock-builtin-face) + (,domtool-vals-regexp . font-lock-variable-name-face) + (,domtool-contexts-regexp . font-lock-constant-face) + (,domtool-env-vars-regexp . font-lock-constant-face) + (,domtool-types-regexp . font-lock-type-face) + ("type[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face) ("val[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 1 font-lock-variable-name-face))) @@ -73,7 +82,10 @@ (font-lock-syntactic-keywords . domtool-font-lock-syntactic-keywords) (font-lock-syntactic-face-function - . domtool-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-nested) t)) (defun domtool-indent-line () (let ((savep (> (current-column) (current-indentation))) @@ -83,12 +95,30 @@ (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 () + (save-excursion + (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))) @@ -98,11 +128,8 @@ '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) + (until-closed)) ((not previous-keyword) base-indent) ((string= previous-keyword "end")