emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Aligning table is incorrect when containing japanese character
@ 2010-02-02 18:58 Taiki SUGAWARA
  2010-02-03  6:23 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Taiki SUGAWARA @ 2010-02-02 18:58 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

Hi,

When I align table containing japanese character as following steps:

  1. insert following table to buffer.
        | 日本語      |   |
        | foo bar baz |   |
  2. move cursor to top-left corner of table.

  3. Hit Tab, Tab

Aligning table is incorrect as following:
        | 日本語   |   |
        | foo bar baz |   |

I think, `org-table-justify-field-maybe' should use string width
instead of buffer's point distance.

I wrote attached patch to use string width. Would you review it?

Regards,
Taiki

[-- Attachment #2: org-table.el.patch --]
[-- Type: application/octet-stream, Size: 570 bytes --]

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 49c59e3..17327af 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -817,7 +817,7 @@ 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 (- (string-width o) 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) ""))

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Aligning table is incorrect when containing japanese character
  2010-02-02 18:58 Aligning table is incorrect when containing japanese character Taiki SUGAWARA
@ 2010-02-03  6:23 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2010-02-03  6:23 UTC (permalink / raw)
  To: Taiki SUGAWARA; +Cc: emacs-orgmode

Hi Taiki,

Org-mode will do this right if you are using a font
that uses a wdith of exactly 2 ASCII characters for each japanese  
character.

- Carsten

On Feb 2, 2010, at 7:58 PM, Taiki SUGAWARA wrote:

> Hi,
>
> When I align table containing japanese character as following steps:
>
>  1. insert following table to buffer.
>        | 日本語      |   |
>        | foo bar baz |   |
>  2. move cursor to top-left corner of table.
>
>  3. Hit Tab, Tab
>
> Aligning table is incorrect as following:
>        | 日本語   |   |
>        | foo bar baz |   |
>
> I think, `org-table-justify-field-maybe' should use string width
> instead of buffer's point distance.
>
> I wrote attached patch to use string width. Would you review it?
>
> Regards,
> Taiki
> <org-table.el.patch>_______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-03  6:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-02 18:58 Aligning table is incorrect when containing japanese character Taiki SUGAWARA
2010-02-03  6:23 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).