]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: do not highlight built-in function if not followed by '('
authorRui Ueyama <ruiu@google.com>
Thu, 27 Mar 2014 21:35:07 +0000 (17:35 -0400)
committerAlan Donovan <adonovan@google.com>
Thu, 27 Mar 2014 21:35:07 +0000 (17:35 -0400)
Name of built-in function is not reserved word in Go, and you can
use it as variable name. "new" is often used as local variable, for
instance.

This patch is to apply font-lock-builtin-face only when built-in
function name is followed by '(', so that it doesn't highlight
non-function variable that happen to have the same name as built-in
function.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef, adonovan
CC=golang-codereviews
https://golang.org/cl/79260043

misc/emacs/go-mode.el

index a536a17d2c47ca3d5da598422c3ca2efacbbaace..29b1fa4423ac2c47e9f953b5fbbcf47511837036 100644 (file)
@@ -262,7 +262,7 @@ For mode=set, all covered lines will have this weight."
   ;; doesn't understand that
   (append
    `((,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) . font-lock-keyword-face)
-     (,(go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) . font-lock-builtin-face)
+     (,(concat "\\(" (go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) "\\)[[:space:]]*(") 1 font-lock-builtin-face)
      (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) . font-lock-constant-face)
      (,go-func-regexp 1 font-lock-function-name-face)) ;; function (not method) name