* run-hooks vs. run-mode-hooks.
@ 2005-05-25 12:28 Lute Kamstra
2005-05-26 5:59 ` Richard Stallman
0 siblings, 1 reply; 16+ messages in thread
From: Lute Kamstra @ 2005-05-25 12:28 UTC (permalink / raw)
Can somebody confirm that this change is correct?
Lute.
Index: src/eval.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/eval.c,v
retrieving revision 1.238
diff -C4 -r1.238 eval.c
*** src/eval.c 8 May 2005 16:30:13 -0000 1.238
--- src/eval.c 25 May 2005 12:25:23 -0000
***************
*** 2291,2306 ****
static Lisp_Object run_hook_with_args P_ ((int, Lisp_Object *,
enum run_hooks_condition));
DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0,
! doc: /* Run each hook in HOOKS. Major mode functions use this.
Each argument should be a symbol, a hook variable.
These symbols are processed in the order specified.
If a hook symbol has a non-nil value, that value may be a function
or a list of functions to be called to run the hook.
If the value is a function, it is called with no arguments.
If it is a list, the elements are called, in order, with no arguments.
Do not use `make-local-variable' to make a hook variable buffer-local.
Instead, use `add-hook' and specify t for the LOCAL argument.
usage: (run-hooks &rest HOOKS) */)
(nargs, args)
--- 2291,2309 ----
static Lisp_Object run_hook_with_args P_ ((int, Lisp_Object *,
enum run_hooks_condition));
DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0,
! doc: /* Run each hook in HOOKS.
Each argument should be a symbol, a hook variable.
These symbols are processed in the order specified.
If a hook symbol has a non-nil value, that value may be a function
or a list of functions to be called to run the hook.
If the value is a function, it is called with no arguments.
If it is a list, the elements are called, in order, with no arguments.
+ Major modes should not use this function directly to run their mode
+ hook; they should use `run-mode-hooks' instead.
+
Do not use `make-local-variable' to make a hook variable buffer-local.
Instead, use `add-hook' and specify t for the LOCAL argument.
usage: (run-hooks &rest HOOKS) */)
(nargs, args)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-25 12:28 run-hooks vs. run-mode-hooks Lute Kamstra
@ 2005-05-26 5:59 ` Richard Stallman
2005-05-27 0:58 ` Katsumi Yamaoka
0 siblings, 1 reply; 16+ messages in thread
From: Richard Stallman @ 2005-05-26 5:59 UTC (permalink / raw)
Cc: emacs-devel
This change is correct--please install it.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-26 5:59 ` Richard Stallman
@ 2005-05-27 0:58 ` Katsumi Yamaoka
2005-05-27 1:40 ` Lute Kamstra
2005-05-27 14:20 ` Richard Stallman
0 siblings, 2 replies; 16+ messages in thread
From: Katsumi Yamaoka @ 2005-05-27 0:58 UTC (permalink / raw)
Cc: emacs-devel, ding
Hi,
run-mode-hooks is only available in Emacs 22, while Gnus v5.11
still supports Emacs 20 and 21 (and No Gnus supports Emacs 21).
2005-05-26 Lute Kamstra <lute@gnu.org>
* score-mode.el (gnus-score-mode): Use run-mode-hooks.
Is it possible to use run-hooks in those Emacs versions?
Regards,
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 0:58 ` Katsumi Yamaoka
@ 2005-05-27 1:40 ` Lute Kamstra
2005-05-27 3:32 ` Katsumi Yamaoka
2005-05-27 8:01 ` Juanma Barranquero
2005-05-27 14:20 ` Richard Stallman
1 sibling, 2 replies; 16+ messages in thread
From: Lute Kamstra @ 2005-05-27 1:40 UTC (permalink / raw)
Cc: emacs-devel, ding
Katsumi Yamaoka <yamaoka@jpl.org> writes:
> run-mode-hooks is only available in Emacs 22, while Gnus v5.11
> still supports Emacs 20 and 21 (and No Gnus supports Emacs 21).
>
> 2005-05-26 Lute Kamstra <lute@gnu.org>
>
> * score-mode.el (gnus-score-mode): Use run-mode-hooks.
Sorry about that.
> Is it possible to use run-hooks in those Emacs versions?
Maybe Gnus can do something like:
(or (fboundp 'run-mode-hooks)
(defalias 'run-mode-hooks 'run-hooks))
I saw that most hooks are run with gnus-run-hooks, which calls
run-hooks. Maybe you can also define a gnus-run-mode-hooks that uses
run-mode-hooks instead and use that function for Gnus' major modes?
Lute.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 1:40 ` Lute Kamstra
@ 2005-05-27 3:32 ` Katsumi Yamaoka
2005-05-27 8:01 ` Juanma Barranquero
1 sibling, 0 replies; 16+ messages in thread
From: Katsumi Yamaoka @ 2005-05-27 3:32 UTC (permalink / raw)
Cc: emacs-devel, ding
>>>>> In <87hdgp4fa1.fsf@xs4all.nl> Lute Kamstra wrote:
>> Is it possible to use run-hooks in those Emacs versions?
> Maybe Gnus can do something like:
> (or (fboundp 'run-mode-hooks)
> (defalias 'run-mode-hooks 'run-hooks))
> I saw that most hooks are run with gnus-run-hooks, which calls
> run-hooks. Maybe you can also define a gnus-run-mode-hooks that uses
> run-mode-hooks instead and use that function for Gnus' major modes?
I've added gnus-run-mode-hooks to both the Gnus trunk and the
v5-10 branch (synch'd with the Emacs trunk). Thank you for the
good suggestion.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 1:40 ` Lute Kamstra
2005-05-27 3:32 ` Katsumi Yamaoka
@ 2005-05-27 8:01 ` Juanma Barranquero
2005-05-27 16:07 ` Stefan Monnier
1 sibling, 1 reply; 16+ messages in thread
From: Juanma Barranquero @ 2005-05-27 8:01 UTC (permalink / raw)
> Maybe Gnus can do something like:
>
> (or (fboundp 'run-mode-hooks)
> (defalias 'run-mode-hooks 'run-hooks))
(Not in this case, that's already been fixed but) that would not be good.
The usual answer is making your own lookalike:
(if (fboundp 'function-in-doubt)
(defalias 'mymodule-function-in-doubt 'function-in-doubt)
(defun mymodule-function-in-doubt ...))
Otherwise, you're gonna mislead any module loaded afterwards that
tries to determine whether 'function-in-doubt exists or not.
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 0:58 ` Katsumi Yamaoka
2005-05-27 1:40 ` Lute Kamstra
@ 2005-05-27 14:20 ` Richard Stallman
2005-05-27 15:12 ` Lute Kamstra
1 sibling, 1 reply; 16+ messages in thread
From: Richard Stallman @ 2005-05-27 14:20 UTC (permalink / raw)
Cc: Lute.Kamstra.lists, ding, emacs-devel
Is it possible to use run-hooks in those Emacs versions?
Yes, but it won't always be correct.
Maybe Gnus can do something like:
(or (fboundp 'run-mode-hooks)
(defalias 'run-mode-hooks 'run-hooks))
Definitely not! Gnus should not mess with the way Emacs defines
(or doesn't define) these functions!
Gnus should define a function called gnus-run-mode-hooks, which calls
run-mode-hooks if that is defined, otherwise run-hooks. Then all the
modes in Gnus could use gnus-run-mode-hooks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 14:20 ` Richard Stallman
@ 2005-05-27 15:12 ` Lute Kamstra
2005-05-27 21:43 ` Miles Bader
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Lute Kamstra @ 2005-05-27 15:12 UTC (permalink / raw)
Cc: Katsumi Yamaoka, ding, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> Maybe Gnus can do something like:
>
> (or (fboundp 'run-mode-hooks)
> (defalias 'run-mode-hooks 'run-hooks))
>
> Definitely not! Gnus should not mess with the way Emacs defines
> (or doesn't define) these functions!
It seems that that I was badly educated by code I read: I've quite
often seen the use of constructs like the one above.
> Gnus should define a function called gnus-run-mode-hooks, which calls
> run-mode-hooks if that is defined, otherwise run-hooks. Then all the
> modes in Gnus could use gnus-run-mode-hooks.
That's what Katsumi did for gnus-score-mode. Other major mode in Gnus
still use gnus-run-hooks which uses run-hooks. Katsumi, could you fix
those modes in a similar way?
Lute.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 8:01 ` Juanma Barranquero
@ 2005-05-27 16:07 ` Stefan Monnier
2005-05-27 16:45 ` Drew Adams
2005-05-27 23:37 ` Juanma Barranquero
0 siblings, 2 replies; 16+ messages in thread
From: Stefan Monnier @ 2005-05-27 16:07 UTC (permalink / raw)
Cc: emacs-devel
> (if (fboundp 'function-in-doubt)
> (defalias 'mymodule-function-in-doubt 'function-in-doubt)
> (defun mymodule-function-in-doubt ...))
Actually this form has the disadvantage that the byte-compiler would have to
check which functions are defnied in every branch. And snice it doesn't do
that as of now, the byte-compiler won't noticve that this form does define
`mymodule-function-in-doubt' and will hencforth issue warnings when you call
that function.
Better use:
(defalias 'mymodule-function-in-doubt
(if (fboundp 'function-in-doubt)
'function-in-doubt
(lambda (..) ...)))
which makes it trivially obvious that `mymodule-function-in-doubt' will
indeed always be defined.
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: run-hooks vs. run-mode-hooks.
2005-05-27 16:07 ` Stefan Monnier
@ 2005-05-27 16:45 ` Drew Adams
2005-05-27 23:37 ` Juanma Barranquero
1 sibling, 0 replies; 16+ messages in thread
From: Drew Adams @ 2005-05-27 16:45 UTC (permalink / raw)
> (if (fboundp 'function-in-doubt)
> (defalias 'mymodule-function-in-doubt 'function-in-doubt)
> (defun mymodule-function-in-doubt ...))
Actually this form has the disadvantage that the
byte-compiler would have to check which functions
are defnied in every branch. And snice it doesn't
do that as of now, the byte-compiler won't noticve
that this form does define
`mymodule-function-in-doubt' and will hencforth
issue warnings when you call that function.
Better use:
(defalias 'mymodule-function-in-doubt
(if (fboundp 'function-in-doubt)
'function-in-doubt
(lambda (..) ...)))
which makes it trivially obvious that `mymodule-function-in-doubt' will
indeed always be defined.
Is the behavior of the byte-compiler for this kind of thing explained
somewhere? That is, are there coding guidelines somewhere to guide Lisp
users wrt the byte compiler?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 15:12 ` Lute Kamstra
@ 2005-05-27 21:43 ` Miles Bader
2005-05-27 23:48 ` Katsumi Yamaoka
2005-05-28 11:52 ` Richard Stallman
2 siblings, 0 replies; 16+ messages in thread
From: Miles Bader @ 2005-05-27 21:43 UTC (permalink / raw)
Cc: ding
Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes:
> It seems that that I was badly educated by code I read: I've quite
> often seen the use of constructs like the one above.
There is, or at least used to be, a fair amount of bad old code that
does stuff like that. One of the worst offenders was (not sure if it's
been fixed) w3.
I remember lots of bug reports where the problem was eventually revealed
to be some package getting confused by w3's mucking around with the
namespace.
-Miles
--
Yo mama's so fat when she gets on an elevator it HAS to go down.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 16:07 ` Stefan Monnier
2005-05-27 16:45 ` Drew Adams
@ 2005-05-27 23:37 ` Juanma Barranquero
1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2005-05-27 23:37 UTC (permalink / raw)
> Better use:
>
> (defalias 'mymodule-function-in-doubt
> (if (fboundp 'function-in-doubt)
> 'function-in-doubt
> (lambda (..) ...)))
I was only highlighting the fact that defining functions from "future"
Emacsen is Not Good, but yes, your way is better. Every non-contrived
way to get rid of warnings is good in my book :)
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 15:12 ` Lute Kamstra
2005-05-27 21:43 ` Miles Bader
@ 2005-05-27 23:48 ` Katsumi Yamaoka
2005-05-30 6:45 ` Katsumi Yamaoka
2005-05-28 11:52 ` Richard Stallman
2 siblings, 1 reply; 16+ messages in thread
From: Katsumi Yamaoka @ 2005-05-27 23:48 UTC (permalink / raw)
Cc: rms, ding, emacs-devel
> Richard Stallman <rms@gnu.org> writes:
>> Gnus should define a function called gnus-run-mode-hooks, which calls
>> run-mode-hooks if that is defined, otherwise run-hooks. Then all the
>> modes in Gnus could use gnus-run-mode-hooks.
>>>>> In <87br6w8zzo.fsf@xs4all.nl>
>>>>> Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> wrote:
> That's what Katsumi did for gnus-score-mode. Other major mode in Gnus
> still use gnus-run-hooks which uses run-hooks. Katsumi, could you fix
> those modes in a similar way?
Ok, I'll make time to do that, maybe in Monday.
Regards,
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 15:12 ` Lute Kamstra
2005-05-27 21:43 ` Miles Bader
2005-05-27 23:48 ` Katsumi Yamaoka
@ 2005-05-28 11:52 ` Richard Stallman
2 siblings, 0 replies; 16+ messages in thread
From: Richard Stallman @ 2005-05-28 11:52 UTC (permalink / raw)
Cc: yamaoka, ding, emacs-devel
> (or (fboundp 'run-mode-hooks)
> (defalias 'run-mode-hooks 'run-hooks))
It seems that that I was badly educated by code I read: I've quite
often seen the use of constructs like the one above.
Are there any examples in the Emacs sources?
If so, could you show me a few?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-27 23:48 ` Katsumi Yamaoka
@ 2005-05-30 6:45 ` Katsumi Yamaoka
2005-05-31 4:17 ` Richard Stallman
0 siblings, 1 reply; 16+ messages in thread
From: Katsumi Yamaoka @ 2005-05-30 6:45 UTC (permalink / raw)
Cc: rms, ding, emacs-devel
>>>>>> In <87br6w8zzo.fsf@xs4all.nl>
>>>>>> Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> wrote:
>> Other major mode in Gnus still use gnus-run-hooks which uses
>> run-hooks. Katsumi, could you fix those modes in a similar way?
>>>>> In <yotld5rccjry.fsf@jpl.org> Katsumi Yamaoka wrote:
> Ok, I'll make time to do that, maybe in Monday.
>>>>> In <E1DbfhH-0004Zk-BU@fencepost.gnu.org> Richard Stallman wrote:
> Is it possible to use run-hooks in those Emacs versions?
> Gnus should define a function called gnus-run-mode-hooks, which calls
> run-mode-hooks if that is defined, otherwise run-hooks. Then all the
> modes in Gnus could use gnus-run-mode-hooks.
I've done it in the Gnus trunk and the v5-10 branch.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: run-hooks vs. run-mode-hooks.
2005-05-30 6:45 ` Katsumi Yamaoka
@ 2005-05-31 4:17 ` Richard Stallman
0 siblings, 0 replies; 16+ messages in thread
From: Richard Stallman @ 2005-05-31 4:17 UTC (permalink / raw)
Cc: Lute.Kamstra.lists, ding, emacs-devel
> Gnus should define a function called gnus-run-mode-hooks, which calls
> run-mode-hooks if that is defined, otherwise run-hooks. Then all the
> modes in Gnus could use gnus-run-mode-hooks.
I've done it in the Gnus trunk and the v5-10 branch.
Thank you.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2005-05-31 4:17 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-25 12:28 run-hooks vs. run-mode-hooks Lute Kamstra
2005-05-26 5:59 ` Richard Stallman
2005-05-27 0:58 ` Katsumi Yamaoka
2005-05-27 1:40 ` Lute Kamstra
2005-05-27 3:32 ` Katsumi Yamaoka
2005-05-27 8:01 ` Juanma Barranquero
2005-05-27 16:07 ` Stefan Monnier
2005-05-27 16:45 ` Drew Adams
2005-05-27 23:37 ` Juanma Barranquero
2005-05-27 14:20 ` Richard Stallman
2005-05-27 15:12 ` Lute Kamstra
2005-05-27 21:43 ` Miles Bader
2005-05-27 23:48 ` Katsumi Yamaoka
2005-05-30 6:45 ` Katsumi Yamaoka
2005-05-31 4:17 ` Richard Stallman
2005-05-28 11:52 ` Richard Stallman
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.