GNU bug report logs - #5055
23.1; etags of perl "use constant"

Previous Next

Package: emacs;

Reported by: Kevin Ryde <user42 <at> zip.com.au>

Date: Fri, 27 Nov 2009 00:25:05 UTC

Severity: normal

Tags: patch

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Kevin Ryde <user42 <at> zip.com.au>
Subject: bug#5055: closed (Re: bug#5055: 23.1; etags of perl "use constant")
Date: Sat, 01 Dec 2012 01:26:02 +0000
[Message part 1 (text/plain, inline)]
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 5055 <at> debbugs.gnu.org.

-- 
5055: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5055
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Chong Yidong <cyd <at> gnu.org>
To: Kevin Ryde <user42 <at> zip.com.au>
Cc: 5055-done <at> debbugs.gnu.org
Subject: Re: bug#5055: 23.1; etags of perl "use constant"
Date: Sat, 01 Dec 2012 09:23:12 +0800
Kevin Ryde <user42 <at> zip.com.au> writes:

> 2009-11-27  Kevin Ryde  <user42 <at> zip.com.au>
>
> 	* 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.

[Message part 3 (message/rfc822, inline)]
From: Kevin Ryde <user42 <at> zip.com.au>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; etags of perl "use constant"
Date: Fri, 27 Nov 2009 11:17:20 +1100
[Message part 4 (text/plain, inline)]
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  <user42 <at> zip.com.au>

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

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

[etags-perl-constant.diff (text/x-diff, inline)]
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 <lomew <at> cs.utah.edu> (1995)
  * Additions by Michael Ernst <mernst <at> alum.mit.edu> (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
[Message part 6 (text/plain, inline)]

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

This bug report was last modified 12 years and 178 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.