aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2014-11-24 23:58:44 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2014-11-24 23:58:44 +0200
commit7f9450f55e41095b2969494c3c8cb878117b77e7 (patch)
tree736fceea581b017a9c88451e15eb243716c51355 /data
parent8771b1f49b5900731fc08d533d2cc20b1c20d995 (diff)
downloadmeson-7f9450f55e41095b2969494c3c8cb878117b77e7.zip
meson-7f9450f55e41095b2969494c3c8cb878117b77e7.tar.gz
meson-7f9450f55e41095b2969494c3c8cb878117b77e7.tar.bz2
Create simple Emacs major mode.
Diffstat (limited to 'data')
-rw-r--r--data/meson.el43
1 files changed, 43 insertions, 0 deletions
diff --git a/data/meson.el b/data/meson.el
new file mode 100644
index 0000000..36f7eb9
--- /dev/null
+++ b/data/meson.el
@@ -0,0 +1,43 @@
+;; command to comment/uncomment text
+(defun meson-comment-dwim (arg)
+ "Comment or uncomment current line or region in a smart way.
+For detail, see `comment-dwim'."
+ (interactive "*P")
+ (require 'newcomment)
+ (let (
+ (comment-start "#") (comment-end "")
+ )
+ (comment-dwim arg)))
+
+;;(setq mymeson-keywords-regex (regex-opt '("if", "endif", "foreach", "endforeach")))
+
+;; keywords for syntax coloring
+(setq meson-keywords
+ `(
+ ( ,(regexp-opt '("if" "endif" "for" "foreach") 'word) . font-lock-keyword-face)
+ )
+ )
+
+;; syntax table
+(defvar meson-syntax-table nil "Syntax table for `meson-mode'.")
+(setq meson-syntax-table
+ (let ((synTable (make-syntax-table)))
+
+ ;; bash style comment: “# …”
+ (modify-syntax-entry ?# "< b" synTable)
+ (modify-syntax-entry ?\n "> b" synTable)
+
+ synTable))
+
+;; define the major mode.
+(define-derived-mode meson-mode fundamental-mode
+ "meson-mode is a major mode for editing Meson build definition files."
+ :syntax-table meson-syntax-table
+
+ (setq font-lock-defaults '(meson-keywords))
+ (setq mode-name "meson")
+
+ ;; modify the keymap
+ (define-key meson-mode-map [remap comment-dwim] 'meson-comment-dwim)
+)
+