* GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
@ 2015-01-30 21:47 Matthew Carter
2015-01-30 21:50 ` Dmitry Gutov
2015-01-30 23:57 ` Artur Malabarba
0 siblings, 2 replies; 11+ messages in thread
From: Matthew Carter @ 2015-01-30 21:47 UTC (permalink / raw)
To: emacs-devel
Currently it works as expected in GNU Elpa (for installing), however it
requires the user to include something like this in their init:
(add-to-list 'custom-theme-load-path
"~/.emacs.d/elpa/ahungry-theme-1.0.3/")
(load-theme 'ahungry t)
Which isn't as bad when they had to explicitly install it from my
github, as they were sure to read the README and see those lines are
required to be manually entered.
With an install via GNU Elpa though, I think that directory is going to
be changing with the version number of the package, so it would require
constant updates to the user's init.
Should I update the package to do some or all of the following? (or
would the theme be too aggressive if so):
1) Add itself to the user's custom-theme-load-path
2) Load itself via load-theme
If either, anyone have a suggestion?
I see Elpa packages have an autoload file generated which adds the
package to the load-path - is there a package meta tag/comment to do the
same for custom-theme-load-path?
I personally would expect a theme I pulled in via package-install to at
least do #1, and if I were new to emacs, I'd probably expect it to do #2
as well.
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-01-30 21:47 GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it? Matthew Carter
@ 2015-01-30 21:50 ` Dmitry Gutov
2015-01-30 23:57 ` Artur Malabarba
1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Gutov @ 2015-01-30 21:50 UTC (permalink / raw)
To: Matthew Carter, emacs-devel
On 01/30/2015 11:47 PM, Matthew Carter wrote:
> 1) Add itself to the user's custom-theme-load-path
Probably this, because other themes do it:
https://github.com/bbatsov/solarized-emacs/blob/3efc1ec8a1338570613726975098a261c3921b7d/solarized.el#L2041-L2044
> I see Elpa packages have an autoload file generated which adds the
> package to the load-path - is there a package meta tag/comment to do the
> same for custom-theme-load-path?
See above.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-01-30 21:47 GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it? Matthew Carter
2015-01-30 21:50 ` Dmitry Gutov
@ 2015-01-30 23:57 ` Artur Malabarba
2015-02-05 17:44 ` Matthew Carter
1 sibling, 1 reply; 11+ messages in thread
From: Artur Malabarba @ 2015-01-30 23:57 UTC (permalink / raw)
To: M; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 383 bytes --]
> 1) Add itself to the user's custom-theme-load-path
Yes. The code is a little tricky, so look into how other themes do it.
> 2) Load itself via load-theme
Absolutely not. Users should be able to have multiple themes installed
without them all turning on simultaneously.
I do agree with need a more intuitive theming experience for new users, but
that's a whole other topic.
[-- Attachment #2: Type: text/html, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-01-30 23:57 ` Artur Malabarba
@ 2015-02-05 17:44 ` Matthew Carter
2015-02-05 19:13 ` Stefan Monnier
2015-02-05 19:31 ` Ivan Shmakov
0 siblings, 2 replies; 11+ messages in thread
From: Matthew Carter @ 2015-02-05 17:44 UTC (permalink / raw)
To: Artur Malabarba; +Cc: emacs-devel
Artur Malabarba <bruce.connor.am@gmail.com> writes:
>> 1) Add itself to the user's custom-theme-load-path
>
> Yes. The code is a little tricky, so look into how other themes do it.
>
>> 2) Load itself via load-theme
>
> Absolutely not. Users should be able to have multiple themes installed
> without them all turning on simultaneously.
>
> I do agree with need a more intuitive theming experience for new users, but
> that's a whole other topic.
When investigating further (and testing with a fresh emacs install) I
have found that the theme loads without requiring any calls to
load-theme or modifying the theme load path when installed via ELPA by
including a simple:
(require 'ahungry-theme)
In the init file, so upon reconsideration I'll probably avoid adding any
further autoload functionality in the theme code.
The fact that the theme becomes active upon a require isn't unintended
functionality is it?
Maybe I'll just update the meta description shown on list-packages from:
"Ahungry color theme for Emacs."
to
"Ahungry color theme for Emacs - just (require 'ahungry-theme) to load."
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 17:44 ` Matthew Carter
@ 2015-02-05 19:13 ` Stefan Monnier
2015-02-05 19:58 ` Matthew Carter
2015-02-05 19:31 ` Ivan Shmakov
1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2015-02-05 19:13 UTC (permalink / raw)
To: Matthew Carter; +Cc: Artur Malabarba, emacs-devel
> The fact that the theme becomes active upon a require isn't unintended
> functionality is it?
I can't speak for the coder's intentions, but at least normally
loading/requiring a file is not supposed to have such side-effects, so
I'd consider it a bug.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 19:13 ` Stefan Monnier
@ 2015-02-05 19:58 ` Matthew Carter
2015-02-05 20:48 ` Stefan Monnier
2015-02-05 22:08 ` Artur Malabarba
0 siblings, 2 replies; 11+ messages in thread
From: Matthew Carter @ 2015-02-05 19:58 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Artur Malabarba, emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> The fact that the theme becomes active upon a require isn't unintended
>> functionality is it?
>
> I can't speak for the coder's intentions, but at least normally
> loading/requiring a file is not supposed to have such side-effects, so
> I'd consider it a bug.
>
>
> Stefan
>
Hi Stefan,
By coder and bug, are you referring to my ahungry-theme ELPA package, or
the author of the deftheme components/package built into emacs 24?
My theme has 3 calls in it:
(deftheme ahungry)
(custom-theme-set-faces 'ahungry <theme face settings omitted>)
(provide-theme 'ahungry)
Which I thought were the 3 standard components to a custom theme file?
In most cases, a user has zero reason to #'require the theme unless they
plan to load it, so the fact that the #'require acts as a #'load-theme
(but based off the load-path instead of custom-theme-load-path) seems
like a good side-effect to me (at least until the ELPA generated
autoload file has support for adding ELPA loaded themes into the
custom-theme-load-path automatically).
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 19:58 ` Matthew Carter
@ 2015-02-05 20:48 ` Stefan Monnier
2015-02-05 22:08 ` Artur Malabarba
1 sibling, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2015-02-05 20:48 UTC (permalink / raw)
To: Matthew Carter; +Cc: Artur Malabarba, emacs-devel
> By coder and bug, are you referring to my ahungry-theme ELPA package, or
> the author of the deftheme components/package built into emacs 24?
I'm not familiar enough with the custom-theme code to be able to answer
that yet, sorry.
> My theme has 3 calls in it:
> (deftheme ahungry)
> (custom-theme-set-faces 'ahungry <theme face settings omitted>)
> (provide-theme 'ahungry)
That looks sane. Do you know which one ends up activating that theme?
I'd guess it's custom-theme-set-faces.
Is there some other way to set the faces of a particular theme without
activating that theme?
> In most cases, a user has zero reason to #'require the theme unless they
> plan to load it,
It's difficult to change the behavior between `load' and `require' and
a `load' can happen as a side-effect of something else, so by convention
we want loading to have "no" side-effect (of course, that's ill-defined
since loading a file has nothing but side-effects, but what is meant is
that the side-effects are minor such as providing new
things (commands/functions/...) rather than modifying existing ones).
Not all files follow this convention, but over the years, we've tried to
get closer to the ideal.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 19:58 ` Matthew Carter
2015-02-05 20:48 ` Stefan Monnier
@ 2015-02-05 22:08 ` Artur Malabarba
2015-02-06 4:03 ` Matthew Carter
1 sibling, 1 reply; 11+ messages in thread
From: Artur Malabarba @ 2015-02-05 22:08 UTC (permalink / raw)
To: Matthew Carter; +Cc: Stefan Monnier, emacs-devel
For starters, a theme *kind of* works if you require it, but that's
the wrong way of doing it. You should use load-theme instead.
> My theme has 3 calls in it:
>
> (deftheme ahungry) [...]
> (provide-theme 'ahungry)
>
> Which I thought were the 3 standard components to a custom theme file?
AFAICT that's the correct way. I think it's always been the case that
loading a theme file loads the theme itself (that's part of what
custom-theme-set-faces does).
> In most cases, a user has zero reason to #'require the theme unless they
> plan to load it, so the fact that the #'require acts as a #'load-theme
> (but based off the load-path instead of custom-theme-load-path) seems
> like a good side-effect to me
Firstly, the user also has zero reason to require the theme. Calling
(load-theme 'ahungry) can be done directly if the theme is on
custom-theme-load-path, so just do that instead.
Secondly, requiring the theme file doesn't do some pretty important
theme-related stuff that load-theme does, so there's a reason NOT to
require.
> (at least until the ELPA generated
> autoload file has support for adding ELPA loaded themes into the
> custom-theme-load-path automatically).
What do you mean by support? Here's what some themes do:
;;;###autoload
(and load-file-name (boundp 'custom-theme-load-path) (add-to-list
'custom-theme-load-path (file-name-as-directory (file-name-directory
load-file-name))))
It might be worth defining a notation of sorts that would have
make-autoloads do this for you automatically. But in the mean time,
use the snippet above, don't ask people to require your theme.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 22:08 ` Artur Malabarba
@ 2015-02-06 4:03 ` Matthew Carter
2015-02-06 8:59 ` Artur Malabarba
0 siblings, 1 reply; 11+ messages in thread
From: Matthew Carter @ 2015-02-06 4:03 UTC (permalink / raw)
To: Artur Malabarba; +Cc: Stefan Monnier, emacs-devel
Artur Malabarba <bruce.connor.am@gmail.com> writes:
>> (at least until the ELPA generated
>> autoload file has support for adding ELPA loaded themes into the
>> custom-theme-load-path automatically).
>
> What do you mean by support? Here's what some themes do:
>
> ;;;###autoload
>
> (and load-file-name (boundp 'custom-theme-load-path) (add-to-list
> 'custom-theme-load-path (file-name-as-directory (file-name-directory
> load-file-name))))
>
> It might be worth defining a notation of sorts that would have
> make-autoloads do this for you automatically. But in the mean time,
> use the snippet above, don't ask people to require your theme.
>
I had actually tried the aforementioned snippet (placed in
ahungry-theme.el) in the past, but it never gets evaluated unless I have
a (require 'ahungry-theme) in the init (which is how I discovered that
the simple 'require' applies most the theme).
Adding the following to ahungry-theme-autoloads.el:
(add-to-list 'custom-theme-load-path (or (file-name-directory #$) (car
load-path)))
lets a simple (load-theme 'ahungry) work as expected (prompt to trust
the theme, and a second to remember the trust choice), as well as
applying the theme, without requiring user intervention of setting the
custom-theme-load-path in their init.
Since I have a dependency defined in the theme file of ((emacs "24)),
which will thus have the load-theme support, it is probably unnecessary
to have a check for (boundp 'custom-theme-load-path) right?
If I manually create and add an "ahungry-theme-autoloads.el" file in
elpa/packages/ahungry-theme, will it supersede the one Elpa creates
automatically?
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-06 4:03 ` Matthew Carter
@ 2015-02-06 8:59 ` Artur Malabarba
0 siblings, 0 replies; 11+ messages in thread
From: Artur Malabarba @ 2015-02-06 8:59 UTC (permalink / raw)
To: M; +Cc: Stefan Monnier, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1897 bytes --]
> > What do you mean by support? Here's what some themes do:
> >
> > ;;;###autoload
> >
> > (and load-file-name (boundp 'custom-theme-load-path) (add-to-list
> > 'custom-theme-load-path (file-name-as-directory (file-name-directory
> > load-file-name))))
> >
> > It might be worth defining a notation of sorts that would have
> > make-autoloads do this for you automatically. But in the mean time,
> > use the snippet above, don't ask people to require your theme.
> >
>
> I had actually tried the aforementioned snippet (placed in
> ahungry-theme.el) in the past, but it never gets evaluated unless I have
> a (require 'ahungry-theme) in the init (which is how I discovered that
> the simple 'require' applies most the theme).
Did you notice that the snippet starts with ";;;###autoload"?
That should take care of adding it to the auto loads file. If it doesn't,
then something is wrong.
>
> Adding the following to ahungry-theme-autoloads.el:
>
> (add-to-list 'custom-theme-load-path (or (file-name-directory #$) (car
> load-path)))
This kind of what the above snippet is supposed to do.
> lets a simple (load-theme 'ahungry) work as expected (prompt to trust
> the theme, and a second to remember the trust choice), as well as
> applying the theme, without requiring user intervention of setting the
> custom-theme-load-path in their init.
Yes.
> Since I have a dependency defined in the theme file of ((emacs "24)),
> which will thus have the load-theme support, it is probably unnecessary
> to have a check for (boundp 'custom-theme-load-path) right?
I believe so.
> If I manually create and add an "ahungry-theme-autoloads.el" file in
> elpa/packages/ahungry-theme, will it supersede the one Elpa creates
> automatically?
Possibly, I'd have to look into the code. But that's the wrong way of doing
things. It's better to just figure out why your file isn't being generated
properly.
[-- Attachment #2: Type: text/html, Size: 2398 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it?
2015-02-05 17:44 ` Matthew Carter
2015-02-05 19:13 ` Stefan Monnier
@ 2015-02-05 19:31 ` Ivan Shmakov
1 sibling, 0 replies; 11+ messages in thread
From: Ivan Shmakov @ 2015-02-05 19:31 UTC (permalink / raw)
To: emacs-devel
>>>>> Matthew Carter <m@ahungry.com> writes:
>>>>> Artur Malabarba <bruce.connor.am@gmail.com> writes:
[…]
>> Users should be able to have multiple themes installed without them
>> all turning on simultaneously.
>> I do agree with need a more intuitive theming experience for new
>> users, but that's a whole other topic.
> When investigating further (and testing with a fresh emacs install) I
> have found that the theme loads without requiring any calls to
> load-theme or modifying the theme load path when installed via ELPA
> by including a simple:
> (require 'ahungry-theme)
> In the init file, so upon reconsideration I'll probably avoid adding
> any further autoload functionality in the theme code.
How is that better than, say, (load-theme 'ahungry t)?
> The fact that the theme becomes active upon a require isn't
> unintended functionality is it?
> Maybe I'll just update the meta description shown on list-packages
> from:
> "Ahungry color theme for Emacs."
> to
> "Ahungry color theme for Emacs - just (require 'ahungry-theme) to
> load."
You can refer to load-theme there just as well, I guess.
--
FSF associate member #7257 http://boycottsystemd.org/ … 3013 B6A0 230E 334A
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-02-06 8:59 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 21:47 GNU Elpa Theme (ahungry-theme) - should I add code to auto load-theme it? Matthew Carter
2015-01-30 21:50 ` Dmitry Gutov
2015-01-30 23:57 ` Artur Malabarba
2015-02-05 17:44 ` Matthew Carter
2015-02-05 19:13 ` Stefan Monnier
2015-02-05 19:58 ` Matthew Carter
2015-02-05 20:48 ` Stefan Monnier
2015-02-05 22:08 ` Artur Malabarba
2015-02-06 4:03 ` Matthew Carter
2015-02-06 8:59 ` Artur Malabarba
2015-02-05 19:31 ` Ivan Shmakov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).