* bug#28191: 25.2; simple TOML mode
@ 2017-08-22 21:27 Tom Tromey
2017-08-23 17:23 ` Eli Zaretskii
2017-08-24 13:34 ` bug#28191: patch checked in Tom Tromey
0 siblings, 2 replies; 3+ messages in thread
From: Tom Tromey @ 2017-08-22 21:27 UTC (permalink / raw
To: 28191
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
I've written a simple "TOML" editing mode, based on conf-mode.
TOML is a config format that's used in some places (my exposure to it
comes from Rust, where it's used to describe Rust packages).
I wasn't sure if I could just check this in so I thought I'd send it for
review first.
Tom
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: toml mode --]
[-- Type: text/x-patch, Size: 2935 bytes --]
diff --git a/lisp/files.el b/lisp/files.el
index b05d453..ff1d080 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2648,6 +2648,7 @@ auto-mode-alist
("\\.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 @@ conf-xdefaults-mode-syntax-table
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 @@ conf-colon-font-lock-keywords
("^[ \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 @@ conf-xdefaults-mode
*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
[-- Attachment #3: Type: text/plain, Size: 6535 bytes --]
In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.8)
of 2017-03-02 built on bapiya
Repository revision: 6e788ef0e262fafc014c21f4ad52cc5dc9f1715b
Windowing system distributor 'Fedora Project', version 11.0.11903000
System Description: Fedora release 25 (Twenty Five)
Configured using:
'configure --prefix=/home/tromey/Emacs/install/ --with-modules'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES
Important settings:
value of $LANG: en_US.utf8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Emacs-Lisp
Minor modes in effect:
shell-dirtrack-mode: t
diff-auto-refine-mode: t
flyspell-mode: t
which-function-mode: t
erc-services-mode: t
erc-list-mode: t
erc-menu-mode: t
erc-autojoin-mode: t
erc-ring-mode: t
erc-networks-mode: t
erc-pcomplete-mode: t
erc-track-mode: t
erc-match-mode: t
erc-netsplit-mode: t
erc-hl-nicks-mode: t
erc-button-mode: t
erc-fill-mode: t
erc-stamp-mode: t
erc-irccontrols-mode: t
erc-noncommands-mode: t
erc-move-to-prompt-mode: t
erc-readonly-mode: t
savehist-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
auto-fill-function: do-auto-fill
transient-mark-mode: t
Recent messages:
Finding changes in /home/tromey/Emacs/trunk/...done
Quit [2 times]
Mark set
Mark saved where search started
Saving file /home/tromey/Emacs/trunk/lisp/textmodes/conf-mode.el...
Wrote /home/tromey/Emacs/trunk/lisp/textmodes/conf-mode.el
C-x C-g is undefined
Undo!
Saving file /home/tromey/gdb/gimli/Cargo.toml...
Wrote /home/tromey/gdb/gimli/Cargo.toml
Load-path shadows:
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.2/lisp/play/bubbles
/home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-inspect hides /home/tromey/Emacs/install/share/emacs/25.2/lisp/net/soap-inspect
/home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-client hides /home/tromey/Emacs/install/share/emacs/25.2/lisp/net/soap-client
Features:
(shadow emacsbug conf-mode debug tabify man gdb-shell vc-annotate
sh-script smie executable eieio-opt speedbar sb-image ezimage dframe js
sgml-mode json map gnus-draft perl-mode calc calc-loaddefs calc-macs tcl
pulse novice texinfo etags xref project gnus-fun make-mode rx rust-mode
gud org-bullets org-element org-rmail org-mhe org-irc org-info org-gnus
org-docview doc-view jka-compr image-mode org-bibtex bibtex org-bbdb
org-w3m org org-macro org-footnote org-pcomplete org-list org-faces
org-entities noutline outline org-version ob-emacs-lisp ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval
org-compat org-macs org-loaddefs find-func gnus-html xml url-cache
mm-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf find-dired find-file shell log-view flow-fill
idutils derived term/xterm xterm smerge-mode goto-addr bug-reference
cc-mode cc-fonts cc-guess cc-menus cc-cmds shr-color url-util url-parse
url-vars shr dom subr-x browse-url mm-archive bbdb-sc supercite regi
bbdb-message vc-mtn vc-hg mailalias mail-hist nnir sort smiley gnus-cite
mail-extr gnus-bcklg misearch multi-isearch qp gnus-async gnus-ml
disp-table gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua
bbdb-com crm network-stream nsm starttls gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg nntp gnus-cache gnus-registry registry
eieio-compat eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime
dig mailcap gnus-sum gnus-group gnus-undo smtpmail sendmail gnus-start
gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc nnoo
parse-time gnus-spec gnus-int gnus-range gnus-win gnus gnus-ems nnheader
dabbrev copyright whitespace log-edit message idna dired rfc822 mml
mml-sec epg mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev mail-utils gmm-utils mailheader pcvs-util
add-log vc-git diff-mode easy-mmode vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs flyspell ispell diminish edmacro kmacro projectile grep compile
ibuf-ext ibuffer dash appt diary-lib diary-loaddefs cal-menu calendar
cal-loaddefs which-func imenu minimap autorevert filenotify cus-start
cus-load status erc-services erc-list erc-menu erc-join erc-ring
erc-networks erc-pcomplete pcomplete erc-track erc-match erc-netsplit
erc-hl-nicks color erc-button erc-fill erc-stamp wid-edit erc-goodies
erc erc-backend erc-compat format-spec auth-source eieio gnus-util
mm-util help-fns mail-prsvr password-cache thingatpt pp warnings advice
vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars
cc-defs bbdb bbdb-site timezone ange-ftp comint ansi-color ring server
savehist finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core
lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl
weblogger-autoloads info package epg-config seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 2301270 631680)
(symbols 48 77269 31)
(miscs 40 22640 14949)
(strings 32 306146 242988)
(string-bytes 1 11878861)
(vectors 16 66577)
(vector-slots 8 2239890 75456)
(floats 8 895 1107)
(intervals 56 293144 4901)
(buffers 976 370))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#28191: 25.2; simple TOML mode
2017-08-22 21:27 bug#28191: 25.2; simple TOML mode Tom Tromey
@ 2017-08-23 17:23 ` Eli Zaretskii
2017-08-24 13:34 ` bug#28191: patch checked in Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2017-08-23 17:23 UTC (permalink / raw
To: Tom Tromey; +Cc: 28191
> From: Tom Tromey <tom@tromey.com>
> Date: Tue, 22 Aug 2017 15:27:20 -0600
>
> I've written a simple "TOML" editing mode, based on conf-mode.
> TOML is a config format that's used in some places (my exposure to it
> comes from Rust, where it's used to describe Rust packages).
>
> I wasn't sure if I could just check this in so I thought I'd send it for
> review first.
Thanks, this looks fine to me, but please also add a NEWS entry about
this, under "New modes and packages".
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#28191: patch checked in
2017-08-22 21:27 bug#28191: 25.2; simple TOML mode Tom Tromey
2017-08-23 17:23 ` Eli Zaretskii
@ 2017-08-24 13:34 ` Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2017-08-24 13:34 UTC (permalink / raw
To: 28191-done
The patch was checked in.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-24 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 21:27 bug#28191: 25.2; simple TOML mode Tom Tromey
2017-08-23 17:23 ` Eli Zaretskii
2017-08-24 13:34 ` bug#28191: patch checked in Tom Tromey
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.