diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2011-01-18 16:25:41 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2011-01-18 16:25:41 +0000 |
commit | fff8ed15d4cbffb850c33bb522c5830837ac3883 (patch) | |
tree | 887249fdbe5ed16e0600c54dc4680d1c688084fb /usr.bin/mg | |
parent | 7a538d74905c998b64023418f8aa1fc19018fd64 (diff) |
Add join-line, bound to M-^
Join the current line to the previous.
original diff by Henri Kemppainen. minor mod to add undo boundaries.
Thanks!
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/util.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/usr.bin/mg/util.c b/usr.bin/mg/util.c index 3f2a14b09af..d2b9c0108df 100644 --- a/usr.bin/mg/util.c +++ b/usr.bin/mg/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.27 2011/01/17 03:12:06 kjell Exp $ */ +/* $OpenBSD: util.c,v 1.28 2011/01/18 16:25:40 kjell Exp $ */ /* This file is in the public domain. */ @@ -453,3 +453,33 @@ backtoindent(int f, int n) ++curwp->w_doto; return (TRUE); } + +/* + * Join the current line to the previous, or with arg, the next line + * to the current one. If the former line is not empty, leave exactly + * one space at the joint. Otherwise, leave no whitespace. + */ +int +joinline(int f, int n) +{ + int doto; + + undo_boundary_enable(FFRAND, 0); + if (f & FFARG) { + gotoeol(FFRAND, 1); + forwdel(FFRAND, 1); + } else { + gotobol(FFRAND, 1); + backdel(FFRAND, 1); + } + + delwhite(FFRAND, 1); + + if ((doto = curwp->w_doto) > 0) { + linsert(1, ' '); + curwp->w_doto = doto; + } + undo_boundary_enable(FFRAND, 1); + + return (TRUE); +} |