1
0
mirror of https://github.com/golang/go synced 2024-11-26 00:07:57 -07:00

misc/emacs: fix go-mode syntax table and whitespace handling.

- 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
This commit is contained in:
Sameer Ajmani 2012-04-02 12:59:37 -04:00
parent e709585151
commit b0f4d805f2

View File

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