emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anders Johansson <mejlaandersj@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Better org-indent alignment when using variable-pitch-mode
Date: Wed, 16 Jan 2019 14:07:12 +0100	[thread overview]
Message-ID: <87fttspy9z.fsf@gmail.com> (raw)

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	other threads:[~2019-01-16 13:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87fttspy9z.fsf@gmail.com \
    --to=mejlaandersj@gmail.com \
    --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).