From unknown Sun Aug 10 16:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22370: [PATCH] Initial support for Go Language in 'etags' Resent-From: lu4nx Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jan 2016 06:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22370 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 22370@debbugs.gnu.org Cc: lu4nx X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145275151626387 (code B ref -1); Thu, 14 Jan 2016 06:06:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Jan 2016 06:05:16 +0000 Received: from localhost ([127.0.0.1]:48752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJb23-0006rW-JT for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39058) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJb21-0006rI-CK for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJb1u-0002bX-TH for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1u-0002bT-QU for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1t-0007Aj-Fq for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJb1o-0002XL-FW for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:05 -0500 Received: from smtpbg3.qq.com ([183.60.61.198]:51013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1n-0002VP-J8 for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:00 -0500 X-QQ-mid: Xesmtp23t1452749288t004t2898 Received: from lx-pc (unknown [182.138.102.86]) by esmtp4.qq.com (ESMTP) with id ; Thu, 14 Jan 2016 13:28:07 +0800 (CST) X-QQ-SSF: B1000000000000F0FF103F00000000Z X-QQ-FEAT: QX/rXDl9P1v7/8mMno5i9yiok3aI6wv1d6614/b2jAwSHc59tdFOgTNS1h1qU D74u3ouDJUspZMOqsrVBSx3++2meLfB/8joEu44aVJzl/n6DJCfZhV7aQFCbveqEHB3+y7F V5YqhafZqdPBLRwl4YZhc8wlB01l9lxnfVgSRAk/2/qAlqkbCFbzYwXSGvA/3AIAkMrIP/r kTJzz4Qt1/VRs2d6ItUSzCiBB+lPz1kdoXX2BAYIxoGt/bvi4bp/2U5WWhuVYn6A/EzPwBS 4jTg== X-QQ-GoodBg: 0 From: lu4nx Date: Thu, 14 Jan 2016 13:27:48 +0800 Message-Id: <1452749268-4569-1-git-send-email-lx@shellcodes.org> X-Mailer: git-send-email 2.5.0 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) * lib-src/etags.c : New variable. (lang_names): Add an entry for Go (Go_functions): Add new function. * test/manual/etags/ETAGS.good_6: Add TAGS content for Go * test/manual/etags/Makefile: (GOSRC): Add new variable. (SRCS): Add an entry for Go. --- lib-src/etags.c | 73 +++++++++++++++++++++++++++++++++++++++ test/manual/etags/ETAGS.good_6 | 15 ++++++++ test/manual/etags/Makefile | 3 +- test/manual/etags/go-src/test.go | 11 ++++++ test/manual/etags/go-src/test1.go | 34 ++++++++++++++++++ 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 test/manual/etags/go-src/test.go create mode 100644 test/manual/etags/go-src/test1.go diff --git a/lib-src/etags.c b/lib-src/etags.c index 2192627..5320686 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."; + static const char *HTML_suffixes [] = { "htm", "html", "shtml", NULL }; static const char HTML_help [] = @@ -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 }, @@ -4210,6 +4216,73 @@ Fortran_functions (FILE *inf) /* + * Go language support + * Idea by Xi Lu . (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 similar to 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/manual/etags/ETAGS.good_6 b/test/manual/etags/ETAGS.good_6 index 39522db..3c53a8b 100644 --- a/test/manual/etags/ETAGS.good_6 +++ b/test/manual/etags/ETAGS.good_6 @@ -5406,3 +5406,18 @@ tex-src/nonewline.tex,0 php-src/sendmail.php,0 a-src/empty.zz,0 + +test.go,48 +package main1,0 +func say(5,28 +func main(9,72 + +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 diff --git a/test/manual/etags/Makefile b/test/manual/etags/Makefile index 4d9f358..81ee7a7 100644 --- a/test/manual/etags/Makefile +++ b/test/manual/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,7 +28,7 @@ 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}\ + ${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 diff --git a/test/manual/etags/go-src/test.go b/test/manual/etags/go-src/test.go new file mode 100644 index 0000000..6aea26e --- /dev/null +++ b/test/manual/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/manual/etags/go-src/test1.go b/test/manual/etags/go-src/test1.go new file mode 100644 index 0000000..6d1efaa --- /dev/null +++ b/test/manual/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) +} -- 2.5.0 From unknown Sun Aug 10 16:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22370: [PATCH] Initial support for Go Language in 'etags' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jan 2016 16:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22370 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: lu4nx Cc: 22370@debbugs.gnu.org, lx@shellcodes.org Reply-To: Eli Zaretskii Received: via spool by 22370-submit@debbugs.gnu.org id=B22370.145278754729175 (code B ref 22370); Thu, 14 Jan 2016 16:06:01 +0000 Received: (at 22370) by debbugs.gnu.org; 14 Jan 2016 16:05:47 +0000 Received: from localhost ([127.0.0.1]:49329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJkPC-0007aS-Bj for submit@debbugs.gnu.org; Thu, 14 Jan 2016 11:05:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41144) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJkPA-0007aD-03 for 22370@debbugs.gnu.org; Thu, 14 Jan 2016 11:05:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJkP1-0006xP-0P for 22370@debbugs.gnu.org; Thu, 14 Jan 2016 11:05:39 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJkOp-0006w8-VU; Thu, 14 Jan 2016 11:05:23 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3275 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aJkOp-0002Ce-95; Thu, 14 Jan 2016 11:05:23 -0500 Date: Thu, 14 Jan 2016 18:05:38 +0200 Message-Id: <8360ywi1t9.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <1452749268-4569-1-git-send-email-lx@shellcodes.org> (message from lu4nx on Thu, 14 Jan 2016 13:27:48 +0800) References: <1452749268-4569-1-git-send-email-lx@shellcodes.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: lu4nx > Date: Thu, 14 Jan 2016 13:27:48 +0800 > Cc: lu4nx > > * lib-src/etags.c : New variable. > (lang_names): Add an entry for Go > (Go_functions): Add new function. Thanks. > * test/manual/etags/ETAGS.good_6: Add TAGS content for Go Why only ETAGS.good_6? What about other ETAGS.good_N files, and the CTAGS file? I will look into pushing this to emacs-25 in a few days, if no one beats me to it. From unknown Sun Aug 10 16:43:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22370: [PATCH] Initial support for Go Language in 'etags' Resent-From: lux Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jan 2016 16:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22370 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 22370@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145278817430184 (code B ref -1); Thu, 14 Jan 2016 16:17:01 +0000 Received: (at submit) by debbugs.gnu.org; 14 Jan 2016 16:16:14 +0000 Received: from localhost ([127.0.0.1]:49340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJkZK-0007qm-B6 for submit@debbugs.gnu.org; Thu, 14 Jan 2016 11:16:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44657) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJkZI-0007qZ-BD for submit@debbugs.gnu.org; Thu, 14 Jan 2016 11:16:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJkZC-0001ZN-Cz for submit@debbugs.gnu.org; Thu, 14 Jan 2016 11:16:07 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33874) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJkZC-0001ZJ-9n for submit@debbugs.gnu.org; Thu, 14 Jan 2016 11:16:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJkZB-0005tN-D3 for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 11:16:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJkZ8-0001Yc-6d for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 11:16:05 -0500 Received: from smtpbg65.qq.com ([103.7.28.233]:8298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJkZ7-0001UW-LO for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 11:16:02 -0500 X-QQ-mid: Xesmtp27t1452788146t743t2439 Received: from [192.168.31.155] (unknown [58.20.19.78]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for ; Fri, 15 Jan 2016 00:15:45 +0800 (CST) X-QQ-SSF: 00000000000000F0FF113000000000Z X-QQ-FEAT: pJiIyMrDeHvix8D+yq9sd5LAEMhrPQEuLbyb7mRu8zVVWSD2erCsjUNhcZIR0 t0krtJEZbNU4yWtkoq2tdSl7JfgnktsVof0PgZGtXMjcrgm4+bEcyfDWIcTn/CXSdWEaal+ jrjeGwDhRPgDTznCKrTUNh0AifZkmBBEN2q6PXg7zFj7Pxnb8C2zh3bNfY09/mp/XXz2VnJ tnKPJSkw0kXVZKKECX+UU+hghfCAk+pheN0C23KbKYBA+KKsjpcA5 X-QQ-GoodBg: 0 References: <1452749268-4569-1-git-send-email-lx@shellcodes.org> <8360ywi1t9.fsf@gnu.org> From: lux Message-ID: <5697C9B1.9070302@shellcodes.org> Date: Fri, 15 Jan 2016 00:15:45 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <8360ywi1t9.fsf@gnu.org> Content-Type: multipart/alternative; boundary="------------040408040506060600040505" X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------040408040506060600040505 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2016年01月15日 00:05, Eli Zaretskii 写道: > Why only ETAGS.good_6? What about other ETAGS.good_N files, and the > CTAGS file? I'm not familiar ETAGS.good_N files and CTAGS file, I run `make check` is failed: /Makefile:61: recipe for target 'ediff_1' failed// //make[1]: *** [ediff_1] Error 1// //make[1]: Leaving directory '/opt/emacs/emacs-25/test/manual/etags'// //Makefile:52: recipe for target 'check' failed// //make: *** [check] Error 2/ So I don't update other ETAGS.good_N files. Thanks. --------------040408040506060600040505 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
在 2016年01月15日 00:05, Eli Zaretskii 写道:
Why only ETAGS.good_6?  What about other ETAGS.good_N files, and the
CTAGS file?
I'm not familiar  ETAGS.good_N files and CTAGS file,
I run `make check` is failed:

