From 3809f91dfa03f4494d6ea8f5c9e0137993531864 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 13 Mar 2012 13:56:31 -0400 Subject: [PATCH] Small calendar-string-spread fix for bug#10978 * lisp/calendar/calendar.el (calendar-string-spread): Handle non-unit-width characters a bit better. --- lisp/ChangeLog | 5 +++++ lisp/calendar/calendar.el | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0109376a50d..1b7eabd2009 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-03-13 Glenn Morris + + * calendar/calendar.el (calendar-string-spread): + Handle non-unit-width characters a bit better. (Bug#10978) + 2012-03-13 Leo Liu * vc/vc-hg.el (vc-hg-working-revision): Rework to work with both diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 0c351c6072f..b09167ea49b 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -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." -- 2.39.5