GNU bug report logs -
#5055
23.1; etags of perl "use constant"
Previous Next
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
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
[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
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.