emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Better org-indent alignment when using variable-pitch-mode


From: Anders Johansson
Subject: [O] Better org-indent alignment when using variable-pitch-mode
Date: Wed, 16 Jan 2019 14:07:12 +0100
User-agent: mu4e 1.1.0; emacs 26.1

I suggest a possible change to org-indent--compute-prefixes to alleviate the problem.

When using variable-pitch-mode (which I particularly like as I write a lot of prose in org-mode), the indent between headlines and body text can be off, depending on the difference in the width of asterisk and space characters in the variable-pitch font.

A workaround is to customize the org-indent face to a monospace font to get it to match somewhat better, but this does not lead to perfect results.

The indent of headlines and text is constructed like this:

!!!##* Headline
!!!!!!!Body text

This is for a third-level headline where ! denotes invisible space, # invisible asterisks (in buffer text, but hidden here because org-indent by default enables org-hide-leading-stars), and * visible asterisks. This means we can still have misalignment since it is only the invisible characters (added as wrap-prefix and line-prefix with the org-indent face) that will (possibly if the user intervenes) be set to a monospace font. We can’t assume that the last two (I think) invisible (line-prefix) spaces before the body text will have the same width as the indent characters.

One solution that seemed to work pretty well for me however was to force org-indent to use the same character (*) for all indents and let the face org-indent use the variable-pitch face (no customization of face org-indent). This results in:

#####* Headline
######!Body text

That is, exactly the same characters (#=hidden asterisks, !=hidden space) preceding the beginning of the text in the headline and the body (the last character before the body text is given by org-indent-boundary-char, which is by default set to a space).

So for this use-case we get a much better alignment with the prefix characters set to asterisk. That is changing line 155 in org-indent, org-indent--compute-prefixes from:
(concat (make-string (+ n indentation) ?\s)
to:
(concat (make-string (+ n indentation) ?*)

If people configure the org-indent face in some other way (with visible characters for example, although I don’t know why this would be a good idea) this could be a bad idea though.

Could it perhaps be made an option? What do you think?

A case which won’t be completely solved by this however, is if the headline faces are customized to be larger than text (some like to do that for a more word-processor-like editing experience). Then the “* ” in the beginning of the headline will probably be taking up more space than any character set for indent with a default size.

There may have been other cases I overlooked as well.


An earlier discussion of this was here:
https://lists.gnu.org/archive/html/emacs-orgmode/2014-12/msg00014.html


--
Anders Johansson



reply via email to

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