[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10978: `calendar-string-spread' loses with double-width characters
From: |
Glenn Morris |
Subject: |
bug#10978: `calendar-string-spread' loses with double-width characters |
Date: |
Mon, 12 Mar 2012 16:26:26 -0400 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Eli Zaretskii wrote:
> But it looks like calendar-insert-at-column and calendar-string-spread
> also need similar changes.
ACK on calendar-insert-at-column, but calendar-string-spread is the
function already being discussed - was there a third?
> Sorry, I don't follow. Could you elaborate on what you had in mind?
I meant, don't do this:
(calendar-string-spread '("a" "b" "c") ?矢 10)
ie, a restriction similar to that of truncate-string-to-width:
The optional 4th arg PADDING, if non-nil, specifies a padding
character (which should have a display width of 1)
But, it can be handled a bit better with:
*** lisp/calendar/calendar.el 2012-03-06 02:18:29 +0000
--- lisp/calendar/calendar.el 2012-03-12 20:23:23 +0000
***************
*** 1756,1763 ****
(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))
(i 0))
--- 1756,1763 ----
(if (< (length strings) 2)
(append (list "") strings (list ""))
strings)))
! (n (- length (string-width (apply 'concat strings))))
! (m (* (1- (length strings)) (char-width char)))
(s (car strings))
(strings (cdr strings))
(i 0))
***************
*** 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."