]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: fix go-mode syntax table and whitespace handling.
authorSameer Ajmani <sameer@golang.org>
Mon, 2 Apr 2012 16:59:37 +0000 (12:59 -0400)
committerSameer Ajmani <sameer@golang.org>
Mon, 2 Apr 2012 16:59:37 +0000 (12:59 -0400)
- flag * and / as comment characters
- mark newline as a comment-ender
- include newline in go-mode-whitespace-p

Thanks Jonathan Amsterdam and Steve Yegge for the patch!

R=golang-dev, rsc
CC=golang-dev, jba, stevey
https://golang.org/cl/5938056

misc/emacs/go-mode.el

index 33ee7022fd0cffb63416a2d44c38ac8582bc5a45..a98c7de589370b7244b40e508209d1ea50a727bc 100644 (file)
@@ -33,8 +33,8 @@
     ;; Operators (punctuation)
     (modify-syntax-entry ?+  "." st)
     (modify-syntax-entry ?-  "." st)
-    (modify-syntax-entry ?*  "." st)
-    (modify-syntax-entry ?/  "." st)
+    (modify-syntax-entry ?*  ". 23" st)   ; also part of comments
+    (modify-syntax-entry ?/  ". 124b" st) ; ditto
     (modify-syntax-entry ?%  "." st)
     (modify-syntax-entry ?&  "." st)
     (modify-syntax-entry ?|  "." st)
@@ -50,6 +50,9 @@
     (modify-syntax-entry ?`  "." st)
     (modify-syntax-entry ?\\ "." st)
 
+    ;; Newline is a comment-ender.
+    (modify-syntax-entry ?\n "> b" st)
+
     st)
   "Syntax table for Go mode.")
 
@@ -545,8 +548,9 @@ token on the line."
          (not (looking-at go-mode-non-terminating-keywords-regexp)))))))
 
 (defun go-mode-whitespace-p (char)
-  "Is char whitespace in the syntax table for go."
-  (eq 32 (char-syntax char)))
+  "Is newline, or char whitespace in the syntax table for go."
+  (or (eq char ?\n)
+      (eq 32 (char-syntax char))))
 
 (defun go-mode-backward-skip-comments ()
   "Skip backward over comments and whitespace."