unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5600: 23.1; etags don't tag (defvar foo) declaration
@ 2010-02-19  0:00 Kevin Ryde
  2010-02-19  9:25 ` Francesco Potortì
  2010-02-19  9:32 ` Francesco Potortì
  0 siblings, 2 replies; 5+ messages in thread
From: Kevin Ryde @ 2010-02-19  0:00 UTC (permalink / raw)
  To: 5600

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

It'd be good if etags didn't tag defvar declaration forms, only actual
variable definitions.  For example it picks up

    (defvar message-indent-citation-function)

in longlines.el ahead of that variable's actual definition in
message.el, so M-. of that var goes to longlines.el first.

Perhaps something along the lines below.

I found the tripe-negative of while(!noninname) hard to follow and
thought a skip_name() could be clearer.  It might be shared by
Perl_functions, PHP_functions and Makefile_functions.

2010-02-18  Kevin Ryde  <user42@zip.com.au>

	* etags.c (Lisp_functions): Don't tag "(defvar foo)" declarations.
	(skip_name): New helper.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: etags.c.defvar.diff --]
[-- Type: text/x-diff, Size: 833 bytes --]

--- etags.c.~3.93.~	2009-11-29 08:42:32.000000000 +1100
+++ etags.c	2010-02-19 10:53:57.000000000 +1100
@@ -4849,6 +4849,16 @@
   get_tag (dbp, NULL);
 }
 
+/* skip past any chars at cp which are "name" class */
+static char *
+skip_name (char *cp)
+{
+  /* '\0' is a notinname() so loop stops there too */
+  while (! notinname (*cp))
+    cp++;
+  return cp;
+}
+
 static void
 Lisp_functions (inf)
      FILE *inf;
@@ -4858,6 +4868,17 @@
       if (dbp[0] != '(')
 	continue;
 
