~protesilaos/modus-themes

12 2

On the deprecation of 'modus-themes-inhibit-reload'

Details
Message ID
<87h6y3gyxx.fsf@posteo.net>
DKIM signature
missing
Download raw message
Hi,

I was just reviewing the list of user options you plan to deprecate, and
was disappointed to see the deprecation of 'modus-themes-inhibit-reload'
in ab3f31a91f3674fa70018c3cd84f070fccccc85c.  Having contributed the
code a while back, I might be biased, but I still consider it very
useful and think it would be a pity to have the user options removed.

Forgive me for saying this, but I believe the feature has been
under-appreciated and it was an unfortunate mistake to have it disabled
by default (which I believe was due to a mistaken judgement by Gustavo
Barros).

If possible, I'd like to convince you to keep the option in the package,
but for that to work I'd have to know why you decided to not only
deprecate, but also remove it (which is a thing I don't quite
understand, usually you deprecate a option/function and remove it at
some later point to give people a chance to adapt their configuration
without it breaking).  If you are willing to discuss this, or perhaps
even improve on what we had, then I'd be more than willing to help!
Details
Message ID
<87mt7v8inz.fsf@protesilaos.com>
In-Reply-To
<87h6y3gyxx.fsf@posteo.net> (view parent)
DKIM signature
missing
Download raw message
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Sat, 10 Dec 2022 13:39:38 +0000
>
> Hi,

Hello Philip,

> I was just reviewing the list of user options you plan to deprecate, and
> was disappointed to see the deprecation of 'modus-themes-inhibit-reload'
> in ab3f31a91f3674fa70018c3cd84f070fccccc85c.  Having contributed the
> code a while back, I might be biased, but I still consider it very
> useful and think it would be a pity to have the user options removed.

Sorry about that.  Note that the files are not final.  I still have
incomplete changes that I have not pushed and others I need to review.
For example, 'modus-themes-org-blocks' is partially broken right now and
I want to see what to do with it.  'modus-themes-completions' is
untested and not perfect.  Also, the user option about the org-agenda
may be worth keeping, but otherwise simplifying.

> Forgive me for saying this, but I believe the feature has been
> under-appreciated and it was an unfortunate mistake to have it disabled
> by default (which I believe was due to a mistaken judgement by Gustavo
> Barros).

I no longer remember the discussion, except that there was some minor
tension.  Back then I was not using customize myself, though now I am
gradually introducing 'setopt' everywhere.  I like how seamless it is
and how it mirrors the 'setq' format.

I admit that I underappreciated and underutilised this feature.  I do
see its added value though.  Enabling it by default is worth it.

> If possible, I'd like to convince you to keep the option in the package,
> but for that to work I'd have to know why you decided to not only
> deprecate, but also remove it (which is a thing I don't quite
> understand, usually you deprecate a option/function and remove it at
> some later point to give people a chance to adapt their configuration
> without it breaking).  If you are willing to discuss this, or perhaps
> even improve on what we had, then I'd be more than willing to help!

There is no need to convince me, as I am fine with keeping it.  I simply
performed multiple drastic changes all at once, but still need to
double-check everything.  Though yes, if nobody would ask about this I
could miss it.

As for improving it, I remember there were some initial problems with it
(recursion?) but they were fixed long ago.  So I don't know if it needs
anything else.  I will thus bring it back, subject to a review.

[ NOTE: The same is true for packages.  I removed lots of them because
  they were using deprecated faces, but I want to gradually bring some
  back.  I did it with a few already, though there probably are more. ]

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87k02z8i8r.fsf@protesilaos.com>
In-Reply-To
<87mt7v8inz.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
> From: Protesilaos Stavrou <info@protesilaos.com>
> Date: Sat, 10 Dec 2022 15:58:24 +0200

> [... 31 lines elided]

> I admit that I underappreciated and underutilised this feature.  I do
> see its added value though.  Enabling it by default is worth it.

Since I am on the "mea culpa" flow, a few days ago I realised that
'custom-safe-themes' can be set to non-nil, which removes the problem I
had with 'theme-choose-variant'.  The command now works fine.  Sorry for
not noticing this before!  (The only addition I would like to see to the
core command is the functionality of "specify two themes to
toggle/choose", so that the user can switch between, say, modus-operandi
and ef-dark.)

Anyhow, my point is that we can revisit the point of deprecating
modus-themes-toggle.

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87lenegpig.fsf@protesilaos.com>
In-Reply-To
<87mt7v8inz.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +105 -1
> From: Protesilaos Stavrou <info@protesilaos.com>
> Date: Sat, 10 Dec 2022 15:58:24 +0200

