mirror of
https://github.com/golang/go
synced 2024-11-11 23:50:22 -07:00
misc/emacs: update go-mode syntax table and comment handling as
suggested by pkleiweg. Fixes #3471. R=adonovan, pkleiweg, rsc CC=golang-dev https://golang.org/cl/7060056
This commit is contained in:
parent
65cb1904c1
commit
f14f458640
@ -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 ?* ". 23" st) ; also part of comments
|
(modify-syntax-entry ?* "." st)
|
||||||
(modify-syntax-entry ?/ (if (featurep 'xemacs) ". 1456" ". 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)
|
(modify-syntax-entry ?| "." st)
|
||||||
@ -50,9 +50,6 @@
|
|||||||
(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.")
|
||||||
|
|
||||||
@ -552,9 +549,8 @@ 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 newline, or char whitespace in the syntax table for go."
|
"Is char whitespace in the syntax table for go."
|
||||||
(or (eq char ?\n)
|
(eq 32 (char-syntax char)))
|
||||||
(= (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."
|
||||||
@ -573,7 +569,7 @@ token on the line."
|
|||||||
((go-mode-in-comment)
|
((go-mode-in-comment)
|
||||||
;; move point to char preceeding current comment
|
;; move point to char preceeding current comment
|
||||||
(goto-char (1- (car (go-mode-in-comment)))))
|
(goto-char (1- (car (go-mode-in-comment)))))
|
||||||
|
|
||||||
;; not in a comment or whitespace? we must be done.
|
;; not in a comment or whitespace? we must be done.
|
||||||
(t (setq loop-guard nil)
|
(t (setq loop-guard nil)
|
||||||
(forward-char 1)))))))
|
(forward-char 1)))))))
|
||||||
@ -727,6 +723,8 @@ functions, and some types. It also provides indentation that is
|
|||||||
;; Comments
|
;; Comments
|
||||||
(set (make-local-variable 'comment-start) "// ")
|
(set (make-local-variable 'comment-start) "// ")
|
||||||
(set (make-local-variable 'comment-end) "")
|
(set (make-local-variable 'comment-end) "")
|
||||||
|
(set (make-local-variable 'comment-use-syntax) nil)
|
||||||
|
(set (make-local-variable 'comment-start-skip) "\\([ \t]*\\)// ")
|
||||||
|
|
||||||
;; Go style
|
;; Go style
|
||||||
(setq indent-tabs-mode t)
|
(setq indent-tabs-mode t)
|
||||||
|
Loading…
Reference in New Issue
Block a user