changeset 52362:28bd29f9f91c

(kinsoku-longer, kinsoku-shorter): Do not choose a line break position in the middle of a non-kinsoku (e.g. latin) word, making it skip until either a space or a character with category "|". (kinsoku-longer): Test for end of buffer.
author Kenichi Handa <handa@m17n.org>
date Fri, 29 Aug 2003 12:06:24 +0000
parents 77ca9d1eec0b
children edbdaabbbdd3
files lisp/international/kinsoku.el
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/kinsoku.el	Fri Aug 29 09:29:39 2003 +0000
+++ b/lisp/international/kinsoku.el	Fri Aug 29 12:06:24 2003 +0000
@@ -121,11 +121,17 @@
 
 ;; Try to resolve `kinsoku' restriction by making the current line longer.
 (defun kinsoku-longer ()
-  (let ((pos-and-column (save-excursion
-			  (forward-char 1)
-			  (while (aref (char-category-set (following-char)) ?>)
-			    (forward-char 1))
-			  (cons (point) (current-column)))))
+  (let ((pos-and-column
+	 (save-excursion
+	   (forward-char 1)
+	   (while (and (not (eobp))
+		       (or (aref (char-category-set (following-char)) ?>)
+			   ;; protect non-kinsoku words
+			   (not (or (eq (preceding-char) ? )
+				    (aref (char-category-set (preceding-char))
+					  ?|)))))
+	     (forward-char 1))
+	   (cons (point) (current-column)))))
     (if (or (<= kinsoku-limit 0)
 	    (< (cdr pos-and-column) (+ (current-fill-column) kinsoku-limit)))
 	(goto-char (car pos-and-column)))))
@@ -135,9 +141,14 @@
 (defun kinsoku-shorter (linebeg)
   (let ((pos (save-excursion
 	       (forward-char -1)
-	       (while (and (< linebeg (point))
-			   (or (aref (char-category-set (preceding-char)) ?<)
-			       (aref (char-category-set (following-char)) ?>)))
+	       (while (and
+		       (< linebeg (point))
+		       (or (aref (char-category-set (preceding-char)) ?<)
+			   (aref (char-category-set (following-char)) ?>)
+			   ;; protect non-kinsoku words
+			   (not (or (eq (preceding-char) ? )
+				    (aref (char-category-set (preceding-char))
+					  ?|)))))
 		 (forward-char -1))
 	       (point))))
     (if (< linebeg pos)