From 4af31090b4420978067bc24512467bcc9a78a7f1 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Wed, 13 Feb 2013 11:56:18 +0800 Subject: [PATCH] Use string width in table field justification org-table.el (org-table-justify-field-maybe): Use `org-string-width' instead of `length' to calculate the visual width of table cells. This is useful for e.g. double-width charsets. --- lisp/org-table.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 6a7935e16..5e0177f1b 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -981,13 +981,16 @@ Optional argument NEW may specify text to replace the current field content." (progn (setq s (match-string 1) o (match-string 0) - l (max 1 (- (match-end 0) (match-beginning 0) 3)) + l (max 1 + (- (org-string-width + (buffer-substring-no-properties + (match-end 0) (match-beginning 0))) 3)) e (not (= (match-beginning 2) (match-end 2)))) (setq f (format (if num " %%%ds %s" " %%-%ds %s") l (if e "|" (setq org-table-may-need-update t) "")) n (format f s)) (if new - (if (<= (length new) l) ;; FIXME: length -> str-width? + (if (<= (org-string-width new) l) (setq n (format f new)) (setq n (concat new "|") org-table-may-need-update t))) (if (equal (string-to-char n) ?-) (setq n (concat " " n))) -- 2.11.4.GIT