emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el,v
Date: Fri, 01 Feb 2008 16:03:33 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     08/02/01 16:01:31

Index: lisp/textmodes/fill.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/fill.el,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -b -r1.215 -r1.216
--- lisp/textmodes/fill.el      8 Jan 2008 20:45:43 -0000       1.215
+++ lisp/textmodes/fill.el      1 Feb 2008 16:01:30 -0000       1.216
@@ -374,15 +374,29 @@
              (looking-at paragraph-start))))
      (run-hook-with-args-until-success 'fill-nobreak-predicate)))))
 
-;; Put `fill-find-break-point-function' property to charsets which
-;; require special functions to find line breaking point.
-(dolist (pair '((katakana-jisx0201 . kinsoku)
-               (chinese-gb2312 . kinsoku)
-               (japanese-jisx0208 . kinsoku)
-               (japanese-jisx0212 . kinsoku)
-               (chinese-big5-1 . kinsoku)
-               (chinese-big5-2 . kinsoku)))
-  (put-charset-property (car pair) 'fill-find-break-point-function (cdr pair)))
+(defvar fill-find-break-point-function-table (make-char-table nil)
+  "Char-table of special functions to find line breaking point.")
+
+(defvar fill-nospace-between-words-table (make-char-table nil)
+  "Char-table of characters that don't use space between words.")
+
+(progn
+  ;; Register `kinsoku' for scripts HAN, KANA, BOPOMPFO, and CJK-MISS.
+  ;; Also tell that they don't use space between words.
+  (map-char-table
+   #'(lambda (key val)
+       (when (memq val '(han kana bopomofo cjk-misc))
+        (set-char-table-range fill-find-break-point-function-table
+                              key 'kinsoku)
+        (set-char-table-range fill-nospace-between-words-table
+                              key t)))
+   char-script-table)
+  ;; Do the same thing also for full width characters and half
+  ;; width kana variants.
+  (set-char-table-range fill-find-break-point-function-table
+                       '(#xFF01 . #xFFE6) 'kinsoku)
+  (set-char-table-range fill-nospace-between-words-table
+                       '(#xFF01 . #xFFE6) 'kinsoku))
 
 (defun fill-find-break-point (limit)
   "Move point to a proper line breaking position of the current line.
@@ -393,15 +407,9 @@
 character has the property `fill-find-break-point-function', this
 function calls the property value as a function with one arg LIMIT.
 If the charset has no such property, do nothing."
-  (let* ((ch (following-char))
-        (charset (char-charset ch))
-        func)
-    (if (eq charset 'ascii)
-       (setq ch (preceding-char)
-             charset (char-charset ch)))
-    (if (charsetp charset)
-       (setq func
-             (get-charset-property charset 'fill-find-break-point-function)))
+  (let ((func (or
+              (aref fill-find-break-point-function-table (following-char))
+              (aref fill-find-break-point-function-table (preceding-char)))))
     (if (and func (fboundp func))
        (funcall func limit))))
 
@@ -460,14 +468,13 @@
   (goto-char from)
   (if enable-multibyte-characters
       ;; Delete unnecessay newlines surrounded by words.  The
-      ;; character category `|' means that we can break a line
-      ;; at the character.  And, charset property
-      ;; `nospace-between-words' tells how to concatenate
-      ;; words.  If the value is non-nil, never put spaces
-      ;; between words, thus delete a newline between them.
-      ;; If the value is nil, delete a newline only when a
-      ;; character preceding a newline has text property
-      ;; `nospace-between-words'.
+      ;; character category `|' means that we can break a line at the
+      ;; character.  And, char-table
+      ;; `fill-nospace-between-words-table' tells how to concatenate
+      ;; words.  If a character has non-nil value in the table, never
+      ;; put spaces between words, thus delete a newline between them.
+      ;; Otherwise, delete a newline only when a character preceding a
+      ;; newline has non-nil value in that table.
       (while (search-forward "\n" to t)
        (if (get-text-property (match-beginning 0) 'fill-space)
            (replace-match (get-text-property (match-beginning 0) 'fill-space))
@@ -475,10 +482,8 @@
                (next (following-char)))
            (if (and (or (aref (char-category-set next) ?|)
                         (aref (char-category-set prev) ?|))
-                    (or (get-charset-property (char-charset prev)
-                                              'nospace-between-words)
-                        (get-text-property (1- (match-beginning 0))
-                                           'nospace-between-words)))
+                    (or (aref fill-nospace-between-words-table next)
+                        (aref fill-nospace-between-words-table prev)))
                (delete-char -1))))))
 
   (goto-char from)




reply via email to

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