2001-08-18 19:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Sun, 19 Aug 2001 02:05:12 +0000 (02:05 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Sun, 19 Aug 2001 02:05:12 +0000 (02:05 +0000)
* gnus-spec.el (gnus-char-width): New.
(gnus-correct-substring, gnus-correct-length): Use it.

lisp/ChangeLog
lisp/gnus-spec.el

index 6d65f24..9f05635 100644 (file)
@@ -1,5 +1,8 @@
 2001-08-18 19:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
+       * gnus-spec.el (gnus-char-width): New.
+       (gnus-correct-substring, gnus-correct-length): Use it.
+
        * message.el (message-required-mail-headers): Fix doc.
 
 2001-08-18 18:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
index 60d687a..14266b0 100644 (file)
     'balloon-help
     ,(intern (format "gnus-balloon-face-%d" type))))
 
+(eval-and-compile
+  (defalias 'gnus-char-width
+    (if (fboundp 'char-width)
+       'char-width
+      (lambda (ch) 1)))) ;; A simple hack.
+
 (defun gnus-correct-length (string)
   "Return the correct width of STRING."
   (let ((length 0))
-    (mapcar (lambda (char) (incf length (char-width char))) string)
+    (mapcar (lambda (char) (incf length (gnus-char-width char))) string)
     length))
 
 (defun gnus-correct-substring (string start end)
     ;; Find the start position.
     (while (and (< seek length)
                (< wstart start))
-      (incf wstart (char-width (aref string seek)))
+      (incf wstart (gnus-char-width (aref string seek)))
       (incf seek))
     (setq wend wstart
          wstart seek)
     ;; Find the end position.
     (while (and (< seek length)
                (< wend end))
-      (incf wend (char-width (aref string seek)))
+      (incf wend (gnus-char-width (aref string seek)))
       (incf seek))
     (setq wend seek)
     (substring string wstart (1- wend))))