Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

auto-fill breaks line too early

11 views
Skip to first unread message

mandar.mitra

unread,
Oct 18, 2012, 4:12:50 AM10/18/12
to
I type the following (single) line in Emacs 24 [1] (started as emacs -Q):

--------------------
A study of the number of relevant documents for queries may provide some insights about the collections when juxtaposed across the FIRE years. Voorhees and
--------------------

I turn on auto-fill-mode, place cursor on i (for insight) and hit C-x f to
set fill column to 73. Then I go to the end of the line and hit space. This
produces:

--------------------
A study of the number of relevant documents for queries may provide some
insights about the collections when juxtaposed across the FIRE
years. Voorhees and
--------------------

Why does auto-fill break the line before years instead of after? This
happens across emacs versions, whenever there is a sentence break close to
the fill-column. If I delete the period, the line break is inserted after
years as expected.

Is this a bug or a feature? Is there a workaround or should I file a bug /
look in the code?

Many thanks,
Mandar.



[1] GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 3.2.0) of 2012-09-19 on litembilla, modified by Debian

Michael Heerdegen

unread,
Oct 18, 2012, 4:33:51 AM10/18/12
to help-gn...@gnu.org
Hi,


the doc of `fill-paragraph' reveals the mystery:

| If `sentence-end-double-space' is non-nil, then period followed by one
| space does not end a sentence, so don't break a line there.

The default value is t. So, no, it's not a bug. Customize
`sentence-end-double-space' to nil to change the behavior.


Michael.

Teemu Likonen

unread,
Oct 18, 2012, 4:34:18 AM10/18/12
to mandar mitra, help-gn...@gnu.org
mandar mitra [2012-10-18 01:12:50 -0700] wrote:

> Is this a bug or a feature?

A feature. See variable "sentence-end-double-space" and the Emacs Editor
manual section "(emacs) Sentences".

Tassilo Horn

unread,
Oct 18, 2012, 4:40:33 AM10/18/12
to help-gn...@gnu.org
"mandar.mitra" <mandar...@gmail.com> writes:

Hi Mandar,

> I turn on auto-fill-mode, place cursor on i (for insight) and hit C-x f to
> set fill column to 73. Then I go to the end of the line and hit space. This
> produces:
>
> --------------------
> A study of the number of relevant documents for queries may provide some
> insights about the collections when juxtaposed across the FIRE
> years. Voorhees and
> --------------------
>
> Why does auto-fill break the line before years instead of after?

That's because emacs thinks "years." is an abbreviation. If you'd use
two spaces after a dot ending a sentence, it'll work as you expected.

You can change this by setting this to nil.

,----[ C-h v sentence-end-double-space RET ]
| sentence-end-double-space is a variable defined in `paragraphs.el'.
| Its value is t
|
| This variable is safe as a file local variable if its value
| satisfies the predicate `booleanp'.
|
| Documentation:
| Non-nil means a single space does not end a sentence.
| This is relevant for filling. See also `sentence-end-without-period'
| and `colon-double-space'.
|
| This value is used by the function `sentence-end' to construct the
| regexp describing the end of a sentence, when the value of the variable
| `sentence-end' is nil. See Info node `(elisp)Standard Regexps'.
|
| You can customize this variable.
`----

However, keep in mind that then the sentence moving commands like `M-a'
and `M-e' also stop at real abbreviations like in "bla, bla, etc. bla
bla."

If you check some messages here on the list, you'll see that most
long-time emacs users have two spaces after the dot ending a sentence.
Ditto in this message. Now you know why.

Bye,
Tassilo


Barry Margolin

unread,
Oct 18, 2012, 8:25:47 AM10/18/12
to
In article <mailman.11206.1350549...@gnu.org>,
Michael Heerdegen <michael_...@web.de> wrote:

> Hi,
>
>
> the doc of `fill-paragraph' reveals the mystery:
>
> | If `sentence-end-double-space' is non-nil, then period followed by one
> | space does not end a sentence, so don't break a line there.
>
> The default value is t. So, no, it's not a bug. Customize
> `sentence-end-double-space' to nil to change the behavior.

And if you want to understand the rationale for this, see a very similar
thread from 3-4 weeks ago.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Mandar Mitra

unread,
Oct 18, 2012, 8:30:35 AM10/18/12
to help-gn...@gnu.org
Teemu Likonen wrote (Thu, Oct 18, 2012 at 11:34:18AM +0300):
> mandar mitra [2012-10-18 01:12:50 -0700] wrote:
>
> > Is this a bug or a feature?
>
> A feature. See variable "sentence-end-double-space" and the Emacs Editor
> manual section "(emacs) Sentences".

Wow! Many thanks! Truly, a lifetime of learning..

mandar.

David Combs

unread,
Nov 24, 2012, 8:27:40 PM11/24/12
to
In article <mailman.11206.1350549...@gnu.org>,
Michael Heerdegen <michael_...@web.de> wrote:
>Hi,
>
>
>the doc of `fill-paragraph' reveals the mystery:
>
>| If `sentence-end-double-space' is non-nil, then period followed by one
>| space does not end a sentence, so don't break a line there.
>
>The default value is t. So, no, it's not a bug. Customize
>`sentence-end-double-space' to nil to change the behavior.
>
>
>Michael.


So I guess the oft-used M-x delete-trailing-whitespace screws up
any use of M-q?

Emacs is so dwim-intelligent about so many things that it's a
surprise to me that a period (or ! or ?, etc) meant to end a
sentence line requires two spaces, which is fine in the middle
of a line, would still obtain at the end of a line.

Perhaps in that double-space mode the emacs user could avoid
ending a line with a period UNLESS that period was to mean
"end of sentence".

Like, he'd have to teach himself to never end a line with
a mid-sentence abbreviation. And he'd never get into that
mode except by deliberately invoking it, plus when he did
enter that mode a message would flash up warning him about
how NOT to end a line.

---

Question: do other emacs users find delete-trailing-whitespace
useful?

Crazy idea? Maybe in that two-spaces mode, delete-trailing-whitespace
would know to NOT remove two spaces following a sentence-ender?


A problem, all this.

David

PS: And oh, yes, I very much like the two-spaces-between-sentences way
of entering and storing text.

Drew Adams

unread,
Nov 24, 2012, 10:05:16 PM11/24/12
to David Combs, help-gn...@gnu.org
> So I guess the oft-used M-x delete-trailing-whitespace screws up
> any use of M-q?

Why do you say that? Did you try it?

> ... it's a surprise to me that a period (or ! or ?, etc)
> meant to end a sentence line requires two spaces, which is
> fine in the middle of a line, would still obtain at the end
> of a line.
>
> Perhaps in that double-space mode the emacs user could avoid
> ending a line with a period UNLESS that period was to mean
> "end of sentence".
>
> Like, he'd have to teach himself to never end a line with
> a mid-sentence abbreviation. And he'd never get into that
> mode except by deliberately invoking it, plus when he did
> enter that mode a message would flash up warning him about
> how NOT to end a line.

It makes no difference whether a line ends in `.'. M-q still respects the
two-space rule if `sentence-end-double-space' is non-nil.

Seems like you went to a lot of trouble (mis)interpreting the doc, without
actually trying it. (Unless of course I misunderstand what you are saying.)

David Combs

unread,
Dec 7, 2012, 7:50:20 PM12/7/12
to
In article <mailman.13738.1353812...@gnu.org>,
Thanks for the info on that variable!

David

0 new messages