Subject: Re: bug#5624: 23.1; etags elisp and scheme "=" in names

From: Alex <[email-masked]>
Date: Mon, 12 Jun 2017 21:31:57 -0600

Eli Zaretskii <[email-masked]> writes:

>> From: Alex <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Sun, 11 Jun 2017 20:44:29 -0600
>> 
>> One issue is that the Lisp and Scheme functions use get_tag, which uses
>> notinname. What do you think about the following diff? It adds a wrapper
>> to notinname which get_tag uses.
>
> I think it would be much cleaner not to use get_tag for these
> languages, but instead either call make_tag directly or write a
> get_lispy_tag function which will DTRT for Lisp-like languages.
>
> Thanks.

I wanted to reduce duplicated code, but I suppose it is cleaner that
way.

I've attached a patch below.

>From a0a5881f654baefef53128e43ac0fe6791643e15 Mon Sep 17 00:00:00 2001
From: Alexander Gramiak <[email-masked]>
Date: Mon, 12 Jun 2017 21:28:39 -0600
Subject: [PATCH] Include '=' 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).
---
 lib-src/etags.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index 6f280d8ab4..7e082dd276 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -372,6 +372,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 *, char **);
 
 static void analyze_regex (char *);
 static void free_regexps (void);
@@ -5346,7 +5347,7 @@ L_getit (void)
       /* Ok, then skip "(" before name in (defstruct (foo)) */
       dbp = skip_spaces (dbp);
   }
-  get_tag (dbp, NULL);
+  get_lispy_tag (dbp, NULL);
 }
 
 static void
@@ -5548,14 +5549,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, NULL);
 	}
       if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!"))
-	get_tag (bp, NULL);
+	get_lispy_tag (bp, NULL);
     }
 }
 
@@ -6590,6 +6591,25 @@ 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, char **namepp)
+{
+  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);
+    }
+
+  if (namepp != NULL)
+    *namepp = savenstr (bp, cp - bp);
+}
+
 /*
  * Read a line of text from `stream' into `lbp', excluding the
  * newline or CR-NL, if any.  Return the number of characters read from
-- 
2.11.0