* lib-src/etags.c <Ruby_help>: Fix documentation of Ruby tags.
<Go_help>: New help.
<Go_suffixes>: New variable.
(Go_functions): New function.
<lang_names>: Add entry for Go. (Bug#22370)
* doc/emacs/maintaining.texi (Tag Syntax): Document Go support.
* doc/man/etags.1: Mention Go support.
* etc/NEWS: Mention Go support.
* test/etags/go-src/test.go:
* test/etags/go-src/test1.go: New test files.
* test/etags/Makefile (GOSRC): New variable.
(SRCS): Add $(GOSRC).
* test/etags/ETAGS.good_1:
* test/etags/ETAGS.good_2:
* test/etags/ETAGS.good_3:
* test/etags/ETAGS.good_4:
* test/etags/ETAGS.good_5:
* test/etags/ETAGS.good_6:
* test/etags/CTAGS.good: Adapt to addition of Go tests.
@item
In Fortran code, functions, subroutines and block data are tags.
+@item
+In Go code, packages, functions, and types are tags.
+
@item
In HTML input files, the tags are the @code{title} and the @code{h1},
@code{h2}, @code{h3} headers. Also, tags are @code{name=} in anchors
.BR vi ( 1 )\c
\&. Both forms of the program understand
the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Erlang,
-Forth, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Pascal, Perl,
+Forth, Go, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Pascal, Perl,
Ruby, PHP, PostScript, Python, Prolog, Scheme and
most assembler\-like syntaxes.
Both forms read the files specified on the command line, and write a tag
Names of modules, classes, methods, functions, and constants are
tagged. Overloaded operators are also tagged.
++++
+*** New language Go
+Names of packages, functions, and types are tagged.
+
+++
*** Improved support for Lua
static void Erlang_functions (FILE *);
static void Forth_words (FILE *);
static void Fortran_functions (FILE *);
+static void Go_functions (FILE *);
static void HTML_labels (FILE *);
static void Lisp_functions (FILE *);
static void Lua_functions (FILE *);
static const char Fortran_help [] =
"In Fortran code, functions, subroutines and block data are tags.";
+static const char *Go_suffixes [] = {"go", NULL};
+static const char Go_help [] =
+ "In Go code, functions, interfaces and packages are tags.";
+
static const char *HTML_suffixes [] =
{ "htm", "html", "shtml", NULL };
static const char HTML_help [] =
{ "rb", "ruby", NULL };
static const char Ruby_help [] =
"In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\
-a line generate a tag.";
+a line generate a tag. Constants also generate a tag.";
/* Can't do the `SCM' or `scm' prefix with a version number. */
static const char *Scheme_suffixes [] =
{ "erlang", Erlang_help, Erlang_functions, Erlang_suffixes },
{ "forth", Forth_help, Forth_words, Forth_suffixes },
{ "fortran", Fortran_help, Fortran_functions, Fortran_suffixes },
+ { "go", Go_help, Go_functions, Go_suffixes },
{ "html", HTML_help, HTML_labels, HTML_suffixes },
{ "java", Cjava_help, Cjava_entries, Cjava_suffixes },
{ "lisp", Lisp_help, Lisp_functions, Lisp_suffixes },
}
}
+\f
+/*
+ * Go language support
+ * Original code by Xi Lu <lx@shellcodes.org> (2016)
+ */
+static void
+Go_functions(FILE *inf)
+{
+ char *cp, *name;
+
+ LOOP_ON_INPUT_LINES(inf, lb, cp)
+ {
+ cp = skip_spaces (cp);
+
+ if (LOOKING_AT (cp, "package"))
+ {
+ name = cp;
+ while (!notinname (*cp) && *cp != '\0')
+ cp++;
+ make_tag (name, cp - name, false, lb.buffer,
+ cp - lb.buffer + 1, lineno, linecharno);
+ }
+ else if (LOOKING_AT (cp, "func"))
+ {
+ /* Go implementation of interface, such as:
+ func (n *Integer) Add(m Integer) ...
+ skip `(n *Integer)` part.
+ */
+ if (*cp == '(')
+ {
+ while (*cp != ')')
+ cp++;
+ cp = skip_spaces (cp+1);
+ }
+
+ if (*cp)
+ {
+ name = cp;
+
+ while (!notinname (*cp))
+ cp++;
+
+ make_tag (name, cp - name, true, lb.buffer,
+ cp - lb.buffer + 1, lineno, linecharno);
+ }
+ }
+ else if (members && LOOKING_AT (cp, "type"))
+ {
+ name = cp;
+
+ /* Ignore the likes of the following:
+ type (
+ A
+ )
+ */
+ if (*cp == '(')
+ return;
+
+ while (!notinname (*cp) && *cp != '\0')
+ cp++;
+
+ make_tag (name, cp - name, false, lb.buffer,
+ cp - lb.buffer + 1, lineno, linecharno);
+ }
+ }
+}
+
\f
/*
* Ada parsing
MoveLayerBefore lua-src/allegro.lua /^function MoveLayerBefore (this_one)$/
MoveLayerBottom lua-src/allegro.lua /^function MoveLayerBottom ()$/
MoveLayerTop lua-src/allegro.lua /^function MoveLayerTop ()$/
+Mtest.go go-src/test.go 1
+Mtest.go go-src/test.go /^func main() {$/
+Mtest1.go go-src/test1.go 1
+Mtest1.go go-src/test1.go /^func main() {$/
Mx.cc cp-src/x.cc /^main(int argc, char *argv[])$/
NAME y-src/cccp.c 8
NATNUMP c-src/emacs/src/lisp.h /^NATNUMP (Lisp_Object x)$/
Pkg1_Proc2/p ada-src/waroquiers.ada /^ procedure Pkg1_Proc2 (I : Integer) is$/
PostControls pyt-src/server.py /^ def PostControls(self):$/
Pre_Call_State/t ada-src/2ataspri.ads /^ type Pre_Call_State is new System.Address;$/
+PrintAdd go-src/test1.go /^func (s str) PrintAdd() {$/
+PrintAdd go-src/test1.go /^func (n intNumber) PrintAdd() {$/
Private objc-src/Subprocess.m /^@interface Subprocess(Private)$/
Private_T/b ada-src/etags-test-for.ada /^ task body Private_T is$/
Private_T/b ada-src/waroquiers.ada /^ task body Private_T is$/
instr y-src/parse.y 80
instr parse.y 80
instruct c-src/etags.c 2527
+intNumber go-src/test1.go 13
integer c-src/emacs/src/lisp.h 2127
integer cccp.y 113
integer y-src/cccp.y 112
plainc c-src/etags.c 2934
plist c-src/emacs/src/lisp.h 697
plus cp-src/functions.cpp /^void Date::plus ( int days , int month , int year /
+plus go-src/test1.go 5
plusvalseq prol-src/natded.prolog /^plusvalseq([]) --> [].$/
pointer c-src/emacs/src/lisp.h 2125
poll_for_input c-src/emacs/src/keyboard.c /^poll_for_input (struct atimer *timer)$/
save_type c-src/emacs/src/lisp.h /^save_type (struct Lisp_Save_Value *v, int n)$/
savenstr c-src/etags.c /^savenstr (const char *cp, int len)$/
savestr c-src/etags.c /^savestr (const char *cp)$/
+say go-src/test.go /^func say(msg string) {$/
scan_separators c-src/etags.c /^scan_separators (char *name)$/
scolonseen c-src/etags.c 2447
scratch c-src/sysdep.h 56
step_everybody cp-src/clheir.cpp /^void step_everybody(void)$/
stop_polling c-src/emacs/src/keyboard.c /^stop_polling (void)$/
store_user_signal_events c-src/emacs/src/keyboard.c /^store_user_signal_events (void)$/
+str go-src/test1.go 9
strcaseeq c-src/etags.c /^#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=/
streq c-src/etags.c /^#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL/
string_intervals c-src/emacs/src/lisp.h /^string_intervals (Lisp_Object s)$/
test c-src/emacs/src/lisp.h 1871
test cp-src/c.C 86
test erl-src/gs_dialog.erl /^test() ->$/
+test go-src/test1.go /^func test(p plus) {$/
test php-src/ptest.php /^test $/
test.me22b lua-src/test.lua /^ local function test.me22b (one)$/
test.me_22a lua-src/test.lua /^ function test.me_22a(one, two)$/
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,119
+package main\7f1,0
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,119
+package main\7f1,0
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,172
+package main\7f1,0
+type plus \7f5,28
+type str \7f9,65
+type intNumber \7f13,99
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,119
+package main\7f1,0
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,172
+package main\7f1,0
+type plus \7f5,28
+type str \7f9,65
+type intNumber \7f13,99
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
code assemby-code-word \7f43,685
: a-forth-word \7f50,870
\f
+go-src/test.go,48
+package main\7f1,0
+func say(\7f5,28
+func main(\7f9,72
+\f
+go-src/test1.go,172
+package main\7f1,0
+type plus \7f5,28
+type str \7f9,65
+type intNumber \7f13,99
+func (s str) PrintAdd(\7f17,136
+func (n intNumber) PrintAdd(\7f21,189
+func test(\7f25,248
+func main(\7f29,285
+\f
html-src/softwarelibero.html,200
Cos'è il software libero?\7f4,38
Licenze d'uso di un programma\7flicenze\ 165,2500
ERLSRC=$(addprefix ./erl-src/,gs_dialog.erl)
FORTHSRC=$(addprefix ./forth-src/,test-forth.fth)
FSRC=$(addprefix ./f-src/,entry.for entry.strange_suffix entry.strange)
+GOSRC=$(addprefix ./go-src/,test.go test1.go)
HTMLSRC=$(addprefix ./html-src/,softwarelibero.html index.shtml algrthms.html software.html)
#JAVASRC=$(addprefix ./java-src/, )
LUASRC=$(addprefix ./lua-src/,allegro.lua test.lua)
TEXSRC=$(addprefix ./tex-src/,testenv.tex gzip.texi texinfo.tex nonewline.tex)
YSRC=$(addprefix ./y-src/,parse.y parse.c atest.y cccp.c cccp.y)
SRCS=${ADASRC} ${ASRC} ${CSRC} ${CPSRC} ${ELSRC} ${ERLSRC} ${FSRC}\
- ${FORTHSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC} ${OBJCSRC}\
- ${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC} ${PROLSRC} ${PYTSRC}\
- ${RBSRC} ${TEXSRC} ${YSRC}
+ ${FORTHSRC} ${GOSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC}\
+ ${OBJCSRC} ${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC}\
+ ${PROLSRC} ${PYTSRC} ${RBSRC} ${TEXSRC} ${YSRC}
NONSRCS=./f-src/entry.strange ./erl-src/lists.erl ./cp-src/clheir.hpp.gz
ETAGS_PROG=../../lib-src/etags
--- /dev/null
+package main
+
+import "fmt"
+
+func say(msg string) {
+ fmt.Println(msg)
+}
+
+func main() {
+ say("Hello, Emacs!")
+}
--- /dev/null
+package main
+
+import "fmt"
+
+type plus interface {
+ PrintAdd()
+}
+
+type str struct {
+ a, b string
+}
+
+type intNumber struct {
+ a, b int
+}
+
+func (s str) PrintAdd() {
+ fmt.Println(s.a + s.b)
+}
+
+func (n intNumber) PrintAdd() {
+ fmt.Println(n.a + n.b)
+}
+
+func test(p plus) {
+ p.PrintAdd()
+}
+
+func main() {
+ s := str{a: "Hello,", b: "Emacs!"}
+ number := intNumber{a: 1, b: 2}
+ test(number)
+ test(s)
+}