[m-dev.] for review: mtags & skipping to pred definition

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Nov 19 03:13:17 AEDT 2000


This changes the user-visible behaviour of mtags.
I prefer the new behaviour -- in fact it is what I had always
intended, but until now hadn't figured out how to implement.
But I suppose I should ask whether anyone prefers the current
behaviour before committing this.

I've tested this with vim 5.4 and with a couple of different
versions of vi (the DEC OSF one and the SunOS one).

----------

Estimated hours taken: 1.5

scripts/mtags:
	Change the sequence of ex commands that we put in the tags
	file (in the default and `--keep-duplicates' configurations),
	so that for pred/func tags, hitting `n' after the tag will
	take you straight to the procedure's clauses (assuming they
	start in column 1), rather than just going to the next use
	of that name.

Workspace: /home/pgrad/fjh/ws/hg3
Index: scripts/mtags
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mtags,v
retrieving revision 1.21
diff -u -d -r1.21 mtags
--- scripts/mtags	2000/10/06 06:37:15	1.21
+++ scripts/mtags	2000/11/18 15:44:51
@@ -227,12 +227,23 @@
 		    $name, $file, $match_line;
 	    } else {
 		# Works with vi or vim 5.0+.  The ex command searches
-		# for the matching line and then places the tag in the 
-		# search buffer so that if this is a pred/func 
-		# declaration you can do `n' to go to the pred/func 
-		# body.
-		printf out "%s\t%s\t/^%s\$/;-;/%s/\n",
-		    $name, $file, $match_line, $name;
+		# for the matching line and then places a new search
+		# string in the search buffer.  If this is a pred/func 
+		# declaration, the new search string is the tag name,
+		# anchored to start in column 1.  The lets you type
+		# `n' to go to the pred/func body.  For other declarations,
+		# we just put the (unanchored) tag name in the string
+		# buffer, so typing `n' will take you to uses of that name.
+		# The way it places the tag in the search buffer
+		# is by making a mark, doing a search, and then
+		# returning to the marked position.
+		if ($kind eq "pred" || $kind eq "func") {
+		    printf out "%s\t%s\t/^%s\$/;kq|/^%s/;'q\n",
+		        $name, $file, $match_line, $name;
+		} else {
+		    printf out "%s\t%s\t/^%s\$/;kq|-;/%s/;'q\n",
+		        $name, $file, $match_line, $name;
+		}
 	    }
 	    $seen{$name} = 1;
 	    $prev_file{$name} = $file;

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list