]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: Add support for methods with unnamed receiver
authorDominik Honnef <dominik.honnef@gmail.com>
Wed, 15 May 2013 03:23:35 +0000 (20:23 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 May 2013 03:23:35 +0000 (20:23 -0700)
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

misc/emacs/go-mode.el

index 6f0442aff0a6842a9620fb62b110d4246f0ed6ba..b44740fafc12923a531e7ff9ba5dee1a9a7de199 100644 (file)
 (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"
      ;; 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.