From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anders Johansson Subject: Better org-indent alignment when using variable-pitch-mode Date: Wed, 16 Jan 2019 14:07:12 +0100 Message-ID: <87fttspy9z.fsf@gmail.com> Reply-To: Anders Johansson Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:56056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjkv1-00050B-5z for emacs-orgmode@gnu.org; Wed, 16 Jan 2019 08:07:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjkuz-0002ux-UG for emacs-orgmode@gnu.org; Wed, 16 Jan 2019 08:07:43 -0500 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:41987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjkuz-0002by-HV for emacs-orgmode@gnu.org; Wed, 16 Jan 2019 08:07:41 -0500 Received: by mail-lj1-x232.google.com with SMTP id l15-v6so5357990lja.9 for ; Wed, 16 Jan 2019 05:07:20 -0800 (PST) Received: from ajeb (h-158-174-22-36.NA.cust.bahnhof.se. [158.174.22.36]) by smtp.gmail.com with ESMTPSA id q20sm1139185lfj.20.2019.01.16.05.07.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Jan 2019 05:07:16 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "emacs-orgmode@gnu.org" I suggest a possible change to org-indent--compute-prefixes to=20 alleviate the problem. When using variable-pitch-mode (which I particularly like as I=20 write a lot of prose in org-mode), the indent between headlines=20 and body text can be off, depending on the difference in the width=20 of asterisk and space characters in the variable-pitch font. A workaround is to customize the org-indent face to a monospace=20 font to get it to match somewhat better, but this does not lead to=20 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=20 space, # invisible asterisks (in buffer text, but hidden here=20 because org-indent by default enables org-hide-leading-stars), and=20 * visible asterisks. This means we can still have misalignment=20 since it is only the invisible characters (added as wrap-prefix=20 and line-prefix with the org-indent face) that will (possibly if=20 the user intervenes) be set to a monospace font. We can=E2=80=99t assume=20 that the last two (I think) invisible (line-prefix) spaces before=20 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=20 force org-indent to use the same character (*) for all indents and=20 let the face org-indent use the variable-pitch face (no=20 customization of face org-indent). This results in: #####* Headline ######!Body text That is, exactly the same characters (#=3Dhidden asterisks, !=3Dhidden=20 space) preceding the beginning of the text in the headline and the=20 body (the last character before the body text is given by=20 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=20 prefix characters set to asterisk. That is changing line 155 in=20 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=20 visible characters for example, although I don=E2=80=99t know why this=20 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=E2=80=99t be completely solved by this however, is if the= =20 headline faces are customized to be larger than text (some like to=20 do that for a more word-processor-like editing experience). Then=20 the =E2=80=9C* =E2=80=9D in the beginning of the headline will probably be = taking=20 up more space than any character set for indent with a default=20 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 --=20 Anders Johansson