From 42cdb68649c24eab07baa39b0c553c87e7ac9989 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sat, 8 Jul 2017 11:25:53 +0300 Subject: [PATCH] Support '=' in Scheme and Lisp tags in 'etags' * lib-src/etags.c (get_lispy_tag): New function. (L_getit, Scheme_functions): Use get_lispy_tag (Bug#5624). * test/manual/etags/CTAGS.good: * test/manual/etags/ETAGS.good_1: * test/manual/etags/ETAGS.good_2: * test/manual/etags/ETAGS.good_3: * test/manual/etags/ETAGS.good_4: * test/manual/etags/ETAGS.good_5: * test/manual/etags/ETAGS.good_6: * test/manual/etags/Makefile: * test/manual/etags/el-src/TAGTEST.EL: Update tests. * test/manual/etags/scm-src/test.scm: New tests for Scheme. --- lib-src/etags.c | 29 +++++++++++++++++++++++------ test/manual/etags/CTAGS.good | 8 ++++++++ test/manual/etags/ETAGS.good_1 | 26 ++++++++++++++++++-------- test/manual/etags/ETAGS.good_2 | 26 ++++++++++++++++++-------- test/manual/etags/ETAGS.good_3 | 26 ++++++++++++++++++-------- test/manual/etags/ETAGS.good_4 | 26 ++++++++++++++++++-------- test/manual/etags/ETAGS.good_5 | 26 ++++++++++++++++++-------- test/manual/etags/ETAGS.good_6 | 26 ++++++++++++++++++-------- test/manual/etags/Makefile | 3 ++- test/manual/etags/el-src/TAGTEST.EL | 1 + test/manual/etags/scm-src/test.scm | 20 ++++++++++++++++++++ 11 files changed, 162 insertions(+), 55 deletions(-) create mode 100644 test/manual/etags/scm-src/test.scm diff --git a/lib-src/etags.c b/lib-src/etags.c index e5ff7bd10fc..7b1a7fc1851 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -373,6 +373,7 @@ static void readline (linebuffer *, FILE *); static long readline_internal (linebuffer *, FILE *, char const *); static bool nocase_tail (const char *); static void get_tag (char *, char **); +static void get_lispy_tag (char *); static void analyze_regex (char *); static void free_regexps (void); @@ -5347,7 +5348,7 @@ L_getit (void) /* Ok, then skip "(" before name in (defstruct (foo)) */ dbp = skip_spaces (dbp); } - get_tag (dbp, NULL); + get_lispy_tag (dbp); } static void @@ -5549,14 +5550,14 @@ Scheme_functions (FILE *inf) if (strneq (bp, "(def", 4) || strneq (bp, "(DEF", 4)) { bp = skip_non_spaces (bp+4); - /* Skip over open parens and white space. Don't continue past - '\0'. */ - while (*bp && notinname (*bp)) + /* Skip over open parens and white space. + Don't continue past '\0' or '='. */ + while (*bp && notinname (*bp) && *bp != '=') bp++; - get_tag (bp, NULL); + get_lispy_tag (bp); } if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!")) - get_tag (bp, NULL); + get_lispy_tag (bp); } } @@ -6591,6 +6592,22 @@ get_tag (register char *bp, char **namepp) *namepp = savenstr (bp, cp - bp); } +/* Similar to get_tag, but include '=' as part of the tag. */ +static void +get_lispy_tag (register char *bp) +{ + register char *cp = bp; + + if (*bp != '\0') + { + /* Go till you get to white space or a syntactic break */ + for (cp = bp + 1; !notinname (*cp) || *cp == '='; cp++) + continue; + make_tag (bp, cp - bp, true, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } +} + /* * Read a line of text from `stream' into `lbp', excluding the * newline or CR-NL, if any. Return the number of characters read from diff --git a/test/manual/etags/CTAGS.good b/test/manual/etags/CTAGS.good index 13bb37c2e6a..519315c6fdd 100644 --- a/test/manual/etags/CTAGS.good +++ b/test/manual/etags/CTAGS.good @@ -202,6 +202,7 @@ ${CHECKOBJS} make-src/Makefile /^${CHECKOBJS}: CFLAGS=-g3 -DNULLFREECHECK=0$/ =\relax tex-src/texinfo.tex /^\\let\\subsubsection=\\relax$/ =\relax tex-src/texinfo.tex /^\\let\\appendix=\\relax$/ =\smartitalic tex-src/texinfo.tex /^\\let\\cite=\\smartitalic$/ +=starts-with-equals! scm-src/test.scm /^(define =starts-with-equals! #t)$/ > tex-src/texinfo.tex /^\\def>{{\\tt \\gtr}}$/ >field1 forth-src/test-forth.fth /^ 9 field >field1$/ >field2 forth-src/test-forth.fth /^ 5 field >field2$/ @@ -2750,6 +2751,7 @@ current-idle-time c-src/emacs/src/keyboard.c /^DEFUN ("current-idle-time", Fcurr current-input-mode c-src/emacs/src/keyboard.c /^DEFUN ("current-input-mode", Fcurrent_input_mode, / current_kboard c-src/emacs/src/keyboard.c 85 current_lb_is_new c-src/etags.c 2926 +curry-test scm-src/test.scm /^(define (((((curry-test a) b) c) d) e)$/ cursor_position cp-src/screen.cpp /^void cursor_position(void)$/ cursor_x cp-src/screen.cpp 15 cursor_y cp-src/screen.cpp 15 @@ -3037,6 +3039,7 @@ foo ruby-src/test1.ru /^ attr_reader :foo$/ foo! ruby-src/test1.ru /^ def foo!$/ foo1 ruby-src/test1.ru /^ attr_reader(:foo1, :bar1, # comment$/ foo2 ruby-src/test1.ru /^ alias_method ( :foo2, #cmmt$/ +foo==bar el-src/TAGTEST.EL /^(defun foo==bar () (message "hi")) ; Bug#5624$/ foobar c-src/c.c /^int foobar() {;}$/ foobar c.c /^extern void foobar (void) __attribute__ ((section / foobar2 c-src/h.h 20 @@ -3161,6 +3164,9 @@ header c-src/emacs/src/lisp.h 1672 header c-src/emacs/src/lisp.h 1826 header_size c-src/emacs/src/lisp.h 1471 heapsize c-src/emacs/src/gmalloc.c 361 +hello scm-src/test.scm /^(define hello "Hello, Emacs!")$/ +hello scm-src/test.scm /^(set! hello "Hello, world!")$/ +hello-world scm-src/test.scm /^(define (hello-world)$/ help c-src/etags.c 193 helpPanel objcpp-src/SimpleCalc.M /^- helpPanel:sender$/ help_char_p c-src/emacs/src/keyboard.c /^help_char_p (Lisp_Object c)$/ @@ -4317,10 +4323,12 @@ test erl-src/gs_dialog.erl /^test() ->$/ test go-src/test1.go /^func test(p plus) {$/ test make-src/Makefile /^test:$/ test php-src/ptest.php /^test $/ +test-begin scm-src/test.scm /^(define-syntax test-begin$/ test.me22b lua-src/test.lua /^ local function test.me22b (one)$/ test.me_22a lua-src/test.lua /^ function test.me_22a(one, two)$/ test_undefined c-src/emacs/src/keyboard.c /^test_undefined (Lisp_Object binding)$/ texttreelist prol-src/natded.prolog /^texttreelist([]).$/ +there-is-a-=-in-the-middle! scm-src/test.scm /^(define (there-is-a-=-in-the-middle!) #t)$/ this c-src/a/b/b.c 1 this-command-keys c-src/emacs/src/keyboard.c /^DEFUN ("this-command-keys", Fthis_command_keys, St/ this-command-keys-vector c-src/emacs/src/keyboard.c /^DEFUN ("this-command-keys-vector", Fthis_command_k/ diff --git a/test/manual/etags/ETAGS.good_1 b/test/manual/etags/ETAGS.good_1 index 6c4a02ae1c1..cd9cd4a8450 100644 --- a/test/manual/etags/ETAGS.good_1 +++ b/test/manual/etags/ETAGS.good_1 @@ -2143,10 +2143,11 @@ main(37,571 class D 41,622 D(43,659 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5069 (defvar tags-file-name 34,1034 @@ -3135,6 +3136,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -3145,11 +3155,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/ETAGS.good_2 b/test/manual/etags/ETAGS.good_2 index fa784d2e7b5..54fd00e95da 100644 --- a/test/manual/etags/ETAGS.good_2 +++ b/test/manual/etags/ETAGS.good_2 @@ -2712,10 +2712,11 @@ main(37,571 class D 41,622 D(43,659 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5188 (defvar tags-file-name 34,1034 @@ -3708,6 +3709,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -3718,11 +3728,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/ETAGS.good_3 b/test/manual/etags/ETAGS.good_3 index 547dee2d43c..508427c501c 100644 --- a/test/manual/etags/ETAGS.good_3 +++ b/test/manual/etags/ETAGS.good_3 @@ -2520,10 +2520,11 @@ main(37,571 D(43,659 int x;44,694 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5069 (defvar tags-file-name 34,1034 @@ -3542,6 +3543,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -3552,11 +3562,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/ETAGS.good_4 b/test/manual/etags/ETAGS.good_4 index 2c50ec1a742..460e31b5d96 100644 --- a/test/manual/etags/ETAGS.good_4 +++ b/test/manual/etags/ETAGS.good_4 @@ -2307,10 +2307,11 @@ main(37,571 class D 41,622 D(43,659 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5069 (defvar tags-file-name 34,1034 @@ -3299,6 +3300,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -3309,11 +3319,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/ETAGS.good_5 b/test/manual/etags/ETAGS.good_5 index 2b431034f44..b7a31602f51 100644 --- a/test/manual/etags/ETAGS.good_5 +++ b/test/manual/etags/ETAGS.good_5 @@ -3253,10 +3253,11 @@ main(37,571 D(43,659 int x;44,694 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5188 (defvar tags-file-name 34,1034 @@ -4279,6 +4280,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -4289,11 +4299,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/ETAGS.good_6 b/test/manual/etags/ETAGS.good_6 index 2cb0d05e72a..a75fd806968 100644 --- a/test/manual/etags/ETAGS.good_6 +++ b/test/manual/etags/ETAGS.good_6 @@ -3253,10 +3253,11 @@ main(37,571 D(D::D43,659 int x;D::x44,694 -el-src/TAGTEST.EL,148 +el-src/TAGTEST.EL,179 (foo::defmumble bletch 1,0 -(defalias 'pending-delete-mode pending-delete-mode5,102 -(defalias (quote explicitly-quoted-pending-delete-mode)8,175 +(defun foo==bar foo==bar2,33 +(defalias 'pending-delete-mode pending-delete-mode6,149 +(defalias (quote explicitly-quoted-pending-delete-mode)9,222 el-src/emacs/lisp/progmodes/etags.el,5188 (defvar tags-file-name 34,1034 @@ -4279,6 +4280,15 @@ module A9,57 alias_method ( :foo2,foo237,586 A::Constant Constant42,655 +scm-src/test.scm,260 +(define hello 1,0 +(set! hello 3,32 +(define (hello-world)5,62 +(define (there-is-a-=-in-the-middle!)there-is-a-=-in-the-middle!10,128 +(define =starts-with-equals! =starts-with-equals!12,171 +(define (((((curry-test 14,205 +(define-syntax test-begin17,265 + tex-src/testenv.tex,52 \newcommand{\nm}\nm4,77 \section{blah}blah8,139 @@ -4289,11 +4299,11 @@ tex-src/gzip.texi,303 @node Overview,83,2705 @node Sample,166,7272 @node Invoking gzip,Invoking gzip210,8828 -@node Advanced usage,Advanced usage357,13495 -@node Environment,420,15207 -@node Tapes,437,15768 -@node Problems,460,16767 -@node Concept Index,Concept Index473,17287 +@node Advanced usage,Advanced usage357,13496 +@node Environment,420,15208 +@node Tapes,437,15769 +@node Problems,460,16768 +@node Concept Index,Concept Index473,17288 tex-src/texinfo.tex,30627 \def\texinfoversion{\texinfoversion26,1032 diff --git a/test/manual/etags/Makefile b/test/manual/etags/Makefile index 07ad0f46416..c1df703905e 100644 --- a/test/manual/etags/Makefile +++ b/test/manual/etags/Makefile @@ -25,12 +25,13 @@ PSSRC=$(addprefix ./ps-src/,rfc1245.ps) PROLSRC=$(addprefix ./prol-src/,ordsets.prolog natded.prolog) PYTSRC=$(addprefix ./pyt-src/,server.py) RBSRC=$(addprefix ./ruby-src/,test.rb test1.ru) +SCMSRC=$(addprefix ./scm-src/,test.scm) 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} ${GOSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC}\ ${OBJCSRC} ${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC}\ - ${PROLSRC} ${PYTSRC} ${RBSRC} ${TEXSRC} ${YSRC} + ${PROLSRC} ${PYTSRC} ${RBSRC} ${SCMSRC} ${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/manual/etags/el-src/TAGTEST.EL b/test/manual/etags/el-src/TAGTEST.EL index acf0baf82f0..89a67913771 100644 --- a/test/manual/etags/el-src/TAGTEST.EL +++ b/test/manual/etags/el-src/TAGTEST.EL @@ -1,4 +1,5 @@ (foo::defmumble bletch beuarghh) +(defun foo==bar () (message "hi")) ; Bug#5624 ;;; Ctags test file for lisp mode. ;; from emacs/lisp/delsel.el:76: diff --git a/test/manual/etags/scm-src/test.scm b/test/manual/etags/scm-src/test.scm new file mode 100644 index 00000000000..e3921e718fc --- /dev/null +++ b/test/manual/etags/scm-src/test.scm @@ -0,0 +1,20 @@ +(define hello "Hello, Emacs!") + +(set! hello "Hello, world!") + +(define (hello-world) + (display hello) + (newline)) + +;; Bug 5624 +(define (there-is-a-=-in-the-middle!) #t) + +(define =starts-with-equals! #t) + +(define (((((curry-test a) b) c) d) e) + (list a b c d e)) + +(define-syntax test-begin + (syntax-rules () + ((test-begin exp ...) + ((lambda () exp ...))))) -- 2.39.2