~grtcdr/pub

2 2

Fix for activation of darkman-mode in Doom Emacs

Details
Message ID
<Njc7OJY--3-9@tuta.io>
DKIM signature
missing
Download raw message
Hi grtcdr,

thank you for developing darkman.el, I like it!

I am using Doom Emacs and Emacs daemon. I installed darkman.el by adding
`(package! darkman)` to my packages.el. To activate the darkman-mode, I
took the code from your tips (https://darkman.grtcdr.tn/),:
```
(when (daemonp)
  (add-hook 'server-after-make-frame-hook #'darkman-mode)
  (advice-add 'darkman-mode
              :after
              (lambda ()
                (remove-hook 'server-after-make-frame-hook
                             #'darkman-mode))))
```
However, with this noticed that when I  open a file in using
`emacsclient -nc file.foo`, it would often not show the file in the new
frame, but the doom fallback buffer, or another buffer I had already
open. And emacsclient would output errors like 'Wrong type argument:
"frame-live-p"'.
Fortunately, I was able to solve it, by using the following code instead
for activating darkman-mode:
```
(advice-add 'doom-init-theme-h :override 'darkman-mode)

```
Of course, this will only work in Doom Emacs, and since I don't know
Emacs well yet, it might not even be the best solution. But at least,
the problem I expired is gone now.
I just wanted let you and other know about this. You may feel free to
add this to the darkman.el docs.

Best
ilbdzumpfl
Details
Message ID
<877cmc7j4x.fsf@esprit.tn>
In-Reply-To
<Njc7OJY--3-9@tuta.io> (view parent)
DKIM signature
missing
Download raw message
> thank you for developing darkman.el, I like it!

Hi, I'm really glad to hear that.

> Fortunately, I was able to solve it, by using the following code 
> instead
> for activating darkman-mode:

> ```
> (advice-add 'doom-init-theme-h :override 'darkman-mode)
> ```

I don't really know much about Doom's architecture, just that it's 
very different and that many of its abstractions can, at times, 
get in the way. Debugging this must have been a challenge, despite 
the solution being a one-liner.

> Of course, this will only work in Doom Emacs, and since I don't 
> know
> Emacs well yet, it might not even be the best solution. But at 
> least,
> the problem I expired is gone now.

If others can confirm that this indeed works for them without any 
side effects, I'll gladly replace the old snippet with the one 
you're suggesting.

> I just wanted let you and other know about this. You may feel 
> free to
> add this to the darkman.el docs.

Thank you, both for sharing this tip and giving the rest of the 
community your permission to utilize it.

Kind regards,
-- 
Aziz
Details
Message ID
<210aa1ed-f84b-4030-8c1c-0ccc51f777f6@geoda.ovh>
In-Reply-To
<877cmc7j4x.fsf@esprit.tn> (view parent)
DKIM signature
missing
Download raw message
Hi there,

I've just come here to give my point of view and I hope to be able to help.

I hadn't had the ilbdzumpfl issue explained. On my side, Emacs loads 
with no issue, maybe because I use a different Emacs configuration. I 
wanted to share it as a reference:

```
;; $DOOMDIR/packages.el
(package! darkman
   :pin "13417d14abb3affc20a903daddd2f1525671b5bf"
   :recipe (:host sourcehut :repo "grtcdr/darkman.el"))
```

```
;; $DOOMDIR/config.el
(use-package! darkman
   :custom
   (darkman-themes '(:light doom-tomorrow-day
                                    :dark doom-tomorrow-night))
   (darkman-switch-themes-silently nil)
   :config
   (when (display-graphic-p)
     (add-hook! 'window-setup-hook (darkman-mode))) ;; after custom.el 
is loaded
   (when (daemonp)
     (add-hook 'server-after-make-frame-hook #'darkman-mode)
     (advice-add 'darkman-mode :after
                 (lambda ()
                   (remove-hook 'server-after-make-frame-hook 
#'darkman-mode)))))

```

I have checked and tested the possible replacement for 
`doom-init-theme-h` advice. Even though I have tried it and it works, I 
initially thought it was not the best solution because it bypasses the 
`load-theme` code hash validation[^1], which we have discussed in the 
past on a github issue[^2] about the value of not skipping it.

As always, it is up to Aziz to decide, but I will provide some references:

- `-h` suffix is a naming convention used in doomemacs for function 
hooks[^3]. You could advice any other internal aspect, but I see it as a 
fragile configuration. Good for a personal configuration, but bad for 
the documentation of a package that is not directly related to modifying 
some aspect of doomemacs.
- `doom-init-theme-h` is configured using a similar logic[^4] to the 
darkman.el documentation snippet.
- The snippet actually does not mention anything related to dooemacs. I 
add a hook related to the framework on my config when Emacs does not 
have a daemon running to load darkman-mode after the 
`$DOOMDIR/custom.el` file where `custom-safe-themes` is. I found it in a 
comment on doomemacs load order[^5]. So it seems to me to be right for 
all kinds of configurations.

I see perhaps an opportunity to improve the documentation to make it 
more friendly to well-known frameworks like doomemacs by creating a 
section in the documentation to adapt it for each one. Anyone in the 
future could send a patch to extend it, something like "community 
contributions".

Best regards,
Agustín

[^1]: 
https://github.com/doomemacs/doomemacs/blob/986398504d09e585c7d1a8d73a6394024fe6f164/lisp/doom-ui.el#L562
[^2]: https://github.com/grtcdr/darkman.el/pull/7
[^3]: 
https://github.com/doomemacs/doomemacs/blob/master/docs/contributing.org#lisp-naming-conventions
[^4]: 
https://github.com/doomemacs/doomemacs/blob/986398504d09e585c7d1a8d73a6394024fe6f164/lisp/doom-ui.el#L607-L616
[^5]: 
https://github.com/doomemacs/doomemacs/blob/e96624926d724aff98e862221422cd7124a99c19/lisp/doom.el#L33-L60
Reply to thread Export thread (mbox)