emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jeff Filipovits <jrfilipovits@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Protesilaos Stavrou <info@protesilaos.com>,
	Eric S Fraga <e.fraga@ucl.ac.uk>
Subject: Re: variable-pitch-mode misaligns org-mode heading tags
Date: Tue, 15 Sep 2020 13:41:04 -0400	[thread overview]
Message-ID: <878sdblyz3.fsf@gmail.com> (raw)
In-Reply-To: <87eenbj9p2.fsf@gnu.org>

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.

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. 

If this looks promising I can throw some more time at it. If not, 
I will happily abandon it. 

(defun org--align-tags-here (to-col)
  "Align tags on the current headline to TO-COL.
Assume point is on a headline.  Preserve point when aligning
tags."
  (save-excursion 
    (when (org-match-line org-tag-line-re)
      (let* ((tags-start (match-beginning 1))
	     (blank-start (progn (goto-char tags-start)
				 (skip-chars-backward " \t")
				 (point))))
	;; If there is more than one space between the headline 
           and tags,
	;; delete the extra spaces.  Might be better to
        ;; make the delete region one space smaller rather than 
        inserting
        ;; a new space?
	(when (> tags-start (1+ blank-start))
	  (delete-region blank-start tags-start)
	  (goto-char blank-start)
	  (insert " "))
	;; Don't set the text property unless it is needed.
	;; Not sure this check is efficient.  Probably not 
           necessary.
	(unless (equal (get-text-property blank-start 'display)
		       `(space . (:align-to ,to-col)))
	  (put-text-property blank-start (1+ blank-start)
			     'display `(space . (:align-to 
			     ,to-col))))))))




Bastien <bzg@gnu.org> writes:

> Hi Eric,
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> Also support for org-indent-mode: having the text align nicely 
>> with the
>> heading (as it does with monospace typefaces) would be more 
>> visually
>> pleasing.
>>
>> But I have a feeling that the calculations required for this 
>> and the
>> above may be significant and arguably not worth it?  
>
> Indeed.
>
>> Org, especially
>> with respect to (large) tables, is already quite slow 
>> unfortunately.
>
> Fortunately, the reasons why tables might be slow are distinct 
> from
> the reasons why org-indent might be slow.  
>
> But yes, space-based alignment is a welcome improvement as long 
> as it
> does not make Org slower.


-- 
Jeff Filipovits
Spears & Filipovits, LLC
1126 Ponce de Leon Avenue
Atlanta, GA 30306
678.237.9302 (direct)
jrfilipovits@gmail.com

All emails confidential to the fullest extent of the law.


  reply	other threads:[~2020-09-15 17:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 19:31 variable-pitch-mode misaligns org-mode heading tags 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 [this message]
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 \
    --in-reply-to=878sdblyz3.fsf@gmail.com \
    --to=jrfilipovits@gmail.com \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=info@protesilaos.com \
    /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).