emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Shingo Tanaka <shingo.fg8@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: shingo.fg8@gmail.com, Nicolas Goaziou <mail@nicolasgoaziou.fr>,
Subject: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used
Date: Sun, 02 May 2021 20:33:23 +0900	[thread overview]
Message-ID: <87pmy9pdz0.wl-shingo.fg8@gmail.com> (raw)
In-Reply-To: <8335v58ppu.fsf@gnu.org>

Thank you for the advice.  I see that `window-text-pixel-size' returns true
displayed width but I think that's TRT for only the other bug I reported
(bug#48149).  These two bugs looks similar but the root causes are completed

This bug (bug#48148) is actually caused by the difference of the width
detection methods between line 1036 in ox-ascii.el (`length') and
`fill-region'.  This is because `org-ascii-template--document-title' first
detects the title width by `length' and then tries to fill it by
`org-ascii--fill-string' which does the action by `fill-region' inside.  And
since the filling point in `fill-region' is based on `move-to-column' and it
looks like giving the same result as `string-width', I think `string-width'
is TRT for this bug.

In other words, specific to this bug, only the same width detection method as
`fill-region' is required, even if it doesn't give you the precise width

Please correct me if I am wrong.

Shingo Tanaka

On Sun, 02 May 2021 18:11:41 +0900,
Eli Zaretskii wrote:
> > From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
> > Cc: Shingo Tanaka <shingo.fg8@gmail.com>,  48148@debbugs.gnu.org
> > Date: Sun, 02 May 2021 10:23:34 +0200
> > 
> > > The accurate method of lining up in these cases is to use
> > > window-text-pixel-size instead.  That function will return the exact
> > > width of a string as it will displayed, in pixels, because it uses the
> > > same code as the display engine.
> > 
> > Would you mind giving an example about `window-text-pixel-size' usage in
> > this situation?
> I'm not sure what kind of example is necessary.  How about if you ask
> specific questions about the arguments of that function which you
> don't understand clearly how to use?
> > AFAIU, `window-text-pixel-size' returns the size of the window
> No, it returns the size of _text_ when displayed in a window.
> > Note that `text-width' in the code above is not related to the width
> > of the window, but is a maximum number of allowed characters on a
> > line.
> I didn't mean text-width, I meant the use of string-width: it should
> be replaced by a call to window-text-pixel-size.

  reply	other threads:[~2021-05-02 13:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87h7jm2es2.wl-shingo.fg8@gmail.com>
2021-05-02  7:03 ` Eli Zaretskii
2021-05-02  8:23   ` Nicolas Goaziou
2021-05-02  9:11     ` Eli Zaretskii
2021-05-02 11:33       ` Shingo Tanaka [this message]
2021-05-02 12:43         ` Eli Zaretskii
2021-05-02 12:18       ` Nicolas Goaziou
2021-05-02 12:48         ` Eli Zaretskii
2021-05-02 15:56           ` Nicolas Goaziou
2021-05-02 16:11             ` Eli Zaretskii

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:

  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=87pmy9pdz0.wl-shingo.fg8@gmail.com \
    --to=shingo.fg8@gmail.com \
    --cc=48148@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --subject='Re: bug#48148: 27.2; ox-ascii breaks TITLE line wrongly when 2 width char is used' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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


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).