From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Add a function that returns pixel distance between points? Date: Mon, 1 Feb 2021 09:16:52 -0500 Message-ID: <51016978-4D2F-45A8-8589-F4562B6DC4A8@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13514"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel\\@gnu.org" To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 01 15:18:41 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 1l6a2L-0003PU-78 for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Feb 2021 15:18:41 +0100 Original-Received: from localhost ([::1]:46148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6a2K-0003sL-6h for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Feb 2021 09:18:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6a0k-000331-6E for emacs-devel@gnu.org; Mon, 01 Feb 2021 09:17:02 -0500 Original-Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:44276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6a0e-0007hi-UA; Mon, 01 Feb 2021 09:17:01 -0500 Original-Received: by mail-qt1-x833.google.com with SMTP id h16so11178233qth.11; Mon, 01 Feb 2021 06:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VJ86/w8z7XDzNeZ6YKSqnHVXPLGdujXOCdmJmRvVXKI=; b=R98v9pqjKUcDL1rd1vGaV76SgtuQ6uY/Jys+gHGwVeTuPsyvpjgexCNuWslAP8Poyp RUagXRlfHYFZhw2/dAFAipJt+Xx5gMxdmcE7oXnyPn9mWt/R8dj62Rc4qbes8HOZGcsI 61dooLz0xzZsq3Qdtsgtk9liLENYNHoLpw7DwFqU8eUZCSPLoLmXjhZhISGORFU0qgdB vnL3zHTM88pSnPCqsI9Ftww0AuohHTBy3sgJosv5UgsAk2vPRUsWV6IG+uNQZRemjsLq ecqbidDOJl92SNIRreorvAw1z4SlT5ShLA0Lg068RIH1JPmCO7nIqEET8R3e59caXcth YMUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VJ86/w8z7XDzNeZ6YKSqnHVXPLGdujXOCdmJmRvVXKI=; b=LsSC5/94NSComAN0TkymZcBkBVJavW8r4/T3Vq/EZgNxNGMlo19d6tOquu8XrV33TA nqzOz5Z9LJt6yh1Mhq4tjq6ar1TJIgulxP800MHClx7rbzQan1P+iML6kcGi1Ez2/HzV kqnLbB7q0OcROtc/yW2oQfglEbic5LFWXGPybj7LywsDOiJXayDXqYz2Rxv05OJgw+6y dsYZI5UNhfZFyOL6VX9kFagjgSbxxjZuiQkD4MXkx/6YIoA4sI5+3sa1uT+iGc664tIz 3IOcmIx6R7y87ES13xqeqjUXkdbpMVR5AkCqjmNAuMcfYeLwPXT2oASTsi4kClYIOUBJ JTzA== X-Gm-Message-State: AOAM531sx3UVsVBQi/2MNO5brqEZHumwLcyscbntDGCRr+A5c+aAHIwM jR6DyHpsWYee6EUtmsV6QPk5QgHZtL1GYA== X-Google-Smtp-Source: ABdhPJzM8ILKSujTGC3cWF/QuC25dTjSlCSxSK1GP3YMqnU+t3nHbmSTPDw1xqaPwyDy+Z7uQMotgQ== X-Received: by 2002:ac8:c88:: with SMTP id n8mr15331572qti.381.1612189014359; Mon, 01 Feb 2021 06:16:54 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4102:3d80:c401:3284:d81e:ec82? ([2601:98a:4102:3d80:c401:3284:d81e:ec82]) by smtp.gmail.com with ESMTPSA id a68sm1524050qkd.29.2021.02.01.06.16.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Feb 2021 06:16:53 -0800 (PST) In-Reply-To: <83ft2g7tlr.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.40.0.2.32) Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=casouri@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:263683 Archived-At: > On Jan 31, 2021, at 3:13 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sun, 31 Jan 2021 14:41:52 -0500 >> Cc: emacs-devel@gnu.org >>=20 >>> 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? >>=20 >> Yes, value given to :align-to needs to account for line-prefix. But = when I want to calculate the pixel width of a column, I don=E2=80=99t = want to include the prefix: that makes the returned value larger than = the actually width of the column (because the line-prefix width is added = to it). >=20 > But the pixel coordinate to which you need to align also needs to be > increased due to line-prefix, doesn't it? >=20 > 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=E2=80=99m trying to measure the width = of the text. Yuan=