Makefile:61: recipe for target 'ediff_1' failed
make[1]: *** [ediff_1] Error 1
make[1]: Leaving directory '/opt/emacs/emacs-25/test/manual/etags'
Makefile:52: recipe for target 'check' failed
make: *** [check] Error 2

So I don't update other ETAGS.good_N files.

Thanks.
--------------040408040506060600040505-- From unknown Sun Aug 10 16:43:49 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: lu4nx Subject: bug#22370: closed (Re: bug#22370: [PATCH] Initial support for Go Language in 'etags') Message-ID: References: <83h9hvw7eu.fsf@gnu.org> <1452749268-4569-1-git-send-email-lx@shellcodes.org> X-Gnu-PR-Message: they-closed 22370 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 22370@debbugs.gnu.org Date: Sat, 30 Jan 2016 13:00:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1454158803-31697-1" This is a multi-part message in MIME format... ------------=_1454158803-31697-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #22370: [PATCH] Initial support for Go Language in 'etags' which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 22370@debbugs.gnu.org. --=20 22370: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D22370 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1454158803-31697-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 22370-done) by debbugs.gnu.org; 30 Jan 2016 12:59:14 +0000 Received: from localhost ([127.0.0.1]:41074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aPV7S-0008Df-L8 for submit@debbugs.gnu.org; Sat, 30 Jan 2016 07:59:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53446) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aPV7R-0008DS-86 for 22370-done@debbugs.gnu.org; Sat, 30 Jan 2016 07:59:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPV7H-0007kx-4I for 22370-done@debbugs.gnu.org; Sat, 30 Jan 2016 07:59:07 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPV7H-0007kt-0x; Sat, 30 Jan 2016 07:59:03 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1860 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aPV7G-000797-7y; Sat, 30 Jan 2016 07:59:02 -0500 Date: Sat, 30 Jan 2016 14:58:33 +0200 Message-Id: <83h9hvw7eu.fsf@gnu.org> From: Eli Zaretskii To: lx@shellcodes.org In-reply-to: <8360ywi1t9.fsf@gnu.org> (message from Eli Zaretskii on Thu, 14 Jan 2016 18:05:38 +0200) Subject: Re: bug#22370: [PATCH] Initial support for Go Language in 'etags' References: <1452749268-4569-1-git-send-email-lx@shellcodes.org> <8360ywi1t9.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 22370-done Cc: 22370-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Thu, 14 Jan 2016 18:05:38 +0200 > From: Eli Zaretskii > Cc: 22370@debbugs.gnu.org, lx@shellcodes.org > > I will look into pushing this to emacs-25 in a few days, if no one > beats me to it. Done. ------------=_1454158803-31697-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Jan 2016 06:05:16 +0000 Received: from localhost ([127.0.0.1]:48752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJb23-0006rW-JT for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39058) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJb21-0006rI-CK for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJb1u-0002bX-TH for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1u-0002bT-QU for submit@debbugs.gnu.org; Thu, 14 Jan 2016 01:05:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1t-0007Aj-Fq for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJb1o-0002XL-FW for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:05 -0500 Received: from smtpbg3.qq.com ([183.60.61.198]:51013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJb1n-0002VP-J8 for bug-gnu-emacs@gnu.org; Thu, 14 Jan 2016 01:05:00 -0500 X-QQ-mid: Xesmtp23t1452749288t004t2898 Received: from lx-pc (unknown [182.138.102.86]) by esmtp4.qq.com (ESMTP) with id ; Thu, 14 Jan 2016 13:28:07 +0800 (CST) X-QQ-SSF: B1000000000000F0FF103F00000000Z X-QQ-FEAT: QX/rXDl9P1v7/8mMno5i9yiok3aI6wv1d6614/b2jAwSHc59tdFOgTNS1h1qU D74u3ouDJUspZMOqsrVBSx3++2meLfB/8joEu44aVJzl/n6DJCfZhV7aQFCbveqEHB3+y7F V5YqhafZqdPBLRwl4YZhc8wlB01l9lxnfVgSRAk/2/qAlqkbCFbzYwXSGvA/3AIAkMrIP/r kTJzz4Qt1/VRs2d6ItUSzCiBB+lPz1kdoXX2BAYIxoGt/bvi4bp/2U5WWhuVYn6A/EzPwBS 4jTg== X-QQ-GoodBg: 0 From: lu4nx To: bug-gnu-emacs@gnu.org Subject: [PATCH] Initial support for Go Language in 'etags' Date: Thu, 14 Jan 2016 13:27:48 +0800 Message-Id: <1452749268-4569-1-git-send-email-lx@shellcodes.org> X-Mailer: git-send-email 2.5.0 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: lu4nx X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) * lib-src/etags.c : New variable. (lang_names): Add an entry for Go (Go_functions): Add new function. * test/manual/etags/ETAGS.good_6: Add TAGS content for Go * test/manual/etags/Makefile: (GOSRC): Add new variable. (SRCS): Add an entry for Go. --- lib-src/etags.c | 73 +++++++++++++++++++++++++++++++++++++++ test/manual/etags/ETAGS.good_6 | 15 ++++++++ test/manual/etags/Makefile | 3 +- test/manual/etags/go-src/test.go | 11 ++++++ test/manual/etags/go-src/test1.go | 34 ++++++++++++++++++ 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 test/manual/etags/go-src/test.go create mode 100644 test/manual/etags/go-src/test1.go diff --git a/lib-src/etags.c b/lib-src/etags.c index 2192627..5320686 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."; + static const char *HTML_suffixes [] = { "htm", "html", "shtml", NULL }; static const char HTML_help [] = @@ -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 }, @@ -4210,6 +4216,73 @@ Fortran_functions (FILE *inf) /* + * Go language support + * Idea by Xi Lu . (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 similar to 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/manual/etags/ETAGS.good_6 b/test/manual/etags/ETAGS.good_6 index 39522db..3c53a8b 100644 --- a/test/manual/etags/ETAGS.good_6 +++ b/test/manual/etags/ETAGS.good_6 @@ -5406,3 +5406,18 @@ tex-src/nonewline.tex,0 php-src/sendmail.php,0 a-src/empty.zz,0 + +test.go,48 +package main1,0 +func say(5,28 +func main(9,72 + +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 diff --git a/test/manual/etags/Makefile b/test/manual/etags/Makefile index 4d9f358..81ee7a7 100644 --- a/test/manual/etags/Makefile +++ b/test/manual/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,7 +28,7 @@ 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}\ + ${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 diff --git a/test/manual/etags/go-src/test.go b/test/manual/etags/go-src/test.go new file mode 100644 index 0000000..6aea26e --- /dev/null +++ b/test/manual/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/manual/etags/go-src/test1.go b/test/manual/etags/go-src/test1.go new file mode 100644 index 0000000..6d1efaa --- /dev/null +++ b/test/manual/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) +} -- 2.5.0 ------------=_1454158803-31697-1--