> [... 47 lines elided]

> As for improving it, I remember there were some initial problems with it
> (recursion?) but they were fixed long ago.  So I don't know if it needs
> anything else.  I will thus bring it back, subject to a review.

Hello again Philip,

I have made the preparations to reinstate this feature.  I think this is
the right time to (i) rename it, and (ii) enable it by default.  I
tweaked it a bit to work with the two extra themes that we have (those
complete the set).

Diff below.  Since you were the original author, can I add you as the
author of this change?


 doc/modus-themes.org | 35 ++++++++++++++++++++++++++
 modus-themes.el      | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 105 insertions(+), 1 deletion(-)

diff --git a/doc/modus-themes.org b/doc/modus-themes.org
index d4464c9..5a7d8af 100644
--- a/doc/modus-themes.org
+++ b/doc/modus-themes.org
@@ -472,6 +472,7 @@ * Customization Options
      modus-themes-subtle-line-numbers nil
      modus-themes-deuteranopia t
      modus-themes-variable-pitch-ui nil
      modus-themes-custom-auto-reload t

      modus-themes-fringes nil ; {nil,'subtle,'intense}

@@ -529,6 +530,40 @@ * Customization Options
        (t . (1.1))))
#+end_src

** Option for inhibiting theme reload
:properties:
:alt_title: Custom reload theme
:description: Toggle auto-reload of the theme when setting custom variables
:custom_id: h:9001527a-4e2c-43e0-98e8-3ef72d770639
:end:
#+vindex: modus-themes-custom-auto-reload

[ Revised as part of {{{development-version}}}.  It used to be named
  ~modus-themes-inhibit-reload~. ]

Brief: Toggle reloading of the active theme when an option is changed
through the Custom UI.

Symbol: ~modus-themes-custom-auto-reload~ (=boolean= type)

Possible values:

1. ~nil~
2. ~t~ (default)

All theme user options take effect when a theme is loaded.  Any
subsequent changes require the theme to be reloaded.

When this variable has a non-nil value, any change made via the Custom
UI or related functions such as ~customize-set-variable~ and ~setopt~
(Emacs 29), will trigger a reload automatically.

With a nil value, changes to user options have no further
consequences.  The user must manually reload the theme.

