;; Define an Emacs Mode for Webtester
;;
;; Features:
;; - indentation support
;; - syntax highlighting
;;
;; Documentations:
;; - mode tutorial:
;; https://www.emacswiki.org/emacs/ModeTutorial
;; - faces for font lock:
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Faces-for-Font-Lock.html
( defvar wt-mode-hook nil )
( defvar wt-mode-map
( let ( ( map ( make-sparse-keymap ) ) )
( define-key map " \C -j " 'newline-and-indent )
map )
" Newline and indent " )
( add-to-list 'auto-mode-alist ' ( " \\ .wt \\ ' " . wt-mode ) )
;; get all keywords:
;; echo $(webrunner -h | sed -n 's, COMMAND: ,,p') | sed 's, ,\\\\|,g'
( defconst wt-font-lock-keywords
( list
' ( " ^ * \\ (auth \\ |ca-certificate \\ |call \\ |case \\ |check \\ |clear-cookies \\ |click \\ |clicktype \\ |client-certificate \\ |do \\ |download \\ |echo \\ |execute \\ |exists \\ |exit \\ |expect \\ |fail \\ |for \\ |function \\ |if \\ |while \\ |ignoreto \\ |include \\ |label \\ |load \\ |not \\ |offline-storage-path \\ |open \\ |screenshot \\ |set \\ |setvalue \\ |sleep \\ |testcase \\ |testsuite \\ |timeout \\ |unset \\ |upload \\ ) " . font-lock-builtin-face )
' ( " ^ *#.*$ " . font-lock-comment-face ) )
" Highlighting expressions for Webtester " )
( defvar wt-mode-syntax-table
( let ( ( st ( make-syntax-table ) ) )
st )
" Syntax table for wt-mode " )
( defun wt-mode ( )
" Major mode for editing Webtester test scripts "
( interactive )
( kill-all-local-variables )
( set-syntax-table wt-mode-syntax-table )
( use-local-map wt-mode-map )
( set ( make-local-variable 'font-lock-defaults ) ' ( wt-font-lock-keywords ) )
( setq major-mode 'wt-mode )
( setq mode-name " Webtester " )
( run-hooks 'wpdl-mode-hook ) )
( provide 'wt-mode )