* Coding Convections - Enabling a feature by loading a file
@ 2003-06-04 18:51 Peter S Galbraith
0 siblings, 0 replies; 6+ messages in thread
From: Peter S Galbraith @ 2003-06-04 18:51 UTC (permalink / raw)
Hi all,
The coding conventions say:
* When a package provides a modification of ordinary Emacs behavior,
it is good to include a command to enable and disable the feature,
Provide a command named `WHATEVER-mode' which turns the feature on
or off, and make it autoload (*note Autoload::). Design the
package so that simply loading it has no visible effect--that
should not enable the feature.(2) Users will request the feature
by invoking the command.
The first part is fine (`include a command to enable and disable the
feature'). But what is the rationale behind the loading of a package
having no visisble effect? If the only purpose of a package is to
enable a feature (say changing the cursor to a bar), why ask users to
do:
(require 'bar-cursor)
(bar-cursor-mode 1)
instead of only:
(require 'bar-cursor)
?
I am perfect happy for packages to install themselves correctly once
loaded without having to go through more hoops.
Thanks,
Peter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding Convections - Enabling a feature by loading a file
[not found] <mailman.7309.1054754086.21513.help-gnu-emacs@gnu.org>
@ 2003-06-04 21:13 ` Stefan Monnier
[not found] ` <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
[not found] ` <mailman.7337.1054774167.21513.help-gnu-emacs@gnu.org>
2003-06-05 16:24 ` Lute Kamstra
1 sibling, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2003-06-04 21:13 UTC (permalink / raw)
>>>>> "Peter" == Peter S Galbraith <psg@debian.org> writes:
> feature'). But what is the rationale behind the loading of a package
> having no visisble effect? If the only purpose of a package is to
A package might be loaded implicitly by something like `customize'
just to get the list of groups/variables it offers. You wouldn't
want to turn a feature ON just because you're browsing some of the
related variables (you might even be browsing something that you didn't
know was related).
> (require 'bar-cursor)
> (bar-cursor-mode 1)
> instead of only:
> (require 'bar-cursor)
It should be only
(bar-cursor-mode 1)
because bar-cursor-mode should be autoloaded.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding Convections - Enabling a feature by loading a file
[not found] ` <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
@ 2003-06-05 0:47 ` Peter S Galbraith
0 siblings, 0 replies; 6+ messages in thread
From: Peter S Galbraith @ 2003-06-05 0:47 UTC (permalink / raw)
Stefan Monnier <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> wrote:
> >>>>> "Peter" == Peter S Galbraith <psg@debian.org> writes:
> > feature'). But what is the rationale behind the loading of a package
> > having no visisble effect? If the only purpose of a package is to
>
> A package might be loaded implicitly by something like `customize'
> just to get the list of groups/variables it offers. You wouldn't
> want to turn a feature ON just because you're browsing some of the
> related variables (you might even be browsing something that you didn't
> know was related).
But this is only true if its defcustoms are copied to another file,
right? How else could it get loaded? Or do you mean if the user loads
it in order to see its customizations?
> > (require 'bar-cursor)
> > (bar-cursor-mode 1)
> > instead of only:
> > (require 'bar-cursor)
>
> It should be only
>
> (bar-cursor-mode 1)
>
> because bar-cursor-mode should be autoloaded.
But this is only true if autoloads are generated. Is it standard
practice to do that for files added to someones site directory or for a
user under $HOME? I know I've never done that (I might start now that I
think of it).
I'm not talking about a file are is part of Emacs, but one distributed
separately. How strongly should we adhere to that coding convention?
Thanks!
--
Peter S. Galbraith, Debian Developer <psg@debian.org>
http://people.debian.org/~psg
GPG key 1024/D2A913A1 - 97CE 866F F579 96EE 6E68 8170 35FF 799E
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding Convections - Enabling a feature by loading a file
[not found] ` <mailman.7337.1054774167.21513.help-gnu-emacs@gnu.org>
@ 2003-06-05 1:02 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2003-06-05 1:02 UTC (permalink / raw)
> But this is only true if autoloads are generated. Is it standard
> practice to do that for files added to someones site directory or for a
> user under $HOME? I know I've never done that (I might start now that I
> think of it).
It's true that it's rarely done, but I think it should be fixed.
My install.el package embryo tries to do that by providing a standard way
for people to install a "package" and that procedure adds the
necessary autoloads.
> I'm not talking about a file are is part of Emacs, but one distributed
> separately. How strongly should we adhere to that coding convention?
Why should there be a difference ? After all, any unbundled package is
just a potential bundled package.
Stefan
PS: Another circumstance where a package might get loaded implicitly
is during byte-compilation. There's probably others.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding Convections - Enabling a feature by loading a file
[not found] <mailman.7309.1054754086.21513.help-gnu-emacs@gnu.org>
2003-06-04 21:13 ` Stefan Monnier
@ 2003-06-05 16:24 ` Lute Kamstra
[not found] ` <Lute.Kamstra@cwi.nl>
1 sibling, 1 reply; 6+ messages in thread
From: Lute Kamstra @ 2003-06-05 16:24 UTC (permalink / raw)
Peter S Galbraith <psg@debian.org> writes:
[...]
> But what is the rationale behind the loading of a package having no
> visisble effect? If the only purpose of a package is to enable a
> feature (say changing the cursor to a bar), why ask users to do:
>
> (require 'bar-cursor)
> (bar-cursor-mode 1)
>
> instead of only:
>
> (require 'bar-cursor)
>
> ?
>
> I am perfect happy for packages to install themselves correctly once
> loaded without having to go through more hoops.
I'm not familiar with bar-cursor.el, but in general a library can
implement more than one feature. In such a case, it is usually not
obvious which feature to turn on. It is best to turn nothing on
automatically and let the user choose which of the features to use by
explicitly turning them on. Even if a library contains only one
feature now, features might be added in future versions. Such changes
won't surprise the user if nothing is turned on upon loading the
library.
Furthermore, some other library could (require 'bar-cursor) to use
some function that is defined in bar-cursor.el. In such a case, you
usually do not want bar-cursor-mode to be turned on.
Lute.
--
(spook) => "unclassified Montenegro Serbian"
(insert-file-contents "~/.signature") => (error "`~/.signature' too rude")
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding Convections - Enabling a feature by loading a file
[not found] ` <Lute.Kamstra@cwi.nl>
@ 2003-06-08 0:58 ` Peter S Galbraith
0 siblings, 0 replies; 6+ messages in thread
From: Peter S Galbraith @ 2003-06-08 0:58 UTC (permalink / raw)
Lute Kamstra <Lute.Kamstra@cwi.nl> wrote:
> Peter S Galbraith <psg@debian.org> writes:
>
> [...]
>
> > But what is the rationale behind the loading of a package having no
> > visisble effect? If the only purpose of a package is to enable a
> > feature (say changing the cursor to a bar), why ask users to do:
> >
> > (require 'bar-cursor)
> > (bar-cursor-mode 1)
> >
> > instead of only:
> >
> > (require 'bar-cursor)
> >
> > ?
> >
> > I am perfect happy for packages to install themselves correctly once
> > loaded without having to go through more hoops.
>
> I'm not familiar with bar-cursor.el, but in general a library can
> implement more than one feature. In such a case, it is usually not
> obvious which feature to turn on. It is best to turn nothing on
> automatically and let the user choose which of the features to use by
> explicitly turning them on. Even if a library contains only one
> feature now, features might be added in future versions. Such changes
> won't surprise the user if nothing is turned on upon loading the
> library.
>
> Furthermore, some other library could (require 'bar-cursor) to use
> some function that is defined in bar-cursor.el. In such a case, you
> usually do not want bar-cursor-mode to be turned on.
>
> Lute.
Yeah, those are good reasons. You guys have convinced me that the added
steps are worth it in the long run.
Thanks for your comments,
Peter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-06-08 0:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-04 18:51 Coding Convections - Enabling a feature by loading a file Peter S Galbraith
[not found] <mailman.7309.1054754086.21513.help-gnu-emacs@gnu.org>
2003-06-04 21:13 ` Stefan Monnier
[not found] ` <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
2003-06-05 0:47 ` Peter S Galbraith
[not found] ` <mailman.7337.1054774167.21513.help-gnu-emacs@gnu.org>
2003-06-05 1:02 ` Stefan Monnier
2003-06-05 16:24 ` Lute Kamstra
[not found] ` <Lute.Kamstra@cwi.nl>
2003-06-08 0:58 ` Peter S Galbraith
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.