[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ad3cd22: Add conf-toml-mode
From: |
Tom Tromey |
Subject: |
[Emacs-diffs] master ad3cd22: Add conf-toml-mode |
Date: |
Wed, 23 Aug 2017 18:12:05 -0400 (EDT) |
branch: master
commit ad3cd227aa915ac1e671c27aa642da49bac5c463
Author: Tom Tromey <address@hidden>
Commit: Tom Tromey <address@hidden>
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.
---
etc/NEWS | 3 +++
lisp/files.el | 1 +
lisp/textmodes/conf-mode.el | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 0939033..a9e2f5a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1115,6 +1115,9 @@ processes on exit.
mode for *.html files. This mode handles indentation,
fontification, and commenting for embedded JavaScript and CSS.
+** New mode 'conf-toml-mode' is a sub-mode of conf-mode, specialized
+ for editing TOML files.
+
** New minor mode 'pixel-scroll-mode' provides smooth pixel-level scrolling.
** New major mode 'less-css-mode' (a minor variant of 'css-mode') for
diff --git a/lisp/files.el b/lisp/files.el
index 0311cc6..bc347c1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2653,6 +2653,7 @@
ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mo
("\\.ppd\\'" . conf-ppd-mode)
("java.+\\.conf\\'" . conf-javaprop-mode)
("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
+ ("\\.toml\\'" . conf-toml-mode)
("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'"
. conf-space-mode)
("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'"
. conf-mode)
;; ChangeLog.old etc. Other change-log-mode entries are above;
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 054d8db..7bcc695 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ad3cd22: Add conf-toml-mode,
Tom Tromey <=