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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5055 in the body.
You can then email your comments to 5055 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#5055; Package emacs. (Fri, 27 Nov 2009 00:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Ryde <user42 <at> zip.com.au>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 27 Nov 2009 00:25:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

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 1 (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 3 (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

bug reassigned from package 'emacs' to 'emacs,etags'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Mon, 30 Nov 2009 07:05:11 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 20 Jan 2010 01:41:02 GMT) Full text and rfc822 format available.

Reply sent to Chong Yidong <cyd <at> gnu.org>:
You have taken responsibility. (Sat, 01 Dec 2012 01:26:02 GMT) Full text and rfc822 format available.

Notification sent to Kevin Ryde <user42 <at> zip.com.au>:
bug acknowledged by developer. (Sat, 01 Dec 2012 01:26:02 GMT) Full text and rfc822 format available.

Message #14 received at 5055-done <at> debbugs.gnu.org (full text, mbox):

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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Dec 2012 12:24:04 GMT) Full text and rfc822 format available.

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.