emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Yasushi SHOJI <yashi@atmark-techno.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [RFC] ox-ascii.el: fixing variable width character handling
Date: Sun, 10 Nov 2013 14:09:48 +0100	[thread overview]
Message-ID: <87vc00768z.fsf@gmail.com> (raw)
In-Reply-To: <87zjpcsfoq.wl@dns1.atmark-techno.com> (Yasushi SHOJI's message of "Sun, 10 Nov 2013 19:40:21 +0900")

Hello,

Yasushi SHOJI <yashi@atmark-techno.com> writes:

> I've been trying to fix ASCII export back-end for variable width
> chars. It is basically replacing `length' with `string-width', but the
> behavior of those two functions differ when you give nil as an
> argument; `length' returns 0, `string-width' yields a type error:
> "eval: Wrong type argument: stringp, nil"

Thank you for your patch.

> While I came up with the following experimental patch, I have a few
> questions:
>
>  - What is the lisp idiom to handle type error?  In the following
>    patch, I've created a new wrapper function
>    `org-ascii--string-width', it's a thin wrapper with if-then-else.
>    I thought placing if-then-else clause in the original place clutter
>    the code.

You only use `org-ascii--string-width' in two places. You can write

  (string-width (or contents ""))

instead, it will be less intrusive.

BTW, what about `org-ascii--current-text-width'? This function also uses
`length' instead of `string-width'.

>  - If wrapped string-width is good idea, would it be also a good idea
>    to merge it with `org-string-width' in org.el?  Because it is not
>    ox-ascii specific.  The current `org-string-width' does not handle
>    nil, neither.

That would be a good idea, but in a distinct patch.

>  - The width of the underline for headlines should be checked with
>    string-width.
>
>    As defined in Unicode Standard Annex #41[1], character width is
>    environment dependent.  So, the calculation of character width at
>    export time might not be sufficient enough.  We can check to see
>    the exported document contains cjk chars more than some thresholds
>    or not, I haven't gone that far.

I don't think there's much to do about it. Hopefully one can always
re-export the Org file in its own environment.

>  - Does anyone using ox-ascii.el depends on the clipped marker `=>'
>    for fixed width columns?  I thought `...' would be much readable.

I have no opinion about it. Though, if we switch to "...", we also need
to provide the utf-8 equivalent when using this charset.

>  - BTW, while looking at table handling, I noticed fixed column width
>    doesn't work with the code at the current git HEAD.  That's because
>    width calculation is mixed with `length' and `string-width', and
>    pass out-of-range arguments to `add-text-properties'.

I guess your patch also fixed that.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2013-11-10 13:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-10 10:40 [RFC] ox-ascii.el: fixing variable width character handling Yasushi SHOJI
2013-11-10 13:09 ` Nicolas Goaziou [this message]
2014-01-03  7:55   ` Yasushi SHOJI
2014-01-03  9:34     ` Nicolas Goaziou
2014-01-04 11:18       ` Yasushi SHOJI
2014-01-04 19:34         ` Nicolas Goaziou
2014-01-16 15:25         ` Nicolas Goaziou

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87vc00768z.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yashi@atmark-techno.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 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).