aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorlu4nx2016-01-30 14:56:43 +0200
committerEli Zaretskii2016-01-30 14:56:43 +0200
commit40a85fba441aa69d47ef9efd645df3411e43ae21 (patch)
tree036fafebce750bb4083bbef7edf3ac0910c903c3 /lib-src
parent25b79d7bc71079cd6ebb2700623e7e3b76b03287 (diff)
downloademacs-40a85fba441aa69d47ef9efd645df3411e43ae21.tar.gz
emacs-40a85fba441aa69d47ef9efd645df3411e43ae21.zip
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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index adc08a23678..bdfced5bc9c 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -354,6 +354,7 @@ static void Cstar_entries (FILE *);
354static void Erlang_functions (FILE *); 354static void Erlang_functions (FILE *);
355static void Forth_words (FILE *); 355static void Forth_words (FILE *);
356static void Fortran_functions (FILE *); 356static void Fortran_functions (FILE *);
357static void Go_functions (FILE *);
357static void HTML_labels (FILE *); 358static void HTML_labels (FILE *);
358static void Lisp_functions (FILE *); 359static void Lisp_functions (FILE *);
359static void Lua_functions (FILE *); 360static void Lua_functions (FILE *);
@@ -641,6 +642,10 @@ static const char *Fortran_suffixes [] =
641static const char Fortran_help [] = 642static const char Fortran_help [] =
642"In Fortran code, functions, subroutines and block data are tags."; 643"In Fortran code, functions, subroutines and block data are tags.";
643 644
645static const char *Go_suffixes [] = {"go", NULL};
646static const char Go_help [] =
647 "In Go code, functions, interfaces and packages are tags.";
648
644static const char *HTML_suffixes [] = 649static const char *HTML_suffixes [] =
645 { "htm", "html", "shtml", NULL }; 650 { "htm", "html", "shtml", NULL };
646static const char HTML_help [] = 651static const char HTML_help [] =
@@ -727,7 +732,7 @@ static const char *Ruby_suffixes [] =
727 { "rb", "ruby", NULL }; 732 { "rb", "ruby", NULL };
728static const char Ruby_help [] = 733static const char Ruby_help [] =
729 "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\ 734 "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\
730a line generate a tag."; 735a line generate a tag. Constants also generate a tag.";
731 736
732/* Can't do the `SCM' or `scm' prefix with a version number. */ 737/* Can't do the `SCM' or `scm' prefix with a version number. */
733static const char *Scheme_suffixes [] = 738static const char *Scheme_suffixes [] =
@@ -794,6 +799,7 @@ static language lang_names [] =
794 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, 799 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes },
795 { "forth", Forth_help, Forth_words, Forth_suffixes }, 800 { "forth", Forth_help, Forth_words, Forth_suffixes },
796 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, 801 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes },
802 { "go", Go_help, Go_functions, Go_suffixes },
797 { "html", HTML_help, HTML_labels, HTML_suffixes }, 803 { "html", HTML_help, HTML_labels, HTML_suffixes },
798 { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, 804 { "java", Cjava_help, Cjava_entries, Cjava_suffixes },
799 { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes }, 805 { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes },
@@ -4209,6 +4215,73 @@ Fortran_functions (FILE *inf)
4209 4215
4210 4216
4211/* 4217/*
4218 * Go language support
4219 * Original code by Xi Lu <lx@shellcodes.org> (2016)
4220 */
4221static void
4222Go_functions(FILE *inf)
4223{
4224 char *cp, *name;
4225
4226 LOOP_ON_INPUT_LINES(inf, lb, cp)
4227 {
4228 cp = skip_spaces (cp);
4229
4230 if (LOOKING_AT (cp, "package"))
4231 {
4232 name = cp;
4233 while (!notinname (*cp) && *cp != '\0')
4234 cp++;
4235 make_tag (name, cp - name, false, lb.buffer,
4236 cp - lb.buffer + 1, lineno, linecharno);
4237 }
4238 else if (LOOKING_AT (cp, "func"))
4239 {
4240 /* Go implementation of interface, such as:
4241 func (n *Integer) Add(m Integer) ...
4242 skip `(n *Integer)` part.
4243 */
4244 if (*cp == '(')
4245 {
4246 while (*cp != ')')
4247 cp++;
4248 cp = skip_spaces (cp+1);
4249 }
4250
4251 if (*cp)
4252 {
4253 name = cp;
4254
4255 while (!notinname (*cp))
4256 cp++;
4257
4258 make_tag (name, cp - name, true, lb.buffer,
4259 cp - lb.buffer + 1, lineno, linecharno);
4260 }
4261 }
4262 else if (members && LOOKING_AT (cp, "type"))
4263 {
4264 name = cp;
4265
4266 /* Ignore the likes of the following:
4267 type (
4268 A
4269 )
4270 */
4271 if (*cp == '(')
4272 return;
4273
4274 while (!notinname (*cp) && *cp != '\0')
4275 cp++;
4276
4277 make_tag (name, cp - name, false, lb.buffer,
4278 cp - lb.buffer + 1, lineno, linecharno);
4279 }
4280 }
4281}
4282
4283
4284/*
4212 * Ada parsing 4285 * Ada parsing
4213 * Original code by 4286 * Original code by
4214 * Philippe Waroquiers (1998) 4287 * Philippe Waroquiers (1998)