summaryrefslogtreecommitdiff
path: root/lisp/calendar
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2012-03-15 21:10:46 -0400
committerGlenn Morris <rgm@gnu.org>2012-03-15 21:10:46 -0400
commitc7e73d5177c6b51d8453830b6400090cc1a052df (patch)
treeac59d7123e089c9d49d12b0c430e49d2075ac626 /lisp/calendar
parentf66eca265da9779c4fd34d81b53dddc7b1a7a150 (diff)
downloademacs-c7e73d5177c6b51d8453830b6400090cc1a052df.tar.gz
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.
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/calendar.el22
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index b09167ea49b..d9ec27b4f88 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1424,16 +1424,24 @@ Optional integers MON and YR are used instead of today's date."
"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)