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: Sun, 31 Jan 2021 17:24:56 +0200 Message-ID: <83tuqx6sdz.fsf@gnu.org> References: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@gmail.com> <837dnt9400.fsf@gnu.org> <1EDD0FA5-025C-4A87-BBA1-7B8944E91A12@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="21049"; 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 Sun Jan 31 16:28:24 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 1l6EeG-0005OL-BJ for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 16:28:24 +0100 Original-Received: from localhost ([::1]:54854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6EeF-0005fa-D7 for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 10:28:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6EaX-00026P-TS for emacs-devel@gnu.org; Sun, 31 Jan 2021 10:24:33 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34235) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6EaX-00033s-Lm; Sun, 31 Jan 2021 10:24:33 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2343 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l6EaX-0008I1-4j; Sun, 31 Jan 2021 10:24:33 -0500 In-Reply-To: <1EDD0FA5-025C-4A87-BBA1-7B8944E91A12@gmail.com> (message from Yuan Fu on Sun, 31 Jan 2021 00:17:58 -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:263657 Archived-At: > From: Yuan Fu > Date: Sun, 31 Jan 2021 00:17:58 -0500 > Cc: emacs-devel@gnu.org > > I want to align text-based tables by pixel size, as in: > > | header | header | header | > | 1 | 1 | 8 | > | 2 | 6 | 3 | > > When the text is displayed in variable-pitch font, the bars aren’t aligned. I’m using display property (space :align-to) to align those bars. To know with pixel position to align to, I need to calculate each column’s pixel width, and met the difficulties mentioned earlier. So the columns in your case have width that changes dynamically? That is, if I type enough characters into a cell that the current width is no longer sufficient, the width of the cell's column will be increased? Also, I don't think I understand why it is a problem for you that posn-at-point requires point to be visible -- are you generating the table in a buffer that is not displayed, or in a portion of a buffer that is not visible? Or is there some other reason why you have problems with this requirement of posn-at-point? Finally, I'm not sure why the behavior of window-text-pixel-size is a problem: if you use :align-to with pixel units (as opposed to column units), then you should _want_ it to account for stuff like line-prefix, no?