diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2016-04-14 17:05:33 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2016-04-14 17:05:33 +0000 |
commit | 2611bc8c275e3a746b1f50a605f18b14c8dc3dfe (patch) | |
tree | 19f5f50a3166d3fd34cf5e77c06e15968a7fb991 /usr.bin/mg/paragraph.c | |
parent | 4106271eff6c51e0b7240ad9ed3fbe9dd5874550 (diff) |
Add 'sentence-end-double-space'.
If you prefer "lighter" punctuation and one space between sentences,
for example:
Mr and Mrs Jones are from the UK. They arrived today.
over more liberal use of full stops and double spaces between
sentences:
Mr. and Mrs. Jones are from the U.K. They arrived today.
then toggling 'sentence-end-double-space' will make mg's
fill-paragraph function format text using one space instead of two
(the default) between sentences. However, be careful, should you have
a double spaced document and accidentally "format" it to have single
spaces, then you may have a problem. mg won't be able to revert the
formatting for you (unless you have a previous version of the text in
the "undo" history, or are using mg's backup facility and haven't
opened and saved multiple times!).
Comments from schwarze@
Diffstat (limited to 'usr.bin/mg/paragraph.c')
-rw-r--r-- | usr.bin/mg/paragraph.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c index 58237c09998..ca902c393fe 100644 --- a/usr.bin/mg/paragraph.c +++ b/usr.bin/mg/paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paragraph.c,v 1.43 2016/04/12 06:20:50 lum Exp $ */ +/* $OpenBSD: paragraph.c,v 1.44 2016/04/14 17:05:32 lum Exp $ */ /* This file is in the public domain. */ @@ -208,12 +208,12 @@ fillpara(int f, int n) * behave the same way if a ')' is preceded by a * [.?!] and followed by a doublespace. */ - if (!eopflag && ((eolflag || + if (dblspace && (!eopflag && ((eolflag || curwp->w_doto == llength(curwp->w_dotp) || (c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' || c == '\t') && (ISEOSP(wbuf[wordlen - 1]) || (wbuf[wordlen - 1] == ')' && wordlen >= 2 && - ISEOSP(wbuf[wordlen - 2]))) && + ISEOSP(wbuf[wordlen - 2])))) && wordlen < MAXWORD - 1)) wbuf[wordlen++] = ' '; @@ -482,3 +482,14 @@ setfillcol(int f, int n) } return (TRUE); } + +int +sentencespace(int f, int n) +{ + if (f & FFARG) + dblspace = n > 1; + else + dblspace = !dblspace; + + return (TRUE); +} |