emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/modus-operandi-theme 2766a1d 27/99: New custom option:


From: Stefan Monnier
Subject: [elpa] externals/modus-operandi-theme 2766a1d 27/99: New custom option: "ORG SRC RAINBOW BLOCKS"
Date: Fri, 31 Jul 2020 09:25:20 -0400 (EDT)

branch: externals/modus-operandi-theme
commit 2766a1d2808091ec35fb2ef5031e0e9202d0c1c8
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    New custom option: "ORG SRC RAINBOW BLOCKS"
    
    This adds theme-level support for 'org-src-block-faces' (read its
    docstring with 'C-h v').  It addresses issue 34:
    https://gitlab.com/protesilaos/modus-themes/-/issues/34
    
    For completeness, this addition is made possible by building on top of
    commit adeee9f73.
---
 README.org              | 21 +++++++++++++++++++++
 modus-operandi-theme.el | 43 ++++++++++++++++++++++++++++++++++++++++++-
 modus-vivendi-theme.el  | 43 ++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 105 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index b3df82d..f10b3d2 100644
--- a/README.org
+++ b/README.org
@@ -211,6 +211,26 @@ the contents of the block, while beginning and end lines 
do not extend
 to the end of the window (again, the "extend" is for Emacs 27 or
 higher).
 
+Also see: [[#h:3eebcc85-b104-4774-a742-6dc4dc3dd122][Option for colourful 
"rainbow" Org SRC blocks]].
+
+** Option for colourful "rainbow" Org SRC blocks
+   :PROPERTIES:
+   :CUSTOM_ID: h:3eebcc85-b104-4774-a742-6dc4dc3dd122
+   :END:
+
++ =modus-operandi-theme-rainbow-org-src-blocks=
++ =modus-vivendi-theme-rainbow-org-src-blocks=
+
+Apply a colour-coded background to Org src blocks.  The exact colour of
+the background depends on the language being used.  These colours are
+designed to work well with all foreground values that are used in
+programming modes.
+
+The default is to use no background at all (it is the same as the rest
+of the buffer).
+
+Also see: [[#h:ca57a3af-6f79-4530-88c0-e35eda9d3bf7][Option for distinct Org 
blocks]].
+
 ** Option for colourful "rainbow" headings
    :PROPERTIES:
    :CUSTOM_ID: h:1be42afb-bcd2-4425-b956-0ba93eb960c2
@@ -467,6 +487,7 @@ being available.
         modus-operandi-theme-subtle-diffs t
         modus-operandi-theme-intense-standard-completions t
         modus-operandi-theme-distinct-org-blocks t
+        modus-operandi-theme-rainbow-org-src-blocks t
         modus-operandi-theme-proportional-fonts t
         modus-operandi-theme-rainbow-headings t
         modus-operandi-theme-section-headings t
diff --git a/modus-operandi-theme.el b/modus-operandi-theme.el
index 6c58ebe..49ab77e 100644
--- a/modus-operandi-theme.el
+++ b/modus-operandi-theme.el
@@ -47,6 +47,7 @@
 ;;     modus-operandi-theme-scale-headings
 ;;     modus-operandi-theme-visible-fringes
 ;;     modus-operandi-theme-distinct-org-blocks
+;;     modus-operandi-theme-rainbow-org-src-blocks
 ;;     modus-operandi-theme-3d-modeline
 ;;     modus-operandi-theme-subtle-diffs
 ;;     modus-operandi-theme-faint-syntax
@@ -372,6 +373,12 @@ between foreground and background is >= 7:1)."
 (defface modus-theme-fringe-blue nil nil)
 (defface modus-theme-fringe-magenta nil nil)
 (defface modus-theme-fringe-cyan nil nil)
+(defface modus-theme-nuanced-red nil nil)
+(defface modus-theme-nuanced-green nil nil)
+(defface modus-theme-nuanced-yellow nil nil)
+(defface modus-theme-nuanced-blue nil nil)
+(defface modus-theme-nuanced-magenta nil nil)
+(defface modus-theme-nuanced-cyan nil nil)
 (defface modus-theme-special-cold nil nil)
 (defface modus-theme-special-mild nil nil)
 (defface modus-theme-special-warm nil nil)
