From 327c094596228b8dfdc3715a560ef226cd1403a9 Mon Sep 17 00:00:00 2001 From: Fanael Linithien Date: Sat, 22 Nov 2014 18:35:46 +0100 Subject: Set up a proper syntax table for ninja-mode. Since quotes are not meant to be treated as string delimiters, the syntax table is the place to tell Emacs so. This also means syntactic fontification can be reenabled and the font-lock keyword entry for comments removed. --- misc/ninja-mode.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/misc/ninja-mode.el b/misc/ninja-mode.el index 10cec3e..021ede1 100644 --- a/misc/ninja-mode.el +++ b/misc/ninja-mode.el @@ -22,8 +22,7 @@ ;;; Code: (defvar ninja-keywords - `(("^#.*" . font-lock-comment-face) - (,(concat "^" (regexp-opt '("rule" "build" "subninja" "include" + `((,(concat "^" (regexp-opt '("rule" "build" "subninja" "include" "pool" "default") 'words)) . font-lock-keyword-face) @@ -38,12 +37,16 @@ ("build +\\(?:[^:$\n]\\|$[:$]\\)+ *: *\\([[:alnum:]_.-]+\\)" . (1 font-lock-function-name-face)))) +(defvar ninja-mode-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\" "." table) + table) + "Syntax table used in `ninja-mode'.") + ;;;###autoload (define-derived-mode ninja-mode prog-mode "ninja" (set (make-local-variable 'comment-start) "#") - ;; Pass extra "t" to turn off syntax-based fontification -- we don't want - ;; quoted strings highlighted. - (setq font-lock-defaults '(ninja-keywords t))) + (setq font-lock-defaults '(ninja-keywords))) ;; Run ninja-mode for files ending in .ninja. ;;;###autoload -- cgit v0.12