X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/e18afed7d695edac870ddf55aabc85c0a95a4b5f..51721edc6ba92f9c7cb6a2daab45bb538a696f3d:/lisp/textmodes/fill.el diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index d0e90c9951..7a5b1812a6 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -1,9 +1,9 @@ ;;; 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-2014 Free +;; Software Foundation, Inc. -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: wp ;; Package: emacs @@ -220,7 +220,7 @@ Remove indentation from each line." (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 @@ -329,13 +329,24 @@ places." (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." @@ -721,7 +732,11 @@ space does not end a sentence, so don't break a line there." (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.