-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with skewer-css autoload #22
Comments
Interesting, I didn't realize derived modes invoked their ancestor's hook. What exactly is the conflict? If you're using autoloads -- which is the case when installed through Melpa -- what's initially being added to
If skewer-css hasn't been loaded yet, it will never get loaded. That is, unless you require/load it yourself or you invoke One of my design goals for Skewer is zero configuration requred: everything should work smoothly out-of-the-box. No one should have to set anything up just to try it out. This means I don't want to have instructions like "After you install, you need to add these lines to your initialization file." Even more so, I don't want to change the behavior for the existing users, who after upating would suddenly find things broken (the minor mode no longer enabled by default), requiring they debug the problem and reconfigure for it. As a middle ground, instead of putting the mode toggle directly on
But before I do this I want to understand why a simple |
Just in case I'm coming across as a grumpy ranter, let me first say that I totally understand the desire to make everything magically work out of the box. And let me also say that Part of the reason for me filing this issue is that I have personally taken flak for doing too much autoloaded magic set-up in my own code, which irked me at the time, but these days I have come to agree that autoloaded set-up code is best limited to adding The key argument is that having a package available is not the same as wanting to enable it. It shouldn't be necessary for people to uninstall packages in order to disable optional functionality, so it's arguably better for users to opt in than opt out. Here's the kicker: if Hope that makes some sense! :-) -Steve |
The issue of adding the hook in autoloads aside (I have no strong opinion either way), how will moving the hook to usage instructions help with |
@dgutov The user will then clearly be responsible for making things work properly and choosing trade-offs, rather than the author of this package. For more related discussion, see purcell/elisp-slime-nav#6, in which I have been convinced to remove the auto-enabling code from my own |
That's clearly not a solution. If I tell them to put something in the init file, and it causes problems, it's still a bug (only now it's in documentation). |
@dgutov I disagree. It would be a suggestion rather than a solution. The point is that it is customary for libaries to simply give the user a function he can use to enable optional functionality, and then he will be responsible for arranging to call it when appropriate for his needs. |
does any minor mode that is part of Emacs automatically get enabled by hook? |
@milkypostman Good question. I can't think of one. |
Do these count? http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/gdb-mi.el#n2893 But most of the time, why would they? Just like you can't uninstall a package included in Emacs, any major mode-specific functionality that's supposed to be "always on" can be incorporated in the same major mode, maybe hidden behind a variable. |
i'll admit I'm a little split on this subject. I most definitely think that keybindings are one thing, but there is a nicety to having a minor mode automatically be initialized when the package in installed. I agree with @purcell's point in the linked post about I think the problem we have is that we are experts but not all people are, and maybe there is a case to be made for having a variable, possibly for this package especially, it seems logical that if you don't want the package enabled you would just uninstall the package and restart emacs. But I think that http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-x.el#n32 goes to support that this package should not auto load itself at CSS time. |
The simple (and arguably idiomatic) solution is for packages to provide an autoloaded |
I finally made up my mind and you've convinced me, Steve. What do you think of 4e4e1ec? |
Yeah, that looks good! I definitely think this is the way to go, and the |
Is requiring the autoloads file correct here? On Tuesday, May 28, 2013, Steve Purcell wrote:
|
@milkypostman I figured maybe it's useful when used outside of package.el. The NOERROR argument is set so it shouldn't hurt anything. |
The current
skewer-css
code has an autoload which auto-enablesskewer-css-mode
viacss-mode-hook
. However, this also auto-enables skewer in derived modes, such asless-css-mode
, which is not compatible withskewer-css-mode
.As a user, this is a pain to work around, because it involves either undoing the hook after
skewer-css
has loaded, or adding further hooks to turn it off afterwards.Automatically changing mode hooks is not generally recommended, because of this type of issue; it's hard for an upstream author to foresee the exact needs of every user. Would you consider accepting a pull request which removes the
(add-hook ...)
code and adds it to the usage instructions?Cheers,
-Steve
The text was updated successfully, but these errors were encountered: