dol-mode.el revision 453058446f4b25ac85504960f6aaf8d9e4bc1a9b
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder;;;###autoload
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder(autoload 'turn-on-dol-indent "dol-indent" "Turn on DOL indentation." t)
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder;;;;;;;;;;;;;;;;;;;;;;;;;;
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder;; $Haeder$
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill Mossakowski;; Copyright: (c) University of Magdeburg, 2007-2016
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder;; License: LGPL, see LICENSE.txt or LIZENZ.txt
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder;; Contact: hets-users@informatik.uni-bremen.de
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder;;;;;;;;;;;;;;;;;;;;;;;;;;
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder;; Version number
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder(defconst dol-mode-version "0.4"
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder "Version of DOL-Mode")
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder(defgroup dol nil
d48085f765fca838c1d972d2123601997174583dChristian Maeder "Major mode for editing (heterogeneous) DOL specifications."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder :group 'languages
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder :prefix "dol-")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian Maeder(defvar dol-mode-hook nil)
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-mode-map (let ((keymap (make-keymap)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (define-key keymap "\C-c\C-r" 'dol-run-hets-r)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (featurep 'xemacs)
d48085f765fca838c1d972d2123601997174583dChristian Maeder (define-key keymap "\C-c\C-u" 'dol-run-hets-g)
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (define-key keymap "\C-c\C-c" 'dol-run-hets-g))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (define-key keymap "\C-c\C-n" 'dol-compile-goto-next-error)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder keymap)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Keymap for DOL major mode")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Are we running FSF Emacs or XEmacs?
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar dol-running-xemacs
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (string-match "Lucid\\|XEmacs" emacs-version)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "non-nil if we are running XEmacs, nil otherwise.")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; ====================== S Y N T A X T A B L E ==================
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Syntax table for DOL major mode
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar dol-mode-syntax-table nil
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Syntax table for DOL mode.")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(if dol-mode-syntax-table
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let ((table (make-syntax-table)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Indicate that underscore may be part of a word
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?_ "w" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?\t " " table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?\" "\"" table)
3c5cc698b0c061209ff83eb8de027daef5ae922aChristian Maeder (modify-syntax-entry ?\' "\'" table)
3c5cc698b0c061209ff83eb8de027daef5ae922aChristian Maeder
3c5cc698b0c061209ff83eb8de027daef5ae922aChristian Maeder (mapcar (lambda (x)
3c5cc698b0c061209ff83eb8de027daef5ae922aChristian Maeder (modify-syntax-entry x "_" table))
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder ;; Some of these are actually OK by default.
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder "!#$&*+.,/\\\\:<=>?@^|~")
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder ;; commenting-out plus including other kinds of comment
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Comments
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (cond ((featurep 'xemacs)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?( "()" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?) ")(" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?{ "(}2" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?} "){3" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?[ "(]2" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?] ")[3" table)
c18e9c3c6d5039618f1f2c05526ece84c7794ea3Christian Maeder (modify-syntax-entry ?% "_ 14" table))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (t
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?\( "()" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?\) ")(" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?{ "(} 2n" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?} "){ 3n" table)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (modify-syntax-entry ?% ". 14nb" table)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (modify-syntax-entry ?\[ "(] 2n" table)
81946e2b3f6dde6167f48769bd02c7a634736856Christian Maeder (modify-syntax-entry ?\] ")[ 3n" table))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder )
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-mode-syntax-table table))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder )
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Various mode variables.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-vars ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (kill-all-local-variables)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (make-local-variable 'comment-start)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq comment-start "%[")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (make-local-variable 'comment-padding)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq comment-padding 0)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (make-local-variable 'comment-start-skip)
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (setq comment-start-skip "%[{[]") ;; %[%{[]() *")
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder (make-local-variable 'comment-column)
c4e912fc181d72c8d0e0e38d0351278182f0d0b5Christian Maeder (setq comment-column 40)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (make-local-variable 'comment-indent-function)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq comment-indent-function 'dol-comment-indent)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (make-local-variable 'comment-end)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq comment-end "]%")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set (make-local-variable 'comment-end-skip) "[\]}]%")
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder)
92aa1b88f02d2a413da60dba78acd34312e6f29aChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Find the indentation level for a comment.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-comment-indent ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (skip-chars-backward " \t")
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder ;; if the line is blank, put the comment at the beginning,
81946e2b3f6dde6167f48769bd02c7a634736856Christian Maeder ;; else at comment-column
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (bolp) 0 (max (1+ (current-column)) comment-column)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder;; ============= K E Y W O R D H I G H L I G H T I N G ============
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defface dol-black-komma-face
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder `((t (:foreground "black")))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ""
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder :group 'basic-faces)
024621f43239cfe9629e35d35a8669fad7acbba2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defface dol-blue-komma-face
d48085f765fca838c1d972d2123601997174583dChristian Maeder `((t (:foreground "blue")))
d48085f765fca838c1d972d2123601997174583dChristian Maeder ""
d48085f765fca838c1d972d2123601997174583dChristian Maeder :group 'basic-faces)
d48085f765fca838c1d972d2123601997174583dChristian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-black-komma-face 'dol-black-komma-face
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder "Face name to use for black komma.")
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(defvar dol-annotation-face 'dol-annotation-face
d48085f765fca838c1d972d2123601997174583dChristian Maeder "DOL mode face for Annotations")
2986838ec286d67e7c199e7ea81e7364ca36ad25Christian Maeder(setq dol-annotation-face 'font-lock-constant-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-name-face 'dol-name-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(setq dol-name-face 'font-lock-variable-name-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-keyword-face 'dol-keyword-face)
d48085f765fca838c1d972d2123601997174583dChristian Maeder(setq dol-keyword-face 'font-lock-keyword-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(defvar dol-library-name-face 'dol-library-name-face)
d48085f765fca838c1d972d2123601997174583dChristian Maeder(setq dol-library-name-face 'font-lock-type-face)
d48085f765fca838c1d972d2123601997174583dChristian Maeder
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(defvar dol-builtin-face 'dol-builtin-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(setq dol-builtin-face 'font-lock-builtin-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-comment-face 'dol-comment-face)
d48085f765fca838c1d972d2123601997174583dChristian Maeder(setq dol-comment-face 'font-lock-comment-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-other-name-face 'dol-other-name-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(if (featurep 'xemacs)
d48085f765fca838c1d972d2123601997174583dChristian Maeder (setq dol-other-name-face 'dol-blue-komma-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (setq dol-other-name-face 'font-lock-function-name-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder)
d48085f765fca838c1d972d2123601997174583dChristian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder(defvar dol-string-char-face 'dol-string-char-face)
d48085f765fca838c1d972d2123601997174583dChristian Maeder(setq dol-string-char-face 'font-lock-string-face)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder;; Syntax highlighting of DOL
d48085f765fca838c1d972d2123601997174583dChristian Maeder;; "Warning: Do not design an element of font-lock-keywords to match
d48085f765fca838c1d972d2123601997174583dChristian Maeder;; text which spans lines; this does not work reliably. While
d48085f765fca838c1d972d2123601997174583dChristian Maeder;; font-lock-fontify-buffer handles multi-line patterns correctly,
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder;; updating when you edit the buffer does not, since it considers
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder;; text one line at a time." (from the GNU Emacs Lisp Reference Manual)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder;; order of all the following highlighting rules is significant,
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder;; ony change if really needed
d48085f765fca838c1d972d2123601997174583dChristian Maeder
d48085f765fca838c1d972d2123601997174583dChristian Maeder ;; Comment
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder(defconst dol-font-lock-specialcomment
d48085f765fca838c1d972d2123601997174583dChristian Maeder (list
d48085f765fca838c1d972d2123601997174583dChristian Maeder '("%%.*$" (0 (symbol-value 'dol-comment-face) keep t)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Special Comment")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Alternativ for Annotation
2986838ec286d67e7c199e7ea81e7364ca36ad25Christian Maeder(defconst dol-font-lock-annotations
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (append dol-font-lock-specialcomment
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (list
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; always highlight closing )%
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\)%\\)[^%]"
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (1 (symbol-value 'dol-annotation-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; %words \n
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("%\\w+\\b[^\n]*$"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (0 (symbol-value 'dol-annotation-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; %(.....)%
d48085f765fca838c1d972d2123601997174583dChristian Maeder '("[^%]\\(%\([^)]*?\)%\\)[^%]"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-annotation-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; %word( ... )%
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder '("\\(%\\sw+\([^)]*?\)%\\)[^%]"
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (1 (symbol-value 'dol-annotation-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Annotation")
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defconst dol-font-lock-keywords
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (append dol-font-lock-annotations
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (list
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; reserved keyword
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\\<\\|\\s-+\\)\\(/\\\\\\|\\\\/\\|=>\\|<=>\\|and\\|arch\\|assoc\\|behaviourally\\|closed\\|comm\\|else\\|end\\|exists\\|fit\\|flexible\\|forall\\|free\\|generated\\|given\\|idem\\|if\\|local\\|modality\\|not\\|orElse\\|unit\\|when\\|alignment\\|along\\|assuming\\|and\\|closed-world\\|cofree\\|combine\\|cons-ext\\|end\\|entails\\|entailment\\|equivalence\\|excluding\\|extract\\|free\\|hide\\|import\\|in\\|for\\|forget\\|interpretation\\|keep\\|language\\|library\\|logic\\|maximize\\|model\\|minimize\\|network\\|ni\\|of\\|oms\\|onto\\|ontology\\|refined\\|refinement\\|reject\\|relation\\|remove\\|result\\|reveal\\|select\\|separators\\|serialization\\|spec\\|specification\\|substitution\\|syntax\\|then\\|to\\|translation\\|using\\|vars\\|via\\|view\\|where\\|with\\|cons\\|ccons\\|complete\\|consistent\\|def\\|implied\\|inconsistent\\|mcons\\|mono\\|notccons\\|notmcons\\|prefix\\|wdef\\|within\\|\\(\\(op\\|pred\\|var\\|type\\|sort\\)s?\\)\\)[,;]?[ \t\n]"
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (2 (symbol-value 'dol-keyword-face) keep t))
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder '("[,;.]" (0 (symbol-value 'dol-black-komma-face) t t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; after forall don't highlight
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\bforall\\b\\(.*\\)"
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (1 (symbol-value 'dol-black-komma-face) keep t))
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder ;; Keywords of loading Library
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder '("\\(\\<\\|\\s-+\\)\\(logic\\|from\\|get\\|library\\|version\\)[ :\t\n]+"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-builtin-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Library and Logic name
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\b\\(library\\|logic\\)\\s-+\\(\\(\\w\\|/\\)+\\)\\(\\s-*->\\s-*\\(\\(\\w\\|/\\)+\\)\\)?[ \t\n]"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-library-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (5 (symbol-value 'dol-library-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; name of from, get and given
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\b\\(get\\|given\\)[ \t\n]+\\(\\(\\sw+\\s-*\\(,[ \t\n]*\\|$\\)\\)+\\)\\(=\\|:\\|$\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-name-face) t t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\bfrom[ \t]+\\(.+\\)\\(get\\|$\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-library-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; the name of specification and view
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\\<\\|\\[\\)\\(spec\\|view\\)\\s-+\\(\\w+\\)[ \t]*\\(\\[\\s-*\\([A-Z]\\w*\\).*\\s-*\\]\\)?\\s-*.*\\([]=:]\\|::=\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (3 (symbol-value 'dol-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (5 (symbol-value 'dol-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; then, and + name
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\b\\(and\\|then\\)[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\([A-Z]\\sw*\\).*\\]\\)?"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (4 (symbol-value 'dol-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; names before and after to
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("[ \t\n]*\\(\\sw+\\)[ \t\n]+to[ \t\n]+\\(\\(\\sw+\\)\\s-*\\(\\[\\([A-Z]\\sw*\\).*\\]\\)?[, \t]*\\)?"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (3 (symbol-value 'dol-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (5 (symbol-value 'dol-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; instance name of specification
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\<spec.+=\\s-*\\(%\\sw+\\s-*\\)?[ \t\n]*\\([A-Z]\\w*\\)\\s-*\\(\\[\\s-*\\([A-Z]\\w*\\).*\\s-*\\]\\)?"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (4 (symbol-value 'dol-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Basic signature: sort X, Y, Z
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\\<\\|\\s-+\\)sorts?[ \t\n]+\\(\\(\\sw+\\s-*\\(\\[\\s-*\\(\\sw\\|,\\)+\\s-*\\]\\s-*\\)?\\(,\\(\\s-\\)*\\|$\\|<\\|;\\|=\\)\\(=\\|<\\|;\\|,\\)*[ \t\n]*\\)+\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Basic signature: op ,pred and var name
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\\(^[^.{%]\\)\\s-*\\|\\bops?\\b\\|\\bpreds?\\b\\|\\bvars?\\b\\)\\([^:{()\n]*\\)\\(\(.*\)\\)?:\\??[^?.:=%].*;?[ \t]*$"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (3 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; highlight a line with , an end
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("^\\(\\(\\(__\\s-*[^_\n]+\\s-*__\\|[^.,:>\n]+\\)\\s-*,\\s-*\\)+\\)$"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (0 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; names before and after '|->'
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("[ \t\n]*\\(__[^|_]+__\\|[^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[ \t\n]*|->[ \t\n]*\\(__[^|_]+__\\|[^[ \t\n]+\\)\\s-*\\(\\[\\([A-Z]\\w*\\).*\\]\\)?[, \t]*"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (3 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (4 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (6 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; type name
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\\(\\btype\\|\\bfree type\\)?\\s-+\\(\\sw+\\)\\s-+\\(\\sw*\\|\\[\\(\\s-*\\sw+\\s-*\\)\\]\\)[ \t\n]*::?=[ \t\n]*\\(\\(\_\_[^_]+\_\_\\|[^|][^(|]+\\)\\s-*\\(\(.*\)\\)?\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (2 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (4 (symbol-value 'dol-other-name-face) keep t)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (6 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; constructor
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\|\\s-+\\(\_\_[^|_]+\_\_\\|[^|][^(|]+\\)\\s-*\\(\([^|]+\)\\)?[ \t\n]*"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; in ()1
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\(\\(\\(\\sw\\|,\\)*\\)\\s-*:\\??[^)]*\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; in ()2
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder '("\([^;]*;\\s-*\\(\\sw+\\)\\s-*:\\??.*\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (1 (symbol-value 'dol-other-name-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Reserved keywords highlighting")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; String and Char
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defconst dol-font-lock-string
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (append dol-font-lock-keywords
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (list '("\\(\\(\"\\|^>[ \t]*\\\\\\)\\([^\"\\\\\n]\\|\\\\.\\)*\\(\"\\|\\\\[ \t]*$\\)\\|'\\([^'\\\\\n]\\|\\\\.[^'\n]*\\)'\\)"
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (0 (symbol-value 'dol-string-char-face) keep t))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Syntax highlighting of String and Char")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Define default highlighting level
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; (defvar dol-font-lock-syntax-highligthing dol-font-lock-keywords
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar dol-font-lock-syntax-highligthing (symbol-value 'dol-font-lock-string)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder "Default syntax highlighting level in DOL mode")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; ======================= R U N H E T S =======================
966e627a1c06b302a06d59d08b8ab45905f3509cChristian Maeder(require 'compile)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(setq dol-error-list nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar hets-program nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar old-buffer nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defvar dol-hets-options nil
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "*the additional options for running hets.")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-run-hets (&rest opt)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Run hets process to compile the current DOL file."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (interactive)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (save-buffer nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq old-buffer (current-buffer))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let* ((run-option " ")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-hets-file-name (buffer-file-name))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (outbuf (get-buffer-create "*hets-run*")))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if hets-program
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-hets-program hets-program)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-hets-program "hets"))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if opt
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dolist (current opt run-option)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq run-option (concat run-option current " "))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq hets-command (concat dol-hets-program run-option "\"" dol-hets-file-name "\""))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Pop up the compilation buffer.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-buffer outbuf)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq buffer-read-only nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (buffer-disable-undo (current-buffer))
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (erase-buffer)
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder (buffer-enable-undo (current-buffer))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-buffer-modified-p nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (insert hets-command "\n")
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (pop-to-buffer outbuf)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char (point-max))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; (display-buffer outbuf nil t)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (save-excursion
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder ;; (set-buffer outbuf)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (compilation-mode "hets-compile")
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder ;; Start the compilation.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (fboundp 'start-process)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let* ((process-environment
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (append
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (and (boundp 'system-uses-terminfo)
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder system-uses-terminfo)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (list "TERM=dumb" "TERMCAP="
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (format "COLUMNS=%d" (window-width)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (list "TERM=emacs"
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (format "TERMCAP=emacs:co#%d:tc=unknown:"
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder (window-width))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Set the EMACS variable, but
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; don't override users' setting of $EMACS.
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder (if (getenv "EMACS")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder process-environment
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (cons "EMACS=t" process-environment))))
da245da15da78363c896e44ea97a14ab1f83eb50Christian Maeder (proc (start-process-shell-command "hets-compile" outbuf
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder hets-command)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq buffer-read-only nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-process-sentinel proc 'dol-compilation-sentinel)
d703a61b7fa9f85d92ac8f768d7c290b7c0a41c5Christian Maeder (set-process-filter proc 'dol-compilation-filter)
abd8dd44106c507dd2cb64359b63d7d56fa0a9c8Christian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-marker (process-mark proc) (point) outbuf))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (pop-to-buffer old-buffer)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-run-hets-r (&rest opt)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Run hets process with options (from dol-hets-options) to compile the
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder current DOL file."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (interactive)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq option1 nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq option2 nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq run-option-r nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if dol-hets-options
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq run-option-r dol-hets-options))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if opt
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dolist (current opt option2)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq option2 (concat option2 current " ")))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder )
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq run-option-r (concat run-option-r " " option2))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-run-hets run-option-r)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-run-hets-g ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Run hets process with -g and other options (from variable dol-hets-options)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder to compile the current DOL file."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (interactive)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-run-hets-r "-g")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; sentinel and filter of asynchronous process of hets
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; Called when compilation process changes state.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-compilation-sentinel (proc msg)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Sentinel for compilation buffers."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let ((buffer (process-buffer proc)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (memq (process-status proc) '(signal exit))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (progn
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (null (buffer-name buffer))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; buffer killed
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-process-buffer proc nil)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (let ((obuf (current-buffer)))
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder ;; save-excursion isn't the right thing if
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder ;; process-buffer is current-buffer
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (unwind-protect
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (progn
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder ;; Write something in the compilation buffer
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; and hack its mode line.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-buffer buffer)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-compilation-handle-exit (process-status proc)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (process-exit-status proc)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder msg)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Since the buffer and mode line will show that the
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; process is dead, we can delete it now. Otherwise it
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; will stay around until M-x list-processes.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (delete-process proc))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (set-buffer obuf))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; (setq compilation-in-progress (delq proc compilation-in-progress))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder;; show the message from hets compile direct on *hets-run* buffer
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-compilation-filter (proc string)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (display-buffer (process-buffer proc))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (unless (equal (buffer-name) "*hets-run*")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (progn
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (pop-to-buffer "*hets-run*")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char (point-max))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (with-current-buffer (process-buffer proc)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let ((moving (= (point) (process-mark proc))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (save-excursion
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Insert the text, advancing the process marker.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char (process-mark proc))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (insert string)
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (set-marker (process-mark proc) (point)))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (if moving (goto-char (process-mark proc)))))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (pop-to-buffer old-buffer))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder(defun dol-compilation-handle-exit (process-status exit-status msg)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Write msg in the current buffer and hack its mode-line-process."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let ((buffer-read-only nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (status (cons msg exit-status))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (omax (point-max))
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder (opoint (point)))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Record where we put the message, so we can ignore it
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; later on.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; (goto-char omax)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char (point-max))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (insert ?\n mode-name " " (car status))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (bolp)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (forward-char -1))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (insert " at " (substring (current-time-string) 0 19))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (goto-char (point-max))
48c4688439e0aade4faeebf25ca8b16d661e47afChristian Maeder (setq mode-line-process (format ":%s [%s]" process-status (cdr status)))
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder ;; Force mode line redisplay soon.
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (force-mode-line-update)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (and opoint (< opoint omax))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char opoint))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; Automatically parse (and mouse-highlight) error messages:
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (zerop exit-status)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-error-list nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-error-list nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-parse-error)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (message "%s errors have been found." (length dol-error-list)))
2dfc7b04f2db681992ca04175f2beb0f127c9844Christian Maeder (pop-to-buffer old-buffer)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
aae7a026a323021c5364aef85a0e03d586e5a5c3Christian Maeder;; also functions with old hets-program?
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-parse-error ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "Error Parser"
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (interactive)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-error-list nil)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;;;(pop-to-buffer compiler-buffer)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (pop-to-buffer "*hets-run*")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (goto-char (point-min))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (while (not (eobp))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (not (or (looking-at "Fail") (and (looking-at "\\*\\*\\*") (looking-at "[0-9]+\\.[0-9]+-[0-9]+\\.[0-9]*"))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (forward-line 1)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (skip-chars-forward "a-zA-Z*,/._\\- ")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (not (search-forward ":" (save-excursion (end-of-line) (point)) t 1))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (forward-line 1)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (re-search-backward "\\(\(\\|\\s-+\\)\\([^.]+\\.\\(dol\\|het\\)\\)" nil t 1)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq file-name (match-string-no-properties 2))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (re-search-forward ":\\([0-9]+\\)\\.\\([0-9]+\\)\\(-[0-9]+\\.[0-9]*\\)?[:,]" (save-excursion (end-of-line) (point)) t 1)
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (when (not (string= (match-string-no-properties 0) ""))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq error-line (match-string-no-properties 1))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq error-colnum (match-string-no-properties 2))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq error-window-point (point))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (setq dol-error-list
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (nconc dol-error-list (list (list file-name error-line error-colnum error-window-point))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder )
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (forward-line 1)))))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder(defun dol-compile-goto-next-error ()
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder "search the next error position from error-list, and move to it."
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (interactive)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder ;; if error-list is empty ...
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (null dol-error-list)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (dol-parse-error))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (null dol-error-list)
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (if (member (get-buffer "*hets-run*") (buffer-list))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (message "no error.")
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (message "this file have not yet been compiled."))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (let* ((this-error (pop dol-error-list))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (error-file-name (nth 0 this-error))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (error-line (nth 1 this-error))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (error-column (nth 2 this-error))
5a13581acc5a76d392c1dec01657bb3efd4dcf2dChristian Maeder (error-window-point (nth 3 this-error)))
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder ;; (message "DEBUG<Goto Error>: file: %s, line: %s, column: %s" error-file-name error-line error-column)
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder ;; if the file already opened ...
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (if (get-file-buffer error-file-name)
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder (pop-to-buffer (get-file-buffer error-file-name))
413db961f13e112716509b6d61d7a7bbf50c98b2Christian Maeder (generate-new-buffer error-file-name)
(pop-to-buffer error-file-name)
(insert-file-contents error-file-name))
;; switch to hets-run window to jump to next error message
(setq file-buffer (current-buffer))
(pop-to-buffer "*hets-run*")
(goto-char error-window-point)
;; return to current file
(pop-to-buffer file-buffer)
(goto-line (string-to-number error-line))
(move-to-column (- (string-to-number error-column) 1))
(message "goto next error... line: %s column: %s" error-line error-column)
(setq dol-error-list (nconc dol-error-list (list this-error)))
)))
;; ================= D O L M A J O R M O D E ===============
;; dol major mode setup
;; Definition of DOL major mode
(defun dol-mode ()
"Major mode for editing DOL models"
(interactive)
(dol-vars)
(setq major-mode 'dol-mode)
(setq mode-name "DOL")
;; Load keymap
(use-local-map dol-mode-map)
;; Load syntax table
(set-syntax-table dol-mode-syntax-table)
;; (dol-create-syntax-table)
;; Highlight DOL keywords
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults
'(dol-font-lock-syntax-highligthing))
(make-local-variable 'font-lock-keywords-only)
(setq font-lock-keywords-only nil)
;; Support for compile.el
;; We just substitute our own functions to go to the error.
(add-hook 'compilation-mode-hook
(lambda()
(set (make-local-variable 'compile-auto-highlight) 40)
;; FIXME: This has global impact! -stef
(define-key compilation-minor-mode-map [mouse-2]
'dol-compile-mouse-goto-error)
(define-key compilation-minor-mode-map "\C-m"
'dol-compile-goto-next-error)))
(run-hooks 'dol-mode-hook)
)
(provide 'dol-mode)
;; DOL-mode ends here