[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 40a85fb: Support Go language in 'etags'
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-25 40a85fb: Support Go language in 'etags' |
Date: |
Sat, 30 Jan 2016 12:58:12 +0000 |
branch: emacs-25
commit 40a85fba441aa69d47ef9efd645df3411e43ae21
Author: lu4nx <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Support Go language in 'etags'
* 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.
---
doc/emacs/maintaining.texi | 3 ++
doc/man/etags.1 | 2 +-
etc/NEWS | 4 ++
lib-src/etags.c | 75 +++++++++++++++++++++++++++++++++++++++++++-
test/etags/CTAGS.good | 11 ++++++
test/etags/ETAGS.good_1 | 12 +++++++
test/etags/ETAGS.good_2 | 12 +++++++
test/etags/ETAGS.good_3 | 15 +++++++++
test/etags/ETAGS.good_4 | 12 +++++++
test/etags/ETAGS.good_5 | 15 +++++++++
test/etags/ETAGS.good_6 | 15 +++++++++
test/etags/Makefile | 7 ++--
test/etags/go-src/test.go | 11 ++++++
test/etags/go-src/test1.go | 34 ++++++++++++++++++++
14 files changed, 223 insertions(+), 5 deletions(-)
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 7039de6..3f1a9c0 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2218,6 +2218,9 @@ in the file.
In Fortran code, functions, subroutines and block data are tags.
@item
+In Go code, packages, functions, and types are tags.
+
address@hidden
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
and all occurrences of @code{id=}.
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index d34063f..fc247f7 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -50,7 +50,7 @@ format understood by
.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
diff --git a/etc/NEWS b/etc/NEWS
index 78dce16..d0415a2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1834,6 +1834,10 @@ 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
Etags now tags functions even if the "function" keyword follows some
diff --git a/lib-src/etags.c b/lib-src/etags.c
index adc08a2..bdfced5 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -354,6 +354,7 @@ static void Cstar_entries (FILE *);
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 *);
@@ -641,6 +642,10 @@ static const char *Fortran_suffixes [] =
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 [] =
@@ -727,7 +732,7 @@ static const char *Ruby_suffixes [] =
{ "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 [] =
@@ -794,6 +799,7 @@ static language lang_names [] =
{ "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 },
@@ -4209,6 +4215,73 @@ Fortran_functions (FILE *inf)
/*
+ * Go language support
+ * Original code by Xi Lu <address@hidden> (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);
+ }
+ }
+}
+
+
+/*
* Ada parsing
* Original code by
* Philippe Waroquiers (1998)
diff --git a/test/etags/CTAGS.good b/test/etags/CTAGS.good
index 86eb9f8..846725e 100644
--- a/test/etags/CTAGS.good
+++ b/test/etags/CTAGS.good
@@ -947,6 +947,10 @@ MoveLayerAfter lua-src/allegro.lua /^function
MoveLayerAfter (this_one)$/
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)$/
@@ -1077,6 +1081,8 @@ Pkg1_Proc2/p ada-src/waroquiers.ada /^ procedure
Pkg1_Proc2 (I : Integer);$/
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 /address@hidden 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$/
@@ -3135,6 +3141,7 @@ instance_method_question? ruby-src/test.rb /^
def instance_method_questio
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
@@ -3738,6 +3745,7 @@ plain_C_suffixes c-src/etags.c 643
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)$/
@@ -3950,6 +3958,7 @@ save_getcjmp c-src/emacs/src/keyboard.c
/^save_getcjmp (sys_jmp_buf temp)$/
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
@@ -4075,6 +4084,7 @@ step cp-src/clheir.hpp /^ virtual void
step(void) { }$/
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)$/
@@ -4217,6 +4227,7 @@ terminateInput objc-src/Subprocess.m /^-
terminateInput$/
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)$/
diff --git a/test/etags/ETAGS.good_1 b/test/etags/ETAGS.good_1
index 44ac091..c7b1221 100644
--- a/test/etags/ETAGS.good_1
+++ b/test/etags/ETAGS.good_1
@@ -2283,6 +2283,18 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,119
+package main1,0
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/ETAGS.good_2 b/test/etags/ETAGS.good_2
index 8a93e3b..8d0f338 100644
--- a/test/etags/ETAGS.good_2
+++ b/test/etags/ETAGS.good_2
@@ -2852,6 +2852,18 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,119
+package main1,0
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/ETAGS.good_3 b/test/etags/ETAGS.good_3
index e575b40..060389c 100644
--- a/test/etags/ETAGS.good_3
+++ b/test/etags/ETAGS.good_3
@@ -2600,6 +2600,21 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,172
+package main1,0
+type plus 5,28
+type str 9,65
+type intNumber 13,99
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/ETAGS.good_4 b/test/etags/ETAGS.good_4
index 2825806..40404f9 100644
--- a/test/etags/ETAGS.good_4
+++ b/test/etags/ETAGS.good_4
@@ -2447,6 +2447,18 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,119
+package main1,0
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/ETAGS.good_5 b/test/etags/ETAGS.good_5
index 35bb353..432819d 100644
--- a/test/etags/ETAGS.good_5
+++ b/test/etags/ETAGS.good_5
@@ -3333,6 +3333,21 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,172
+package main1,0
+type plus 5,28
+type str 9,65
+type intNumber 13,99
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/ETAGS.good_6 b/test/etags/ETAGS.good_6
index 8add300..4ad5d76 100644
--- a/test/etags/ETAGS.good_6
+++ b/test/etags/ETAGS.good_6
@@ -3333,6 +3333,21 @@ constant (a-forth-constant(a-forth-constant38,628
code assemby-code-word 43,685
: a-forth-word 50,870
+go-src/test.go,48
+package main1,0
+func say(5,28
+func main(9,72
+
+go-src/test1.go,172
+package main1,0
+type plus 5,28
+type str 9,65
+type intNumber 13,99
+func (s str) PrintAdd(17,136
+func (n intNumber) PrintAdd(21,189
+func test(25,248
+func main(29,285
+
html-src/softwarelibero.html,200
Cos'è il software libero?4,38
Licenze d'uso di un programmalicenze65,2500
diff --git a/test/etags/Makefile b/test/etags/Makefile
index 00d5b9f..21a77eb 100644
--- a/test/etags/Makefile
+++ b/test/etags/Makefile
@@ -11,6 +11,7 @@ ELSRC=$(addprefix ./el-src/,TAGTEST.EL
emacs/lisp/progmodes/etags.el)
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)
@@ -27,9 +28,9 @@ RBSRC=$(addprefix ./ruby-src/,test.rb test1.ruby)
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
diff --git a/test/etags/go-src/test.go b/test/etags/go-src/test.go
new file mode 100644
index 0000000..6aea26e
--- /dev/null
+++ b/test/etags/go-src/test.go
@@ -0,0 +1,11 @@
+package main
+
+import "fmt"
+
+func say(msg string) {
+ fmt.Println(msg)
+}
+
+func main() {
+ say("Hello, Emacs!")
+}
diff --git a/test/etags/go-src/test1.go b/test/etags/go-src/test1.go
new file mode 100644
index 0000000..6d1efaa
--- /dev/null
+++ b/test/etags/go-src/test1.go
@@ -0,0 +1,34 @@
+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)
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 40a85fb: Support Go language in 'etags',
Eli Zaretskii <=