Skip to content
Snippets Groups Projects
Verified Commit bf60795e authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Emacs mode improvements

- bugfix: in "model_name", the "model" part will no longer be colorized
- add colorization for on-the-fly type declarations
- no longer categorize dots as word constituents (they are not even symbol
  constituents)
- no longer categorize @ and # as symbol constituents
parent 6f80abd1
No related branches found
No related tags found
No related merge requests found
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
;; + change face for macroprocessor? ;; + change face for macroprocessor?
;; + handle dates? ;; + handle dates?
;; + multi-line macro-commands/exprs ;; + multi-line macro-commands/exprs
;; + components of option names should not be recognized (e.g. "model"
;; should not be colorized in "model_name")
;; - M-a and M-e should skip statements (separated with ;) ;; - M-a and M-e should skip statements (separated with ;)
;; - improve indentation ;; - improve indentation
;; + w.r.t. to statements/equations/macro-commands split on several lines ;; + w.r.t. to statements/equations/macro-commands split on several lines
...@@ -107,6 +105,10 @@ ...@@ -107,6 +105,10 @@
'("nan" "inf") '("nan" "inf")
"Dynare constants.") "Dynare constants.")
(defvar dynare-type-attributes
'("|e" "|x" "|p")
"Dynare attributes for on-the-fly type declarations.")
(defvar dynare-macro-keywords (defvar dynare-macro-keywords
'("in" "length" "line" "define" "echomacrovars" "save" "for" "endfor" "ifdef" '("in" "length" "line" "define" "echomacrovars" "save" "for" "endfor" "ifdef"
"ifndef" "if" "else" "endif" "echo" "error" "include" "includepath") "ifndef" "if" "else" "endif" "echo" "error" "include" "includepath")
...@@ -114,18 +116,19 @@ ...@@ -114,18 +116,19 @@
(defvar dynare-font-lock-keywords (defvar dynare-font-lock-keywords
`(("@#" . font-lock-variable-name-face) ; Beginning of macro-statement `(("@#" . font-lock-variable-name-face) ; Beginning of macro-statement
("@#" ,(regexp-opt dynare-macro-keywords 'words) ("@#" ,(regexp-opt dynare-macro-keywords 'symbols)
nil nil (0 font-lock-variable-name-face)) ; Keywords in macro-statements nil nil (0 font-lock-variable-name-face)) ; Keywords in macro-statements
("@{[^}]*}" . font-lock-variable-name-face) ; For macro-substitutions ("@{[^}]*}" . font-lock-variable-name-face) ; For macro-substitutions
;;; Below is an alternative way of dealing with macro-substitutions ;;; Below is an alternative way of dealing with macro-substitutions
;;; Only the delimiters and the keywords are colorized ;;; Only the delimiters and the keywords are colorized
;; ("@{" . font-lock-variable-name-face) ;; ("@{" . font-lock-variable-name-face)
;; ("@{" "[^}]*\\(}\\)" nil nil (1 font-lock-variable-name-face)) ;; ("@{" "[^}]*\\(}\\)" nil nil (1 font-lock-variable-name-face))
;; ("@{" ,(concat (regexp-opt dynare-macro-keywords 'words) "[^}]*}") nil nil (1 font-lock-variable-name-face)) ;; ("@{" ,(concat (regexp-opt dynare-macro-keywords 'symbols) "[^}]*}") nil nil (1 font-lock-variable-name-face))
("^[ \t]*#" . font-lock-warning-face) ; For model-local variables ("^[ \t]*#" . font-lock-warning-face) ; For model-local variables
(,(regexp-opt (append dynare-statements dynare-statements-like dynare-blocks) 'words) . font-lock-keyword-face) (,(regexp-opt (append dynare-statements dynare-statements-like dynare-blocks) 'symbols) . font-lock-keyword-face)
(,(regexp-opt dynare-functions 'words) . font-lock-builtin-face) (,(regexp-opt dynare-functions 'symbols) . font-lock-builtin-face)
(,(regexp-opt dynare-constants 'words) . font-lock-constant-face)) (,(regexp-opt dynare-constants 'symbols) . font-lock-constant-face))
(,(concat (regexp-opt dynare-type-attributes) "\\_>") . font-lock-type-face))
"Keyword highlighting specification for `dynare-mode'.") "Keyword highlighting specification for `dynare-mode'.")
(defvar dynare-mode-map (defvar dynare-mode-map
...@@ -135,9 +138,6 @@ ...@@ -135,9 +138,6 @@
(defvar dynare-mode-syntax-table (defvar dynare-mode-syntax-table
(let ((st (make-syntax-table))) (let ((st (make-syntax-table)))
;; decimal numbers should be treated as words
(modify-syntax-entry ?\. "w" st)
;; mathematical operators are treated as punctuation ;; mathematical operators are treated as punctuation
;; "*" is treated further below ;; "*" is treated further below
(modify-syntax-entry ?+ "." st) (modify-syntax-entry ?+ "." st)
...@@ -146,10 +146,10 @@ ...@@ -146,10 +146,10 @@
(modify-syntax-entry ?^ "." st) (modify-syntax-entry ?^ "." st)
;; symbols for the macrolanguage ;; symbols for the macrolanguage
(modify-syntax-entry ?@ "_" st) (modify-syntax-entry ?@ "." st)
(modify-syntax-entry ?# "_" st) (modify-syntax-entry ?# "." st)
;; underscores are treated as word constituents ;; underscores are symbol constituents
(modify-syntax-entry ?_ "_" st) (modify-syntax-entry ?_ "_" st)
;; Single-quoted strings ;; Single-quoted strings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment