mtags: work-around for vim

Fergus Henderson fjh at hydra.cs.mu.oz.au
Thu Aug 28 00:22:58 AEST 1997


scripts/mtags:
	Add a `--vim' option to work-around limitations in vim;
	if `--vim' is specified, it generates a dumbed-down tags
	file that vim can understand.

Index: mtags
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/mtags,v
retrieving revision 1.15
diff -u -u -r1.15 mtags
--- mtags	1997/07/27 15:09:45	1.15
+++ mtags	1997/08/27 14:22:39
@@ -15,15 +15,30 @@
 # option is specified) an emacs style `TAGS' file for Mercury programs.
 # It takes its list of filenames from the command line.
 
+# Note that `vim' does not properly support vi-style tags files,
+# at least not as of vim 4.2.  If you're using vim rather than real vi,
+# you need to specify the `--vim' option, which causes mtags to generate
+# a dumbed-down tags file that vim can understand.
+
 $warnings = 0;
 $emacs = 0;
+$vim = 0;
 
-if ($ARGV[0] eq "-e" || $ARGV[0] eq "--emacs") {
-	$emacs = 1;
-	shift(ARGV);
+OPTION:
+while ($#ARGV >= 0 && $ARGV[0] =~ /^-/) {
+	if ($ARGV[0] eq "-e" || $ARGV[0] eq "--emacs") {
+		$emacs = 1;
+		shift(ARGV);
+		next OPTION;
+	}
+	if ($ARGV[0] eq "--vim") {
+		$vim = 1;
+		shift(ARGV);
+		next OPTION;
+	}
 }
 
-die "Usage: mtags [-e] [--emacs] file1.m ...\n" if $#ARGV < 0;
+die "Usage: mtags [--vim] [-e] [--emacs] file1.m ...\n" if $#ARGV < 0;
 
 #---------------------------------------------------------------------------#
 
@@ -56,6 +71,9 @@
 	    if ($emacs) {
 		printf out "%s\177%s\001%d,%d\n",
 		    $_, $name, $., $.;
+	    } elsif ($vim) {
+		printf out "%s\t%s\t/^%s\$/\n",
+		    $name, $file, $_, $name;
 	    } else {
 		printf out "%s\t%s\t/^%s\$/;-;/%s/\n",
 		    $name, $file, $_, $name;

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list