]> code.delx.au - gnu-emacs/commitdiff
Small calendar-string-spread fix for bug#10978
authorGlenn Morris <rgm@gnu.org>
Tue, 13 Mar 2012 17:56:31 +0000 (13:56 -0400)
committerGlenn Morris <rgm@gnu.org>
Tue, 13 Mar 2012 17:56:31 +0000 (13:56 -0400)
* lisp/calendar/calendar.el (calendar-string-spread):
Handle non-unit-width characters a bit better.

lisp/ChangeLog
lisp/calendar/calendar.el

index 0109376a50d5fb1c643d2832e2c9a08fd87e9dfd..1b7eabd200903f9a4522165d7aab7dc23cc50296 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-13  Glenn Morris  <rgm@gnu.org>
+
+       * calendar/calendar.el (calendar-string-spread):
+       Handle non-unit-width characters a bit better.  (Bug#10978)
+
 2012-03-13  Leo Liu  <sdl.web@gmail.com>
 
        * vc/vc-hg.el (vc-hg-working-revision): Rework to work with both
index 0c351c6072f94bfc4059d1094d8e501d6acd24c4..b09167ea49be20f34b33492f0320e66e25190820 100644 (file)
@@ -1756,8 +1756,8 @@ the STRINGS are just concatenated and the result truncated."
                           (if (< (length strings) 2)
                               (append (list "") strings (list ""))
                             strings)))
-         (n (- length (length (apply 'concat strings))))
-         (m (1- (length strings)))
+         (n (- length (string-width (apply 'concat strings))))
+         (m (* (1- (length strings)) (char-width char)))
          (s (car strings))
          (strings (cdr strings))
          (i 0))
@@ -1766,7 +1766,7 @@ the STRINGS are just concatenated and the result truncated."
                       (make-string (max 0 (/ (+ n i) m)) char)
                       string)
             i (1+ i)))
-    (substring s 0 length)))
+    (truncate-string-to-width s length)))
 
 (defun calendar-update-mode-line ()
   "Update the calendar mode line with the current date and date style."