summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/funmap.c3
-rw-r--r--usr.bin/mg/keymap.c4
-rw-r--r--usr.bin/mg/mg.18
-rw-r--r--usr.bin/mg/random.c15
5 files changed, 26 insertions, 7 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index f6e8a0eb599..d9abec3e367 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.113 2010/06/30 19:12:54 oga Exp $ */
+/* $OpenBSD: def.h,v 1.114 2011/01/17 03:12:06 kjell Exp $ */
/* This file is in the public domain. */
@@ -511,6 +511,7 @@ int indent(int, int);
int forwdel(int, int);
int backdel(int, int);
int space_to_tabstop(int, int);
+int backtoindent(int, int);
/* extend.c X */
int insert(int, int);
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
index d620743ebb1..0ec02a031f2 100644
--- a/usr.bin/mg/funmap.c
+++ b/usr.bin/mg/funmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.c,v 1.32 2008/09/15 16:13:35 kjell Exp $ */
+/* $OpenBSD: funmap.c,v 1.33 2011/01/17 03:12:06 kjell Exp $ */
/* This file is in the public domain */
@@ -26,6 +26,7 @@ static struct funmap functnames[] = {
{auto_execute, "auto-execute", },
{fillmode, "auto-fill-mode",},
{indentmode, "auto-indent-mode",},
+ {backtoindent, "back-to-indentation",},
{backchar, "backward-char",},
{delbword, "backward-kill-word",},
{gotobop, "backward-paragraph",},
diff --git a/usr.bin/mg/keymap.c b/usr.bin/mg/keymap.c
index 4918a14007c..8cb89f96647 100644
--- a/usr.bin/mg/keymap.c
+++ b/usr.bin/mg/keymap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keymap.c,v 1.43 2008/08/27 04:11:52 kjell Exp $ */
+/* $OpenBSD: keymap.c,v 1.44 2011/01/17 03:12:06 kjell Exp $ */
/* This file is in the public domain. */
@@ -241,7 +241,7 @@ static PF metasqf[] = {
static PF metal[] = {
lowerword, /* l */
- rescan, /* m */
+ backtoindent, /* m */
rescan, /* n */
rescan, /* o */
rescan, /* p */
diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1
index 12f8868e0aa..aa467398f85 100644
--- a/usr.bin/mg/mg.1
+++ b/usr.bin/mg/mg.1
@@ -1,7 +1,7 @@
-.\" $OpenBSD: mg.1,v 1.47 2010/10/07 17:08:58 sobrado Exp $
+.\" $OpenBSD: mg.1,v 1.48 2011/01/17 03:12:06 kjell Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: October 7 2010 $
+.Dd $Mdocdate: January 17 2011 $
.Dt MG 1
.Os
.Sh NAME
@@ -230,6 +230,8 @@ kill-word
forward-word
.It M-l
downcase-word
+.It M-m
+back-to-indentation
.It M-q
fill-paragraph
.It M-r
@@ -304,6 +306,8 @@ where text inserted past the fill column is automatically wrapped
to a new line.
.It auto-indent-mode
Toggle indent mode, where indentation is preserved after a newline.
+.It back-to-indentation
+Move the dot to the first non-whitespace character on the current line.
.It backward-char
Move cursor backwards one character.
.It backward-kill-word
diff --git a/usr.bin/mg/random.c b/usr.bin/mg/random.c
index 8a34e495e75..a3c3893e4b5 100644
--- a/usr.bin/mg/random.c
+++ b/usr.bin/mg/random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: random.c,v 1.26 2008/09/15 16:13:35 kjell Exp $ */
+/* $OpenBSD: random.c,v 1.27 2011/01/17 03:12:06 kjell Exp $ */
/* This file is in the public domain. */
@@ -440,3 +440,16 @@ space_to_tabstop(int f, int n)
return (linsert((n << 3) - (curwp->w_doto & 7), ' '));
}
#endif /* NOTAB */
+
+/*
+ * Move the dot to the first non-whitespace character of the current line.
+ */
+int
+backtoindent(int f, int n)
+{
+ gotobol(FFRAND, 1);
+ while (curwp->w_doto < llength(curwp->w_dotp) &&
+ (isspace(lgetc(curwp->w_dotp, curwp->w_doto))))
+ ++curwp->w_doto;
+ return (TRUE);
+}