aboutsummaryrefslogtreecommitdiffstats
path: root/meson/data/syntax-highlighting/emacs/meson.el
blob: a640bbe7102813c73f53686e0649f29fd08b688b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;; keywords for syntax coloring
(setq meson-keywords
      `(
        ( ,(regexp-opt '("elif" "if" "else" "endif" "foreach" "endforeach") '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 prog-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")
  (setq-local comment-start "# ")
  (setq-local comment-end ""))

(add-to-list 'auto-mode-alist '("meson.build" . meson-mode))
(provide 'meson)
;;; meson.el ends here