* elisp/hoa-mode.el: Update from its master.
This commit is contained in:
parent
6a64b0804c
commit
9d8fd50821
1 changed files with 39 additions and 41 deletions
|
|
@ -83,33 +83,37 @@
|
||||||
:group 'hoa-mode-faces)
|
:group 'hoa-mode-faces)
|
||||||
|
|
||||||
(defconst hoa-alias-regex
|
(defconst hoa-alias-regex
|
||||||
"@[a-zA-Z0-9_-]*\\_>"
|
"@[a-zA-Z0-9_.-]*\\_>"
|
||||||
"Regex for matching aliases.")
|
"Regex for matching aliases.")
|
||||||
|
|
||||||
(defvar hoa-font-lock-keywords
|
(defvar hoa-font-lock-keywords-1
|
||||||
(list
|
`(("\\_<--\\(:?BODY\\|END\\|ABORT\\)--" . 'hoa-keyword-face)
|
||||||
'("\\_<[A-Z][a-zA-Z0-9_-]*:" . 'hoa-header-uppercase-face)
|
("\\_<\\(:?Inf\\|Fin\\|t\\|f\\)\\_>" . 'hoa-builtin-face)
|
||||||
'("\\_<[a-z][a-zA-Z0-9_-]*:" . 'hoa-header-lowercase-face)
|
("\\_<[A-Z][a-zA-Z0-9_.-]*:" . 'hoa-header-uppercase-face)
|
||||||
`(,hoa-alias-regex . 'hoa-alias-face)
|
("\\_<[a-z][a-zA-Z0-9_.-]*:" . 'hoa-header-lowercase-face)
|
||||||
'("\\_<--\\(BODY\\|END\\|ABORT\\)--" . 'hoa-keyword-face)
|
(,hoa-alias-regex . 'hoa-alias-face))
|
||||||
'("\\_<\\(Inf\\|Fin\\|t\\|f\\)\\_>" . 'hoa-builtin-face)
|
"Fontification rules for keywords, builtins, headers and aliases.")
|
||||||
'("(\\s-*\\([0-9]+\\)\\s-*)" 1 'hoa-acceptance-set-face)
|
|
||||||
'("{\\(\\([0-9]\\|\\s-\\)+\\)}" 1 'hoa-acceptance-set-face)
|
(defvar hoa-font-lock-keywords-2
|
||||||
;; numbers between brackets denote atomic propositions.
|
(append hoa-font-lock-keywords-1
|
||||||
'("\\["
|
`(("(\\s-*\\([0-9]+\\)\\s-*)" 1 'hoa-acceptance-set-face)
|
||||||
("\\_<[0-9]+\\_>"
|
("{\\(\\([0-9]\\|\\s-\\)+\\)}" 1 'hoa-acceptance-set-face)
|
||||||
(save-excursion (search-forward "]" nil t))
|
;; numbers between brackets denote atomic propositions.
|
||||||
nil
|
("\\["
|
||||||
(0 'hoa-ap-number-face)))
|
("\\_<[0-9]+\\_>"
|
||||||
;; likewise for numbers following an Alias: definition
|
(save-excursion (search-forward "]" nil t))
|
||||||
`(,(concat "Alias:\\s-*" hoa-alias-regex)
|
nil
|
||||||
("\\_<[0-9]+\\_>"
|
(0 'hoa-ap-number-face)))
|
||||||
(save-excursion
|
;; likewise for numbers following an Alias: definition
|
||||||
(re-search-forward
|
(,(concat "Alias:\\s-*" hoa-alias-regex)
|
||||||
(concat "\\(" hoa-alias-regex "\\|[0-9|&!]\\|\\s-\\)+") nil t))
|
("\\_<[0-9]+\\_>"
|
||||||
nil
|
(save-excursion
|
||||||
(0 'hoa-ap-number-face))))
|
(re-search-forward
|
||||||
"Hilighting rules for `hoa-mode'.")
|
(concat "\\(" hoa-alias-regex
|
||||||
|
"\\|[0-9|&!]\\|\\_<[ft]\\_>\\|\\s-\\)+") nil t))
|
||||||
|
nil
|
||||||
|
(0 'hoa-ap-number-face)))))
|
||||||
|
"Complete fontification rules, including acceptance sets and AP numbers.")
|
||||||
|
|
||||||
(defvar hoa-mode-syntax-table
|
(defvar hoa-mode-syntax-table
|
||||||
(let ((st (make-syntax-table)))
|
(let ((st (make-syntax-table)))
|
||||||
|
|
@ -117,6 +121,7 @@
|
||||||
(modify-syntax-entry ?> "." st)
|
(modify-syntax-entry ?> "." st)
|
||||||
(modify-syntax-entry ?| "." st)
|
(modify-syntax-entry ?| "." st)
|
||||||
(modify-syntax-entry ?_ "_" st)
|
(modify-syntax-entry ?_ "_" st)
|
||||||
|
(modify-syntax-entry ?. "_" st)
|
||||||
(modify-syntax-entry ?- "_" st)
|
(modify-syntax-entry ?- "_" st)
|
||||||
(modify-syntax-entry ?$ "." st)
|
(modify-syntax-entry ?$ "." st)
|
||||||
(modify-syntax-entry ?& "." st)
|
(modify-syntax-entry ?& "." st)
|
||||||
|
|
@ -192,11 +197,14 @@ put in `hoa-display-error-buffer' and shown."
|
||||||
(call-process-region b e shell-file-name nil (list dotbuf errfile)
|
(call-process-region b e shell-file-name nil (list dotbuf errfile)
|
||||||
nil shell-command-switch hoa-display-command)))
|
nil shell-command-switch hoa-display-command)))
|
||||||
(when (equal 0 exit-status)
|
(when (equal 0 exit-status)
|
||||||
(let ((hoa-img (create-image (with-current-buffer dotbuf (buffer-string))
|
(let ((hoa-img (create-image (with-current-buffer dotbuf
|
||||||
|
(buffer-string))
|
||||||
'png t)))
|
'png t)))
|
||||||
(with-current-buffer (get-buffer-create hoa-display-buffer)
|
(with-current-buffer (get-buffer-create hoa-display-buffer)
|
||||||
|
(setq buffer-read-only nil)
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert-image hoa-img)
|
(insert-image hoa-img)
|
||||||
|
(setq buffer-read-only t)
|
||||||
(display-buffer (current-buffer)))))
|
(display-buffer (current-buffer)))))
|
||||||
(when (file-exists-p errfile)
|
(when (file-exists-p errfile)
|
||||||
(when (< 0 (nth 7 (file-attributes errfile)))
|
(when (< 0 (nth 7 (file-attributes errfile)))
|
||||||
|
|
@ -217,13 +225,8 @@ put in `hoa-display-error-buffer' and shown."
|
||||||
map)
|
map)
|
||||||
"Keymap for `hoa-mode'.")
|
"Keymap for `hoa-mode'.")
|
||||||
|
|
||||||
(defcustom hoa-mode-hook nil
|
|
||||||
"Hook run whenever `hoa-mode' is activated."
|
|
||||||
:group 'hoa-mode
|
|
||||||
:type 'hook)
|
|
||||||
|
|
||||||
;;;### autoload
|
;;;### autoload
|
||||||
(defun hoa-mode ()
|
(define-derived-mode hoa-mode fundamental-mode "HOA"
|
||||||
"Major mode for editing files in the Hanoi Omega Automata format.
|
"Major mode for editing files in the Hanoi Omega Automata format.
|
||||||
|
|
||||||
See URL `http://adl.github.io/hoaf/' for a definition of that format.
|
See URL `http://adl.github.io/hoaf/' for a definition of that format.
|
||||||
|
|
@ -235,15 +238,10 @@ The following key bindings are installed in hoa-mode:
|
||||||
By default the `hoa-display-automaton-at-point' function requires
|
By default the `hoa-display-automaton-at-point' function requires
|
||||||
extra software (Spot and GraphViz), but can be configured to use
|
extra software (Spot and GraphViz), but can be configured to use
|
||||||
other tools. See that function for details."
|
other tools. See that function for details."
|
||||||
(interactive)
|
:group 'hoa-mode
|
||||||
(kill-all-local-variables)
|
(setq font-lock-defaults '((hoa-font-lock-keywords-1
|
||||||
(set-syntax-table hoa-mode-syntax-table)
|
hoa-font-lock-keywords-1
|
||||||
(set (make-local-variable 'font-lock-defaults) '(hoa-font-lock-keywords))
|
hoa-font-lock-keywords-2))))
|
||||||
(use-local-map hoa-mode-map)
|
|
||||||
(setq major-mode 'hoa-mode)
|
|
||||||
(setq mode-name "HOA")
|
|
||||||
(run-hooks 'hoa-mode-hook))
|
|
||||||
|
|
||||||
(provide 'hoa-mode)
|
(provide 'hoa-mode)
|
||||||
|
|
||||||
;;; hoa-mode.el ends here
|
;;; hoa-mode.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue