Subject: Re: bug#20871: 25.0.50; fill-single-char-nobreak-p does not recognize a single-letter word when it is preceded by an open paren

From: Marcin Borkowski <[email-masked]>
Date: Sun, 17 Apr 2016 17:34:04 +0200

On 2016-04-17, at 14:57, Eli Zaretskii <[email-masked]> wrote:

>> From: Marcin Borkowski <[email-masked]>
>> Date: Sun, 17 Apr 2016 08:34:30 +0200
>> 
>> >> today I found that fill-single-char-nobreak-p is just a bit too
>> >> simplistic.  When point is after e.g. the string " (a", it returns nil
>> >> instead of t.  I am not sure which characters should be added to the
>> >> regex, but at least the opening paren (and maybe bracket) should be
>> >> there, so I'd change the regex into [[:space:]][[(]*[[:alpha:]].  (Two
>> >> or more opening parens/brackets are unlikely, but when in doubt, I guess
>> >> it's better to return t than nil than the other way round.)
>> >>
>> >> Best regards,
>> >
>> > Just noticed that there is a hardcoded (backward-char 2), so it
>> > seems that adding a few characters to the regex is not enough.  Maybe
>> > looking-back is the way to go (though it might slow filling down)?
>> > I don't know.
>> 
>> Hi there,
>> 
>> so here's a patch for the bug I reported some time ago.
>
> Could you please elaborate on the bug itself?

In Polish typography, it is customary to foribid line breaks after
one-letter words (and we have quite a few of them: a, i, o, w, z - they
are conjunctions or prepositions).  And it is not uncommon to have
a combination of them with a parenthesized remark or something like
that.  That's why allowing a linebreak after, say "(a" when writing
something in Polish (like an email, for instance) is a bug IMO.

> See, the function in question, fill-single-char-nobreak-p, is
> documented as a possible value to use in the fill hook, for a very
> specific purpose.  If you are saying that it doesn't fulfill that
> purpose well enough, please show a use case where it fails to do that.
> At least the situation you described, with " (a", doesn't seem to fit
> the use cases which this function is supposed to cover, since the
> parenthesis makes a 2-character sequence, whereas
> fill-single-char-nobreak-p aims to support isolated one-character
> words.

I see.  So you suggest that instead of patching
`fill-single-char-nobreak-p' I should have provided another function,
customized for Polish?

In fact, I'm not so sure about it.  The whole point of such functions
(as I see it) is help write texts in natural langauges.  It seems
unnatural to treat words preceded by a space and by a parenthesis *in
a natural language* differently, no?

> I also am not sure I understand what is so special about '(' that it
> has to be hard-coded here.  What about '[' or '{' or '<' (or any other
> punctuation character, for that matter)?

The special thing about `(' is that (unlike other characters you
mentioned) is that it is actually used in a text in a natural language
(though one could make a case for `[', too).

>> Please review both the patch and the commit message (I'm still
>> learning to write them...).
>
> The commit message should begin with a capital letter.  Also, I think
> this variant is more clear:
>
>  Don't break after a single-character word that follows an opening
>  parenthesis.
>
> Thanks.

Thanks and best regards,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University