Repository navigation
Conversation
|
Hi, We should develop this more, as this change introduces a potential risk of running arbitrary Emacs Lisp code unbeknownst to the user, i.e. because they've delegated the theme loading task to this package. We should introduce a new customizable variable, e.g. |
|
If we take this approach, the new variable should then be utilized in |
|
Another approach would be to work hand in hand with the This has the added benefit of not introducing any code changes to the package, only documentation. I personally like this approach a lot more; nevertheless, I would like to hear what our users think before deciding on anything final. |
|
Hi, @grtcdr thanks for considering a workaround to handle my issue. However, I understand the potential risk and adding a variable to do not confirm the changes looks a good way to deal with this. I'll happy to try add the code solution you proposed but maybe it took me a while since I never developed any real Elisp code. In any case, I would like to see more opinions from other users. |
If we decide to go with the first proposal, you would have to define In contrast, the second proposal requires that the documentation be
I'm glad we both agree.
I'm happy to guide you along the way :) Footnotes: |
Thank you very much 😄. Before start typing code, I did more research on the topic and I'd like your opinion.
What are your thoughts on this? I see three possible solutions:
Footnotes |
|
Do not use
Thanks for the links, they're all very interesting approaches.
I think this package should rely on the pre-existing mechanisms of Footnotes:
|
* Include documentation to aware users of this change
|
Thank you for sharing your thoughts @grtcdr I missed some details on the usage of I've done some basic work on the optional variable, just in case you want a quicker solution for now. I'd like comments on the code or any suggestions to go further and improve anything you're considering. |
|
I have included documentation changes which can be also used to explain other options such as |
Thank you :)
That won't be necessary if we adopt
I'm going to try and make some tiny adjustments. EDIT: I've opened a pull request on your fork at aerz#1 |
|
Merged! 😁
That's what I was thinking when I did the commit because you mentioned in #7 (comment) a better integration. However to be honest, I don't know how integrate that |
Thanks for merging the changes. Integrating with |
|
Hi, can you please review the comments I left? |
Hi, I checked the new changes, I didn't notice it yesterday, sorry for the late. I think everything is great and well explained. On the other hand, you already add the changes to the main branch, so I can close the PR whenever you want. |
I'm glad you think so :)
I completely agree, it's very handy to be able to advise functions!
The structure of a defadvice is as follows: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
[DOCSTRING] [INTERACTIVE-FORM]
BODY...)The snippet from the documentation sets the CLASS, NAME and FLAG You can at any time disable this advice interactively by hitting |
I shouldn't have done that, your contribution will still count. :) |
Great! 🙂 I've continued testing your piece of advice. If I'm not wrong, the idea to add it is: if there's no I personally use doomemacs and I was using this config: ;; $DOOMDIR/package.el
(package! darkman
:recipe (:host github :repo "grtcdr/darkman.el"));; $DOOMDIR/config.el
(use-package! darkman
:config
(setq darkman-themes '(:light doom-tomorrow-day
:dark doom-tomorrow-night))
(darkman-mode)
(defadvice darkman-set (before no-theme-stacking activate)
"Disable the previous theme before loading a new one."
(mapc #'disable-theme custom-enabled-themes)))However, the confirmation kept appearing at start when I set a theme that is not in Because of that, I was seeking for a way to only load (use-package! darkman
:config
(setq darkman-themes '(:light doom-tomorrow-day
:dark doom-tomorrow-night))
(defadvice darkman-set (before no-theme-stacking activate)
"Disable the previous theme before loading a new one."
(mapc #'disable-theme custom-enabled-themes))
(if (display-graphic-p)
(darkman-mode))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'darkman-mode)))This works both with and without an Emacs server. The hook I used is documented here. I'm sure you could provide a better solution. 😄 I think the idea is useful for this issue. Maybe this could be added it to the package or documentation. |
The
As previously mentioned, I don't intend to support or condone any methods besides the defaults because they seem very reasonable to me. If you wish to avoid confirmation, please enable the theme beforehand. :)
If I understand the documentation correctly, |
|
Ok, I misunderstood the intention of defadvise, but I agree with you on the way to deal with this issue. I also didn't want to avoid any security confirmation as we talk before. I'm just trying to avoid a crash when I start Emacs from systemd or any other init system where you don't have an opportunity to do any confirmation. Let me explain it. My Emacs server is stopped and the value of (use-package darkman
:ensure t
:load-path "darkman.el"
:config
(setq darkman-themes '(:light doom-tomorrow-day
:dark doom-tomorrow-night))
(darkman-mode))Now I start the server and the minor (if (display-graphic-p)
(darkman-mode))This will only happen when I run Emacs without a server backend. (if (daemonp)
(add-hook 'server-after-make-frame-hook #'darkman-mode))This will load only when I open a new frame from a server. In both cases I can confirm or not the elisp execution code and it will update |
|
I understand now. I was thinking we should add what you're proposing in the package Hooking This ensures that the daemon does not get blocked by the prompt and We can start with something like this: (define-minor-mode darkman-mode
"Minor mode providing integration with Darkman."
:global t
:init-value nil
:require 'dbus
:version "0.1"
(if darkman-mode
(progn
(and (darkman--check-dbus-service)
(setq darkman--dbus-signal
(dbus-register-signal
:session
darkman--dbus-service
darkman--dbus-path
darkman--dbus-interface
"ModeChanged"
#'darkman--mode-changed-signal-handler))
(load-theme (darkman-get-theme)))
(when (daemonp)
(remove-hook 'server-after-make-frame-hook #'darkman-mode)))
(dbus-unregister-object darkman--dbus-signal)
(setq darkman--dbus-signal nil)))And right at the end of the package, we include that handy hook: (when (daemonp) (add-hook 'server-after-make-frame-hook #'darkman-mode)) |
|
I'll let you include the change so we can finally merge this pull request :) |
|
Hey @grtcdr, sorry for the late. I'm glad you understood that case. I downloaded the latest commits from darkman.el and now my config looks like: ;; $DOOMDIR/config.el
(use-package! darkman
:custom
(darkman-themes '(:light doom-tomorrow-day
:dark doom-tomorrow-night))
:config
(darkman-mode));; $DOOMDIR/packages.el
(package! darkman
:recipe (:host github :repo "grtcdr/darkman.el"))The variable Are there any limitations on what a package can do in this case? I'll check it and comment if I found some workaround. 😥 |
|
I can't reproduce the problem you're describing, but I put together a video that demonstrates the expected behavior. I hope that clears any confusion. 2023-02-08.mp4 |
|
Ok, I didn't notice you always add the hook to load I'm still getting confirmation request when I run Emacs without the daemon but I think this is because doom emacs. Maybe it loads the package too early and |
|
Glad things are working again. You should still keep |
|
I fixed it. Doom Emacs loads the packages too early even before of ;; $DOOMDIR/config.el
(use-package! darkman
:custom
(darkman-themes '(:light doom-tomorrow-day
:dark doom-tomorrow-night))
:config
(if (display-graphic-p)
(add-hook! 'after-init-hook (darkman-mode))))Using this config it works with and with no daemon and only requests confirmation when the theme it's not in I'm sorry for this @grtcdr. If I had more knowledge about all this, I wouldn't have gone round and round and bothered you a bit. 😅 Anyway, I think the original idea of adding |
Good catch :-)
I failed to reproduce this behavior using a vanilla configuration, so
Don't apologize! This has been a wonderful learning experience for me,
Yes, we won't require any of that. |
Yes, as future references I found a comment in the doomemacs code about what is the load order. We could confirm that
Great! Thank you 😁
Yes! I've learnt a lot and thank you for making this package, it makes Emacs is almost the perfect tool for me. Back to the PR, I would prefer you to close it if you think we have fixed the issue. From my side everything's fine now. |
Thank you so much for linking this resource - and kudos to Henrik,
I'm very glad to hear that it's enhancing your experience.
Will do, thanks a lot for your help and patience. :-) |
|
Hey @aerz, I just wanted to let you know that in commit d1da4a7 we dropped the hook that addresses this issue, it has to be manually added from now on, though the relevant snippet is mentioned in the documentation. I've been told it may be impolite to register a hook such as this one which the user may or may not know about. |
Okay, thanks for letting me know about the change. I understand the reason and it makes sense, even if it should be included in the user configuration, wouldn't it make more sense to use a defavice (after) for darkman-mode to remove the hook? |
|
Advising the function after it is run will probably not fix the issue of a prompt appearing too early in the initialization process, if that's what you mean. With a hook, you're attaching the function to when the server's made a client frame, with a piece of advice with an |
I've recently configured the package in my config and I have a problem when I enable
darkman-modebecause theload-themefunction requires confirmation to run the code from a theme.In my case I have a systemd unit to start emacs where I can't do any confirmation.
I suggest using the no-confirm argument to avoid this by default.