emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] Fixed-pitch tables and code blocks that do not break variable-pi


From: Protesilaos Stavrou
Subject: [PATCH] Fixed-pitch tables and code blocks that do not break variable-pitch-mode
Date: Wed, 09 Sep 2020 17:18:18 +0300

Hello everyone,

Please see the attached diff.  An explanation is offered below.  I have
already assigned copyright to the FSF.


The problem
-----------

Running 'M-x variable-pitch-mode' in an Org buffer will make all
space-sensitive constructs lose their alignment.  This is particularly
problematic for (1) tables, whose tabular looks are functionally
significant, and (2) for code blocks that are meant to display
programming code where the visual effects of indentation can have
important implications.

Note that 'variable-pitch-mode' effectively remaps the 'default' face to
'variable-pitch', meaning that the former inherits the font family of
the latter.


A possible solution (scope of this patch)
-----------------------------------------

Emacs provides the generic 'fixed-pitch' face.  The idea with this is to
always define it as having a monospaced font family (its default state).
Other faces may thus inherit from it.  We can apply this face to all
constructs that we always want to keep in fixed width spacing.  Tables,
code blocks, and faces related to them are the obvious candidates,
covered by this patch, though the principle could be extended to other
items as well (see ANNEX 1).

By making some faces inherit from fixed-pitch, we guarantee that users
who activate 'variable-pitch-mode' will get variable width fonts for
their main text and also retain the necessary fixed width proportions of
some constructs that make Org look good and work well.

The attached screenshot shows how this would appear.

We may consider this a "mixed typeface" or "mixed font" scenario (see
ANNEX 2).


ANNEX 1: other candidates for fixed-pitch inheritance
-----------------------------------------------------

I tried to keep my patch limited to the essentials, though we could
expand it a bit to make the experience as consistent as possible.  Other
faces that can be monospaced in a mixed typeface scenario:

+ org-code
+ org-hide (org-indent inherits from it)
+ org-verbatim


ANNEX 2: mixed typeface configurations
--------------------------------------

Perhaps we would like to also offer some documentation on how users
could specify their desired font families for fixed/variable width
constructs (not strictly limited to Org).  We should also explain how
relative font heights behave.

I can already provide such a document, if you want, as I have written
the relevant instructions in the manual of the Modus themes ("Modus
Operandi" and "Modus Vivendi", which are in the Emacs 'master' branch):
https://protesilaos.com/modus-themes/#h:defcf4fc-8fa8-4c29-b12e-7119582cc929

NOTE: The manual is not distributed with Emacs yet.  It will happen at
the next tagged release of the themes.

Best regards,
Prot

P.S. Feel free to adapt this patch.

-- 
Protesilaos Stavrou
protesilaos.com

Attachment: org-faces-fixed-pitch.diff
Description: Text Data

Attachment: org-faces-fixed-pitch.png
Description: PNG image


reply via email to

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