emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Adam Spiers <orgmode@adamspiers.org>
To: Jeff Filipovits <jrfilipovits@gmail.com>
Cc: Protesilaos Stavrou <info@protesilaos.com>,
	emacs-orgmode@gnu.org, Eric S Fraga <e.fraga@ucl.ac.uk>
Subject: Re: variable-pitch-mode misaligns org-mode heading tags
Date: Wed, 16 Sep 2020 17:21:43 +0100	[thread overview]
Message-ID: <20200916162143.xyg7j5rg6xalmv2j@ionian.linksys.moosehall> (raw)
In-Reply-To: <878sdblyz3.fsf@gmail.com>

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


  reply	other threads:[~2020-09-16 16:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 19:31 Protesilaos Stavrou
2020-09-09  8:44 ` Bastien
2020-09-09 11:03   ` Eric S Fraga
2020-09-09 14:39     ` Bastien
2020-09-15 17:41       ` Jeff Filipovits
2020-09-16 16:21         ` Adam Spiers [this message]
2020-09-16 19:03           ` Jeff Filipovits
2020-09-16 21:14             ` Samuel Wales
2020-09-16 22:55             ` Adam Spiers
2020-09-17  0:18               ` Adam Spiers
2020-09-17  2:03               ` Jeff Filipovits
2020-09-17 15:36                 ` Jeff Filipovits
2020-09-18 12:49                 ` Ihor Radchenko
2021-04-27 19:41           ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200916162143.xyg7j5rg6xalmv2j@ionian.linksys.moosehall \
    --to=orgmode@adamspiers.org \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=info@protesilaos.com \
    --cc=jrfilipovits@gmail.com \
    --subject='Re: variable-pitch-mode misaligns org-mode heading tags' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).