Subject: bug#5055: closed (Re: bug#5055: 23.1; etags of perl "use constant")

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 01 Dec 2012 01:26:02 +0000

Your bug report

#5055: 23.1; etags of perl "use constant"

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 [email-masked].

-- 
5055: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5055
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#5055: 23.1; etags of perl "use constant"
From: Chong Yidong <[email-masked]>
To: Kevin Ryde <[email-masked]>
Cc: [email-masked]
Date: Sat, 01 Dec 2012 09:23:12 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Kevin Ryde <[email-masked]> writes:

> 2009-11-27  Kevin Ryde  <[email-masked]>
>
> 	* etags.c (Perl_functions): Tag "use constant" subs too.
>
> 	* maintaining.texi (Tag Syntax): Add Perl "use constant".

Sorry for the long delay.  Since no one else has commented on this, and
the patch looks reasonable, I've just now added it to trunk.

Subject: 23.1; etags of perl "use constant"
From: Kevin Ryde <[email-masked]>
To: [email-masked]
Date: Fri, 27 Nov 2009 11:17:20 +1100

It'd be good if etags recognised perl constants like

    use constant FOO => 123;

which defines a subroutine called FOO, basically the same as if you
wrote

    sub FOO () { return 123 }

"constant::defer" in the diff below is one of my things.  Is it too
cheeky to slip that in?  It's on cpan, but probably used only by me as
yet :-).

2009-11-27  Kevin Ryde  <[email-masked]>

	* etags.c (Perl_functions): Tag "use constant" subs too.

	* maintaining.texi (Tag Syntax): Add Perl "use constant".

Index: lib-src/etags.c
===================================================================
RCS file: /sources/emacs/emacs/lib-src/etags.c,v
retrieving revision 3.93
diff -u -r3.93 etags.c
--- lib-src/etags.c	23 Nov 2009 09:51:06 -0000	3.93
+++ lib-src/etags.c	27 Nov 2009 00:05:52 -0000
@@ -4388,6 +4388,7 @@
 /*
  * Perl support
  * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/
+ *                 /^use constant[ \t\n]+[^ \t\n{=,;]+/
  * Perl variable names: /^(my|local).../
  * Original code by Bart Robinson <[email-masked]> (1995)
  * Additions by Michael Ernst <[email-masked]> (1997)
@@ -4411,9 +4412,9 @@
 	}
       else if (LOOKING_AT (cp, "sub"))
 	{
-	  char *pos;
-	  char *sp = cp;
-
+	  char *pos, *sp;
+	subr:
+	  sp = cp;
 	  while (!notinname (*cp))
 	    cp++;
 	  if (cp == sp)
@@ -4436,6 +4437,21 @@
 			lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
 	      free (name);
 	    }
+	}
+      else if (LOOKING_AT (cp, "use constant")
+	       || LOOKING_AT (cp, "use constant::defer"))
+	{
+	  /* For hash style multi-constant like
+	   *     use constant { FOO => 123,
+	   *                    BAR => 456 };
+	   * only the first FOO is picked up.  Parsing across the value
+	   * expressions would be difficult in general, due to possible nested
+	   * hashes, here-documents, etc.  Maybe simple values could be
+	   * handled.
+	   */
+	  if (*cp == '{')
+	    cp = skip_spaces (cp+1);
+	  goto subr;
  	}
        else if (globals)	/* only if we are tagging global vars */
  	{
Index: doc/emacs/maintaining.texi
===================================================================
RCS file: /sources/emacs/emacs/doc/emacs/maintaining.texi,v
retrieving revision 1.22
diff -u -r1.22 maintaining.texi
--- doc/emacs/maintaining.texi	11 Jul 2009 02:49:07 -0000	1.22
+++ doc/emacs/maintaining.texi	27 Nov 2009 00:06:02 -0000
@@ -1681,7 +1681,8 @@
 
 @item
 In Perl code, the tags are the packages, subroutines and variables
-defined by the @code{package}, @code{sub}, @code{my} and @code{local}
+defined by the @code{package}, @code{sub}, @code{use constant},
+@code{my} and @code{local}
 keywords.  Use @samp{--globals} if you want to tag global variables.
 Tags for subroutines are named @samp{@var{package}::@var{sub}}.  The
 name for subroutines defined in the default package is

In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
 of 2009-09-14 on raven, modified by Debian
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_AU
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default-enable-multibyte-characters: t