;;; fill.el --- fill commands for Emacs -*- coding: utf-8 -*-
-;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2012
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2015 Free
+;; Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: wp
;; Package: emacs
(let ((str (or
(and adaptive-fill-function (funcall adaptive-fill-function))
(and adaptive-fill-regexp (looking-at adaptive-fill-regexp)
- (match-string-no-properties 0)))))
+ (match-string 0)))))
(if (>= (+ (current-left-margin) (length str)) (current-fill-column))
;; Death to insanely long prefixes.
nil
(and (memq (preceding-char) '(?\t ?\s))
(eq (char-syntax (following-char)) ?w)))))))
+(defun fill-single-char-nobreak-p ()
+ "Return non-nil if a one-letter word is before point.
+This function is suitable for adding to the hook `fill-nobreak-predicate',
+to prevent the breaking of a line just after a one-letter word,
+which is an error according to some typographical conventions."
+ (save-excursion
+ (skip-chars-backward " \t")
+ (backward-char 2)
+ (looking-at "[[:space:]][[:alpha:]]")))
+
(defcustom fill-nobreak-predicate nil
"List of predicates for recognizing places not to break a line.
The predicates are called with no arguments, with point at the place to
be tested. If it returns t, fill commands do not break the line there."
:group 'fill
:type 'hook
- :options '(fill-french-nobreak-p fill-single-word-nobreak-p))
+ :options '(fill-french-nobreak-p fill-single-word-nobreak-p
+ fill-single-char-nobreak-p))
(defcustom fill-nobreak-invisible nil
"Non-nil means that fill commands do not break lines in invisible text."
(move-to-column (current-fill-column))
(if (when (< (point) to)
;; Find the position where we'll break the line.
- (forward-char 1) ;Use an immediately following space, if any.
+ ;; Use an immediately following space, if any.
+ ;; However, note that `move-to-column' may overshoot
+ ;; if there are wide characters (Bug#3234).
+ (unless (> (current-column) (current-fill-column))
+ (forward-char 1))
(fill-move-to-break-point linebeg)
;; Check again to see if we got to the end of
;; the paragraph.