Hi,
I was just skimming through the source of your new notmuch-indicator
package (I don't use notmuch so I can't try it out), and saw this comment:
;; TODO 2022-09-19: If this changes, the `notmuch-indicator-mode' needs
;; to be restarted. We can add a custom setter here. Perhaps there is
;; also some elegant way to handle this when the variable is changed
;; with `setq'.
My advice would be to stick to using a custom setter, but just FYI this
could be done by using `add-variable-watcher'. Keep in mind that this
is a really low-level thing, and that officially setting the value of a
symbol as a variable doesn't have any side effects. The reason
`add-variable-watcher' exists is to implement low-level stuff like
debuggers.
If people want that, then using `setq' is simply the wrong level of
abstraction (It would be like going to a restaurant and ordering how
many carbohydrates, proteins, etc. your meal should consist of).
All known configuration macros and now even Emacs with 29+ (see
`setopt') have easy ways of configuring user options that should be made
use of for these kinds of things. I'd point out that `setq' might not
do what you want it to, but otherwise implement this as a "proper" user
option.
> From: Philip Kaludercic <philipk@posteo.net>
> Date: Wed, 21 Sep 2022 07:36:43 +0000
>
>
> Hi,
Hello Philip,
> I was just skimming through the source of your new notmuch-indicator
> package (I don't use notmuch so I can't try it out), and saw this comment:
>
> ;; TODO 2022-09-19: If this changes, the `notmuch-indicator-mode' needs
> ;; to be restarted. We can add a custom setter here. Perhaps there is
> ;; also some elegant way to handle this when the variable is changed
> ;; with `setq'.
>
> My advice would be to stick to using a custom setter, but just FYI this
> could be done by using `add-variable-watcher'. Keep in mind that this
> is a really low-level thing, and that officially setting the value of a
> symbol as a variable doesn't have any side effects. The reason
> `add-variable-watcher' exists is to implement low-level stuff like
> debuggers.
Thanks for the information! I have not used that before.
> If people want that, then using `setq' is simply the wrong level of
> abstraction (It would be like going to a restaurant and ordering how
> many carbohydrates, proteins, etc. your meal should consist of).
Oh, this is why I keep getting weird looks at restaurants. 🤣
> All known configuration macros and now even Emacs with 29+ (see
> `setopt') have easy ways of configuring user options that should be made
> use of for these kinds of things. I'd point out that `setq' might not
> do what you want it to, but otherwise implement this as a "proper" user
> option.
The idea I had to make 'setq' fit into the picture was to abstract the
code so that it uses a function which reads the variable (assuming that
would even work with timers). Though this is not a major issue anyway,
as I don't expect a user to change this variable often.
[ I need to switch to 'setopt' in my own config, by the way. ]
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com