* loading spam.el and gnus-registry.el with set variables only
@ 2003-10-07 18:44 Ted Zlatanov
2003-10-09 14:42 ` Ted Zlatanov
0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2003-10-07 18:44 UTC (permalink / raw)
Speaking for those two packages, it has been the #1 problem that
people have to set a variable (gnus-registry-install or
spam-install-hooks) and then do a require of the .el file. How could
I make it so setting any of the two variables above will load its
appropriate package when Gnus is loaded? I can just put code into
gnus.el, but I thought maybe there was a "right" way of loading
packages like that.
Thanks
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-07 18:44 loading spam.el and gnus-registry.el with set variables only Ted Zlatanov
@ 2003-10-09 14:42 ` Ted Zlatanov
2003-10-09 16:24 ` Reiner Steib
0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2003-10-09 14:42 UTC (permalink / raw)
On Tue, 07 Oct 2003, tzz@lifelogs.com wrote:
> Speaking for those two packages, it has been the #1 problem that
> people have to set a variable (gnus-registry-install or
> spam-install-hooks) and then do a require of the .el file. How
> could I make it so setting any of the two variables above will load
> its appropriate package when Gnus is loaded? I can just put code
> into gnus.el, but I thought maybe there was a "right" way of loading
> packages like that.
Anyone? If this is not yet standardized in Gnus, I'll go ahead and
put some code in gnus.el that will look in a table of symbols and if
the symbol is set, will load the corresponding library. I just want
to make sure I'm not missing something obvious.
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-09 14:42 ` Ted Zlatanov
@ 2003-10-09 16:24 ` Reiner Steib
2003-10-09 18:00 ` Ted Zlatanov
0 siblings, 1 reply; 7+ messages in thread
From: Reiner Steib @ 2003-10-09 16:24 UTC (permalink / raw)
On Thu, Oct 09 2003, Ted Zlatanov wrote:
> On Tue, 07 Oct 2003, tzz@lifelogs.com wrote:
>
>> Speaking for those two packages, it has been the #1 problem that
>> people have to set a variable (gnus-registry-install or
>> spam-install-hooks) and then do a require of the .el file. How
>> could I make it so setting any of the two variables above will load
>> its appropriate package when Gnus is loaded?
[Disclaimer: I'm not familiar with gnus-registry.el and spam*.el
internals.]
The importance of the order seems quite fragile to me, isn't it?
_Normally_ (counter-examples follow below) I'd expect that changing a
variable has some effect, no matter if a corresponding package is
loaded before or after setting the variable.
I'd use functions, say `gnus-registry-initialize' and
`spam-initialize' (or -install?) and autoload those functions:
;;;###autoload
(defun gnus-registry-initialize ...)
;;;###autoload
(defun spam-initialize ...)
Probably, you should also add autoload cookies to the relevant
variables. E.g. in my current setup, gnus-registry isn't loaded, so I
cannot customize `gnus-registry-install'.
> Anyone? If this is not yet standardized in Gnus, I'll go ahead and
> put some code in gnus.el that will look in a table of symbols and if
> the symbol is set, will load the corresponding library. I just want
> to make sure I'm not missing something obvious.
I doubt that we have a Gnus-specific standard/convention. Maybe
there's something in the Emacs or Elisp manual?
Maybe, instead of ...-initialize, using a minor mode is better?
Grepping the Emacs lisp sources for "no effect" gives some examples:
,----[ C-h v normal-erase-is-backspace RET ]
| normal-erase-is-backspace's value is t
| [...]
| Setting this variable with setq doesn't take effect. Programmatically,
| call `normal-erase-is-backspace-mode' (which see) instead.
|
| You can customize this variable.
|
| Defined in `simple'.
`----
,----[ C-h v utf-translate-cjk-mode RET (in CVS HEAD) ]
| utf-translate-cjk-mode's value is nil
|
| Non-nil if Utf-Translate-Cjk mode is enabled.
| See the command `utf-translate-cjk-mode' for a description of this
| minor-mode.
| Setting this variable directly does not take effect;
| use either M-x customize or the function `utf-translate-cjk-mode'.
|
| You can customize this variable.
|
| Defined in `international/utf-8'.
`----
See the ":set" and ":initialize" keyword of `defcustom'.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-09 16:24 ` Reiner Steib
@ 2003-10-09 18:00 ` Ted Zlatanov
2003-10-09 19:37 ` Reíner Steib
0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2003-10-09 18:00 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
On Thu, 09 Oct 2003, 4.uce.03.r.s@nurfuerspam.de wrote:
> The importance of the order seems quite fragile to me, isn't it?
Definitely, that's why I'd like to make it simpler and more robust.
> I'd use functions, say `gnus-registry-initialize' and
> `spam-initialize' (or -install?) and autoload those functions:
Excellent, I don't know why I didn't think of something so obvious.
Thanks a lot, Reiner! Let me know if the attached patch looks OK.
Ted
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: autoloading-registry-and-spam.patch --]
[-- Type: text/x-patch, Size: 1776 bytes --]
? autoloading-registry-and-spam.patch
Index: gnus-registry.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-registry.el,v
retrieving revision 6.33
diff -u -r6.33 gnus-registry.el
--- gnus-registry.el 8 Sep 2003 18:25:57 -0000 6.33
+++ gnus-registry.el 9 Oct 2003 18:00:31 -0000
@@ -569,6 +569,14 @@
(setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))
(setq gnus-registry-dirty t))
+;;;###autoload
+(defun gnus-registry-initialize ()
+ (interactive)
+ (setq gnus-registry-install t)
+ (gnus-registry-install-hooks)
+ (gnus-registry-read))
+
+;;;###autoload
(defun gnus-registry-install-hooks ()
"Install the registry hooks."
(interactive)
Index: spam.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/spam.el,v
retrieving revision 6.116
diff -u -r6.116 spam.el
--- spam.el 3 Oct 2003 18:58:33 -0000 6.116
+++ spam.el 9 Oct 2003 18:00:32 -0000
@@ -370,13 +370,6 @@
"Msx" gnus-summary-mark-as-spam
"\M-d" gnus-summary-mark-as-spam)
-;;; How to highlight a spam summary line.
-
-;; TODO: How do we redo this every time spam-face is customized?
-
-(push '((eq mark gnus-spam-mark) . spam-face)
- gnus-summary-highlight)
-
;; convenience functions
(defun spam-group-ham-mark-p (group mark &optional spam)
(when (stringp group)
@@ -1222,6 +1215,15 @@
nil))
\f
;;;; Hooks
+
+;;;###autoload
+(defun spam-initialize ()
+ (interactive)
+ (setq spam-install-hooks t)
+ (spam-install-hooks-function)
+ ;; TODO: How do we redo this every time spam-face is customized?
+ (push '((eq mark gnus-spam-mark) . spam-face)
+ gnus-summary-highlight))
;;;###autoload
(defun spam-install-hooks-function ()
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-09 18:00 ` Ted Zlatanov
@ 2003-10-09 19:37 ` Reíner Steib
2003-10-09 19:51 ` Ted Zlatanov
0 siblings, 1 reply; 7+ messages in thread
From: Reíner Steib @ 2003-10-09 19:37 UTC (permalink / raw)
On Thu, Oct 09 2003, Ted Zlatanov wrote:
> Let me know if the attached patch looks OK.
I don't understand the need and the use of the variable
`spam-install-hooks':
(defcustom spam-use-dig t
[...])
[... other spam-use-VAR defaulting to nil ...]
(defcustom spam-install-hooks (or
spam-use-dig
spam-use-blacklist
[...]
spam-use-stat
spam-use-spamoracle)
"Whether the spam hooks should be installed, default to t if one of
the spam-use-* variables is set." [...])
I.e. `spam-install-hooks' is always t when you load `spam.el'? If you
use the `spam-initialize' function, why do you need the variable
`spam-install-hooks' at all?
If it's not used anymore, you may issue a warning if it's bound while
loading `spam.el', i.e. if someone wants to use the obsoleted
interface.
> +;;;###autoload
> +(defun spam-initialize ()
> + (interactive)
> + (setq spam-install-hooks t)
> + (spam-install-hooks-function)
> + ;; TODO: How do we redo this every time spam-face is customized?
> + (push '((eq mark gnus-spam-mark) . spam-face)
> + gnus-summary-highlight))
Then, I'd add "(push ...) to `spam-install-hooks-function' and rename
it to `spam-initialize'.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-09 19:37 ` Reíner Steib
@ 2003-10-09 19:51 ` Ted Zlatanov
2003-10-10 16:05 ` Ted Zlatanov
0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2003-10-09 19:51 UTC (permalink / raw)
On Thu, 09 Oct 2003, 4.uce.03.r.s@nurfuerspam.de wrote:
On Thu, Oct 09 2003, Ted Zlatanov wrote:
>
>> Let me know if the attached patch looks OK.
>
> I don't understand the need and the use of the variable
> `spam-install-hooks':
It's legacy, I didn't want to disable it or people may suddenly find
their spam.el setup broken. Decisions, decisions...
> (defcustom spam-install-hooks (or
> spam-use-dig
> spam-use-blacklist
> [...]
> spam-use-stat
> spam-use-spamoracle)
> "Whether the spam hooks should be installed, default to t if one
> of
> the spam-use-* variables is set." [...])
> I.e. `spam-install-hooks' is always t when you load `spam.el'? If
> you use the `spam-initialize' function, why do you need the variable
> `spam-install-hooks' at all?
If no spam-use-* variables are set, spam-install-hooks remains nil.
That way you can load spam.el without installing the hooks (for
customization), and also you can force the installation of the hooks
without using a spam-use-* backend.
> If it's not used anymore, you may issue a warning if it's bound
> while loading `spam.el', i.e. if someone wants to use the obsoleted
> interface.
I may do that, is there any place this is done so I can see the error
message I should be using?
> Then, I'd add "(push ...) to `spam-install-hooks-function' and
> rename it to `spam-initialize'.
OK, thanks!
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: loading spam.el and gnus-registry.el with set variables only
2003-10-09 19:51 ` Ted Zlatanov
@ 2003-10-10 16:05 ` Ted Zlatanov
0 siblings, 0 replies; 7+ messages in thread
From: Ted Zlatanov @ 2003-10-10 16:05 UTC (permalink / raw)
OK, spam-initialize (replaces spam-install-hooks-function) and
gnus-registry-initialize have been put in CVS, autoloaded as Reiner
suggested. I tried to keep the existing setups of people who may have
spam-install-hooks or gnus-registry-install set to t and do a manual
require, so those variables should still be respected. Please let me
know if there are problems.
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-10-10 16:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-07 18:44 loading spam.el and gnus-registry.el with set variables only Ted Zlatanov
2003-10-09 14:42 ` Ted Zlatanov
2003-10-09 16:24 ` Reiner Steib
2003-10-09 18:00 ` Ted Zlatanov
2003-10-09 19:37 ` Reíner Steib
2003-10-09 19:51 ` Ted Zlatanov
2003-10-10 16:05 ` Ted Zlatanov
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 NNTP newsgroup(s).