summaryrefslogtreecommitdiff
path: root/lisp/textmodes/conf-mode.el
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-08-23 16:06:48 -0600
committerTom Tromey <tom@tromey.com>2017-08-23 16:06:48 -0600
commitad3cd227aa915ac1e671c27aa642da49bac5c463 (patch)
treea9d41df74d4420745cf4bf2db6c1b7de510368e0 /lisp/textmodes/conf-mode.el
parent9538ba6a0f7b906fed3bb7d10b9b98244469047b (diff)
downloademacs-ad3cd227aa915ac1e671c27aa642da49bac5c463.tar.gz
Add conf-toml-mode
* etc/NEWS: Mention conf-toml-mode. * lisp/files.el (auto-mode-alist): Add entry for .toml. * lisp/textmodes/conf-mode.el (conf-toml-mode-syntax-table) (conf-toml-font-lock-keywords): New defvars. (conf-toml-mode): New mode.
Diffstat (limited to 'lisp/textmodes/conf-mode.el')
-rw-r--r--lisp/textmodes/conf-mode.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 054d8dbb8b2..7bcc69572d2 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -175,6 +175,16 @@ not align (only setting space according to `conf-assignment-space')."
table)
"Syntax table in use in Xdefaults style `conf-mode' buffers.")
+(defvar conf-toml-mode-syntax-table
+ (let ((table (make-syntax-table conf-mode-syntax-table)))
+ (modify-syntax-entry ?\" "\"" table)
+ (modify-syntax-entry ?' "\"" table)
+ (modify-syntax-entry ?\\ "\\" table)
+ (modify-syntax-entry ?# "<" table)
+ ;; override
+ (modify-syntax-entry ?\; "." table)
+ table)
+ "Syntax table in use in TOML style `conf-mode' buffers.")
(defvar conf-font-lock-keywords
'(;; [section] (do this first because it may look like a parameter)
@@ -242,6 +252,16 @@ This variable is best set in the file local variables, or through
("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))
"Keywords to highlight in Conf Colon mode.")
+(defvar conf-toml-font-lock-keywords
+ '(;; [section] (do this first because it may look like a parameter)
+ ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face)
+ ;; var=val or var[index]=val
+ ("^[ \t]*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?[ \t]*="
+ (1 'font-lock-variable-name-face)
+ (2 'font-lock-constant-face nil t))
+ ("\\_<false\\|true\\_>" 0 'font-lock-keyword-face))
+ "Keywords to highlight in Conf TOML mode.")
+
(defvar conf-assignment-sign ?=
"Sign used for assignments (char or string).")
@@ -617,6 +637,20 @@ For details see `conf-mode'. Example:
*foreground: black"
(conf-mode-initialize "!"))
+;;;###autoload
+(define-derived-mode conf-toml-mode conf-mode "Conf[TOML]"
+ "Conf Mode starter for TOML files.
+Comments start with `#' and \"assignments\" are with `='.
+For details see `conf-mode'. Example:
+
+# Conf mode font-locks this right with \\[conf-toml-mode]
+
+\[entry]
+value = \"some string\""
+ (conf-mode-initialize "#" 'conf-toml-font-lock-keywords)
+ (setq-local conf-assignment-column 0)
+ (setq-local conf-assignment-sign ?=))
+
(provide 'conf-mode)
;;; conf-mode.el ends here