Leonid's diff would seem to be an improvement on current behaviour, any objections to adding it to mg? Or comments/ok?

Mark

From openbsd-tech  Tue Jun 11 15:16:29 2019
From: Leonid Bobrov <mazocomp () disroot ! org>
Date: Tue, 11 Jun 2019 15:16:29 +0000
To: openbsd-tech
Subject: About transient mark mode
Message-Id: <20190611151629.GA7591 () mazocomp ! lan>
X-MARC-Message: https://marc.info/?l=openbsd-tech&m=156026622527096

Hi!

If we don't have to follow what GNU Emacs is doing anyway, let's just
change behavior of {beginning,end}-of-buffer to this instead of
implementing a useless mode:

Index: basic.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.48
diff -u -p -r1.48 basic.c
--- basic.c     3 Jun 2019 16:26:30 -0000       1.48
+++ basic.c     11 Jun 2019 15:15:15 -0000
@@ -124,7 +124,8 @@ forwchar(int f, int n)
 int
 gotobob(int f, int n)
 {
-       (void) setmark(f, n);
+       if (!curwp-&gt;w_markp)
+               (void) setmark(f, n);
        curwp-&gt;w_dotp = bfirstlp(curbp);
        curwp-&gt;w_doto = 0;
        curwp-&gt;w_rflag |= WFFULL;
@@ -150,7 +151,8 @@ gotoeob(int f, int n)
        int              ln;
        struct line     *lp;

-       (void) setmark(f, n);
+       if (!curwp-&gt;w_markp)
+               (void) setmark(f, n);
        curwp-&gt;w_dotp = blastlp(curbp);
        curwp-&gt;w_doto = llength(curwp-&gt;w_dotp);
        curwp-&gt;w_dotline = curwp-&gt;w_bufp-&gt;b_lines;
Index: mg.1
===================================================================
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.114
diff -u -p -r1.114 mg.1
--- mg.1        6 Jun 2019 18:17:34 -0000       1.114
+++ mg.1        11 Jun 2019 15:15:15 -0000
@@ -1,7 +1,7 @@
 .\"       $OpenBSD: mg.1,v 1.114 2019/06/06 18:17:34 jmc Exp $
 .\" This file is in the public domain.
 .\"
-.Dd $Mdocdate: June 6 2019 $
+.Dd $Mdocdate: June 11 2019 $
 .Dt MG 1
 .Os
 .Sh NAME
@@ -408,6 +408,7 @@ Move cursor to the top of the buffer.
 A numeric argument
 .Va n
 will move n/10th of the way from the top.
+Set mark at previous position if mark is not set.
 .It beginning-of-line
 Move cursor to the beginning of the line.
 .It blink-and-insert
@@ -532,6 +533,7 @@ Move cursor to the end of the buffer.
 A numeric argument
 .Va n
 will move n/10th of the way from the end.
+Set mark at previous position if mark is not set.
 .It end-of-line
 Move cursor to the end of the line.
 .It enlarge-window
Index: region.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/region.c,v
retrieving revision 1.37
diff -u -p -r1.37 region.c
--- region.c    9 Sep 2016 06:05:51 -0000       1.37
+++ region.c    11 Jun 2019 15:15:15 -0000
@@ -405,6 +405,7 @@ markbuffer(int f, int n)
 {
        if (gotoeob(f,n) == FALSE)
                return (FALSE);
+       (void) clearmark(f, n);
        if (gotobob(f,n) == FALSE)
                return (FALSE);
        return (TRUE);

Reply via email to