From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Add a function that returns pixel distance between points? Date: Mon, 01 Feb 2021 20:22:38 +0200 Message-ID: <83v9bb6429.fsf@gnu.org> References: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@gmail.com> <837dnt9400.fsf@gnu.org> <1EDD0FA5-025C-4A87-BBA1-7B8944E91A12@gmail.com> <83tuqx6sdz.fsf@gnu.org> <83ft2g7tlr.fsf@gnu.org> <51016978-4D2F-45A8-8589-F4562B6DC4A8@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40577"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 01 19:23:04 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l6dqq-000AT3-Ck for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Feb 2021 19:23:04 +0100 Original-Received: from localhost ([::1]:45108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6dqp-0003AR-Eu for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Feb 2021 13:23:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6dq0-0002Wz-Rj for emacs-devel@gnu.org; Mon, 01 Feb 2021 13:22:12 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57972) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6dq0-0003uu-Kv; Mon, 01 Feb 2021 13:22:12 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3934 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l6dpz-0000ii-Ry; Mon, 01 Feb 2021 13:22:12 -0500 In-Reply-To: <51016978-4D2F-45A8-8589-F4562B6DC4A8@gmail.com> (message from Yuan Fu on Mon, 1 Feb 2021 09:16:52 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263690 Archived-At: > From: Yuan Fu > Date: Mon, 1 Feb 2021 09:16:52 -0500 > Cc: "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.