[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH] org: Fix tag width calculation for multi-column chars
From: |
Rasmus |
Subject: |
Re: [O] [PATCH] org: Fix tag width calculation for multi-column chars |
Date: |
Wed, 01 Jun 2016 16:27:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Samuel Wales <address@hidden> writes:
> i wonder if this also fixes tags for variable pitch (proportional)
> fonts. i have been having great success with variable pitch fonts and
> it would be great if this fixes tags for them too.
No.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Size-of-Displayed-Text.html
You'd need pixel alignment.
Here’s a version that aligns the left part pf tags.
(defun org-align-tags-here (&optional arg)
;; Assumes that this is a headline
"Align tags on the current headline to TO-COL."
(save-excursion
(when (org-at-heading-p)
(beginning-of-line)
(re-search-forward org-complex-heading-regexp (line-end-position) t)
(when (match-end 5) ; There’s a tag.
(goto-char (match-end 4))
(delete-region (point) (match-beginning 5))
(insert (propertize
(make-string (- (abs org-tags-column) (current-column)
(- (match-end 5) (match-beginning 5)))
?\s)
;; one would need somehow intelligently figure out
;; the maximum pixel number.
'display '(space :align-to (600))))))))
Questions if we were to pixel align:
- Can we drop right alignment of tags? (i.e. org-tags-column < 0).
- We might need to know the pixel width of :tags: anyway to set the width
of the white space to "right-margin" - "width-of-tags". Is this robust
to resizing? Or is there a "\hfill"-like property for Emacs space?
- How to determine max width on "auto-filled" file? Go through each line
or just make it a custom value?
Perhaps a nice "conservative" way is to introduce a org-tags-column-pixel,
but if we can find a good "automatic" way that’s nicer IMO.
Rasmus
--
The second rule of Fight Club is: You do not talk about Fight Club