Regardless of this option, the active theme must be reloaded for changes
to user options to take effect ([[#h:3f3c3728-1b34-437d-9d0c-b110f5b161a9][Enable and load]]).

** Option for red-green color deficiency or deuteranopia
:properties:
:alt_title: Deuteranopia style
diff --git a/modus-themes.el b/modus-themes.el
index 3e4b4df..720b56a 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -291,6 +291,44 @@ (make-obsolete-variable 'modus-themes-box-button-pressed nil "4.0.0")

;;;; Customization variables

(define-obsolete-variable-alias
  'modus-themes-inhibit-reload
  'modus-themes-custom-auto-reload
  "4.0.0")

(defcustom modus-themes-custom-auto-reload t
  "Automatically reload theme after setting options with Customize.

All theme user options take effect when a theme is loaded.  Any
subsequent changes require the theme to be reloaded.

When this variable has a non-nil value, any change made via the
Custom UI or related functions such as `customize-set-variable'
and `setopt' (Emacs 29), will trigger a reload automatically.

With a nil value, changes to user options have no further
consequences.  The user must manually reload the theme."
  :group 'modus-themes
  :package-version '(modus-themes . "4.0.0")
  :version "30.1"
  :type 'boolean
  :link '(info-link "(modus-themes) Custom reload theme"))

(defun modus-themes--set-option (sym val)
  "Custom setter for theme related user options.
Will set SYM to VAL, and reload the current theme, unless
`modus-themes-custom-auto-reload' is non-nil."
  (set-default sym val)
  (when (or modus-themes-custom-auto-reload
            ;; Check if a theme is being loaded, in which case we
            ;; don't want to reload a theme if the setter is
            ;; invoked. `custom--inhibit-theme-enable' is set to nil
            ;; by `enable-theme'.
            (bound-and-true-p custom--inhibit-theme-enable))
    (when-let* ((modus-themes-custom-auto-reload t)
                (theme (modus-themes--current-theme)))
      (modus-themes-load-theme theme))))

(defconst modus-themes-items
  '( modus-operandi modus-vivendi
     modus-operandi-tinted modus-vivendi-tinted)
@@ -321,6 +359,8 @@ (defcustom modus-themes-to-toggle '(modus-operandi modus-vivendi)
                                  modus-themes-items))))
  :package-version '(modus-themes . "4.0.0")
  :version "30.1"
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :group 'modus-themes)

(defvaralias 'modus-themes-post-load-hook 'modus-themes-after-load-theme-hook)
@@ -331,9 +371,10 @@ (defcustom modus-themes-after-load-theme-hook nil
  :type 'hook
  :package-version '(modus-themes . "4.0.0")
  :version "30.1"
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :group 'modus-themes)

(make-obsolete-variable 'modus-themes-inhibit-reload nil "4.0.0")
(make-obsolete-variable 'modus-themes-operandi-color-overrides nil "4.0.0")
(make-obsolete-variable 'modus-themes-vivendi-color-overrides nil "4.0.0")

@@ -345,6 +386,8 @@ (defcustom modus-themes-italic-constructs nil
  :package-version '(modus-themes . "1.5.0")
  :version "28.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Italic constructs"))

(defcustom modus-themes-bold-constructs nil
@@ -353,6 +396,8 @@ (defcustom modus-themes-bold-constructs nil
  :package-version '(modus-themes . "1.0.0")
  :version "28.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Bold constructs"))

(defcustom modus-themes-variable-pitch-ui nil
@@ -362,6 +407,8 @@ (defcustom modus-themes-variable-pitch-ui nil
  :package-version '(modus-themes . "1.1.0")
  :version "28.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) UI typeface"))

(defcustom modus-themes-mixed-fonts nil
@@ -379,6 +426,8 @@ (defcustom modus-themes-mixed-fonts nil
  :package-version '(modus-themes . "1.7.0")
  :version "29.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Mixed fonts"))

(make-obsolete-variable 'modus-themes-intense-mouseovers nil "4.0.0")
@@ -498,6 +547,8 @@ (defcustom modus-themes-headings nil
                            '(0 1 2 3 4 5 6 7 8 t agenda-date agenda-structure))
          :key-type symbol
          :value-type ,modus-themes--headings-choice)
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Heading styles"))

(make-obsolete-variable 'modus-themes-org-agenda nil "4.0.0")
@@ -518,6 +569,8 @@ (defcustom modus-themes-fringes 'subtle
          (const :format "[%v] %t\n" :tag "No visible fringes" nil)
          (const :format "[%v] %t\n" :tag "Subtle gray background" subtle)
          (const :format "[%v] %t\n" :tag "Intense gray background" intense))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Fringes"))

(make-obsolete-variable 'modus-themes-lang-checkers nil "4.0.0")
@@ -566,6 +619,8 @@ (defcustom modus-themes-org-blocks nil
          (const :format "[%v] %t\n" :tag "No Org block background (default)" nil)
          (const :format "[%v] %t\n" :tag "Subtle gray block background" gray-background)
          (const :format "[%v] %t\n" :tag "Color-coded background per programming language" tinted-background))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Org mode blocks"))

(defcustom modus-themes-mode-line nil
@@ -683,6 +738,8 @@ (defcustom modus-themes-mode-line nil
                     (cons :tag "Cons cell of `(height . FLOAT)'"
                           (const :tag "The `height' key (constant)" height)
                           (float :tag "Floating point"))))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Mode line"))

(make-obsolete-variable 'modus-themes-diffs nil "4.0.0")
@@ -807,6 +864,8 @@ (defcustom modus-themes-completions nil
                     (const :tag "With accented background" accented)
                     (const :tag "Italic font (oblique or slanted forms)" italic)
                     (const :tag "Underline" underline))))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Completion UIs"))

(defcustom modus-themes-prompts nil
@@ -842,6 +901,8 @@ (defcustom modus-themes-prompts nil
              (const :tag "With Background" background)
              (const :tag "Bold font weight" bold)
              (const :tag "Italic font slant" italic))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Command prompts"))

(make-obsolete-variable 'modus-themes-hl-line nil "4.0.0")
@@ -852,6 +913,8 @@ (defcustom modus-themes-subtle-line-numbers nil
  :package-version '(modus-themes . "1.2.0")
  :version "28.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Line numbers"))

(make-obsolete-variable 'modus-themes-markup nil "4.0.0")
@@ -903,6 +966,8 @@ (defcustom modus-themes-links nil
                      (const :tag "No underline" no-underline))
              (const :tag "Bold font weight" bold)
              (const :tag "Italic font slant" italic))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Link styles"))

(defcustom modus-themes-region nil
@@ -937,6 +1002,8 @@ (defcustom modus-themes-region nil
  :type '(set :tag "Properties" :greedy t
              (const :tag "Do not extend to the edge of the window" no-extend)
              (const :tag "Background only (preserve underlying colors)" bg-only))
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Active region"))

(defcustom modus-themes-deuteranopia nil
@@ -962,6 +1029,8 @@ (defcustom modus-themes-deuteranopia nil
  :package-version '(modus-themes . "2.0.0")
  :version "29.1"
  :type 'boolean
  :set #'modus-themes--set-option
  :initialize #'custom-initialize-default
  :link '(info-link "(modus-themes) Deuteranopia style"))

(make-obsolete-variable 'modus-themes-mail-citations nil "4.0.0")


All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87r0x5vbsx.fsf@posteo.net>
In-Reply-To
<87lenegpig.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Protesilaos Stavrou <info@protesilaos.com> writes:

>> From: Protesilaos Stavrou <info@protesilaos.com>
>> Date: Sat, 10 Dec 2022 15:58:24 +0200
>
>> [... 47 lines elided]
>
>> As for improving it, I remember there were some initial problems with it
>> (recursion?) but they were fixed long ago.  So I don't know if it needs
>> anything else.  I will thus bring it back, subject to a review.
>
> Hello again Philip,

Hi, sorry for the late response,

> I have made the preparations to reinstate this feature.  I think this is
> the right time to (i) rename it, and (ii) enable it by default.  I
> tweaked it a bit to work with the two extra themes that we have (those
> complete the set).

Sounds great, thank you for reconsidering.

> Diff below.  Since you were the original author, can I add you as the
> author of this change?
>
>
>  doc/modus-themes.org | 35 ++++++++++++++++++++++++++
>  modus-themes.el      | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 105 insertions(+), 1 deletion(-)
>
> diff --git a/doc/modus-themes.org b/doc/modus-themes.org
> index d4464c9..5a7d8af 100644
> --- a/doc/modus-themes.org
> +++ b/doc/modus-themes.org
> @@ -472,6 +472,7 @@ * Customization Options
>        modus-themes-subtle-line-numbers nil
>        modus-themes-deuteranopia t
>        modus-themes-variable-pitch-ui nil
> +      modus-themes-custom-auto-reload t
>  
>        modus-themes-fringes nil ; {nil,'subtle,'intense}
>  
> @@ -529,6 +530,40 @@ * Customization Options
>          (t . (1.1))))
>  #+end_src
>  
> +** Option for inhibiting theme reload
> +:properties:
> +:alt_title: Custom reload theme
> +:description: Toggle auto-reload of the theme when setting custom variables
> +:custom_id: h:9001527a-4e2c-43e0-98e8-3ef72d770639
> +:end:
> +#+vindex: modus-themes-custom-auto-reload
> +
> +[ Revised as part of {{{development-version}}}.  It used to be named
> +  ~modus-themes-inhibit-reload~. ]
> +
> +Brief: Toggle reloading of the active theme when an option is changed
> +through the Custom UI.
> +
> +Symbol: ~modus-themes-custom-auto-reload~ (=boolean= type)
> +
> +Possible values:
> +
> +1. ~nil~
> +2. ~t~ (default)
> +
> +All theme user options take effect when a theme is loaded.  Any
> +subsequent changes require the theme to be reloaded.
> +
> +When this variable has a non-nil value, any change made via the Custom
> +UI or related functions such as ~customize-set-variable~ and ~setopt~
> +(Emacs 29), will trigger a reload automatically.
> +
> +With a nil value, changes to user options have no further
> +consequences.  The user must manually reload the theme.
> +
> +Regardless of this option, the active theme must be reloaded for changes
> +to user options to take effect ([[#h:3f3c3728-1b34-437d-9d0c-b110f5b161a9][Enable and load]]).

Maybe this should be clarified, because I first read it as negating the
entire point of the user option.  I believe you are trying to clarify
that when the option is enabled, the theme is
"automatically"/"implicitly" reloaded, right?

>  ** Option for red-green color deficiency or deuteranopia
>  :properties:
>  :alt_title: Deuteranopia style
> diff --git a/modus-themes.el b/modus-themes.el
> index 3e4b4df..720b56a 100644
> --- a/modus-themes.el
> +++ b/modus-themes.el
> @@ -291,6 +291,44 @@ (make-obsolete-variable 'modus-themes-box-button-pressed nil "4.0.0")
>  
>  ;;;; Customization variables
>  
> +(define-obsolete-variable-alias
> +  'modus-themes-inhibit-reload
> +  'modus-themes-custom-auto-reload
> +  "4.0.0")

Isn't adding this alias "dangerous", because now if someone sets
`modus-themes-inhibit-reload' to t (I know of people who follow your
example and set variables to their default values to protect against
future changes), they would unintentionally be setting
`modus-themes-custom-auto-reload' to t which would have the opposite of
the intended effect?  Shouldn't we just mark
`modus-themes-inhibit-reload' as deprecated and mention
`modus-themes-custom-auto-reload' in the reason?

(define-obsolete-variable-alias uses defvaralias, and the docstrings
says "Aliased variables always have the same value; setting one sets the
other.")

> +(defcustom modus-themes-custom-auto-reload t
> +  "Automatically reload theme after setting options with Customize.
> +
> +All theme user options take effect when a theme is loaded.  Any
> +subsequent changes require the theme to be reloaded.
> +
> +When this variable has a non-nil value, any change made via the
> +Custom UI or related functions such as `customize-set-variable'
> +and `setopt' (Emacs 29), will trigger a reload automatically.
> +
> +With a nil value, changes to user options have no further
> +consequences.  The user must manually reload the theme."
> +  :group 'modus-themes
> +  :package-version '(modus-themes . "4.0.0")
> +  :version "30.1"
> +  :type 'boolean
> +  :link '(info-link "(modus-themes) Custom reload theme"))
> +
> +(defun modus-themes--set-option (sym val)
> +  "Custom setter for theme related user options.
> +Will set SYM to VAL, and reload the current theme, unless
> +`modus-themes-custom-auto-reload' is non-nil."
> +  (set-default sym val)
> +  (when (or modus-themes-custom-auto-reload
> +            ;; Check if a theme is being loaded, in which case we
> +            ;; don't want to reload a theme if the setter is
> +            ;; invoked. `custom--inhibit-theme-enable' is set to nil
> +            ;; by `enable-theme'.
> +            (bound-and-true-p custom--inhibit-theme-enable))
> +    (when-let* ((modus-themes-custom-auto-reload t)
> +                (theme (modus-themes--current-theme)))
> +      (modus-themes-load-theme theme))))
> +
>  (defconst modus-themes-items
>    '( modus-operandi modus-vivendi
>       modus-operandi-tinted modus-vivendi-tinted)
> @@ -321,6 +359,8 @@ (defcustom modus-themes-to-toggle '(modus-operandi modus-vivendi)
>                                    modus-themes-items))))
>    :package-version '(modus-themes . "4.0.0")
>    :version "30.1"
> +  :set #'modus-themes--set-option
> +  :initialize #'custom-initialize-default
>    :group 'modus-themes)

BTW, we could simplify this by making use of the fact that all user
options of a group are stored under the `custom-group' symbol property
for the symbol designating the group name:

  (get 'modus-themes 'custom-group)
  => ((modus-themes-faces custom-group)
      (modus-themes-inhibit-reload custom-variable)
      (modus-themes-operandi-color-overrides custom-variable)
      (modus-themes-vivendi-color-overrides custom-variable)
      ;; ...
      )

At the end of the file, we could then check all options in a group,
modify the respective properties (:set puts `custom-set' and :initialize
is directly invoked, see `custom-declare-variable').  Optionally this
could be wrapped in a function and invoked.  If you wish to avoid
modifying all user options without involving some heuristics, the
respective options would be placed in a "modus-themes-appearance"-like
group, which doesn't even sound that bad unrelated to this change.
Details
Message ID
<87mt7tvblk.fsf@posteo.net>
In-Reply-To
<87k02z8i8r.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Protesilaos Stavrou <info@protesilaos.com> writes:

>> From: Protesilaos Stavrou <info@protesilaos.com>
>> Date: Sat, 10 Dec 2022 15:58:24 +0200
>
>> [... 31 lines elided]
>
>> I admit that I underappreciated and underutilised this feature.  I do
>> see its added value though.  Enabling it by default is worth it.
>
> Since I am on the "mea culpa" flow, a few days ago I realised that
> 'custom-safe-themes' can be set to non-nil, which removes the problem I
> had with 'theme-choose-variant'.  

The default value of `custom-safe-themes' is not arbitrary, custom
themes carry the burden of not just being colour schemes in Lisp, which
is something a lot of users aren't conscious of.  Promoting the usage of
"disabling" `custom-safe-themes' is something I would be careful of
doing.

>                                   The command now works fine.  Sorry for
> not noticing this before!  (The only addition I would like to see to the
> core command is the functionality of "specify two themes to
> toggle/choose", so that the user can switch between, say, modus-operandi
> and ef-dark.)

Right, that was my intention (I have bound the key to C-c t).  I still
get the warnings that a theme might be unsafe when playing with
ef-themes from time to time, but I consider this a fair point.

What could be done, but I don't know if it should be done, is to have
all ef-themes mark each other as safe as soon as one of them has been
enabled (since the main logic is shared anyway and each "theme" is just
an instanciation of a macro).

> Anyhow, my point is that we can revisit the point of deprecating
> modus-themes-toggle.
Details
Message ID
<87y1rdpati.fsf@protesilaos.com>
In-Reply-To
<87r0x5vbsx.fsf@posteo.net> (view parent)
DKIM signature
missing
Download raw message
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Sun, 11 Dec 2022 22:02:38 +0000
>
> Protesilaos Stavrou <info@protesilaos.com> writes:
>
>>> From: Protesilaos Stavrou <info@protesilaos.com>
>>> Date: Sat, 10 Dec 2022 15:58:24 +0200
>>
>>> [... 47 lines elided]
>>
>>> As for improving it, I remember there were some initial problems with it
>>> (recursion?) but they were fixed long ago.  So I don't know if it needs
>>> anything else.  I will thus bring it back, subject to a review.
>>
>> Hello again Philip,
>
> Hi, sorry for the late response,

No worries!

> [... 62 lines elided]

>> +Regardless of this option, the active theme must be reloaded for changes
>> +to user options to take effect ([[#h:3f3c3728-1b34-437d-9d0c-b110f5b161a9][Enable and load]]).
>
> Maybe this should be clarified, because I first read it as negating
> the entire point of the user option.  I believe you are trying to
> clarify that when the option is enabled, the theme is
> "automatically"/"implicitly" reloaded, right?

Indeed.  This is a leftover from before.  I will rephrase it.

>>  ** Option for red-green color deficiency or deuteranopia
>>  :properties:
>>  :alt_title: Deuteranopia style
>> diff --git a/modus-themes.el b/modus-themes.el
>> index 3e4b4df..720b56a 100644
>> --- a/modus-themes.el
>> +++ b/modus-themes.el
>> @@ -291,6 +291,44 @@ (make-obsolete-variable 'modus-themes-box-button-pressed nil "4.0.0")
>>  
>>  ;;;; Customization variables
>>  
>> +(define-obsolete-variable-alias
>> +  'modus-themes-inhibit-reload
>> +  'modus-themes-custom-auto-reload
>> +  "4.0.0")
>
> Isn't adding this alias "dangerous", because now if someone sets
> `modus-themes-inhibit-reload' to t (I know of people who follow your
> example and set variables to their default values to protect against
> future changes), they would unintentionally be setting
> `modus-themes-custom-auto-reload' to t which would have the opposite of
> the intended effect?  Shouldn't we just mark
> `modus-themes-inhibit-reload' as deprecated and mention
> `modus-themes-custom-auto-reload' in the reason?
>
> (define-obsolete-variable-alias uses defvaralias, and the docstrings
> says "Aliased variables always have the same value; setting one sets the
> other.")

Oh right!  We do as you say.

> [... 44 lines elided]

> BTW, we could simplify this by making use of the fact that all user
> options of a group are stored under the `custom-group' symbol property
> for the symbol designating the group name:
>
>   (get 'modus-themes 'custom-group)
>   => ((modus-themes-faces custom-group)
>       (modus-themes-inhibit-reload custom-variable)
>       (modus-themes-operandi-color-overrides custom-variable)
>       (modus-themes-vivendi-color-overrides custom-variable)
>       ;; ...
>       )
>
> At the end of the file, we could then check all options in a group,
> modify the respective properties (:set puts `custom-set' and :initialize
> is directly invoked, see `custom-declare-variable').  Optionally this
> could be wrapped in a function and invoked.  If you wish to avoid
> modifying all user options without involving some heuristics, the
> respective options would be placed in a "modus-themes-appearance"-like
> group, which doesn't even sound that bad unrelated to this change.

I am fine with this.  I will now add the change, simply bringing back
the feature with the tweaks we covered, and then we can simplify it
further.

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87v8mhp6w7.fsf@protesilaos.com>
In-Reply-To
<87y1rdpati.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
> From: Protesilaos Stavrou <info@protesilaos.com>
> Date: Mon, 12 Dec 2022 05:20:25 +0200

> [... 78 lines elided]

>> At the end of the file, we could then check all options in a group,
>> modify the respective properties (:set puts `custom-set' and :initialize
>> is directly invoked, see `custom-declare-variable').  Optionally this
>> could be wrapped in a function and invoked.  If you wish to avoid
>> modifying all user options without involving some heuristics, the
>> respective options would be placed in a "modus-themes-appearance"-like
>> group, which doesn't even sound that bad unrelated to this change.
>
> I am fine with this.  I will now add the change, simply bringing back
> the feature with the tweaks we covered, and then we can simplify it
> further.

I pushed the change earlier and enabled the feature by default.  Though
I now encountered a problem with 'setopt'.  Before, I was using it with
modus-operandi and only with one variable at a time.  But trying the
following with modus-vivendi has a noticeable delay, as it flashes in a
white background:

    (setopt modus-themes-mixed-fonts t
            modus-themes-variable-pitch-ui t
            modus-themes-italic-constructs t
            modus-themes-bold-constructs t
            modus-themes-prompts '(background bold italic)
            modus-themes-mode-line '(3d accented)
            modus-themes-fringes 'intense
            modus-themes-deuteranopia t
            modus-themes-headings nil)

    (setopt modus-themes-mixed-fonts nil
            modus-themes-variable-pitch-ui nil
            modus-themes-italic-constructs nil
            modus-themes-bold-constructs nil
            modus-themes-prompts nil
            modus-themes-mode-line nil
            modus-themes-fringes nil
            modus-themes-deuteranopia nil
            modus-themes-headings nil)

This shows that the theme is being reloaded for each variable.  Whereas
we would only want to do it once.  I probably did something wrong with
'modus-themes--set-option', but I am looking into it.

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87sfhks7iy.fsf@posteo.net>
In-Reply-To
<87v8mhp6w7.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Protesilaos Stavrou <info@protesilaos.com> writes:

>> From: Protesilaos Stavrou <info@protesilaos.com>
>> Date: Mon, 12 Dec 2022 05:20:25 +0200
>
>> [... 78 lines elided]
>
>>> At the end of the file, we could then check all options in a group,
>>> modify the respective properties (:set puts `custom-set' and
>>> :initialize
>>> is directly invoked, see `custom-declare-variable').  Optionally this
>>> could be wrapped in a function and invoked.  If you wish to avoid
>>> modifying all user options without involving some heuristics, the
>>> respective options would be placed in a "modus-themes-appearance"-like
>>> group, which doesn't even sound that bad unrelated to this change.
>>
>> I am fine with this.  I will now add the change, simply bringing back
>> the feature with the tweaks we covered, and then we can simplify it
>> further.
>
> I pushed the change earlier and enabled the feature by default.  Though
> I now encountered a problem with 'setopt'.  Before, I was using it with
> modus-operandi and only with one variable at a time.  But trying the
> following with modus-vivendi has a noticeable delay, as it flashes in a
> white background:
>
>     (setopt modus-themes-mixed-fonts t
>             modus-themes-variable-pitch-ui t
>             modus-themes-italic-constructs t
>             modus-themes-bold-constructs t
>             modus-themes-prompts '(background bold italic)
>             modus-themes-mode-line '(3d accented)
>             modus-themes-fringes 'intense
>             modus-themes-deuteranopia t
>             modus-themes-headings nil)
>
>     (setopt modus-themes-mixed-fonts nil
>             modus-themes-variable-pitch-ui nil
>             modus-themes-italic-constructs nil
>             modus-themes-bold-constructs nil
>             modus-themes-prompts nil
>             modus-themes-mode-line nil
>             modus-themes-fringes nil
>             modus-themes-deuteranopia nil
>             modus-themes-headings nil)
>
> This shows that the theme is being reloaded for each variable.  Whereas
> we would only want to do it once.  I probably did something wrong with
> 'modus-themes--set-option', but I am looking into it.

I don't think that there is anything wrong wit
`modus-themes--set-option', that is the expected behaviour of a custom
setter.  The way I see it, we have a few options:

1. Accept this overhead and advise setting user options programmatically
   before loading the theme.

2. Adding some ugly hacks to detect how the custom setter is being
   invoked, and anticipate if the theme should be reloaded or not.

3. Change the behaviour of the hook, e.g. to defer reloading to the end
   of an init file and avoid reloading the theme if it has already been
   loaded.

4. Be more clever about reloading and only change what an options
   affects.  For this to be done properly, it would require some
   annotations.  I can take a look at how the code looks like right now,
   and perhaps propose a macro that would make this easier.

I think that 4. would be the best strategy, if the effort is reasonable.

But perhaps all of this shouldn't be theme-specific anyway, and it would
be better to move the work into the core again, specifying some generic
way to associate user options with a theme.
Details
Message ID
<87sfhjs4wc.fsf@protesilaos.com>
In-Reply-To
<87mt7tvblk.fsf@posteo.net> (view parent)
DKIM signature
missing
Download raw message
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Sun, 11 Dec 2022 22:07:03 +0000

> [... 21 lines elided]

>>                                   The command now works fine.  Sorry for
>> not noticing this before!  (The only addition I would like to see to the
>> core command is the functionality of "specify two themes to
>> toggle/choose", so that the user can switch between, say, modus-operandi
>> and ef-dark.)
>
> Right, that was my intention (I have bound the key to C-c t).  I still
> get the warnings that a theme might be unsafe when playing with
> ef-themes from time to time, but I consider this a fair point.
>
> What could be done, but I don't know if it should be done, is to have
> all ef-themes mark each other as safe as soon as one of them has been
> enabled (since the main logic is shared anyway and each "theme" is just
> an instanciation of a macro).

The documentation of 'custom-face-themes' states that:

    This variable cannot be set in a Custom theme.

Maybe we can work around it, though a clean solution is preferable for
the long-term.

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87v8mfgvls.fsf@posteo.net>
In-Reply-To
<87sfhjs4wc.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Protesilaos Stavrou <info@protesilaos.com> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Sun, 11 Dec 2022 22:07:03 +0000
>
>> [... 21 lines elided]
>
>>>                                   The command now works fine.  Sorry for
>>> not noticing this before!  (The only addition I would like to see to the
>>> core command is the functionality of "specify two themes to
>>> toggle/choose", so that the user can switch between, say, modus-operandi
>>> and ef-dark.)
>>
>> Right, that was my intention (I have bound the key to C-c t).  I still
>> get the warnings that a theme might be unsafe when playing with
>> ef-themes from time to time, but I consider this a fair point.
>>
>> What could be done, but I don't know if it should be done, is to have
>> all ef-themes mark each other as safe as soon as one of them has been
>> enabled (since the main logic is shared anyway and each "theme" is just
>> an instanciation of a macro).
>
> The documentation of 'custom-face-themes' states that:

I am guessing you mean `custom-safe-themes'?

>     This variable cannot be set in a Custom theme.

Does this include a direct manipulation of the user option written in
Lisp?

> Maybe we can work around it, though a clean solution is preferable for
> the long-term.

Perhaps `custom-theme-load-confirm' could check if any theme from the
family has been marked as safe?
Details
Message ID
<87pmcns3ca.fsf@protesilaos.com>
In-Reply-To
<87sfhks7iy.fsf@posteo.net> (view parent)
DKIM signature
missing
Download raw message
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Mon, 12 Dec 2022 20:15:33 +0000

> [... 47 lines elided]

>> This shows that the theme is being reloaded for each variable.  Whereas
>> we would only want to do it once.  I probably did something wrong with
>> 'modus-themes--set-option', but I am looking into it.
>
> I don't think that there is anything wrong wit
> `modus-themes--set-option', that is the expected behaviour of a custom
> setter.  The way I see it, we have a few options:
>
> 1. Accept this overhead and advise setting user options programmatically
>    before loading the theme.
>
> 2. Adding some ugly hacks to detect how the custom setter is being
>    invoked, and anticipate if the theme should be reloaded or not.
>
> 3. Change the behaviour of the hook, e.g. to defer reloading to the end
>    of an init file and avoid reloading the theme if it has already been
>    loaded.
>
> 4. Be more clever about reloading and only change what an options
>    affects.  For this to be done properly, it would require some
>    annotations.  I can take a look at how the code looks like right now,
>    and perhaps propose a macro that would make this easier.
>
> I think that 4. would be the best strategy, if the effort is reasonable.
>
> But perhaps all of this shouldn't be theme-specific anyway, and it would
> be better to move the work into the core again, specifying some generic
> way to associate user options with a theme.

Yes, this seems like it belongs in emacs.git.  If we can have something
in the modus-themes, it will make it possible to provide the feature
for earlier versions of Emacs.

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<87mt7rs371.fsf@protesilaos.com>
In-Reply-To
<87v8mfgvls.fsf@posteo.net> (view parent)
DKIM signature
missing
Download raw message
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Tue, 13 Dec 2022 15:40:47 +0000

> [... 23 lines elided]

>> The documentation of 'custom-face-themes' states that:
>
> I am guessing you mean `custom-safe-themes'?

Yes, sorry.  A funny mistake of mine!

>>     This variable cannot be set in a Custom theme.
>
> Does this include a direct manipulation of the user option written in
> Lisp?

I did not check the code and did not put this to the test.  Sorry!

>> Maybe we can work around it, though a clean solution is preferable for
>> the long-term.
>
> Perhaps `custom-theme-load-confirm' could check if any theme from the
> family has been marked as safe?

This makes sense.  Many theme packages contain multiple items.

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