emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable-pitch-mode misaligns org-mode heading tags


From: Jeff Filipovits
Subject: Re: variable-pitch-mode misaligns org-mode heading tags
Date: Tue, 15 Sep 2020 13:41:04 -0400
User-agent: mu4e 1.2.0; emacs 28.0.50

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 via email to

[Prev in Thread] Current Thread [Next in Thread]