[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mg +linenumber patch



Here's a small patch for mg to support starting at a specific line
number.

I find this handy for use a mail editor in mutt. I have a line in
.muttrc that sets the editor to 'mg +8' which starts editing just
past all the default headers.

Index: def.h
===================================================================
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.44
diff -u -r1.44 def.h
--- def.h	2002/07/24 14:08:33	1.44
+++ def.h	2002/12/24 17:29:44
@@ -603,6 +603,7 @@
 extern int	 thisflag;
 extern int	 lastflag;
 extern int	 curgoal;
+extern int	 startrow;
 extern int	 epresf;
 extern int	 sgarbf;
 extern int	 mode;
Index: file.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/file.c,v
retrieving revision 1.23
diff -u -r1.23 file.c
--- file.c	2002/09/15 22:18:40	1.23
+++ file.c	2002/12/24 17:29:44
@@ -166,6 +166,9 @@
 		curbp->b_flag |= BFREADONLY;
 	else
 		curbp->b_flag &=~ BFREADONLY;
+	
+	if(startrow)
+		forwline(FFRAND,startrow);
 
 	return status;
 }
Index: fileio.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/fileio.c,v
retrieving revision 1.34
diff -u -r1.34 fileio.c
--- fileio.c	2002/08/22 23:28:19	1.34
+++ fileio.c	2002/12/24 17:29:45
@@ -268,6 +268,10 @@
 		if (*fn == '/')
 			fn++;
 	}
+	if (fn[0] == '+' && (strlen(fn) >= 2)) {
+		startrow = (int)strtol(&fn[1],(char **)NULL,10);
+		return (NULL);
+	}
 	strlcat(path, fn, sizeof path);
 
 	return (realpath(path, fnb));
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/main.c,v
retrieving revision 1.22
diff -u -r1.22 main.c
--- main.c	2002/07/25 16:37:54	1.22
+++ main.c	2002/12/24 17:29:45
@@ -15,6 +15,7 @@
 int		 thisflag;			/* flags, this command	*/
 int		 lastflag;			/* flags, last command	*/
 int		 curgoal;			/* goal column		*/
+int		 startrow;			/* row to start         */
 BUFFER		*curbp;				/* current buffer	*/
 BUFFER		*bheadp;			/* BUFFER listhead	*/
 MGWIN		*curwp;				/* current window	*/