Currently, if you are at the start of a buffer that is longer than the
window and press M->, you will move to the end of the buffer. There is
a difference between mg and emacs' behaviour though. In emacs, your
cursor will be placed at the bottom of the window (minus 3 lines)
which means most of the window above is displaying buffer contents,
while mg places the cursor in the middle of the window only allowing
half the screen to display buffer contents. This diff makes mg behave
the same as emacs. 

ok?

-lum

Index: basic.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.36
diff -u -p -r1.36 basic.c
--- basic.c     8 Jun 2012 21:21:57 -0000       1.36
+++ basic.c     16 Jun 2012 03:03:54 -0000
@@ -115,17 +115,30 @@ gotobob(int f, int n)
 }
 
 /*
- * Go to the end of the buffer.
- * Setting WFFULL is conservative, but
- * almost always the case.
+ * Go to the end of the buffer. Leave dot 3 lines from the bottom of the
+ * window if buffer length is longer than window length; same as emacs.
+ * Setting WFFULL is conservative, but almost always the case.
  */
 int
 gotoeob(int f, int n)
 {
+       struct line     *lp;
+       
        (void) setmark(f, n);
        curwp->w_dotp = blastlp(curbp);
        curwp->w_doto = llength(curwp->w_dotp);
        curwp->w_dotline = curwp->w_bufp->b_lines;
+
+       lp = curwp->w_dotp;
+       n = curwp->w_ntrows - 3;
+
+       if (n < curwp->w_bufp->b_lines && n >= 3) {
+               while (n--)
+                       curwp->w_dotp = lback(curwp->w_dotp);
+
+               curwp->w_linep = curwp->w_dotp;
+               curwp->w_dotp = lp;
+       }
        curwp->w_rflag |= WFFULL;
        return (TRUE);
 }

Reply via email to