@@ -480,6 +487,11 @@ For more on the matter, read the documentation of
 (defcustom modus-operandi-theme-distinct-org-blocks nil
   "Use a distinct neutral background for `org-mode' blocks."
   :type 'boolean)
+
+(defcustom modus-operandi-theme-rainbow-org-src-blocks nil
+  "Use colour-coded backgrounds for `org-mode' source blocks.
+The colour in use depends on the language (send feedback to
+include more languages)."
   :type 'boolean)
 
 (defcustom modus-operandi-theme-3d-modeline nil
@@ -859,6 +871,20 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(modus-theme-active-blue ((,class :background ,blue-active :foreground 
,bg-active)))
    `(modus-theme-active-magenta ((,class :background ,magenta-active 
:foreground ,bg-active)))
    `(modus-theme-active-cyan ((,class :background ,cyan-active :foreground 
,bg-active)))
+   ;;; for adding a coloured background that is suitable for all main
+   ;;; foreground colours (intended for use in Org source blocks)
+   `(modus-theme-nuanced-red ((,class :background ,red-nuanced-bg
+                                      ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-green ((,class :background ,green-nuanced-bg
+                                        ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-yellow ((,class :background ,yellow-nuanced-bg
+                                         ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-blue ((,class :background ,blue-nuanced-bg
+                                       ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-magenta ((,class :background ,magenta-nuanced-bg
+                                          ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-cyan ((,class :background ,cyan-nuanced-bg
+                                       ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
    ;;; for fringe indicators
    `(modus-theme-fringe-red ((,class :background ,red-fringe-bg :foreground 
,fg-dim)))
    `(modus-theme-fringe-green ((,class :background ,green-fringe-bg 
:foreground ,fg-dim)))
@@ -3734,7 +3760,22 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(vc-annotate-very-old-color nil)
    ;;;; xterm-color
    `(xterm-color-names [,fg-main ,red ,green ,yellow ,blue ,magenta ,cyan 
,bg-alt])
-   `(xterm-color-names-bright [,fg-alt ,red-alt ,green-alt ,yellow-alt 
,blue-alt ,magenta-alt ,cyan-alt ,bg-main])))
+   `(xterm-color-names-bright [,fg-alt ,red-alt ,green-alt ,yellow-alt 
,blue-alt ,magenta-alt ,cyan-alt ,bg-main]))
+  ;;; Conditional theme variables
+  ;;;; org-src-block-faces (this is a user option to add a colour-coded
+  ;;;; background to source blocks for various programming languages)
+  (when modus-operandi-theme-rainbow-org-src-blocks
+    (custom-theme-set-variables
+     'modus-operandi
+     `(org-src-block-faces              ; TODO this list should be expanded
+       `(("emacs-lisp" 'modus-theme-nuanced-magenta)
+         ("c" 'modus-theme-nuanced-blue)
+         ("c++" 'modus-theme-nuanced-cyan)
+         ("sh" 'modus-theme-nuanced-green)
+         ("html" 'modus-theme-nuanced-yellow)
+         ("css" 'modus-theme-nuanced-cyan)
+         ("scss" 'modus-theme-nuanced-magenta)
+         ("python" 'modus-theme-nuanced-red))))))
 
 ;;;###autoload
 (when load-file-name
diff --git a/modus-vivendi-theme.el b/modus-vivendi-theme.el
index 5899482..6dc5b5e 100644
--- a/modus-vivendi-theme.el
+++ b/modus-vivendi-theme.el
@@ -47,6 +47,7 @@
 ;;     modus-vivendi-theme-scale-headings
 ;;     modus-vivendi-theme-visible-fringes
 ;;     modus-vivendi-theme-distinct-org-blocks
+;;     modus-vivendi-theme-rainbow-org-src-blocks
 ;;     modus-vivendi-theme-3d-modeline
 ;;     modus-vivendi-theme-subtle-diffs
 ;;     modus-vivendi-theme-faint-syntax
@@ -372,6 +373,12 @@ between foreground and background is >= 7:1)."
 (defface modus-theme-fringe-blue nil nil)
 (defface modus-theme-fringe-magenta nil nil)
 (defface modus-theme-fringe-cyan nil nil)
+(defface modus-theme-nuanced-red nil nil)
+(defface modus-theme-nuanced-green nil nil)
+(defface modus-theme-nuanced-yellow nil nil)
+(defface modus-theme-nuanced-blue nil nil)
+(defface modus-theme-nuanced-magenta nil nil)
+(defface modus-theme-nuanced-cyan nil nil)
 (defface modus-theme-special-cold nil nil)
 (defface modus-theme-special-mild nil nil)
 (defface modus-theme-special-warm nil nil)
@@ -480,6 +487,11 @@ For more on the matter, read the documentation of
 (defcustom modus-vivendi-theme-distinct-org-blocks nil
   "Use a distinct neutral background for `org-mode' blocks."
   :type 'boolean)
+
+(defcustom modus-vivendi-theme-rainbow-org-src-blocks nil
+  "Use colour-coded backgrounds for `org-mode' source blocks.
+The colour in use depends on the language (send feedback to
+include more languages)."
   :type 'boolean)
 
 (defcustom modus-vivendi-theme-3d-modeline nil
@@ -859,6 +871,20 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(modus-theme-active-blue ((,class :background ,blue-active :foreground 
,bg-active)))
    `(modus-theme-active-magenta ((,class :background ,magenta-active 
:foreground ,bg-active)))
    `(modus-theme-active-cyan ((,class :background ,cyan-active :foreground 
,bg-active)))
+   ;;; for adding a coloured background that is suitable for all main
+   ;;; foreground colours (intended for use in Org source blocks)
+   `(modus-theme-nuanced-red ((,class :background ,red-nuanced-bg
+                                      ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-green ((,class :background ,green-nuanced-bg
+                                        ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-yellow ((,class :background ,yellow-nuanced-bg
+                                         ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-blue ((,class :background ,blue-nuanced-bg
+                                       ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-magenta ((,class :background ,magenta-nuanced-bg
+                                          ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
+   `(modus-theme-nuanced-cyan ((,class :background ,cyan-nuanced-bg
+                                       ,@(and (>= emacs-major-version 27) 
'(:extend t)))))
    ;;; for fringe indicators
    `(modus-theme-fringe-red ((,class :background ,red-fringe-bg :foreground 
,fg-dim)))
    `(modus-theme-fringe-green ((,class :background ,green-fringe-bg 
:foreground ,fg-dim)))
@@ -3734,7 +3760,22 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(vc-annotate-very-old-color nil)
    ;;;; xterm-color
    `(xterm-color-names [,bg-main ,red ,green ,yellow ,blue ,magenta ,cyan 
,fg-alt])
-   `(xterm-color-names-bright [,bg-alt ,red-alt ,green-alt ,yellow-alt 
,blue-alt ,magenta-alt ,cyan-alt ,fg-main])))
+   `(xterm-color-names-bright [,bg-alt ,red-alt ,green-alt ,yellow-alt 
,blue-alt ,magenta-alt ,cyan-alt ,fg-main]))
+  ;;; Conditional theme variables
+  ;;;; org-src-block-faces (this is a user option to add a colour-coded
+  ;;;; background to source blocks for various programming languages)
+  (when modus-vivendi-theme-rainbow-org-src-blocks
+    (custom-theme-set-variables
+     'modus-vivendi
+     `(org-src-block-faces              ; TODO this list should be expanded
+       `(("emacs-lisp" 'modus-theme-nuanced-magenta)
+         ("c" 'modus-theme-nuanced-blue)
+         ("c++" 'modus-theme-nuanced-cyan)
+         ("sh" 'modus-theme-nuanced-green)
+         ("html" 'modus-theme-nuanced-yellow)
+         ("css" 'modus-theme-nuanced-cyan)
+         ("scss" 'modus-theme-nuanced-magenta)
+         ("python" 'modus-theme-nuanced-red))))))
 
 ;;;###autoload
 (when load-file-name



reply via email to

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