~protesilaos/modus-themes

3 2

[Feature] v4: Document how to customize border/boxes?

Details
Message ID
<m1fscxrr0s.fsf@christiantietze.de>
DKIM signature
missing
Download raw message
Hi Prot,

While documenting the migration process from my old modus-themes
settings to the new v4 format, I found that the mode-line face was
declared thus:

    `(mode-line ((,c :inherit modus-themes-ui-variable-pitch
                     :box ,border-mode-line-active
                     :background ,bg-mode-line-active
                     :foreground ,fg-mode-line-active)))

So the value of the 'border-mode-line-active' variable would be inserted
here during evaluation. Yet I couldn't get anything but simple color
literals to work.

I tried to set it to a list in various ways to try to get a thick box
around the mode line in palette overrides, e.g.:

(border-mode-line-active '(:line-width 10 :color "#ff0000"))

But that or other forms of quoted and unquoted lists don't do the trick.

Is setting a box supported, and if so, how?

For the time being, and if anyone else is interested, I'm replacing the
border in a hook like so:

      (defun ct/modus-themes-color (color)
        "Returns hex value for COLOR in the current modus theme."
        (car (modus-themes-with-colors (list (symbol-value color)))))

(defun ct/modus-themes-customize-mode-line ()
  "Apply padding to mode-line via box that has the background color"
  (let ((bg-active (ct/modus-theme-color 'bg-mode-line-active))
        (bg-inactive (ct/modus-theme-color 'bg-mode-line-inactive)))
       (set-face-attribute 'mode-line nil
                           :box `(:line-width 10
                                  :color ,bg-active))
       (set-face-attribute 'mode-line-inactive nil
                           :box `(:line-width 10
                                  :color ,bg-inactive))))
(add-hook 'modus-themes-after-load-theme-hook #'ct/modus-themes-customize-mode-line)

Cheers,
Christian

-- 
Sent from Bielefeld, Germany <3
https://christiantietze.de -- Programming + Personal
https://zettelkasten.de    -- Creative Knowledge Work

Mode line padding (was: [Feature] v4: Document how to customize border/boxes?)

Details
Message ID
<87o7rl2fwn.fsf@protesilaos.com>
In-Reply-To
<m1fscxrr0s.fsf@christiantietze.de> (view parent)
DKIM signature
missing
Download raw message
> From: Christian Tietze <me@christiantietze.de>
> Date: Fri, 30 Dec 2022 13:54:11 +0100
>
> Hi Prot,

Hello Christian,

> [... 22 lines elided]

> For the time being, and if anyone else is interested, I'm replacing the
> border in a hook like so:
>
>       (defun ct/modus-themes-color (color)
>         "Returns hex value for COLOR in the current modus theme."
>         (car (modus-themes-with-colors (list (symbol-value color)))))
>
> (defun ct/modus-themes-customize-mode-line ()
>   "Apply padding to mode-line via box that has the background color"
>   (let ((bg-active (ct/modus-theme-color 'bg-mode-line-active))
>         (bg-inactive (ct/modus-theme-color 'bg-mode-line-inactive)))
>        (set-face-attribute 'mode-line nil
>                            :box `(:line-width 10
>                                   :color ,bg-active))
>        (set-face-attribute 'mode-line-inactive nil
>                            :box `(:line-width 10
>                                   :color ,bg-inactive))))
> (add-hook 'modus-themes-after-load-theme-hook #'ct/modus-themes-customize-mode-line)

I still have not documented this.  Will do it a bit later as I still
need to tweak some things.  In general, overrides only concern colours.

Your code works, though you don't need ct/modus-themes-color as you can
wrap the face definitions around modus-themes-with-colors.  The above
can be written thus:

    (defun ct/modus-themes-customize-mode-line ()
      "Apply padding to mode-line via box that has the background color"
      (modus-themes-with-colors
        (custom-set-faces
        `(mode-line ((,c :box (:line-width 10 :color ,bg-active))))
        `(mode-line-inactive ((,c :box (:line-width 10 :color ,bg-inactive)))))))

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: Mode line padding (was: [Feature] v4: Document how to customize border/boxes?)

Details
Message ID
<m1fscxqa3f.fsf@christiantietze.de>
In-Reply-To
<87o7rl2fwn.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
> I still have not documented this.  Will do it a bit later as I still
> need to tweak some things.  In general, overrides only concern colours.

Alright 👍


> Your code works, though you don't need ct/modus-themes-color as you can
> wrap the face definitions around modus-themes-with-colors.  The above
> can be written thus:
>
>     (defun ct/modus-themes-customize-mode-line ()
>       "Apply padding to mode-line via box that has the background color"
>       (modus-themes-with-colors
>         (custom-set-faces
>         `(mode-line ((,c :box (:line-width 10 :color ,bg-active))))
>         `(mode-line-inactive ((,c :box (:line-width 10 :color ,bg-inactive)))))))

This looks even better than what I came up with in the meantime:

    (defun ct/modus-themes-customize-mode-line ()
      "Apply padding to mode-line via box that has the background color"
      (modus-themes-with-colors
        (set-face-attribute 'mode-line nil
                            :box `(:line-width 10 :color ,bg-mode-line-active))
        (set-face-attribute 'mode-line-inactive nil
                            :box `(:line-width 10 :color ,bg-mode-line-inactive))))

Plus yours stays consistent with the scoping to 256+ color environments.

Thanks!

-- Christian


-- 
Sent from Bielefeld, Germany <3
https://christiantietze.de -- Programming + Personal
https://zettelkasten.de    -- Creative Knowledge Work

Re: Mode line padding (was: [Feature] v4: Document how to customize border/boxes?)

Details
Message ID
<87zgb4n51g.fsf@protesilaos.com>
In-Reply-To
<m1fscxqa3f.fsf@christiantietze.de> (view parent)
DKIM signature
missing
Download raw message
> From: Christian Tietze <me@christiantietze.de>
> Date: Fri, 30 Dec 2022 14:45:08 +0100
>
>> I still have not documented this.  Will do it a bit later as I still
>> need to tweak some things.  In general, overrides only concern colours.
>
> Alright 👍

I just wrote this entry as well.  In it I explain why I removed the
option for mode line padding.

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)