From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SN3yKNE7Yl98RwAA0tVLHw (envelope-from ) for ; Wed, 16 Sep 2020 16:22:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KErXJNE7Yl8pWAAA1q6Kng (envelope-from ) for ; Wed, 16 Sep 2020 16:22:41 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 865F5940291 for ; Wed, 16 Sep 2020 16:22:40 +0000 (UTC) Received: from localhost ([::1]:35576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIaCd-0008H1-8y for larch@yhetil.org; Wed, 16 Sep 2020 12:22:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIaBs-0008EP-BM for emacs-orgmode@gnu.org; Wed, 16 Sep 2020 12:21:52 -0400 Received: from coral.adamspiers.org ([2001:ba8:1f1:f27f::2]:36570) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIaBo-00005R-75 for emacs-orgmode@gnu.org; Wed, 16 Sep 2020 12:21:51 -0400 Received: from localhost (243.103.2.81.in-addr.arpa [81.2.103.243]) by coral.adamspiers.org (Postfix) with ESMTPSA id 9573E2E6DD; Wed, 16 Sep 2020 17:21:43 +0100 (BST) Date: Wed, 16 Sep 2020 17:21:43 +0100 From: Adam Spiers To: Jeff Filipovits Subject: Re: variable-pitch-mode misaligns org-mode heading tags Message-ID: <20200916162143.xyg7j5rg6xalmv2j@ionian.linksys.moosehall> X-OS: GNU/Linux References: <87wo1483r5.fsf@protesilaos.com> <87v9gnl4on.fsf@gnu.org> <87mu1znrf1.fsf@ucl.ac.uk> <87eenbj9p2.fsf@gnu.org> <878sdblyz3.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <878sdblyz3.fsf@gmail.com> Received-SPF: pass client-ip=2001:ba8:1f1:f27f::2; envelope-from=orgmode@adamspiers.org; helo=coral.adamspiers.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Protesilaos Stavrou , emacs-orgmode@gnu.org, Eric S Fraga Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=adamspiers.org (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.91 X-TUID: qkyfGxnEwJig Hi Jeff, Firstly thanks a lot for looking into this! On Tue, Sep 15, 2020 at 01:41:04PM -0400, Jeff Filipovits wrote: >Following the call for help to fix bugs, and with building guilt, I’ve >taken a stab at fixing aligning tags when using a variable-pitch font. >I haven’t tested this much because I do not know if it is misguided, >but it seems to work. > >Seems the only way to do it is to use the ‘display text property and >expand a single space between the headline and tags. Here is a drop-in >replacement of org--align-tags-here which ensures there is one space >between the tags and headline, and then expands that space by setting >a text property. Yes, this is the same conclusion I reached a little while ago: https://gitlab.com/protesilaos/modus-themes/-/issues/85#note_407147422 However as mentioned there, AFAICS this approach only manages to *left*-align the tags, not *right*-align them. When there are several tags, this can be problematic as the colon-delimited list of tags will either spill over the buffer's right margin, or avoid that by requiring an alignment column which is further to the left and ends up interfering with the main text of the buffer. Given that the colon-delimited lists have variable numbers of characters, I think it's clear that right alignment is the only decent space-efficient layout. BTW I tried your code and for some reason it didn't insert any space for me, but I didn't look into that yet. >I’ve removed the point-preserving code because it does not seem to be >needed using this method. This would also allow removing >org-fix-tags-on-the-fly from org-self-insert-command since there is >only a single space between the headline and the tags and it is >adjusted automatically. Makes sense. >If this looks promising I can throw some more time at it. If not, I >will happily abandon it. I think it's promising for sure. But I think there is still a remaining problem regarding how to implement the right alignment of the colon-delimited list of tags. If this list uses a fixed-width font then it is relatively easy, because then the value to provide to :align-to can be calculated as `org-tags-column' minus the column width of the tag list. And indeed this seems to be how the original version of `org--align-tags-here' achieves right alignment: (new (max (if (>= to-col 0) to-col (- (abs to-col) (string-width (match-string 1)))) But the whole point of this exercise is to support variable-width fonts. In this case, the correct position for the end of the single space is most likely not even a multiple of the fixed column width, so it would probably need to be measured in pixels rather than columns. And in order to calculate it, it is first necessary to calculate the exact width in pixels of the colon-delimited list of tags. As I mentioned in the comment linked above, I searched for a way of calculating the pixel width of the tag list, and the best I could find was `pos-visible-in-window-p' which has some issues which I mentioned there. If you have thoughts on whether I'm right about those, and if so how to solve them, I'd love to hear! Cheers, Adam