Change default style of Org block (no backgrounds)

As I explained in Emacs bug#52587,[1] Org has code that overrides themes
which prefer not to extend the block delimiter faces to the edge of the
window.  This practically means that we cannot have backgrounds for
those lines and keep them limited to the stretch of area covered by
their text.

As such, the default for Org block delimiter lines now is a gray
foreground with no distinct background colour.  The user option
'modus-themes-org-blocks' provides "blocky" alternatives that use
background colours---those extend to the edge of the window.

[1] <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52587#46>
This commit is contained in:
Protesilaos Stavrou 2021-12-31 06:06:08 +02:00
parent 2b47e0c1e5
commit 2d5ed2ff29
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
3 changed files with 114 additions and 91 deletions

View file

@ -1516,21 +1516,28 @@ Brief: Set the overall style of Org code blocks, quotes, and the like.
3. tinted-background (value rainbow exists for backward
compatibility)
The default means that the block has no distinct background of its
own and uses the one that applies to the rest of the buffer.
Nil (the default) means that the block has no background of its own:
it uses the one that applies to the rest of the buffer. In this case,
the delimiter lines have a gray color for their text, making them look
exactly like all other Org properties.
Option gray-background applies a subtle gray background to the
blocks contents. It also affects the begin and end lines of the block:
their background extends to the edge of the window for Emacs version >=
27 where the :extend keyword is recognized by set-face-attribute
(this is contingent on the variable
org-fontify-whole-block-delimiter-line).
blocks contents. It also affects the begin and end lines of the block
as they get another shade of gray as their background, which
differentiates them from the contents of the block. All background
colors extend to the edge of the window, giving the area a rectangular,
“blocky” presentation.
Option tinted-background uses a slightly colored background for the
contents of the block. The exact color will depend on the programming
language and is controlled by the variable org-src-block-faces (refer
to the themes source code for the current association list). For this
to take effect, Org must be restarted with M-x org-mode-restart.
to take effect, the Org buffer needs to be restarted with
org-mode-restart. In this scenario, it may be better to inhibit the
extension of the delimiter lines background to the edge of the window
because Org does not provide a mechanism to update their colors
depending on the contents of the block. Disable the extension of such
backgrounds by setting org-fontify-whole-block-delimiter-line to nil.
Code blocks use their major modes colors only when the variable
org-src-fontify-natively is non-nil. While quote/verse blocks require
@ -5413,70 +5420,70 @@ Node: Matching parentheses52251
Node: Active region53636
Node: Diffs55049
Node: Org mode blocks56655
Node: Org agenda58582
Node: Heading styles67084
Node: UI typeface71509
Node: Advanced customization72408
Node: Per-theme customization settings73774
Node: Case-by-case face specs using the themes' palette75079
Node: Face specs at scale using the themes' palette79445
Node: Remap face with local value84112
Node: Cycle through arbitrary colors86537
Node: Override colors92965
Node: Override color saturation97774
Node: Override colors through blending103453
Node: Font configurations for Org and others106308
Ref: Font configurations for Org and others-Footnote-1109133
Node: Configure bold and italic faces109320
Node: Custom Org user faces113447
Node: Update Org block delimiter fontification117072
Node: Measure color contrast118985
Node: Load theme depending on time of day121708
Node: Backdrop for pdf-tools122701
Node: Decrease mode line height125396
Node: A theme-agnostic hook for theme loading129521
Node: Diffs with only the foreground131912
Node: Face coverage134986
Node: Supported packages135438
Node: Indirectly covered packages141803
Node: Notes on individual packages142791
Node: Note on avy hints143831
Node: Note on calendarel weekday and weekend colors144999
Node: Note on underlines in compilation buffers146182
Node: Note on inline Latex in Org buffers146994
Node: Note on dimmerel147604
Node: Note on display-fill-column-indicator-mode149089
Node: Note on highlight-parenthesesel150652
Node: Note on mmm-modeel background colors156641
Node: Note for prism158956
Node: Note for god-mode162110
Node: Note on company-mode overlay pop-up163714
Ref: Note on company-mode overlay pop-up-Footnote-1164404
Ref: Note on company-mode overlay pop-up-Footnote-2164471
Node: Note on ERC escaped color sequences164526
Ref: Note on ERC escaped color sequences-Footnote-1165954
Node: Note on powerline or spaceline166064
Node: Note on SHR colors166478
Node: Note on EWW and Elfeed fonts166901
Node: Note on Helm grep167566
Node: Note on vc-annotate-background-mode169041
Node: Note on pdf-tools link hints169926
Node: Frequently Asked Questions172358
Node: Is the contrast ratio about adjacent colors?172914
Node: What does it mean to avoid exaggerations?174421
Node: Why are colors mostly variants of blue magenta cyan?176250
Node: What is the best setup for legibility?180563
Node: Contributing183175
Node: Sources of the themes183572
Node: Issues you can help with184208
Node: Patches require copyright assignment to the FSF185408
Node: Acknowledgements187703
Node: Meta190537
Node: GNU Free Documentation License192701
Node: Indices218053
Node: Function index218232
Node: Variable index219439
Node: Concept index221580
Node: Org agenda59045
Node: Heading styles67547
Node: UI typeface71972
Node: Advanced customization72871
Node: Per-theme customization settings74237
Node: Case-by-case face specs using the themes' palette75542
Node: Face specs at scale using the themes' palette79908
Node: Remap face with local value84575
Node: Cycle through arbitrary colors87000
Node: Override colors93428
Node: Override color saturation98237
Node: Override colors through blending103916
Node: Font configurations for Org and others106771
Ref: Font configurations for Org and others-Footnote-1109596
Node: Configure bold and italic faces109783
Node: Custom Org user faces113910
Node: Update Org block delimiter fontification117535
Node: Measure color contrast119448
Node: Load theme depending on time of day122171
Node: Backdrop for pdf-tools123164
Node: Decrease mode line height125859
Node: A theme-agnostic hook for theme loading129984
Node: Diffs with only the foreground132375
Node: Face coverage135449
Node: Supported packages135901
Node: Indirectly covered packages142266
Node: Notes on individual packages143254
Node: Note on avy hints144294
Node: Note on calendarel weekday and weekend colors145462
Node: Note on underlines in compilation buffers146645
Node: Note on inline Latex in Org buffers147457
Node: Note on dimmerel148067
Node: Note on display-fill-column-indicator-mode149552
Node: Note on highlight-parenthesesel151115
Node: Note on mmm-modeel background colors157104
Node: Note for prism159419
Node: Note for god-mode162573
Node: Note on company-mode overlay pop-up164177
Ref: Note on company-mode overlay pop-up-Footnote-1164867
Ref: Note on company-mode overlay pop-up-Footnote-2164934
Node: Note on ERC escaped color sequences164989
Ref: Note on ERC escaped color sequences-Footnote-1166417
Node: Note on powerline or spaceline166527
Node: Note on SHR colors166941
Node: Note on EWW and Elfeed fonts167364
Node: Note on Helm grep168029
Node: Note on vc-annotate-background-mode169504
Node: Note on pdf-tools link hints170389
Node: Frequently Asked Questions172821
Node: Is the contrast ratio about adjacent colors?173377
Node: What does it mean to avoid exaggerations?174884
Node: Why are colors mostly variants of blue magenta cyan?176713
Node: What is the best setup for legibility?181026
Node: Contributing183638
Node: Sources of the themes184035
Node: Issues you can help with184671
Node: Patches require copyright assignment to the FSF185871
Node: Acknowledgements188166
Node: Meta191000
Node: GNU Free Documentation License193164
Node: Indices218516
Node: Function index218695
Node: Variable index219902
Node: Concept index222043

