Index: tools/gn/misc/emacs/gn-mode.el |
diff --git a/tools/gn/misc/emacs/gn-mode.el b/tools/gn/misc/emacs/gn-mode.el |
index ebac11b80c333d781e5d3e0f7e9f7c1173b0ee64..c7ee08bcf0a8de08e0584a3afb403995e666c122 100644 |
--- a/tools/gn/misc/emacs/gn-mode.el |
+++ b/tools/gn/misc/emacs/gn-mode.el |
@@ -20,8 +20,6 @@ |
;; - We syntax highlight builtin actions, but don't highlight instantiations of |
;; templates. Should we? |
-;; - `fill-paragraph' works for comments, but when pointed at code, breaks |
-;; spectacularly. |
@@ -118,6 +116,14 @@ variable name or the '{{' and '}}' which surround it." |
(and (not (smie-rule-bolp)) (smie-rule-prev-p "else") |
(smie-rule-parent))))) |
+(defun gn-fill-paragraph (&optional justify) |
+ "We only fill inside of comments in GN mode." |
+ (interactive "P") |
+ (or (fill-comment-paragraph justify) |
+ ;; Never return nil; `fill-paragraph' will perform its default behavior |
+ ;; if we do. |
+ t)) |
+ |
;;;###autoload |
(define-derived-mode gn-mode prog-mode "GN" |
"Major mode for editing gn (Generate Ninja)." |
@@ -127,6 +133,8 @@ variable name or the '{{' and '}}' which surround it." |
(setq-local comment-start "#") |
(setq-local comment-end "") |
+ (setq-local fill-paragraph-function 'gn-fill-paragraph) |
+ |
(setq-local font-lock-defaults '(gn-font-lock-keywords)) |
;; For every 'rule("name") {', adds "name" to the imenu for quick navigation. |