Commit 1251868f authored by erg's avatar erg Committed by Commit bot

gn-mode: Get fill-paragraph working correctly.

Define a fill-paragraph-function which only fills in comments instead of
everywhere. Previously, we would fill in other contexts, like lists.

BUG=none

Review URL: https://codereview.chromium.org/1071733002

Cr-Commit-Position: refs/heads/master@{#324328}
parent 3f5bfc1e
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment