diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2011-01-17 03:12:07 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2011-01-17 03:12:07 +0000 |
commit | d4091f5270ba3a39a5223b8db12f9950d863fe3d (patch) | |
tree | 3e5131339a227bf371a392af198a0ea17706ec5e /usr.bin/mg | |
parent | bd01b017361308097f0e7cc0d5b6210ca4615a75 (diff) |
Add back-to-indentation. (M-m)
Move the dot to the first non-whitespace character on the current line.
from Henri Kemppainen . ok theo
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/funmap.c | 3 | ||||
-rw-r--r-- | usr.bin/mg/keymap.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/mg.1 | 8 | ||||
-rw-r--r-- | usr.bin/mg/random.c | 15 |
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); +} |