emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107609: calendar-insert-at-column sm


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107609: calendar-insert-at-column small fix for bug#10978
Date: Thu, 15 Mar 2012 21:10:46 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107609
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Thu 2012-03-15 21:10:46 -0400
message:
  calendar-insert-at-column small fix for bug#10978
  
  * lisp/calendar/calendar.el (calendar-insert-at-column):
  Handle non-unit-width characters a bit better.
modified:
  lisp/ChangeLog
  lisp/calendar/calendar.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-03-15 08:00:43 +0000
+++ b/lisp/ChangeLog    2012-03-16 01:10:46 +0000
@@ -1,3 +1,8 @@
+2012-03-16  Glenn Morris  <address@hidden>
+
+       * calendar/calendar.el (calendar-insert-at-column):
+       Handle non-unit-width characters a bit better.  (Bug#10978)
+
 2012-03-15  Chong Yidong  <address@hidden>
 
        * emacs-lisp/ring.el (ring-extend): New function.

=== modified file 'lisp/calendar/calendar.el'
--- a/lisp/calendar/calendar.el 2012-03-13 17:56:31 +0000
+++ b/lisp/calendar/calendar.el 2012-03-16 01:10:46 +0000
@@ -1424,16 +1424,24 @@
   "Move to column INDENT, adding spaces as needed.
 Inserts STRING so that it ends at INDENT.  STRING is either a
 literal string, or a sexp to evaluate to return such.  Truncates
-STRING to length TRUNCATE, ensure a trailing space."
+STRING to length TRUNCATE, and ensures a trailing space."
   (if (not (ignore-errors (stringp (setq string (eval string)))))
       (calendar-move-to-column indent)
-    (if (> (length string) truncate)
-        (setq string (substring string 0 truncate)))
+    (if (> (string-width string) truncate)
+        (setq string (truncate-string-to-width string truncate)))
     (or (string-match " $" string)
-        (if (= (length string) truncate)
-            (aset string (1- truncate) ?\s)
-          (setq string (concat string " "))))
-    (calendar-move-to-column (- indent (length string)))
+        (setq string (concat (if (= (string-width string) truncate)
+                                 (substring string 0 -1)
+                               string)
+                             ;; Avoid inserting text properties unless
+                             ;; we have to (ie, non-unit-width chars).
+                             ;; This is by no means essential.
+                             (if (= (string-width string) (length string))
+                                 " "
+                               ;; Cribbed from buff-menu.el.
+                               (propertize
+                                " " 'display `(space :align-to ,indent))))))
+    (calendar-move-to-column (- indent (string-width string)))
     (insert string)))
 
 (defun calendar-generate-month (month year indent)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]