[-- Attachment #1: Type: text/plain, Size: 2802 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-faces-fixed-pitch.diff --]
[-- Type: text/x-patch, Size: 2859 bytes --]
lisp/org-faces.el | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 8b0e387e6..637d32c30 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -179,7 +179,9 @@ set the properties in the `org-column' face. For example, set
:group 'org-faces)
(defface org-date
- '((((class color) (background light)) (:foreground "Purple" :underline t))
+ ;; NOTE: `fixed-pitch' ensures compatibility with `variable-pitch-mode'
+ '((default :inherit fixed-pitch)
+ (((class color) (background light)) (:foreground "Purple" :underline t))
(((class color) (background dark)) (:foreground "Cyan" :underline t))
(t (:underline t)))
"Face for date/time stamps."
@@ -355,7 +357,9 @@ changes."
(sexp :tag "Face")))))
(defface org-table ;Copied from `font-lock-function-name-face'
- '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
+ ;; NOTE: `fixed-pitch' ensures compatibility with `variable-pitch-mode'
+ '((default :inherit fixed-pitch)
+ (((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
(((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
(((class color) (min-colors 16) (background light)) (:foreground "Blue"))
(((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
@@ -371,7 +375,9 @@ changes."
:group 'org-faces)
(defface org-formula
- '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
+ ;; NOTE: `fixed-pitch' ensures compatibility with `variable-pitch-mode'
+ '((default :inherit fixed-pitch)
+ (((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
(((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
(((class color) (min-colors 8) (background light)) (:foreground "red"))
(((class color) (min-colors 8) (background dark)) (:foreground "red"))
@@ -384,7 +390,8 @@ changes."
:group 'org-faces
:version "22.1")
-(defface org-meta-line '((t :inherit font-lock-comment-face))
+;; NOTE: `fixed-pitch' ensures compatibility with `variable-pitch-mode'
+(defface org-meta-line '((t :inherit (fixed-pitch font-lock-comment-face)))
"Face for meta lines starting with \"#+\"."
:group 'org-faces
:version "22.1")
@@ -408,7 +415,8 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
"Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
:group 'org-faces)
-(defface org-block `((t :inherit shadow
+;; NOTE: `fixed-pitch' ensures compatibility with `variable-pitch-mode'
+(defface org-block `((t :inherit (fixed-pitch shadow)
,@(and (>= emacs-major-version 27) '(:extend t))))
"Face text in #+begin ... #+end blocks.
For source-blocks, `org-src-block-faces' takes precedence."
[-- Attachment #3: org-faces-fixed-pitch.png --]
[-- Type: image/png, Size: 317899 bytes --]