all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 10978@debbugs.gnu.org, stepnem@gmail.com
Subject: bug#10978: `calendar-string-spread' loses with double-width characters
Date: Mon, 12 Mar 2012 16:26:26 -0400	[thread overview]
Message-ID: <n3ehsxy39p.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <837gyszscr.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 10 Mar 2012 12:02:28 +0200")

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."






  reply	other threads:[~2012-03-12 20:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 11:57 bug#10978: `calendar-string-spread' loses with double-width characters Štěpán Němec
2012-03-09 12:33 ` Eli Zaretskii
2012-03-09 14:05   ` Drew Adams
2012-03-10  9:57     ` Eli Zaretskii
2012-03-10  2:27   ` Glenn Morris
2012-03-10  2:32     ` Glenn Morris
2012-03-10 10:02       ` Eli Zaretskii
2012-03-12 20:26         ` Glenn Morris [this message]
2012-03-16  1:12           ` Glenn Morris
2012-03-10  7:32     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=n3ehsxy39p.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=10978@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stepnem@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.