summaryrefslogtreecommitdiffstats
path: root/misc/ninja-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'misc/ninja-mode.el')
-rw-r--r--misc/ninja-mode.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/misc/ninja-mode.el b/misc/ninja-mode.el
index 021ede1..fd54b29 100644
--- a/misc/ninja-mode.el
+++ b/misc/ninja-mode.el
@@ -43,9 +43,26 @@
table)
"Syntax table used in `ninja-mode'.")
+(defun ninja-syntax-propertize (start end)
+ (save-match-data
+ (save-excursion
+ (goto-char start)
+ (while (search-forward "#" end t)
+ (let ((match-pos (match-beginning 0)))
+ (when (and
+ ;; Is it the first non-white character on the line?
+ (eq match-pos (save-excursion (back-to-indentation) (point)))
+ ;; Are we *not* continuing the previous line?
+ (not (eq ?$ (char-before (line-end-position 0)))))
+ (put-text-property match-pos (1+ match-pos) 'syntax-table '(11))
+ (let ((line-end (line-end-position)))
+ (put-text-property line-end (1+ line-end) 'syntax-table '(12)))))))))
+
;;;###autoload
(define-derived-mode ninja-mode prog-mode "ninja"
(set (make-local-variable 'comment-start) "#")
+ (set (make-local-variable 'parse-sexp-lookup-properties) t)
+ (set (make-local-variable 'syntax-propertize-function) #'ninja-syntax-propertize)
(setq font-lock-defaults '(ninja-keywords)))
;; Run ninja-mode for files ending in .ninja.