End Tag Table

View file

@ -1405,20 +1405,28 @@ Possible values:
2. ~gray-background~ (value ~grayscale~ exists for backward compatibility)
3. ~tinted-background~ (value ~rainbow~ exists for backward compatibility)
The default means that the block has no distinct background of its own
and uses the one that applies to the rest of the buffer.
Nil (the default) means that the block has no background of its own: it
uses the one that applies to the rest of the buffer. In this case, the
delimiter lines have a gray color for their text, making them look
exactly like all other Org properties.
Option ~gray-background~ applies a subtle gray background to the block's
contents. It also affects the begin and end lines of the block: their
background extends to the edge of the window for Emacs version >= 27
where the ~:extend~ keyword is recognized by ~set-face-attribute~ (this is
contingent on the variable ~org-fontify-whole-block-delimiter-line~).
contents. It also affects the begin and end lines of the block as they
get another shade of gray as their background, which differentiates them
from the contents of the block. All background colors extend to the
edge of the window, giving the area a rectangular, "blocky"
presentation.
Option ~tinted-background~ uses a slightly colored background for the
contents of the block. The exact color will depend on the programming
language and is controlled by the variable ~org-src-block-faces~ (refer to
the theme's source code for the current association list). For this to
take effect, Org must be restarted with {{{kbd(M-x org-mode-restart)}}}.
take effect, the Org buffer needs to be restarted with ~org-mode-restart~.
In this scenario, it may be better to inhibit the extension of the
delimiter lines' background to the edge of the window because Org does
not provide a mechanism to update their colors depending on the contents
of the block. Disable the extension of such backgrounds by setting
~org-fontify-whole-block-delimiter-line~ to nil.
Code blocks use their major mode's colors only when the variable
~org-src-fontify-natively~ is non-nil. While quote/verse blocks require

View file

@ -5,7 +5,7 @@
;; Author: Protesilaos Stavrou <info@protesilaos.com>
;; URL: https://gitlab.com/protesilaos/modus-themes
;; Version: 2.0.0
;; Last-Modified: <2021-12-31 04:37:27 +0200>
;; Last-Modified: <2021-12-31 05:55:23 +0200>
;; Package-Requires: ((emacs "27.1"))
;; Keywords: faces, theme, accessibility
@ -2323,25 +2323,32 @@ variables `flymake-fringe-indicator-position' and
:link '(info-link "(modus-themes) Language checkers"))
(defcustom modus-themes-org-blocks nil
"Use a subtle gray or color-coded background for Org blocks.
"Set the overall style of Org code blocks, quotes, and the like.
Nil (the default) means that the block has no distinct background
of its own and uses the one that applies to the rest of the
buffer.
Nil (the default) means that the block has no background of its
own: it uses the one that applies to the rest of the buffer. In
this case, the delimiter lines have a gray color for their text,
making them look exactly like all other Org properties.
Option `gray-background' applies a subtle gray background to the
block's contents. It also affects the begin and end lines of the
block: their background extends to the edge of the window for
Emacs version >= 27 where the ':extend' keyword is recognized by
`set-face-attribute' (this is contingent on the variable
`org-fontify-whole-block-delimiter-line').
block as they get another shade of gray as their background,
which differentiates them from the contents of the block. All
background colors extend to the edge of the window, giving the
area a rectangular, \"blocky\" presentation.
Option `tinted-background' uses a slightly colored background for
the contents of the block. The exact color will depend on the
programming language and is controlled by the variable
`org-src-block-faces' (refer to the theme's source code for the
current association list). For this to take effect, the Org
buffer needs to be restarted with `org-mode-restart'.
buffer needs to be restarted with `org-mode-restart'. In this
scenario, it may be better to inhibit the extension of the
delimiter lines' background to the edge of the window because Org
does not provide a mechanism to update their colors depending on
the contents of the block. Disable the extension of such
backgrounds by setting `org-fontify-whole-block-delimiter-line'
to nil.
Code blocks use their major mode's colors only when the variable
`org-src-fontify-natively' is non-nil. While quote/verse blocks
@ -2353,7 +2360,7 @@ Older versions of the themes provided options `grayscale' (or
are aliases for `gray-background' and `tinted-background',
respectively."
:group 'modus-themes
:package-version '(modus-themes . "1.4.0")
:package-version '(modus-themes . "2.1.0")
:version "28.1"
:type '(choice
(const :format "[%v] %t\n" :tag "No Org block background (default)" nil)
@ -3526,8 +3533,9 @@ set to `rainbow'."
('gray-background (list :background bg :foreground fg :extend t))
('grayscale (list :background bg :foreground fg :extend t))
('greyscale (list :background bg :foreground fg :extend t))
('tinted-background (list :background bgaccent :foreground fgaccent :extend nil))
('rainbow (list :background bgaccent :foreground fgaccent :extend nil))
(_ (list :background bg :foreground fg :extend nil))))
(_ (list :foreground fg :extend nil))))
(defun modus-themes--mode-line-attrs
(fg bg fg-alt bg-alt fg-accent bg-accent border border-3d &optional alt-style fg-distant)