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 05:31:11 +0200 Message-ID: <837dnt9400.fsf@gnu.org> References: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@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="23405"; 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 04:32:17 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 1l63TF-0005zb-L3 for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 04:32:17 +0100 Original-Received: from localhost ([::1]:59280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l63TD-0006Gs-P8 for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Jan 2021 22:32:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l63Rp-0005Sy-EW for emacs-devel@gnu.org; Sat, 30 Jan 2021 22:30:49 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55815) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l63Ro-0003YZ-Er; Sat, 30 Jan 2021 22:30:49 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2622 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l63Rn-0001Mw-H0; Sat, 30 Jan 2021 22:30:48 -0500 In-Reply-To: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@gmail.com> (message from Yuan Fu on Sat, 30 Jan 2021 15:47:38 -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:263650 Archived-At: > From: Yuan Fu > Date: Sat, 30 Jan 2021 15:47:38 -0500 > > For aligning text according to their display size, I need to calculate the width of some text. Currently I’m using window-text-pixel-size, but it has some problem: if the text I’m measuring has line-prefix or wrap-prefix, the size returned will include the width of the prefix. So if the prefix is 14 pixels wide and the text is 7 pixels wide, the returned value is 21 instead of 7. Line number width is sometimes included in the result and sometimes not. > > There is also posn-at-point but that requires the point to be visible in the window. My alignment function wants to run in jit-lock so point is not always visible, so I can’t use posn-at-point. Please explain what you mean by "align text according to display size". It isn't clear what you want to accomplish, and therefore the full set of requirements and restrictions is not evident, which makes it hard to provide useful advice.