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

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

[elpa] externals/modus-operandi-theme c7dfa1e 014/153: New custom option


From: Stefan Monnier
Subject: [elpa] externals/modus-operandi-theme c7dfa1e 014/153: New custom option to control modeline styles
Date: Thu, 18 Mar 2021 13:47:29 -0400 (EDT)

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

    New custom option to control modeline styles
    
    * README.org (Option for "3D" or "moody" mode line): Deprecate old
    customisation options 'modus-operandi-theme-3d-modeline' and
    'modus-vivendi-theme-3d-modeline'.
    (Option for "3D" or "moody" mode line): Document new options
    'modus-operandi-theme-mode-line', 'modus-vivendi-theme-mode-line'.
    
    * modus-operandi-theme.el (modus-operandi-theme-3d-modeline):
    Deprecate old customisation option.
    (modus-operandi-theme-mode-line): Define new customisation option.
    (modus-operandi-theme-modeline-box)
    (modus-operandi-theme-modeline-props)
    (modus-operandi-theme-mode-line-attrs): Deprecate two old internal
    functions and use just a single one.
    (custom-theme-set-faces): Let 'keycast-key' use the new internal
    function.
    (custom-theme-set-faces): Let 'mode-line' and 'mode-line-inactive'
    use the new internal function.
    
    * modus-vivendi-theme.el (modus-vivendi-theme-3d-modeline):
    Deprecate old customisation option.
    (modus-vivendi-theme-mode-line): Define new customisation option.
    (modus-vivendi-theme-modeline-box)
    (modus-vivendi-theme-modeline-props)
    (modus-vivendi-theme-mode-line-attrs): Deprecate two old internal
    functions and use just a single one.
    (custom-theme-set-faces): Let 'keycast-key' use the new internal
    function.
    (custom-theme-set-faces): Let 'mode-line' and 'mode-line-inactive'
    use the new internal function.
    
    Special thanks to Nicolas De Jaeghere for the feedback in issue 80:
    https://gitlab.com/protesilaos/modus-themes/-/issues/80
---
 README.org              | 31 +++++++++++------
 modus-operandi-theme.el | 93 ++++++++++++++++++++++++++++++++-----------------
 modus-vivendi-theme.el  | 93 ++++++++++++++++++++++++++++++++-----------------
 3 files changed, 142 insertions(+), 75 deletions(-)

diff --git a/README.org b/README.org
index 349908f..4d4cc9a 100644
--- a/README.org
+++ b/README.org
@@ -487,29 +487,37 @@ it throughout the theme:
 (set-face-attribute 'bold nil :weight 'semibold)
 #+end_src
 
-** Option for three-dimensional focused mode line
+** Option for "3D" or "moody" mode line
 :PROPERTIES:
 :CUSTOM_ID: h:ce155208-fdd6-4ada-9e0c-54aab7e2aff8
 :END:
 
 Symbol names:
 
-+ =modus-operandi-theme-3d-modeline=
-+ =modus-vivendi-theme-3d-modeline=
++ =modus-operandi-theme-mode-line=
++ =modus-vivendi-theme-mode-line=
 
 Possible values:
 
 1. =nil= (default)
-2. =t=
+2. =3d=
+3. =moody=
+
+The default value (=nil=) produces a two-dimensional effect both for the
+active and inactive modelines.  The differences between the two are
+limited to distinct shades of greyscale values, with the active being
+more intense than the inactive.
 
-Use a three-dimensional, "released button" effect for the focused
-window's mode line.  When enabled, this option will also affect the
-styles of any inactive mode lines, making them slightly less intense in
-order to accommodate the added element of depth.
+A =3d= symbol will make the active modeline look like a three-dimensional
+rectangle.  Inactive modelines remain 2D, though they are slightly toned
+down relative to the default.  This aesthetic is the same as what you
+get when you run Emacs without any customisations (=emacs -Q= on the
+command line).
 
