Subject: Re: bug#10978: `calendar-string-spread' loses with double-width characters

From: Glenn Morris <[email-masked]>
Date: Fri, 09 Mar 2012 21:27:08 -0500

Eli Zaretskii wrote:

> It should use `string-width' instead of `length'.

Like so?

*** lisp/calendar/calendar.el	2012-03-06 02:18:29 +0000
--- lisp/calendar/calendar.el	2012-03-10 02:16:16 +0000
***************
*** 1756,1762 ****
                            (if (< (length strings) 2)
                                (append (list "") strings (list ""))
                              strings)))
!          (n (- length (length (apply 'concat strings))))
           (m (1- (length strings)))
           (s (car strings))
           (strings (cdr strings))
--- 1756,1762 ----
                            (if (< (length strings) 2)
                                (append (list "") strings (list ""))
                              strings)))
!          (n (- length (string-width (apply 'concat strings))))
           (m (1- (length strings)))
           (s (car strings))
           (strings (cdr strings))
***************
*** 1766,1772 ****
                        (make-string (max 0 (/ (+ n i) m)) char)
                        string)
              i (1+ i)))
!     (substring s 0 length)))
  
  (defun calendar-update-mode-line ()
    "Update the calendar mode line with the current date and date style."
--- 1766,1772 ----
                        (make-string (max 0 (/ (+ n i) m)) char)
                        string)
              i (1+ i)))
!     (truncate-string-to-width s length)))
  
  (defun calendar-update-mode-line ()
    "Update the calendar mode line with the current date and date style."