emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Better org-indent alignment when using variable-pitch-mode
@ 2019-01-16 13:07 Anders Johansson
  0 siblings, 0 replies; only message in thread
From: Anders Johansson @ 2019-01-16 13:07 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-16 13:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 13:07 Better org-indent alignment when using variable-pitch-mode Anders Johansson

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).