summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2008-06-10 23:23:54 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2008-06-10 23:23:54 +0000
commit1630be5a5f17109c29fac59198f098bec891af3b (patch)
tree4092a867f5e875a3db643d298cc554436ce300f4 /usr.bin
parented288b30f57c93ff80969e2da9755a1df7cea8a0 (diff)
Add a clear-mark function.
Use it to clear the region it is copied (M-w), or yanked (C-w). This matches xemacs behavior, is not horribly different from gnu emacs, and way less wrong than the current behavior. Noticed by Han Boetes. ok otto@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/basic.c17
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/funmap.c3
-rw-r--r--usr.bin/mg/region.c15
4 files changed, 29 insertions, 9 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c
index ce685a92320..e89f02c1ae0 100644
--- a/usr.bin/mg/basic.c
+++ b/usr.bin/mg/basic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basic.c,v 1.28 2006/12/20 21:21:09 kjell Exp $ */
+/* $OpenBSD: basic.c,v 1.29 2008/06/10 23:23:52 kjell Exp $ */
/* This file is in the public domain */
@@ -396,6 +396,21 @@ setmark(int f, int n)
return (TRUE);
}
+/* Clear the mark, if set. */
+/* ARGSUSED */
+int
+clearmark(int f, int n)
+{
+ if (!curwp->w_markp)
+ return (FALSE);
+
+ curwp->w_markp = NULL;
+ curwp->w_marko = 0;
+ curwp->w_markline = 0;
+
+ return (TRUE);
+}
+
/*
* Swap the values of "dot" and "mark" in
* the current window. This is pretty easy, because
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 232c15fd77a..808ca15948f 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.100 2007/05/28 17:52:17 kjell Exp $ */
+/* $OpenBSD: def.h,v 1.101 2008/06/10 23:23:53 kjell Exp $ */
/* This file is in the public domain. */
@@ -476,6 +476,7 @@ int back1page(int, int);
int pagenext(int, int);
void isetmark(void);
int setmark(int, int);
+int clearmark(int, int);
int swapmark(int, int);
int gotoline(int, int);
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
index 2d3819e6cfa..c641c735a52 100644
--- a/usr.bin/mg/funmap.c
+++ b/usr.bin/mg/funmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.c,v 1.28 2008/06/10 00:19:31 kjell Exp $ */
+/* $OpenBSD: funmap.c,v 1.29 2008/06/10 23:23:53 kjell Exp $ */
/* This file is in the public domain */
@@ -42,6 +42,7 @@ static struct funmap functnames[] = {
#endif /* !NO_MACRO */
{capword, "capitalize-word",},
{changedir, "cd",},
+ {clearmark, "clear-mark",},
{copyregion, "copy-region-as-kill",},
#ifdef REGEX
{cntmatchlines, "count-matches",},
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c
index bb4a1e22a83..751f63fea7f 100644
--- a/usr.bin/mg/region.c
+++ b/usr.bin/mg/region.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: region.c,v 1.25 2006/12/16 17:00:03 kjell Exp $ */
+/* $OpenBSD: region.c,v 1.26 2008/06/10 23:23:53 kjell Exp $ */
/* This file is in the public domain. */
@@ -16,7 +16,7 @@ static int setsize(struct region *, RSIZE);
/*
* Kill the region. Ask "getregion" to figure out the bounds of the region.
- * Move "." to the start, and kill the characters.
+ * Move "." to the start, and kill the characters. Mark is cleared afterwards.
*/
/* ARGSUSED */
int
@@ -34,14 +34,15 @@ killregion(int f, int n)
curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset;
s = ldelete(region.r_size, KFORW);
- if (s == TRUE && curwp->w_dotline > curwp->w_markline)
- curwp->w_dotline = curwp->w_markline;
+ clearmark(FFARG, 0);
+
return (s);
}
/*
- * Copy all of the characters in the region to the kill buffer. Don't move
- * dot at all. This is a bit like a kill region followed by a yank.
+ * Copy all of the characters in the region to the kill buffer,
+ * clearing the mark afterwards.
+ * This is a bit like a kill region followed by a yank.
*/
/* ARGSUSED */
int
@@ -78,6 +79,8 @@ copyregion(int f, int n)
++loffs;
}
}
+ clearmark(FFARG, 0);
+
return (TRUE);
}