all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Add a function that returns pixel distance between points?
Date: Mon, 01 Feb 2021 20:22:38 +0200	[thread overview]
Message-ID: <83v9bb6429.fsf@gnu.org> (raw)
In-Reply-To: <51016978-4D2F-45A8-8589-F4562B6DC4A8@gmail.com> (message from Yuan Fu on Mon, 1 Feb 2021 09:16:52 -0500)

> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 1 Feb 2021 09:16:52 -0500
> Cc: "emacs-devel\\@gnu.org" <emacs-devel@gnu.org>
> 
> > IOW, can you show a test case where using window-text-pixel-size
> > returns incorrect results for :align-to due to line-prefix?
> 
> Here is an example:
> 
> (let ((width))
>   (insert "woome")
>   (setq width (car (window-text-pixel-size
>                     nil (line-beginning-position) (point))))
>   (put-text-property (line-beginning-position) (point)
>                      'line-prefix "   ")
>   (message "true width: %d returned width: %d"
>            width (car (window-text-pixel-size
>                        nil (line-beginning-position) (point)))))
> 
> Run it in an empty buffer and it will print the expected width and returned width. In the snippet I’m trying to measure the width of the text.

This says:

  true width: 40 returned width: 64

However, if I use :align-to with the value of 64 pixels, the stretch
of whitespace ends where I'd expect it to end: aligned to right after
"woome".

So I still don't understand the problem you are facing.  Which is why
I asked for an example code which uses :align-to in a way similar to
what you intend to do in your table rendering code, because I wanted
to see a situation where :align-to produces incorrect results when
using the return value of window-text-pixel-size in the presence of
line-prefix.  But the example you show doesn't use :align-to.



  reply	other threads:[~2021-02-01 18:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-30 20:47 Add a function that returns pixel distance between points? Yuan Fu
2021-01-31  3:31 ` Eli Zaretskii
2021-01-31  5:17   ` Yuan Fu
2021-01-31  5:52     ` Ihor Radchenko
2021-01-31 19:42       ` Yuan Fu
2021-01-31 15:24     ` Eli Zaretskii
2021-01-31 19:41       ` Yuan Fu
2021-01-31 20:13         ` Eli Zaretskii
2021-02-01 14:16           ` Yuan Fu
2021-02-01 18:22             ` Eli Zaretskii [this message]
2021-02-01 23:00               ` Yuan Fu
2021-02-02 16:29                 ` Eli Zaretskii
2021-02-03 15:04                   ` Eli Zaretskii
2021-02-03 16:48                     ` Yuan Fu
2021-02-04 16:02                       ` Eli Zaretskii
2021-02-05 10:15                         ` martin rudalics
2021-02-05 12:25                           ` Eli Zaretskii
2021-02-05 15:48                             ` martin rudalics

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

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

  git send-email \
    --in-reply-to=83v9bb6429.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.