meson.el 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;; command to comment/uncomment text
  2. (defun meson-comment-dwim (arg)
  3. "Comment or uncomment current line or region in a smart way.
  4. For detail, see `comment-dwim'."
  5. (interactive "*P")
  6. (require 'newcomment)
  7. (let (
  8. (comment-start "#") (comment-end "")
  9. )
  10. (comment-dwim arg)))
  11. ;;(setq mymeson-keywords-regex (regex-opt '("if", "endif", "foreach", "endforeach")))
  12. ;; keywords for syntax coloring
  13. (setq meson-keywords
  14. `(
  15. ( ,(regexp-opt '("if" "endif" "for" "foreach") 'word) . font-lock-keyword-face)
  16. )
  17. )
  18. ;; syntax table
  19. (defvar meson-syntax-table nil "Syntax table for `meson-mode'.")
  20. (setq meson-syntax-table
  21. (let ((synTable (make-syntax-table)))
  22. ;; bash style comment: “# …”
  23. (modify-syntax-entry ?# "< b" synTable)
  24. (modify-syntax-entry ?\n "> b" synTable)
  25. synTable))
  26. ;; define the major mode.
  27. (define-derived-mode meson-mode fundamental-mode
  28. "meson-mode is a major mode for editing Meson build definition files."
  29. :syntax-table meson-syntax-table
  30. (setq font-lock-defaults '(meson-keywords))
  31. (setq mode-name "meson")
  32. ;; modify the keymap
  33. (define-key meson-mode-map [remap comment-dwim] 'meson-comment-dwim)
  34. )