Download
(defvar wpdl-mode-hook nil)
(defvar wpdl-mode-map
(let ((wpdl-mode-map (make-keymap)))
(define-key wpdl-mode-map "\C-j" 'newline-and-indent)
wpdl-mode-map)
"Keymap for WPDL major mode")
(add-to-list 'auto-mode-alist '("\\.wpd\\'" . wpdl-mode))
(defconst wpdl-font-lock-keywords-1
(list
'("\\<\\(A\\(CTIVITY\\|PPLICATION\\)\\|DATA\\|END_\\(A\\(CTIVITY\\|PPLICATION\\)\\|DATA\\|MODEL\\|PARTICIPANT\\|T\\(OOL_LIST\\|RANSITION\\)\\|WORKFLOW\\)\\|MODEL\\|PARTICIPANT\\|T\\(OOL_LIST\\|RANSITION\\)\\|WORKFLOW\\)\\>" . font-lock-builtin-face)
'("\\('\\w*'\\)" . font-lock-variable-name-face))
"Minimal highlighting expressions for WPDL mode.")
(defconst wpdl-font-lock-keywords-2
(append wpdl-font-lock-keywords-1
(list
'("\\<\\(AUTHOR\\|C\\(ONDITION\\|REATED\\)\\|DE\\(FAULT_VALUE\\|SCRIPTION\\)\\|EXTENDED_ATTRIBUTE\\|FROM\\|I\\(MPLEMENTATION\\|N_PARAMETERS\\)\\|JOIN\\|NAME\\|O\\(THERWISE\\|UT_PARAMETERS\\)\\|PERFORMER\\|ROUTE\\|S\\(PLIT\\|TATUS\\)\\|T\\(O\\(OLNAME\\)?\\|YPE\\)\\|VENDOR\\|WPDL_VERSION\\)\\>" . font-lock-keyword-face)
'("\\<\\(TRUE\\|FALSE\\)\\>" . font-lock-constant-face)))
"Additional Keywords to highlight in WPDL mode.")
(defconst wpdl-font-lock-keywords-3
(append wpdl-font-lock-keywords-2
(list
'("\\<\\(A\\(ND\\|PPLICATIONS\\)\\|BOOLEAN\\|HUMAN\\|INTEGER\\|NO\\|OR\\(GANISATIONAL_UNIT\\)?\\|R\\(EFERENCE\\|OLE\\)\\|S\\(TRING\\|YNCHR\\)\\|UNDER_REVISION\\|WORKFLOW\\|XOR\\)\\>" . font-lock-constant-face)))
"Balls-out highlighting in WPDL mode.")
(defvar wpdl-font-lock-keywords wpdl-font-lock-keywords-3
"Default highlighting expressions for WPDL mode.")
(defun wpdl-indent-line ()
"Indent current line as WPDL code."
(interactive)
(beginning-of-line)
(if (bobp)
(indent-line-to 0)
(let ((not-indented t) cur-indent)
(if (looking-at "^[ \t]*END_")
(progn
(save-excursion
(forward-line -1)
(setq cur-indent (- (current-indentation) default-tab-width)))
(if (< cur-indent 0)
(setq cur-indent 0)))
(save-excursion
(while not-indented
(forward-line -1)
(if (looking-at "^[ \t]*END_")
(progn
(setq cur-indent (current-indentation))
(setq not-indented nil))
(if (looking-at "^[ \t]*\\(PARTICIPANT\\|MODEL\\|APPLICATION\\|WORKFLOW\\|ACTIVITY\\|DATA\\|TOOL_LIST\\|TRANSITION\\)")
(progn
(setq cur-indent (+ (current-indentation) default-tab-width))
(setq not-indented nil))
(if (bobp)
(setq not-indented nil)))))))
(if cur-indent
(indent-line-to cur-indent)
(indent-line-to 0)))))
(defvar wpdl-mode-syntax-table
(let ((wpdl-mode-syntax-table (make-syntax-table)))
(modify-syntax-entry ?_ "w" wpdl-mode-syntax-table)
(modify-syntax-entry ?/ ". 124b" wpdl-mode-syntax-table)
(modify-syntax-entry ?* ". 23" wpdl-mode-syntax-table)
(modify-syntax-entry ?\n "> b" wpdl-mode-syntax-table)
wpdl-mode-syntax-table)
"Syntax table for wpdl-mode")
(defun wpdl-mode ()
(interactive)
(kill-all-local-variables)
(use-local-map wpdl-mode-map)
(set-syntax-table wpdl-mode-syntax-table)
(set (make-local-variable 'font-lock-defaults) '(wpdl-font-lock-keywords))
(set (make-local-variable 'indent-line-function) 'wpdl-indent-line)
(setq major-mode 'wpdl-mode)
(setq mode-name "WPDL")
(run-hooks 'wpdl-mode-hook))
(provide 'wpdl-mode)