Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: tools/gn/misc/emacs/gn-mode.el

Issue 1071733002: gn-mode: Get fill-paragraph working correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rietveld is flake. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698