+      /* ignore declaration "(defvar foo)", it's not a definition */
+      {
+	char *p = dbp+1;
+	if (LOOKING_AT (p, "defvar")) {
+	  p = skip_name (p); /* past var name */
+	  p = skip_spaces (p);
+	  if (*p == ')')
+	    continue;
+	}
+      }
+
       if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3))
 	{
 	  dbp = skip_non_spaces (dbp);

[-- Attachment #3: Type: text/plain, Size: 733 bytes --]




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=''

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5600: 23.1; etags don't tag (defvar foo) declaration
  2010-02-19  0:00 bug#5600: 23.1; etags don't tag (defvar foo) declaration Kevin Ryde
@ 2010-02-19  9:25 ` Francesco Potortì
  2010-02-20  0:06   ` Kevin Ryde
  2010-02-19  9:32 ` Francesco Potortì
  1 sibling, 1 reply; 5+ messages in thread
From: Francesco Potortì @ 2010-02-19  9:25 UTC (permalink / raw)
  To: Kevin Ryde; +Cc: bug-gnu-emacs, owner, 5600

>It'd be good if etags didn't tag defvar declaration forms, only actual
>variable definitions.  

Lisp_functions should distinguish between defvar and other (def*
constructs, and tag the former only if --declarations.

Would you consider a different patch that looks at the declarations
global variable and distinguishes among "(defvar" and other "(def"
contructs?  Such a change would reuire to be reflected in the help
strings, the man page and the info docs.

I can do that myself, but I cannot guarantee a deadline earlier than
some weeks from now.

>I found the tripe-negative of while(!noninname) hard to follow and
>thought a skip_name() could be clearer.

I agree.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5600: 23.1; etags don't tag (defvar foo) declaration
  2010-02-19  0:00 bug#5600: 23.1; etags don't tag (defvar foo) declaration Kevin Ryde
  2010-02-19  9:25 ` Francesco Potortì
@ 2010-02-19  9:32 ` Francesco Potortì
  1 sibling, 0 replies; 5+ messages in thread
From: Francesco Potortì @ 2010-02-19  9:32 UTC (permalink / raw)
  To: Kevin Ryde; +Cc: bug-gnu-emacs, owner, 5600

>I found the tripe-negative of while(!noninname) hard to follow and
>thought a skip_name() could be clearer.  It might be shared by
>Perl_functions, PHP_functions and Makefile_functions.

Yes, but the helper should go together with the other helper funciotns
(right after skip_non_spaces) and be declared at the beginning after
skip_non_spaces.

>
>2010-02-18  Kevin Ryde  <user42@zip.com.au>
>
>	* etags.c (Lisp_functions): Don't tag "(defvar foo)" declarations.
>	(skip_name): New helper.
>
>--- etags.c.~3.93.~	2009-11-29 08:42:32.000000000 +1100
>+++ etags.c	2010-02-19 10:53:57.000000000 +1100
>@@ -4849,6 +4849,16 @@
>   get_tag (dbp, NULL);
> }
> 
>+/* skip past any chars at cp which are "name" class */
>+static char *
>+skip_name (char *cp)
>+{
>+  /* '\0' is a notinname() so loop stops there too */
>+  while (! notinname (*cp))
>+    cp++;
>+  return cp;
>+}
>+
> static void
> Lisp_functions (inf)
>      FILE *inf;
>@@ -4858,6 +4868,17 @@
>       if (dbp[0] != '(')
> 	continue;
> 
>+      /* ignore declaration "(defvar foo)", it's not a definition */
>+      {
>+	char *p = dbp+1;
>+	if (LOOKING_AT (p, "defvar")) {
>+	  p = skip_name (p); /* past var name */
>+	  p = skip_spaces (p);
>+	  if (*p == ')')
>+	    continue;
>+	}
>+      }
>+
>       if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3))
> 	{
> 	  dbp = skip_non_spaces (dbp);
>
>
>
>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=''







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5600: 23.1; etags don't tag (defvar foo) declaration
  2010-02-19  9:25 ` Francesco Potortì
@ 2010-02-20  0:06   ` Kevin Ryde
  2012-12-02  1:49     ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Ryde @ 2010-02-20  0:06 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 5600

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]

Francesco Potortì <pot@gnu.org> writes:
>
> Lisp_functions should distinguish between defvar and other (def*
> constructs, and tag the former only if --declarations.

Sounds likely.  I didn't know about that option, new diff below.
I suppose it could tag `declare-function' and the like too, but start
with untagging the defvar ones.

(The bloat of bizaar has made the tree inaccessible for me, so excuse
three separate diff files.)

2010-02-19  Kevin Ryde  <user42@zip.com.au>

	* etags.c (skip_name): New helper.
	(Lisp_functions): Tag "(defvar foo)" only under --declarations.
	(Lisp_help): Describe this --declarations.

2010-02-19  Kevin Ryde  <user42@zip.com.au>

	* maintaining.texi (Tag Syntax): Add Lisp --declarations for
	(defvar foo).

2010-02-19  Kevin Ryde  <user42@zip.com.au>

	* doc/man/etags.1 (--declarations): Add Lisp (defvar foo).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: etags.c.defvar-2.diff --]
[-- Type: text/x-diff, Size: 1728 bytes --]

--- etags.c.~3.93.~	2009-11-29 08:42:32.000000000 +1100
+++ etags.c	2010-02-20 10:14:45.000000000 +1100
@@ -433,6 +433,7 @@
 static char *concat __P((char *, char *, char *));
 static char *skip_spaces __P((char *));
 static char *skip_non_spaces __P((char *));
+static char *skip_name __P((char *));
 static char *savenstr __P((char *, int));
 static char *savestr __P((char *));
 static char *etags_strchr __P((const char *, int));
@@ -699,7 +700,9 @@
 "In Lisp code, any function defined with `defun', any variable\n\
 defined with `defvar' or `defconst', and in general the first\n\
 argument of any expression that starts with `(def' in column zero\n\
-is a tag.";
+is a tag.\n\
+`--declarations' tags declarations \"(defvar foo)\" as well as\n\
+definitions.";
 
 static char *Lua_suffixes [] =
   { "lua", "LUA", NULL };
@@ -4858,6 +4861,19 @@
       if (dbp[0] != '(')
 	continue;
 
+      /* "(defvar foo)" is a declaration rather than a definition.
+	 ENHANCE-ME: Maybe also Elisp (declare-function funcname ...),
+	 and/or CL and Elisp (declare (special varname)), or (proclaim). */
+      if (! declarations) {
+	char *p = dbp+1;
+	if (LOOKING_AT (p, "defvar")) {
+	  p = skip_name (p); /* past var name */
+	  p = skip_spaces (p);
+	  if (*p == ')')
+	    continue;
+	}
+      }
+
       if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3))
 	{
 	  dbp = skip_non_spaces (dbp);
@@ -6510,6 +6526,16 @@
     cp++;
   return cp;
 }
+
+/* Skip past any chars at cp which are "name" class, meaning not notinname().*/
+static char *
+skip_name (char *cp)
+{
+  /* '\0' is a notinname() so loop stops there too */
+  while (! notinname (*cp))
+    cp++;
+  return cp;
+}
 
 /* Print error message and exit.  */
 void

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: maintaining.texi.defvar-2.diff --]
[-- Type: text/x-diff, Size: 557 bytes --]

--- maintaining.texi.~1.22.~	2009-11-29 08:42:21.000000000 +1100
+++ maintaining.texi	2010-02-20 10:32:11.000000000 +1100
@@ -1593,7 +1593,8 @@
 In Lisp code, any function defined with @code{defun}, any variable
 defined with @code{defvar} or @code{defconst}, and in general the first
 argument of any expression that starts with @samp{(def} in column zero is
-a tag.
+a tag.  The @option{--declarations} option tags declarations
+@code{(defvar foo)} as well as definitions.
 
 @item
 In Scheme code, tags include anything defined with @code{def} or with a

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: etags.1.defvar-2.diff --]
[-- Type: text/x-diff, Size: 432 bytes --]

--- etags.1.~1.8.~	2009-01-12 11:01:43.000000000 +1100
+++ etags.1	2010-02-20 10:28:25.000000000 +1100
@@ -88,6 +88,8 @@
 .B \-\-declarations
 In C and derived languages, create tags for function declarations,
 and create tags for extern variables unless \-\-no\-globals is used.
+
+In Lisp, create tags for declarations (defvar foo).
 .TP
 .B \-D, \-\-no\-defines
 Do not create tag entries for C preprocessor constant definitions

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#5600: 23.1; etags don't tag (defvar foo) declaration
  2010-02-20  0:06   ` Kevin Ryde
@ 2012-12-02  1:49     ` Chong Yidong
  0 siblings, 0 replies; 5+ messages in thread
From: Chong Yidong @ 2012-12-02  1:49 UTC (permalink / raw)
  To: Kevin Ryde; +Cc: 5600-done

Kevin Ryde <user42@zip.com.au> writes:

> Sounds likely.  I didn't know about that option, new diff below.
> I suppose it could tag `declare-function' and the like too, but start
> with untagging the defvar ones.

I've now committed this patch to trunk.  Thanks.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-02  1:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19  0:00 bug#5600: 23.1; etags don't tag (defvar foo) declaration Kevin Ryde
2010-02-19  9:25 ` Francesco Potortì
2010-02-20  0:06   ` Kevin Ryde
2012-12-02  1:49     ` Chong Yidong
2010-02-19  9:32 ` Francesco Potortì

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).