Re: mg - sentence-end-double-space

2016-04-12 Thread Mark Lumsden
Hi Ingo,

On Tue, Apr 12, 2016 at 08:39:07PM +0200, Ingo Schwarze wrote:
> Hi Mark,
> 
> Mark Lumsden wrote on Tue, Apr 12, 2016 at 06:47:40PM +:
> 
> > This diff allows a single space for sentence delimitation. 
> > ok/comments/objections?
> 
> No objection, but a comment.  Note that *using* the option is
> destructive.  Once you have replaced double spaces at the ends
> of sentences with single spaces, there is no algorithm short of
> computer linguistics that can take you back, because with that
> change, abbreviations become indistinguishable from full stops.
> 

You are correct though there is "undo".

> You might or might not want to mention that in the manual -
> depending on whether you consider it more important to prevent
> people from hurting themselves or to keep the manual concise.
>

I think conciseness is more important here.

Thanks for the comments.

mark



Re: mg - sentence-end-double-space

2016-04-12 Thread Ingo Schwarze
Hi Mark,

Mark Lumsden wrote on Tue, Apr 12, 2016 at 06:47:40PM +:

> This diff allows a single space for sentence delimitation. 
> ok/comments/objections?

No objection, but a comment.  Note that *using* the option is
destructive.  Once you have replaced double spaces at the ends
of sentences with single spaces, there is no algorithm short of
computer linguistics that can take you back, because with that
change, abbreviations become indistinguishable from full stops.

You might or might not want to mention that in the manual -
depending on whether you consider it more important to prevent
people from hurting themselves or to keep the manual concise.

Note that i didn't test the patch.

Yours,
  Ingo

> The default of a double space is left as is.



mg - sentence-end-double-space

2016-04-12 Thread Mark Lumsden
This diff allows a single space for sentence delimitation. 
ok/comments/objections? The default of a double space is left as is.

mark

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.154
diff -u -p -u -p -r1.154 def.h
--- def.h   2 Jan 2016 10:39:19 -   1.154
+++ def.h   12 Apr 2016 18:01:57 -
@@ -593,6 +593,7 @@ int  fillword(int, int);
 int setfillcol(int, int);
 int markpara(int, int);
 int transposepara(int, int);
+int sentencespace(int, int);
 
 /* word.c X */
 int backword(int, int);
@@ -734,6 +735,7 @@ extern int   defb_nmodes;
 extern int  defb_flag;
 extern int  doaudiblebell;
 extern int  dovisiblebell;
+extern int  dblspace;
 extern char cinfo[];
 extern char*keystrings[];
 extern char pat[NPAT];
Index: funmap.c
===
RCS file: /cvs/src/usr.bin/mg/funmap.c,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 funmap.c
--- funmap.c29 Dec 2015 19:44:32 -  1.52
+++ funmap.c12 Apr 2016 18:01:57 -
@@ -180,6 +180,7 @@ static struct funmap functnames[] = {
{backsearch, "search-backward",},
{forwsearch, "search-forward",},
{selfinsert, "self-insert-command",},
+   {sentencespace, "sentence-end-double-space",},
 #ifdef REGEX
{setcasefold, "set-case-fold-search",},
 #endif /* REGEX */
Index: main.c
===
RCS file: /cvs/src/usr.bin/mg/main.c,v
retrieving revision 1.81
diff -u -p -u -p -r1.81 main.c
--- main.c  24 Dec 2015 09:07:47 -  1.81
+++ main.c  12 Apr 2016 18:01:57 -
@@ -27,6 +27,7 @@ intcurgoal;   /* goal column  
*/
 int startrow;  /* row to start */
 int doaudiblebell; /* audible bell toggle  */
 int dovisiblebell; /* visible bell toggle  */
+int dblspace;  /* sentence end #spaces */
 struct buffer  *curbp; /* current buffer   */
 struct buffer  *bheadp;/* BUFFER list head */
 struct mgwin   *curwp; /* current window   */
@@ -109,6 +110,7 @@ main(int argc, char **argv)
edinit(bp); /* Buffers, windows.*/
ttykeymapinit();/* Symbols, bindings.   */
bellinit(); /* Audible and visible bell.*/
+   dblspace = 1;   /* two spaces for sentence end. */
 
/*
 * doing update() before reading files causes the error messages from
Index: mg.1
===
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.103
diff -u -p -u -p -r1.103 mg.1
--- mg.117 Mar 2016 21:56:12 -  1.103
+++ mg.112 Apr 2016 18:01:58 -
@@ -838,6 +838,10 @@ If found, dot gets moved to just after t
 characters, if not found, print a message.
 .It self-insert-command
 Insert a character.
+.It sentence-end-double-space
+Toggle double or single spaces for end of sentences.
+Double is the default.
+Currently only affects fill-paragraph.
 .It set-case-fold-search
 Set case-fold searching, causing case not to matter
 in regular expression searches.
Index: paragraph.c
===
RCS file: /cvs/src/usr.bin/mg/paragraph.c,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 paragraph.c
--- paragraph.c 12 Apr 2016 06:20:50 -  1.43
+++ paragraph.c 12 Apr 2016 18:01:58 -
@@ -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++] = ' ';
 
@@ -480,5 +480,16 @@ setfillcol(int f, int n)
fillcol = nfill;
ewprintf("Fill column set to %d", fillcol);
}
+   return (TRUE);
+}
+
+int
+sentencespace(int f, int n)
+{
+   if (f & FFARG)
+   dblspace = n > 1;
+   else