]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/fill.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / textmodes / fill.el
index 08254c6f5f73630287e2ae69ee748723ac597ee7..5b6d5f359e64e1075e91a3f161031ca49e85d977 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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-2013 Free
+;; Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: wp
@@ -721,7 +721,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.
@@ -1011,7 +1015,8 @@ space does not end a sentence, so don't break a line there."
                       (if current-prefix-arg 'full))))
   (unless (memq justify '(t nil none full center left right))
     (setq justify 'full))
-  (let (max beg fill-pfx)
+  (let ((start-point (point-marker))
+       max beg fill-pfx)
     (goto-char (max from to))
     (when to-eop
       (skip-chars-backward "\n")
@@ -1042,6 +1047,8 @@ space does not end a sentence, so don't break a line there."
            (setq fill-pfx
                  (fill-region-as-paragraph (point) end justify nosqueeze))
          (goto-char end))))
+    (goto-char start-point)
+    (set-marker start-point nil)
     fill-pfx))
 
 \f