From 3e8a3b64bdaa8ec1e457e2c3b55c761b5a0a2771 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 7 Feb 2022 17:06:41 +0100 Subject: [PATCH] Put together a simple tridactylrc mode Parts gathered from vimrc-mode --- config.org | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/config.org b/config.org index 12deecc..99cc111 100644 --- a/config.org +++ b/config.org @@ -11,6 +11,7 @@ - [[#line-numbers][Line numbers]] - [[#battery-indicator][Battery indicator]] - [[#programming][Programming]] + - [[#tridactyl-mode][Tridactyl mode]] - [[#smart-parens][Smart parens]] - [[#rust][Rust]] - [[#column-width][Column width]] @@ -165,6 +166,41 @@ I'm on a laptop, so let's display my battery in the modeline: * Programming +** Tridactyl mode + +#+begin_src emacs-lisp +(defvar tridactylrc-font-lock-keywords + `( ;; Line comment + ("^[\t ]*\\(\"\\)\\(.*\\)$" + (1 font-lock-comment-delimiter-face) + (2 font-lock-comment-face)) + + ;; Trailing comment + ("[\t ]+\\(\"\\)\\([^\"\r\n]*\\)$" + (1 font-lock-comment-delimiter-face) + (2 font-lock-comment-face)) + + ;; String start: + ("\\(\"[^\n\r\"]*\"\\)\\|\\('[^\n\r]*'\\)" + (0 font-lock-string-face)) ;; String end; + )) + +(defvar tridactylrc-mode-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?' "\"" table) + (modify-syntax-entry ?\" "<" table) + (modify-syntax-entry ?\n ">" table) + table)) + +(define-derived-mode tridactylrc-mode prog-mode "tridactylrc" + "Major mode for editing tridactylrc configuration files." + :group 'tridactylrc-mode + :syntax-table tridactylrc-mode-syntax-table + (font-lock-add-keywords nil tridactylrc-font-lock-keywords) + (setq-local comment-start "\"") + (setq-local comment-end "")) +#+end_src + ** Smart parens Disable smart parens because half of the time it doesn't do what I want: