emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org: Fix tag width calculation for multi-column chars
Date: Wed, 01 Jun 2016 16:27:54 +0200	[thread overview]
Message-ID: <874m9dq905.fsf@gmx.us> (raw)
In-Reply-To: CAJcAo8s7kx0=BMM6-sjPU40bgeB-E0dk1RAVH9U11BTo2zVoog@mail.gmail.com

Samuel Wales <samologist@gmail.com> 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

  parent reply	other threads:[~2016-06-01 14:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  7:25 [PATCH] org: Fix tag width calculation for multi-column chars Yasushi SHOJI
2016-05-31 20:02 ` Nicolas Goaziou
2016-05-31 21:06   ` Samuel Wales
2016-06-01  5:57     ` Georgiy Tugai
2016-06-02 11:29       ` Yasushi SHOJI
2016-06-01 13:00     ` [PATCH] " Yasushi SHOJI
2016-06-01 14:27     ` Rasmus [this message]
2016-06-01 12:52   ` Yasushi SHOJI
2016-06-01 17:34     ` Nicolas Goaziou
2016-06-02 11:13       ` Yasushi SHOJI
2016-06-02 11:34         ` Nicolas Goaziou

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=874m9dq905.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).