From: Protesilaos Stavrou <firstname.lastname@example.org> To: email@example.com Subject: variable-pitch-mode misaligns org-mode heading tags Date: Tue, 08 Sep 2020 22:31:10 +0300 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) [-- Attachment #1: Type: text/plain, Size: 1177 bytes --] 1. Run 'emacs -Q' 2. Open a new Org file 'C-x C-f /tmp/test.org' 3. Insert the following contents: * TODO this is a test :tag: * TODO here is another test :tag: The tags should align to the right with the standard monospaced font. 4. Run 'M-x variable-pitch-mode'. 5. The tags are now misaligned. Please see attached screenshots for the before and after states of the 'variable-pitch-mode' activation. Running 'M-x describe-char' in the space between the heading's title and the tag informs us that the space's face is the same as the heading's (e.g. 'org-level-1'). I am also relaying the technical insight of Adam Spiers. Please see attached plain text document or visit the comment's URL: https://gitlab.com/protesilaos/modus-themes/-/issues/85#note_407147422 Overview of my setup: + GNU Emacs 27.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) of 2020-08-14 + Org mode version 9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/) * * * This message was also posted on debbugs.gnu.org, bug#43272. -- Protesilaos Stavrou protesilaos.com [-- Attachment #2: variable-pitch-mode-org-headings-misaligned-1.png --] [-- Type: image/png, Size: 48799 bytes --] [-- Attachment #3: variable-pitch-mode-org-headings-misaligned-2.png --] [-- Type: image/png, Size: 49261 bytes --] [-- Attachment #4: adam-spiers-align-org-tags.txt --] [-- Type: text/plain, Size: 2266 bytes --] I've investigated this and it's not nearly as easy as I had hoped. It turns out that the right alignment supported by display properties can only align space, not text. Something like this works as an experiment: ```lisp (with-current-buffer "org/TODO.org" (put-text-property (region-beginning) (region-end) 'display '(space :align-to (- right 10)))) ``` If a region of space characters is selected, the above will adjust the region's width so that its right hand side is 10 character widths in from the right margin. However if the region contains text, it will make that text invisible. This could be used to *left*-align the tags, but not *right*-align them, which doesn't really work because each heading's tags can be a different number of characters wide. So to get our desired behaviour of adjusting the space in between the heading and the tags correctly in order to right-align the tags to [the right margin specified by `org-tags-column`](https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-09/msg00728.html), we'd first have to calculate the display width of the (proportionally spaced) tags text, and then subtract that from the right margin. In theory this width can be retrieved via `pos-visible-in-window-p` with the `PARTIALLY` argument set to `t`, but I haven't got that working yet, and even if I could, it would need to be done dynamically for each line and then the corresponding text property updated whenever that width changed (e.g. any of that line was edited, or when the window was scrolled to bring different headings into view). However that raises questions about how well this would perform, since it would be creating quite a lot of work to do on each redisplay. I suspect that the emacs gurus would say that support for right-alignment of variable pitch text would need to be added to emacs's internal display routines (the ones written in C, not Elisp). But that's only a vague guess. Hopefully I've underestimated what emacs can currently do here and there's an easier solution, but there's little chance of finding out either way without asking on the Org list, and then falling back to the `help-gnu-emacs` or `emacs-devel` list if it's even too difficult a question for any of the Org gurus.
next reply other threads:[~2020-09-08 19:32 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-08 19:31 Protesilaos Stavrou [this message] 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 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 \ --email@example.com \ --firstname.lastname@example.org \ --email@example.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).