From: Dominik Honnef Date: Wed, 15 May 2013 03:23:35 +0000 (-0700) Subject: misc/emacs: Add support for methods with unnamed receiver X-Git-Tag: go1.2rc2~1513 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=72b14cbb75b3b0d8899d24174a94ece100d073b7;p=gostls13.git misc/emacs: Add support for methods with unnamed receiver This fixes fontification, navigation and indentation for methods of the form `func (Foo) Bar...` R=adonovan CC=gobot, golang-dev https://golang.org/cl/8951043 --- diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el index 6f0442aff0..b44740fafc 100644 --- a/misc/emacs/go-mode.el +++ b/misc/emacs/go-mode.el @@ -77,7 +77,12 @@ (defconst go-label-regexp go-identifier-regexp) (defconst go-type-regexp "[[:word:][:multibyte:]*]+") (defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(" go-identifier-regexp "\\)")) -(defconst go-func-meth-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" go-identifier-regexp "\\s +" go-type-regexp "\\s *)\\s *\\)?\\(" go-identifier-regexp "\\)(")) +(defconst go-func-meth-regexp (concat + (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" + "\\(" go-identifier-regexp "\\s +\\)?" go-type-regexp + "\\s *)\\s *\\)?\\(" + go-identifier-regexp + "\\)(")) (defconst go-builtins '("append" "cap" "close" "complex" "copy" "delete" "imag" "len" "make" "new" @@ -159,6 +164,7 @@ ;; TODO do we actually need this one or isn't it just a function call? (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type conversion (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" go-identifier-regexp "[[:space:]]+" go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver + (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver without variable name ;; Like the original go-mode this also marks compound literal ;; fields. There, it was marked as to fix, but I grew quite ;; accustomed to it, so it'll stay for now.