-The default is to present the mode lines as rectangles with a border
-around them and with the active one having more intense colours than any
-inactive ones.
+While =moody= removes all box effects from the modelines and applies
+underline and overline properties instead.  It also tones down a bit the
+inactive modelines.  This is meant to optimise things for use with the
+[[https://github.com/tarsius/moody][moody package]], though it can work fine 
even without it.
 
 ** Option for desaturated or coloured-text-only diffs
 :PROPERTIES:
@@ -1198,6 +1206,7 @@ the "full support" may not be 100% true…
 + minimap
 + modeline
 + mood-line
++ moody (read [[#h:ce155208-fdd6-4ada-9e0c-54aab7e2aff8][Option for "3D" or 
"moody" mode line]])
 + mu4e
 + mu4e-conversation
 + multiple-cursors
diff --git a/modus-operandi-theme.el b/modus-operandi-theme.el
index 494337b..8c85918 100644
--- a/modus-operandi-theme.el
+++ b/modus-operandi-theme.el
@@ -48,7 +48,7 @@
 ;;     modus-operandi-theme-fringes                        (choice)
 ;;     modus-operandi-theme-org-blocks                     (choice)
 ;;     modus-operandi-theme-prompts                        (choice)
-;;     modus-operandi-theme-3d-modeline                    (boolean)
+;;     modus-operandi-theme-mode-line                      (choice)
 ;;     modus-operandi-theme-diffs                          (choice)
 ;;     modus-operandi-theme-faint-syntax                   (boolean)
 ;;     modus-operandi-theme-intense-hl-line                (boolean)
@@ -566,10 +566,35 @@ association list)."
           (const :tag "Subtle grey block background" greyscale)
           (const :tag "Colour-coded background per programming language" 
rainbow)))
 
