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: Sun, 31 Jan 2021 14:41:52 -0500 Message-ID: References: <960DAE7C-A1AF-416A-ACA5-F6674C87A2C9@gmail.com> <837dnt9400.fsf@gnu.org> <1EDD0FA5-025C-4A87-BBA1-7B8944E91A12@gmail.com> <83tuqx6sdz.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="15829"; 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 Sun Jan 31 20:43:27 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 1l6Id5-00041o-2e for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 20:43:27 +0100 Original-Received: from localhost ([::1]:56540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6Id3-0006qR-TL for ged-emacs-devel@m.gmane-mx.org; Sun, 31 Jan 2021 14:43:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6Ibd-0005zd-CY for emacs-devel@gnu.org; Sun, 31 Jan 2021 14:41:57 -0500 Original-Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:44391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6Ibb-0004z5-Df; Sun, 31 Jan 2021 14:41:57 -0500 Original-Received: by mail-qk1-x736.google.com with SMTP id v126so14234953qkd.11; Sun, 31 Jan 2021 11:41:54 -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=r+gGlfv93A69NJXtwRoI869y6YxAMcSIOApGS8ALhfA=; b=QDRbFUM7w9wwErRIILrr7zAlN+3LFf43kI84BcTt7naEC27GjgwsP4J8QOa2b3ce/I y2LfW3POm1Jf4kOsivtgVu+3/snrmLSDI/5JCYeTWiXAiJyj0qnuVwxdoPWukJjwOiuS u+RadOgk/NfstElqtXPyF0Fy3MVT0s9YY2lzyIpWej6Polcrs/FkDzZ2+IHHWrkfdwWg kJkONo1JTg4yR/ek5jTNNt2eDCqkwsnHKe5xwg5lvE384PYoQa3AmwJ4Bx6ABhJ1pr3H YIF+ioIoLNCTjIcUqrtP9MprHv8HOrk6ReHmoBFgQ7R0YPo2ogiNnT15j6PKcUtSkQgL GKDQ== 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=r+gGlfv93A69NJXtwRoI869y6YxAMcSIOApGS8ALhfA=; b=rR6qofd3MNIpLJkuCr1761RN7ngIMlOGewF19+fgtypn7C+CnHONipbxnwHOxJRRP1 mMfXIPoULIcda3l/caguKs79Wgx++1c7X/yNPKus6u0EnnyflfsqC5VIVivaqB/gRl3L ed0JoaWzQAcPTLrjKehd3bM68VHeD1wULzHQzgjwHTjO7InNze1uc3nCP1ckZ3f15tvk IALBre2E+8tISCJlffSK84DMHazQTsu6X5lDxkuqB3t0iK5Kzznpm77td5TLu9f9HCQK mw/V2T6QBBNTJFAoJJM/C8Chqk36wHgkONIqIXR3cE9718mEvXkvIkP0absZ04LFAsRI G9Cg== X-Gm-Message-State: AOAM5316SEYC0fBu47whe392b8K/S+5q9rzQ5i3tI8BwQZP/x9lQd0hE J+cUlp0HcyYBnP2zMq3xbsxjf6ckNSc0rw== X-Google-Smtp-Source: ABdhPJxwUwuGZpJzDOJjKb5dqAtR0vk/ZxB33G9apXNYPrTv+u60bLv4RaRY2TQJHp4vdR+nEEG6/Q== X-Received: by 2002:a37:ad0a:: with SMTP id f10mr10174361qkm.16.1612122113701; Sun, 31 Jan 2021 11:41:53 -0800 (PST) Original-Received: from ?IPv6:2601:98a:4200:9210:d580:9ad5:a27e:26fc? ([2601:98a:4200:9210:d580:9ad5:a27e:26fc]) by smtp.gmail.com with ESMTPSA id y26sm12424152qth.53.2021.01.31.11.41.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Jan 2021 11:41:53 -0800 (PST) In-Reply-To: <83tuqx6sdz.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.40.0.2.32) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=casouri@gmail.com; helo=mail-qk1-x736.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:263664 Archived-At: > On Jan 31, 2021, at 10:24 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sun, 31 Jan 2021 00:17:58 -0500 >> Cc: emacs-devel@gnu.org >>=20 >> I want to align text-based tables by pixel size, as in: >>=20 >> | header | header | header | >> | 1 | 1 | 8 | >> | 2 | 6 | 3 | >>=20 >> When the text is displayed in variable-pitch font, the bars aren=E2=80=99= t aligned. I=E2=80=99m using display property (space :align-to) to align = those bars. To know with pixel position to align to, I need to calculate = each column=E2=80=99s pixel width, and met the difficulties mentioned = earlier. >=20 > 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? >=20 Yes, naturally you want to adapt the alignment while the user is = editing. > 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? Using posn-at-point would be too complicated: Table might by partially = visible, I need to make sure the alignment function is immediately = called when an unaligned table is displayed in the window, etc. = Comparing to that, adding my alignment function into jit-lock hooks is = much simpler and cleaner. >=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? 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). Yuan