emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fill-single-word-nobreak-p


From: Juri Linkov
Subject: fill-single-word-nobreak-p
Date: Tue, 27 Dec 2005 02:19:29 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

The purpose of the filling breaking predicate `fill-single-word-nobreak-p'
is defined in its docstring as:

"Don't break a line after the first or before the last word of a sentence."

However, currently it fails to do this at two points:

1. it leaves the last word of a sentence on the next line;

2. it breaks the sentence at point where a period inside the sentence
   is followed by only one space and `sentence-end-double-space' is t.

I could install the following patch if no one finds a flaw in it:

Index: lisp/textmodes/fill.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/fill.el,v
retrieving revision 1.182
diff -c -r1.182 fill.el
*** lisp/textmodes/fill.el      21 Oct 2005 08:50:28 -0000      1.182
--- lisp/textmodes/fill.el      27 Dec 2005 00:12:12 -0000
***************
*** 291,302 ****
  
  (defun fill-single-word-nobreak-p ()
    "Don't break a line after the first or before the last word of a sentence."
!   (or (looking-at "[ \t]*\\sw+[ \t]*[.?!:][ \t]*$")
        (save-excursion
        (skip-chars-backward " \t")
        (and (/= (skip-syntax-backward "w") 0)
             (/= (skip-chars-backward " \t") 0)
!            (/= (skip-chars-backward ".?!:") 0)))))
  
  (defun fill-french-nobreak-p ()
    "Return nil if French style allows breaking the line at point.
--- 291,303 ----
  
  (defun fill-single-word-nobreak-p ()
    "Don't break a line after the first or before the last word of a sentence."
!   (or (looking-at (concat "[ \t]*\\sw+" "\\(?:" (sentence-end) "\\)"))
        (save-excursion
        (skip-chars-backward " \t")
        (and (/= (skip-syntax-backward "w") 0)
             (/= (skip-chars-backward " \t") 0)
!            (/= (skip-chars-backward ".?!:") 0)
!            (looking-at (sentence-end))))))
  
  (defun fill-french-nobreak-p ()
    "Return nil if French style allows breaking the line at point.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]