+(define-obsolete-variable-alias 'modus-operandi-theme-3d-modeline
+  'modus-operandi-theme-mode-line "`modus-operandi-theme' 0.13.0")
+
 (defcustom modus-operandi-theme-3d-modeline nil
   "Use a three-dimensional style for the active mode line."
   :type 'boolean)
 
+(defcustom modus-operandi-theme-mode-line nil
+  "Adjust the overall style of the mode line.
+
+Nil is a two-dimensional rectangle with a border around it.  The
+active and the inactive modelines use different shades of
+greyscale values for the background and foreground.
+
+A `3d' value will apply a three-dimensional effect to the active
+modeline.  The inactive modelines remain two-dimensional and are
+toned down a bit, relative to the nil value.
+
+The `moody' option is meant to optimise the modeline for use with
+the library of the same name.  This practically means to remove
+the box effect and rely on underline and overline properties
+instead.  It also tones down the inactive modelines.  Despite its
+intended purpose, this option can also be used without the
+`moody' library."
+  :type '(choice
+          (const :tag "Two-dimensional box (default)" nil)
+          (const :tag "Three-dimensional style for the active mode line" 3d)
+          (const :tag "No box effects, which are optimal for use with the 
`moody' library" moody)))
+
 (define-obsolete-variable-alias 'modus-operandi-theme-subtle-diffs
   'modus-operandi-theme-diffs "`modus-operandi-theme' 0.13.0")
 
@@ -763,26 +788,31 @@ set to `rainbow'."
     ('rainbow (list :background bgaccent :foreground fgaccent))
     (_ (list :background bg :foreground fg))))
 
-(defun modus-operandi-theme-modeline-box (col3d col &optional btn int)
-  "Control the box properties of the mode line.
-COL3D is the border that is intended for the three-dimensional
-modeline.  COL applies to the two-dimensional modeline.  Optional
-BTN provides the 3d button style.  Optional INT defines a border
-width."
-  (let* ((style (if btn 'released-button nil))
-         (int (if int int 1)))
-    (if modus-operandi-theme-3d-modeline
-        (list :line-width int :color col3d :style style)
-      (list :line-width 1 :color col :style nil))))
+(defun modus-operandi-theme-mode-line-attrs
+    (fg bg fg-alt bg-alt border border-3d &optional alt-style border-width)
+  "Colour combinations for `modus-operandi-theme-mode-line'.
+
+FG and BG are the default colours.  FG-ALT and BG-ALT are meant
+to accommodate the options for a 3D modeline or a `moody'
+compliant one.  BORDER applies to all permutations of the
+modeline, except the three-dimensional effect, where BORDER-3D is
+used instead.
+
+Optional ALT-STYLE applies an appropriate style to the mode
+line's box property.
 
-(defun modus-operandi-theme-modeline-props (bg3d fg3d &optional bg fg)
-  "Control the background and foreground of the mode line.
-BG is the modeline's background.  FG is the modeline's
-foreground.  BG3D and FG3D apply to the three-dimensional
-modeline style."
-  (if modus-operandi-theme-3d-modeline
-      (list :background bg3d :foreground fg3d)
-    (list :background bg :foreground fg)))
+Optional BORDER-WIDTH specifies an integer for the width of the
+rectangle that produces the box effect."
+  (pcase modus-operandi-theme-mode-line
+    ('3d
+     `(:foreground ,fg-alt :background ,bg-alt
+                   :box (:line-width ,(or border-width 1)
+                                     :color ,border-3d
+                                     :style ,(and alt-style 
'released-button))))
+    ('moody
+     `(:foreground ,fg-alt :background ,bg-alt :underline ,border :overline 
,border))
+    (_
+     `(:foreground ,fg :background ,bg :box ,border))))
 
 (defun modus-operandi-theme-diff (fg-only-bg fg-only-fg mainbg mainfg altbg 
altfg)
   "Colour combinations for `modus-operandi-theme-diffs'.
@@ -2739,10 +2769,11 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(kaocha-runner-warning-face ((,class :foreground ,yellow)))
 ;;;;; keycast
    `(keycast-command ((,class :inherit bold :foreground ,blue-active)))
-   `(keycast-key ((,class :box ,(modus-operandi-theme-modeline-box blue-alt 
blue-active t -3)
-                          ,@(modus-operandi-theme-modeline-props
-                             blue-active bg-main
-                             blue-active bg-active))))
+   `(keycast-key ((,class ,@(modus-operandi-theme-mode-line-attrs
+                             bg-main blue-active
+                             bg-main blue-active
+                             blue-active blue-intense
+                             'alt-style -3))))
 ;;;;; line numbers (display-line-numbers-mode and global variant)
    `(line-number ((,class :background ,bg-dim :foreground ,fg-alt)))
    `(line-number-current-line ((,class :inherit bold :background ,bg-active 
:foreground ,fg-active)))
@@ -3007,17 +3038,15 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(minimap-active-region-background ((,class :background ,bg-active)))
    `(minimap-current-line-face ((,class :background ,cyan-intense-bg 
:foreground ,fg-main)))
 ;;;;; modeline
-   `(mode-line ((,class :box ,(modus-operandi-theme-modeline-box bg-active 
fg-alt t)
-                        ,@(modus-operandi-theme-modeline-props
-                           bg-active fg-dim
-                           bg-active fg-active))))
+   `(mode-line ((,class ,@(modus-operandi-theme-mode-line-attrs
+                           fg-active bg-active fg-dim bg-active
+                           fg-alt bg-active 'alt-style))))
    `(mode-line-buffer-id ((,class :inherit bold)))
    `(mode-line-emphasis ((,class :inherit bold :foreground ,blue-active)))
    `(mode-line-highlight ((,class :inherit modus-theme-active-blue :box 
(:line-width -1 :style pressed-button))))
-   `(mode-line-inactive ((,class :box ,(modus-operandi-theme-modeline-box 
bg-active bg-region)
-                                 ,@(modus-operandi-theme-modeline-props
-                                    bg-dim fg-inactive
-                                    bg-inactive fg-inactive))))
+   `(mode-line-inactive ((,class ,@(modus-operandi-theme-mode-line-attrs
+                                    fg-inactive bg-inactive fg-alt bg-dim
+                                    bg-region bg-active))))
 ;;;;; mood-line
    `(mood-line-modified ((,class :foreground ,magenta-active)))
    `(mood-line-status-error ((,class :inherit bold :foreground ,red-active)))
diff --git a/modus-vivendi-theme.el b/modus-vivendi-theme.el
index e6e8172..357584a 100644
--- a/modus-vivendi-theme.el
+++ b/modus-vivendi-theme.el
@@ -48,7 +48,7 @@
 ;;     modus-vivendi-theme-fringes                        (choice)
 ;;     modus-vivendi-theme-org-blocks                     (choice)
 ;;     modus-vivendi-theme-prompts                        (choice)
-;;     modus-vivendi-theme-3d-modeline                    (boolean)
+;;     modus-vivendi-theme-mode-line                      (choice)
 ;;     modus-vivendi-theme-diffs                          (choice)
 ;;     modus-vivendi-theme-faint-syntax                   (boolean)
 ;;     modus-vivendi-theme-intense-hl-line                (boolean)
@@ -566,10 +566,35 @@ association list)."
           (const :tag "Subtle grey block background" greyscale)
           (const :tag "Colour-coded background per programming language" 
rainbow)))
 
+(define-obsolete-variable-alias 'modus-vivendi-theme-3d-modeline
+  'modus-vivendi-theme-mode-line "`modus-vivendi-theme' 0.13.0")
+
 (defcustom modus-vivendi-theme-3d-modeline nil
   "Use a three-dimensional style for the active mode line."
   :type 'boolean)
 
+(defcustom modus-vivendi-theme-mode-line nil
+  "Adjust the overall style of the mode line.
+
+Nil is a two-dimensional rectangle with a border around it.  The
+active and the inactive modelines use different shades of
+greyscale values for the background and foreground.
+
+A `3d' value will apply a three-dimensional effect to the active
+modeline.  The inactive modelines remain two-dimensional and are
+toned down a bit, relative to the nil value.
+
+The `moody' option is meant to optimise the modeline for use with
+the library of the same name.  This practically means to remove
+the box effect and rely on underline and overline properties
+instead.  It also tones down the inactive modelines.  Despite its
+intended purpose, this option can also be used without the
+`moody' library."
+  :type '(choice
+          (const :tag "Two-dimensional box (default)" nil)
+          (const :tag "Three-dimensional style for the active mode line" 3d)
+          (const :tag "No box effects, which are optimal for use with the 
`moody' library" moody)))
+
 (define-obsolete-variable-alias 'modus-vivendi-theme-subtle-diffs
   'modus-vivendi-theme-diffs "`modus-vivendi-theme' 0.13.0")
 
@@ -763,26 +788,31 @@ set to `rainbow'."
     ('rainbow (list :background bgaccent :foreground fgaccent))
     (_ (list :background bg :foreground fg))))
 
-(defun modus-vivendi-theme-modeline-box (col3d col &optional btn int)
-  "Control the box properties of the mode line.
-COL3D is the border that is intended for the three-dimensional
-modeline.  COL applies to the two-dimensional modeline.  Optional
-BTN provides the 3d button style.  Optional INT defines a border
-width."
-  (let* ((style (if btn 'released-button nil))
-         (int (if int int 1)))
-    (if modus-vivendi-theme-3d-modeline
-        (list :line-width int :color col3d :style style)
-      (list :line-width 1 :color col :style nil))))
+(defun modus-vivendi-theme-mode-line-attrs
+    (fg bg fg-alt bg-alt border border-3d &optional alt-style border-width)
+  "Colour combinations for `modus-vivendi-theme-mode-line'.
+
+FG and BG are the default colours.  FG-ALT and BG-ALT are meant
+to accommodate the options for a 3D modeline or a `moody'
+compliant one.  BORDER applies to all permutations of the
+modeline, except the three-dimensional effect, where BORDER-3D is
+used instead.
+
+Optional ALT-STYLE applies an appropriate style to the mode
+line's box property.
 
-(defun modus-vivendi-theme-modeline-props (bg3d fg3d &optional bg fg)
-  "Control the background and foreground of the mode line.
-BG is the modeline's background.  FG is the modeline's
-foreground.  BG3D and FG3D apply to the three-dimensional
-modeline style."
-  (if modus-vivendi-theme-3d-modeline
-      (list :background bg3d :foreground fg3d)
-    (list :background bg :foreground fg)))
+Optional BORDER-WIDTH specifies an integer for the width of the
+rectangle that produces the box effect."
+  (pcase modus-vivendi-theme-mode-line
+    ('3d
+     `(:foreground ,fg-alt :background ,bg-alt
+                   :box (:line-width ,(or border-width 1)
+                                     :color ,border-3d
+                                     :style ,(and alt-style 
'released-button))))
+    ('moody
+     `(:foreground ,fg-alt :background ,bg-alt :underline ,border :overline 
,border))
+    (_
+     `(:foreground ,fg :background ,bg :box ,border))))
 
 (defun modus-vivendi-theme-diff (fg-only-bg fg-only-fg mainbg mainfg altbg 
altfg)
   "Colour combinations for `modus-vivendi-theme-diffs'.
@@ -2739,10 +2769,11 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(kaocha-runner-warning-face ((,class :foreground ,yellow)))
 ;;;;; keycast
    `(keycast-command ((,class :inherit bold :foreground ,blue-active)))
-   `(keycast-key ((,class :box ,(modus-vivendi-theme-modeline-box blue-alt 
blue-active t -3)
-                          ,@(modus-vivendi-theme-modeline-props
-                             blue-active bg-main
-                             blue-active bg-active))))
+   `(keycast-key ((,class ,@(modus-vivendi-theme-mode-line-attrs
+                             bg-main blue-active
+                             bg-main blue-active
+                             blue-active blue-intense
+                             'alt-style -3))))
 ;;;;; line numbers (display-line-numbers-mode and global variant)
    `(line-number ((,class :background ,bg-dim :foreground ,fg-alt)))
    `(line-number-current-line ((,class :inherit bold :background ,bg-active 
:foreground ,fg-active)))
@@ -3007,17 +3038,15 @@ Also bind `class' to ((class color) (min-colors 89))."
    `(minimap-active-region-background ((,class :background ,bg-active)))
    `(minimap-current-line-face ((,class :background ,cyan-intense-bg 
:foreground ,fg-main)))
 ;;;;; modeline
-   `(mode-line ((,class :box ,(modus-vivendi-theme-modeline-box bg-active 
fg-alt t)
-                        ,@(modus-vivendi-theme-modeline-props
-                           bg-active fg-dim
-                           bg-active fg-active))))
+   `(mode-line ((,class ,@(modus-vivendi-theme-mode-line-attrs
+                           fg-active bg-active fg-dim bg-active
+                           fg-alt bg-active 'alt-style))))
    `(mode-line-buffer-id ((,class :inherit bold)))
    `(mode-line-emphasis ((,class :inherit bold :foreground ,blue-active)))
    `(mode-line-highlight ((,class :inherit modus-theme-active-blue :box 
(:line-width -1 :style pressed-button))))
-   `(mode-line-inactive ((,class :box ,(modus-vivendi-theme-modeline-box 
bg-active bg-region)
-                                 ,@(modus-vivendi-theme-modeline-props
-                                    bg-dim fg-inactive
-                                    bg-inactive fg-inactive))))
+   `(mode-line-inactive ((,class ,@(modus-vivendi-theme-mode-line-attrs
+                                    fg-inactive bg-inactive fg-alt bg-dim
+                                    bg-region bg-active))))
 ;;;;; mood-line
    `(mood-line-modified ((,class :foreground ,magenta-active)))
    `(mood-line-status-error ((,class :inherit bold :foreground ,red-active)))



reply via email to

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