* bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
@ 2011-03-17 14:52 Julien Danjou
2011-03-18 17:39 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Julien Danjou @ 2011-03-17 14:52 UTC (permalink / raw)
To: 8274; +Cc: Julien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
---
I've seen a little comment in lisp.h indicating that Frun_hooks should be
the good way to call hooks, which make sense. This patch is a try to
factorize the remaining code not using that function and remove their direct
calls to Vrun_hooks.
I'm not very familiar with Emacs code yet, so feel free to correct this.
src/ChangeLog | 29 +++++++++++++++++++++++++++++
src/buffer.c | 3 +--
src/callint.c | 3 +--
src/cmds.c | 2 +-
src/editfns.c | 25 ++++++++++++++-----------
src/emacs.c | 5 +++--
src/fileio.c | 6 +++---
src/frame.c | 2 +-
src/insdel.c | 6 ++----
src/keyboard.c | 35 +++++++++++++++--------------------
src/minibuf.c | 12 ++----------
src/term.c | 22 ++++++++--------------
src/window.c | 38 +++++++++++++++++---------------------
13 files changed, 97 insertions(+), 91 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 2797ca2..32c2b8d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,32 @@
+2011-03-17 Julien Danjou <julien@danjou.info>
+
+ * term.c (Fsuspend_tty, Fresume_tty): Use Frun_hooks.
+
+ * minibuf.c (read_minibuf, run_exit_minibuf_hook): Use Frun_hooks.
+
+ * window.c (temp_output_buffer_show): Use Frun_hooks.
+
+ * keyboard.c (Fcommand_execute, Fsuspend_emacs, safe_run_hooks_1):
+ Use Frun_hooks.
+ (command_loop_1): Use Frun_hooks. Call safe_run_hooks
+ unconditionnaly since it does the check itself.
+
+ * insdel.c (signal_before_change): Use Frun_hooks.
+
+ * frame.c (Fhandle_switch_frame): Use Frun_hooks.
+
+ * fileio.c (Fdo_auto_save): Use Frun_hooks.
+
+ * emacs.c (Fkill_emacs): Use Frun_hooks.
+
+ * editfns.c (save_excursion_restore): Use Frun_hooks.
+
+ * cmds.c (internal_self_insert): Use Frun_hooks.
+
+ * callint.c (Fcall_interactively): Use Frun_hooks.
+
+ * buffer.c (Fkill_all_local_variables): Use Frun_hooks.
+
2011-03-16 Stefan Monnier <monnier@iro.umontreal.ca>
* print.c (PRINT_CIRCLE_CANDIDATE_P): New macro.
diff --git a/src/buffer.c b/src/buffer.c
index c0485c1..152b06d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2520,8 +2520,7 @@ The first thing this function does is run
the normal hook `change-major-mode-hook'. */)
(void)
{
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qchange_major_mode_hook);
+ Frun_hooks (1, &Qchange_major_mode_hook);
/* Make sure none of the bindings in local_var_alist
remain swapped in, in their symbols. */
diff --git a/src/callint.c b/src/callint.c
index 21dd3cd..5171736 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -423,8 +423,7 @@ invoke it. If KEYS is omitted or nil, the return value of
error ("Attempt to select inactive minibuffer window");
/* If the current buffer wants to clean up, let it. */
- if (!NILP (Vmouse_leave_buffer_hook))
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
Fselect_window (tem, Qnil);
}
diff --git a/src/cmds.c b/src/cmds.c
index 5e6884c..7cb3695 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -501,7 +501,7 @@ internal_self_insert (int c, EMACS_INT n)
}
/* Run hooks for electric keys. */
- call1 (Vrun_hooks, Qpost_self_insert_hook);
+ Frun_hooks (1, &Qpost_self_insert_hook);
return hairy;
}
diff --git a/src/editfns.c b/src/editfns.c
index d92d348..4ad55fc 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -928,18 +928,21 @@ save_excursion_restore (Lisp_Object info)
tem1 = BVAR (current_buffer, mark_active);
BVAR (current_buffer, mark_active) = tem;
- if (!NILP (Vrun_hooks))
+ /* If mark is active now, and either was not active
+ or was at a different place, run the activate hook. */
+ if (! NILP (BVAR (current_buffer, mark_active)))
{
- /* If mark is active now, and either was not active
- or was at a different place, run the activate hook. */
- if (! NILP (BVAR (current_buffer, mark_active)))
- {
- if (! EQ (omark, nmark))
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
- }
- /* If mark has ceased to be active, run deactivate hook. */
- else if (! NILP (tem1))
- call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
+ if (! EQ (omark, nmark))
+ {
+ tem = intern ("activate-mark-hook");
+ Frun_hooks (1, &tem);
+ }
+ }
+ /* If mark has ceased to be active, run deactivate hook. */
+ else if (! NILP (tem1))
+ {
+ tem = intern ("deactivate-mark-hook");
+ Frun_hooks (1, &tem);
}
/* If buffer was visible in a window, and a different window was
diff --git a/src/emacs.c b/src/emacs.c
index 84092e1..9eb501b 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1971,14 +1971,15 @@ all of which are called before Emacs is actually killed. */)
(Lisp_Object arg)
{
struct gcpro gcpro1;
+ Lisp_Object hook;
GCPRO1 (arg);
if (feof (stdin))
arg = Qt;
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("kill-emacs-hook"));
+ hook = intern ("kill-emacs-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
diff --git a/src/fileio.c b/src/fileio.c
index 18e9dbe9..8c3a422 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5174,7 +5174,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
(Lisp_Object no_message, Lisp_Object current_only)
{
struct buffer *old = current_buffer, *b;
- Lisp_Object tail, buf;
+ Lisp_Object tail, buf, hook;
int auto_saved = 0;
int do_handled_files;
Lisp_Object oquit;
@@ -5204,8 +5204,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
/* No GCPRO needed, because (when it matters) all Lisp_Object variables
point to non-strings reached from Vbuffer_alist. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("auto-save-hook"));
+ hook = intern ("auto-save-hook");
+ Frun_hooks (1, &hook);
if (STRINGP (Vauto_save_list_file_name))
{
diff --git a/src/frame.c b/src/frame.c
index 05938f3..0b8689d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -890,7 +890,7 @@ to that frame. */)
{
/* Preserve prefix arg that the command loop just cleared. */
KVAR (current_kboard, Vprefix_arg) = Vcurrent_prefix_arg;
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
return do_switch_frame (event, 0, 0, Qnil);
}
diff --git a/src/insdel.c b/src/insdel.c
index bdf6aff..686466a 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -2136,13 +2136,11 @@ signal_before_change (EMACS_INT start_int, EMACS_INT end_int,
specbind (Qinhibit_modification_hooks, Qt);
/* If buffer is unmodified, run a special hook for that case. */
- if (SAVE_MODIFF >= MODIFF
- && !NILP (Vfirst_change_hook)
- && !NILP (Vrun_hooks))
+ if (SAVE_MODIFF >= MODIFF)
{
PRESERVE_VALUE;
PRESERVE_START_END;
- call1 (Vrun_hooks, Qfirst_change_hook);
+ Frun_hooks (1, &Qfirst_change_hook);
}
/* Now run the before-change-functions if any. */
diff --git a/src/keyboard.c b/src/keyboard.c
index e9c6d50..25ca38b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1490,10 +1490,7 @@ command_loop_1 (void)
Vthis_command = cmd;
real_this_command = cmd;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
- safe_run_hooks (Qpre_command_hook);
+ safe_run_hooks (Qpre_command_hook);
already_adjusted = 0;
@@ -1539,18 +1536,14 @@ command_loop_1 (void)
}
KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
- safe_run_hooks (Qpost_command_hook);
+ safe_run_hooks (Qpost_command_hook);
/* If displaying a message, resize the echo area window to fit
that message's size exactly. */
if (!NILP (echo_area_buffer[0]))
resize_echo_area_exactly ();
- if (!NILP (Vdeferred_action_list))
- safe_run_hooks (Qdeferred_action_function);
+ safe_run_hooks (Qdeferred_action_function);
/* If there is a prefix argument,
1) We don't want Vlast_command to be ``universal-argument''
@@ -1619,7 +1612,10 @@ command_loop_1 (void)
}
if (current_buffer != prev_buffer || MODIFF != prev_modiff)
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ {
+ Lisp_Object hook = intern ("activate-mark-hook");
+ Frun_hooks (1, &hook);
+ }
}
Vsaved_region_selection = Qnil;
@@ -1817,9 +1813,7 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
static Lisp_Object
safe_run_hooks_1 (void)
{
- if (NILP (Vrun_hooks))
- return Qnil;
- return call1 (Vrun_hooks, Vinhibit_quit);
+ return Frun_hooks (1, &Vinhibit_quit);
}
/* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */
@@ -10125,11 +10119,11 @@ a special event, so ignore the prefix argument and don't clear it. */)
if (SYMBOLP (cmd))
{
tem = Fget (cmd, Qdisabled);
- if (!NILP (tem) && !NILP (Vrun_hooks))
+ if (!NILP (tem))
{
tem = Fsymbol_value (Qdisabled_command_function);
if (!NILP (tem))
- return call1 (Vrun_hooks, Qdisabled_command_function);
+ return Frun_hooks (1, &Qdisabled_command_function);
}
}
@@ -10613,6 +10607,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
int old_height, old_width;
int width, height;
struct gcpro gcpro1;
+ Lisp_Object hook;
if (tty_list && tty_list->next)
error ("There are other tty frames open; close them before suspending Emacs");
@@ -10621,8 +10616,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
CHECK_STRING (stuffstring);
/* Run the functions in suspend-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-hook"));
+ hook = intern ("suspend-hook");
+ Frun_hooks (1, &hook);
GCPRO1 (stuffstring);
get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
@@ -10646,8 +10641,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
/* Run suspend-resume-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-resume-hook"));
+ hook = intern ("suspend-resume-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
return Qnil;
diff --git a/src/minibuf.c b/src/minibuf.c
index 83587b5..4ce705b 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -648,12 +648,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method)))
call1 (Qactivate_input_method, input_method);
- /* Run our hook, but not if it is empty.
- (run-hooks would do nothing if it is empty,
- but it's important to save time here in the usual case.) */
- if (!NILP (Vminibuffer_setup_hook) && !EQ (Vminibuffer_setup_hook, Qunbound)
- && !NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qminibuffer_setup_hook);
+ Frun_hooks (1, &Qminibuffer_setup_hook);
/* Don't allow the user to undo past this point. */
BVAR (current_buffer, undo_list) = Qnil;
@@ -805,10 +800,7 @@ get_minibuffer (int depth)
static Lisp_Object
run_exit_minibuf_hook (Lisp_Object data)
{
- if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
- && !NILP (Vrun_hooks))
- safe_run_hooks (Qminibuffer_exit_hook);
-
+ safe_run_hooks (Qminibuffer_exit_hook);
return Qnil;
}
diff --git a/src/term.c b/src/term.c
index e84bbe1..739b7c4 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2500,13 +2500,10 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
/* First run `suspend-tty-functions' and then clean up the tty
state because `suspend-tty-functions' might need to change
the tty state. */
- if (!NILP (Vrun_hooks))
- {
- Lisp_Object args[2];
- args[0] = intern ("suspend-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ Lisp_Object args[2];
+ args[0] = intern ("suspend-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
@@ -2597,13 +2594,10 @@ frame's terminal). */)
init_sys_modes (t->display_info.tty);
/* Run `resume-tty-functions'. */
- if (!NILP (Vrun_hooks))
- {
- Lisp_Object args[2];
- args[0] = intern ("resume-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ Lisp_Object args[2];
+ args[0] = intern ("resume-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
}
set_tty_hooks (t);
diff --git a/src/window.c b/src/window.c
index eaa9105..9ab9fab 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3690,27 +3690,23 @@ temp_output_buffer_show (register Lisp_Object buf)
/* Run temp-buffer-show-hook, with the chosen window selected
and its buffer current. */
-
- if (!NILP (Vrun_hooks)
- && !NILP (Fboundp (Qtemp_buffer_show_hook))
- && !NILP (Fsymbol_value (Qtemp_buffer_show_hook)))
- {
- int count = SPECPDL_INDEX ();
- Lisp_Object prev_window, prev_buffer;
- prev_window = selected_window;
- XSETBUFFER (prev_buffer, old);
-
- /* Select the window that was chosen, for running the hook.
- Note: Both Fselect_window and select_window_norecord may
- set-buffer to the buffer displayed in the window,
- so we need to save the current buffer. --stef */
- record_unwind_protect (Fset_buffer, prev_buffer);
- record_unwind_protect (select_window_norecord, prev_window);
- Fselect_window (window, Qt);
- Fset_buffer (w->buffer);
- call1 (Vrun_hooks, Qtemp_buffer_show_hook);
- unbind_to (count, Qnil);
- }
+ {
+ int count = SPECPDL_INDEX ();
+ Lisp_Object prev_window, prev_buffer;
+ prev_window = selected_window;
+ XSETBUFFER (prev_buffer, old);
+
+ /* Select the window that was chosen, for running the hook.
+ Note: Both Fselect_window and select_window_norecord may
+ set-buffer to the buffer displayed in the window,
+ so we need to save the current buffer. --stef */
+ record_unwind_protect (Fset_buffer, prev_buffer);
+ record_unwind_protect (select_window_norecord, prev_window);
+ Fselect_window (window, Qt);
+ Fset_buffer (w->buffer);
+ Frun_hooks (1, &Qtemp_buffer_show_hook);
+ unbind_to (count, Qnil);
+ }
}
}
\f
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
2011-03-17 14:52 bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually Julien Danjou
@ 2011-03-18 17:39 ` Stefan Monnier
2011-03-21 14:35 ` Julien Danjou
2011-03-23 10:20 ` Julien Danjou
0 siblings, 2 replies; 4+ messages in thread
From: Stefan Monnier @ 2011-03-18 17:39 UTC (permalink / raw)
To: Julien Danjou; +Cc: 8274
> I've seen a little comment in lisp.h indicating that Frun_hooks should be
> the good way to call hooks, which make sense. This patch is a try to
> factorize the remaining code not using that function and remove their direct
> calls to Vrun_hooks.
Thanks, this looks like a good (tho not important) change.
A few comments below.
> +2011-03-17 Julien Danjou <julien@danjou.info>
> +
> + * term.c (Fsuspend_tty, Fresume_tty): Use Frun_hooks.
> +
> + * minibuf.c (read_minibuf, run_exit_minibuf_hook): Use Frun_hooks.
> +
> + * window.c (temp_output_buffer_show): Use Frun_hooks.
> +
> + * keyboard.c (Fcommand_execute, Fsuspend_emacs, safe_run_hooks_1):
> + Use Frun_hooks.
> + (command_loop_1): Use Frun_hooks. Call safe_run_hooks
> + unconditionnaly since it does the check itself.
> +
> + * insdel.c (signal_before_change): Use Frun_hooks.
> +
> + * frame.c (Fhandle_switch_frame): Use Frun_hooks.
> +
> + * fileio.c (Fdo_auto_save): Use Frun_hooks.
> +
> + * emacs.c (Fkill_emacs): Use Frun_hooks.
> +
> + * editfns.c (save_excursion_restore): Use Frun_hooks.
> +
> + * cmds.c (internal_self_insert): Use Frun_hooks.
> +
> + * callint.c (Fcall_interactively): Use Frun_hooks.
> +
> + * buffer.c (Fkill_all_local_variables): Use Frun_hooks.
You don't need the empty lines between each one of the above, since they
logically belong together. You can also leave a text empty after the
":" to mean "same as the next". E.g.
* cmds.c (internal_self_insert):
* callint.c (Fcall_interactively):
* buffer.c (Fkill_all_local_variables): Use Frun_hooks.
I dislike this form when there's an empty line between the items, but
otherwise I like it.
> @@ -928,18 +928,21 @@ save_excursion_restore (Lisp_Object info)
> tem1 = BVAR (current_buffer, mark_active);
> BVAR (current_buffer, mark_active) = tem;
> - if (!NILP (Vrun_hooks))
> + /* If mark is active now, and either was not active
> + or was at a different place, run the activate hook. */
> + if (! NILP (BVAR (current_buffer, mark_active)))
[ This is not introduced by your change, but it's a good opportunity to
clean it up. ]
The above "BVAR (current_buffer, mark_active)" should necessarily be
equal to `tem', so please use `tem' here to clarify.
> {
> - /* If mark is active now, and either was not active
> - or was at a different place, run the activate hook. */
> - if (! NILP (BVAR (current_buffer, mark_active)))
> - {
> - if (! EQ (omark, nmark))
> - call1 (Vrun_hooks, intern ("activate-mark-hook"));
> - }
> - /* If mark has ceased to be active, run deactivate hook. */
> - else if (! NILP (tem1))
> - call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
> + if (! EQ (omark, nmark))
> + {
> + tem = intern ("activate-mark-hook");
> + Frun_hooks (1, &tem);
> + }
> + }
> + /* If mark has ceased to be active, run deactivate hook. */
> + else if (! NILP (tem1))
> + {
> + tem = intern ("deactivate-mark-hook");
> + Frun_hooks (1, &tem);
> }
When sending patches for review, you can use "-w" so reindentation does
not interfere.
> /* If buffer is unmodified, run a special hook for that case. */
> - if (SAVE_MODIFF >= MODIFF
> - && !NILP (Vfirst_change_hook)
> - && !NILP (Vrun_hooks))
> + if (SAVE_MODIFF >= MODIFF)
Please leave the !NILP (Vfirst_change_hook) test which is an
optimization (this hook is almost never used). You could add a quick
comment mentioning it's just an optimization.
> @@ -2597,13 +2594,10 @@ frame's terminal). */)
> init_sys_modes (t->display_info.tty);
> /* Run `resume-tty-functions'. */
> - if (!NILP (Vrun_hooks))
> - {
> - Lisp_Object args[2];
> - args[0] = intern ("resume-tty-functions");
> - XSETTERMINAL (args[1], t);
> - Frun_hook_with_args (2, args);
> - }
> + Lisp_Object args[2];
> + args[0] = intern ("resume-tty-functions");
> + XSETTERMINAL (args[1], t);
> + Frun_hook_with_args (2, args);
> }
This declares a variable in the middle of a block, which is a "recent"
feature of C on which we do not want to rely yet.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
2011-03-18 17:39 ` Stefan Monnier
@ 2011-03-21 14:35 ` Julien Danjou
2011-03-23 10:20 ` Julien Danjou
1 sibling, 0 replies; 4+ messages in thread
From: Julien Danjou @ 2011-03-21 14:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 8274
[-- Attachment #1.1: Type: text/plain, Size: 1549 bytes --]
On Fri, Mar 18 2011, Stefan Monnier wrote:
> Thanks, this looks like a good (tho not important) change.
Yes. This is not was I wanting to hack at first, but I can't resist some
grunt work. :)
> You don't need the empty lines between each one of the above, since they
> logically belong together. You can also leave a text empty after the
> ":" to mean "same as the next". E.g.
>
> * cmds.c (internal_self_insert):
> * callint.c (Fcall_interactively):
> * buffer.c (Fkill_all_local_variables): Use Frun_hooks.
>
> I dislike this form when there's an empty line between the items, but
> otherwise I like it.
Ok. I just used `C-x 4 a' blindly, did not know that was authorized. :)
Fixed.
> [ This is not introduced by your change, but it's a good opportunity to
> clean it up. ]
> The above "BVAR (current_buffer, mark_active)" should necessarily be
> equal to `tem', so please use `tem' here to clarify.
Sure, fixed.
> When sending patches for review, you can use "-w" so reindentation does
> not interfere.
Well, I'll send both then, so you'll be able to review and merge if that
version is ok.
> Please leave the !NILP (Vfirst_change_hook) test which is an
> optimization (this hook is almost never used). You could add a quick
> comment mentioning it's just an optimization.
Done, with a comment, so I won't try to remove it once again later. :)
> This declares a variable in the middle of a block, which is a "recent"
> feature of C on which we do not want to rely yet.
Right, I've added a simple {} block, I hope that's ok.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Use-Frun_hooks-rather-than-calling-Vrun_hooks-manual-review.patch --]
[-- Type: text/x-diff, Size: 13192 bytes --]
From c8f051ae7c702b052b2ae417b884ec4889bec0de Mon Sep 17 00:00:00 2001
From: Julien Danjou <julien@danjou.info>
Date: Thu, 17 Mar 2011 12:02:38 +0100
Subject: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
Signed-off-by: Julien Danjou <julien@danjou.info>
---
src/ChangeLog | 18 ++++++++++++++++++
src/buffer.c | 3 +--
src/callint.c | 3 +--
src/cmds.c | 2 +-
src/editfns.c | 13 ++++++++-----
src/emacs.c | 5 +++--
src/fileio.c | 6 +++---
src/frame.c | 2 +-
src/insdel.c | 8 ++++----
src/keyboard.c | 29 ++++++++++++-----------------
src/minibuf.c | 10 +---------
src/term.c | 6 +-----
src/window.c | 6 +-----
13 files changed, 55 insertions(+), 56 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index d6dd038..9e24e3c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
+2011-03-20 Julien Danjou <julien@danjou.info>
+
+ * term.c (Fsuspend_tty, Fresume_tty):
+ * minibuf.c (read_minibuf, run_exit_minibuf_hook):
+ * window.c (temp_output_buffer_show):
+ * insdel.c (signal_before_change):
+ * frame.c (Fhandle_switch_frame):
+ * fileio.c (Fdo_auto_save):
+ * emacs.c (Fkill_emacs):
+ * editfns.c (save_excursion_restore):
+ * cmds.c (internal_self_insert):
+ * callint.c (Fcall_interactively):
+ * buffer.c (Fkill_all_local_variables):
+ * keyboard.c (Fcommand_execute, Fsuspend_emacs, safe_run_hooks_1):
+ Use Frun_hooks.
+ (command_loop_1): Use Frun_hooks. Call safe_run_hooks
+ unconditionnaly since it does the check itself.
+
2011-03-20 Glenn Morris <rgm@gnu.org>
* config.in: Remove file.
diff --git a/src/buffer.c b/src/buffer.c
index c0e6866..da2cc15 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2520,8 +2520,7 @@ The first thing this function does is run
the normal hook `change-major-mode-hook'. */)
(void)
{
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qchange_major_mode_hook);
+ Frun_hooks (1, &Qchange_major_mode_hook);
/* Make sure none of the bindings in local_var_alist
remain swapped in, in their symbols. */
diff --git a/src/callint.c b/src/callint.c
index 282d8a8..bb815a5 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -423,8 +423,7 @@ invoke it. If KEYS is omitted or nil, the return value of
error ("Attempt to select inactive minibuffer window");
/* If the current buffer wants to clean up, let it. */
- if (!NILP (Vmouse_leave_buffer_hook))
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
Fselect_window (w, Qnil);
}
diff --git a/src/cmds.c b/src/cmds.c
index fa1ac50..ebbb223 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -501,7 +501,7 @@ internal_self_insert (int c, EMACS_INT n)
}
/* Run hooks for electric keys. */
- call1 (Vrun_hooks, Qpost_self_insert_hook);
+ Frun_hooks (1, &Qpost_self_insert_hook);
return hairy;
}
diff --git a/src/editfns.c b/src/editfns.c
index 1f98ff0..009e1d3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -928,18 +928,21 @@ save_excursion_restore (Lisp_Object info)
tem1 = BVAR (current_buffer, mark_active);
BVAR (current_buffer, mark_active) = tem;
- if (!NILP (Vrun_hooks))
- {
/* If mark is active now, and either was not active
or was at a different place, run the activate hook. */
- if (! NILP (BVAR (current_buffer, mark_active)))
+ if (! NILP (tem))
{
if (! EQ (omark, nmark))
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ {
+ tem = intern ("activate-mark-hook");
+ Frun_hooks (1, &tem);
+ }
}
/* If mark has ceased to be active, run deactivate hook. */
else if (! NILP (tem1))
- call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
+ {
+ tem = intern ("deactivate-mark-hook");
+ Frun_hooks (1, &tem);
}
/* If buffer was visible in a window, and a different window was
diff --git a/src/emacs.c b/src/emacs.c
index 052f22e..00a8f1c 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1972,14 +1972,15 @@ all of which are called before Emacs is actually killed. */)
(Lisp_Object arg)
{
struct gcpro gcpro1;
+ Lisp_Object hook;
GCPRO1 (arg);
if (feof (stdin))
arg = Qt;
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("kill-emacs-hook"));
+ hook = intern ("kill-emacs-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
diff --git a/src/fileio.c b/src/fileio.c
index 5d33fb9..14a2147 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5179,7 +5179,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
(Lisp_Object no_message, Lisp_Object current_only)
{
struct buffer *old = current_buffer, *b;
- Lisp_Object tail, buf;
+ Lisp_Object tail, buf, hook;
int auto_saved = 0;
int do_handled_files;
Lisp_Object oquit;
@@ -5209,8 +5209,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
/* No GCPRO needed, because (when it matters) all Lisp_Object variables
point to non-strings reached from Vbuffer_alist. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("auto-save-hook"));
+ hook = intern ("auto-save-hook");
+ Frun_hooks (1, &hook);
if (STRINGP (Vauto_save_list_file_name))
{
diff --git a/src/frame.c b/src/frame.c
index 05938f3..0b8689d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -890,7 +890,7 @@ to that frame. */)
{
/* Preserve prefix arg that the command loop just cleared. */
KVAR (current_kboard, Vprefix_arg) = Vcurrent_prefix_arg;
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
return do_switch_frame (event, 0, 0, Qnil);
}
diff --git a/src/insdel.c b/src/insdel.c
index ad3460f..1cbe3de 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -2137,14 +2137,14 @@ signal_before_change (EMACS_INT start_int, EMACS_INT end_int,
specbind (Qinhibit_modification_hooks, Qt);
- /* If buffer is unmodified, run a special hook for that case. */
+ /* If buffer is unmodified, run a special hook for that case. The
+ check for Vfirst_change_hook is just a minor optimization. */
if (SAVE_MODIFF >= MODIFF
- && !NILP (Vfirst_change_hook)
- && !NILP (Vrun_hooks))
+ && !NILP (Vfirst_change_hook))
{
PRESERVE_VALUE;
PRESERVE_START_END;
- call1 (Vrun_hooks, Qfirst_change_hook);
+ Frun_hooks (1, &Qfirst_change_hook);
}
/* Now run the before-change-functions if any. */
diff --git a/src/keyboard.c b/src/keyboard.c
index fc8622d..39848ee 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1492,9 +1492,6 @@ command_loop_1 (void)
Vthis_command = cmd;
real_this_command = cmd;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
safe_run_hooks (Qpre_command_hook);
already_adjusted = 0;
@@ -1541,9 +1538,6 @@ command_loop_1 (void)
}
KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
safe_run_hooks (Qpost_command_hook);
/* If displaying a message, resize the echo area window to fit
@@ -1551,7 +1545,6 @@ command_loop_1 (void)
if (!NILP (echo_area_buffer[0]))
resize_echo_area_exactly ();
- if (!NILP (Vdeferred_action_list))
safe_run_hooks (Qdeferred_action_function);
/* If there is a prefix argument,
@@ -1621,7 +1614,10 @@ command_loop_1 (void)
}
if (current_buffer != prev_buffer || MODIFF != prev_modiff)
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ {
+ Lisp_Object hook = intern ("activate-mark-hook");
+ Frun_hooks (1, &hook);
+ }
}
Vsaved_region_selection = Qnil;
@@ -1819,9 +1815,7 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
static Lisp_Object
safe_run_hooks_1 (void)
{
- if (NILP (Vrun_hooks))
- return Qnil;
- return call1 (Vrun_hooks, Vinhibit_quit);
+ return Frun_hooks (1, &Vinhibit_quit);
}
/* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */
@@ -10129,11 +10123,11 @@ a special event, so ignore the prefix argument and don't clear it. */)
if (SYMBOLP (cmd))
{
tem = Fget (cmd, Qdisabled);
- if (!NILP (tem) && !NILP (Vrun_hooks))
+ if (!NILP (tem))
{
tem = Fsymbol_value (Qdisabled_command_function);
if (!NILP (tem))
- return call1 (Vrun_hooks, Qdisabled_command_function);
+ return Frun_hooks (1, &Qdisabled_command_function);
}
}
@@ -10617,6 +10611,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
int old_height, old_width;
int width, height;
struct gcpro gcpro1;
+ Lisp_Object hook;
if (tty_list && tty_list->next)
error ("There are other tty frames open; close them before suspending Emacs");
@@ -10625,8 +10620,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
CHECK_STRING (stuffstring);
/* Run the functions in suspend-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-hook"));
+ hook = intern ("suspend-hook");
+ Frun_hooks (1, &hook);
GCPRO1 (stuffstring);
get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
@@ -10650,8 +10645,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
/* Run suspend-resume-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-resume-hook"));
+ hook = intern ("suspend-resume-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
return Qnil;
diff --git a/src/minibuf.c b/src/minibuf.c
index b6b79be..7bed9bb 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -649,12 +649,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method)))
call1 (Qactivate_input_method, input_method);
- /* Run our hook, but not if it is empty.
- (run-hooks would do nothing if it is empty,
- but it's important to save time here in the usual case.) */
- if (!NILP (Vminibuffer_setup_hook) && !EQ (Vminibuffer_setup_hook, Qunbound)
- && !NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qminibuffer_setup_hook);
+ Frun_hooks (1, &Qminibuffer_setup_hook);
/* Don't allow the user to undo past this point. */
BVAR (current_buffer, undo_list) = Qnil;
@@ -806,10 +801,7 @@ get_minibuffer (int depth)
static Lisp_Object
run_exit_minibuf_hook (Lisp_Object data)
{
- if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
- && !NILP (Vrun_hooks))
safe_run_hooks (Qminibuffer_exit_hook);
-
return Qnil;
}
diff --git a/src/term.c b/src/term.c
index e84bbe1..b3392df 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2500,13 +2500,10 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
/* First run `suspend-tty-functions' and then clean up the tty
state because `suspend-tty-functions' might need to change
the tty state. */
- if (!NILP (Vrun_hooks))
- {
Lisp_Object args[2];
args[0] = intern ("suspend-tty-functions");
XSETTERMINAL (args[1], t);
Frun_hook_with_args (2, args);
- }
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
@@ -2596,9 +2593,8 @@ frame's terminal). */)
init_sys_modes (t->display_info.tty);
- /* Run `resume-tty-functions'. */
- if (!NILP (Vrun_hooks))
{
+ /* Run `resume-tty-functions'. */
Lisp_Object args[2];
args[0] = intern ("resume-tty-functions");
XSETTERMINAL (args[1], t);
diff --git a/src/window.c b/src/window.c
index eaa9105..9ab9fab 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3690,10 +3690,6 @@ temp_output_buffer_show (register Lisp_Object buf)
/* Run temp-buffer-show-hook, with the chosen window selected
and its buffer current. */
-
- if (!NILP (Vrun_hooks)
- && !NILP (Fboundp (Qtemp_buffer_show_hook))
- && !NILP (Fsymbol_value (Qtemp_buffer_show_hook)))
{
int count = SPECPDL_INDEX ();
Lisp_Object prev_window, prev_buffer;
@@ -3708,7 +3704,7 @@ temp_output_buffer_show (register Lisp_Object buf)
record_unwind_protect (select_window_norecord, prev_window);
Fselect_window (window, Qt);
Fset_buffer (w->buffer);
- call1 (Vrun_hooks, Qtemp_buffer_show_hook);
+ Frun_hooks (1, &Qtemp_buffer_show_hook);
unbind_to (count, Qnil);
}
}
--
1.7.4.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0001-Use-Frun_hooks-rather-than-calling-Vrun_hooks-manual-merge.patch --]
[-- Type: text/x-diff, Size: 15204 bytes --]
From c8f051ae7c702b052b2ae417b884ec4889bec0de Mon Sep 17 00:00:00 2001
From: Julien Danjou <julien@danjou.info>
Date: Thu, 17 Mar 2011 12:02:38 +0100
Subject: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
Signed-off-by: Julien Danjou <julien@danjou.info>
---
src/ChangeLog | 18 ++++++++++++++++++
src/buffer.c | 3 +--
src/callint.c | 3 +--
src/cmds.c | 2 +-
src/editfns.c | 25 ++++++++++++++-----------
src/emacs.c | 5 +++--
src/fileio.c | 6 +++---
src/frame.c | 2 +-
src/insdel.c | 8 ++++----
src/keyboard.c | 35 +++++++++++++++--------------------
src/minibuf.c | 12 ++----------
src/term.c | 26 +++++++++++---------------
src/window.c | 38 +++++++++++++++++---------------------
13 files changed, 91 insertions(+), 92 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index d6dd038..9e24e3c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
+2011-03-20 Julien Danjou <julien@danjou.info>
+
+ * term.c (Fsuspend_tty, Fresume_tty):
+ * minibuf.c (read_minibuf, run_exit_minibuf_hook):
+ * window.c (temp_output_buffer_show):
+ * insdel.c (signal_before_change):
+ * frame.c (Fhandle_switch_frame):
+ * fileio.c (Fdo_auto_save):
+ * emacs.c (Fkill_emacs):
+ * editfns.c (save_excursion_restore):
+ * cmds.c (internal_self_insert):
+ * callint.c (Fcall_interactively):
+ * buffer.c (Fkill_all_local_variables):
+ * keyboard.c (Fcommand_execute, Fsuspend_emacs, safe_run_hooks_1):
+ Use Frun_hooks.
+ (command_loop_1): Use Frun_hooks. Call safe_run_hooks
+ unconditionnaly since it does the check itself.
+
2011-03-20 Glenn Morris <rgm@gnu.org>
* config.in: Remove file.
diff --git a/src/buffer.c b/src/buffer.c
index c0e6866..da2cc15 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2520,8 +2520,7 @@ The first thing this function does is run
the normal hook `change-major-mode-hook'. */)
(void)
{
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qchange_major_mode_hook);
+ Frun_hooks (1, &Qchange_major_mode_hook);
/* Make sure none of the bindings in local_var_alist
remain swapped in, in their symbols. */
diff --git a/src/callint.c b/src/callint.c
index 282d8a8..bb815a5 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -423,8 +423,7 @@ invoke it. If KEYS is omitted or nil, the return value of
error ("Attempt to select inactive minibuffer window");
/* If the current buffer wants to clean up, let it. */
- if (!NILP (Vmouse_leave_buffer_hook))
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
Fselect_window (w, Qnil);
}
diff --git a/src/cmds.c b/src/cmds.c
index fa1ac50..ebbb223 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -501,7 +501,7 @@ internal_self_insert (int c, EMACS_INT n)
}
/* Run hooks for electric keys. */
- call1 (Vrun_hooks, Qpost_self_insert_hook);
+ Frun_hooks (1, &Qpost_self_insert_hook);
return hairy;
}
diff --git a/src/editfns.c b/src/editfns.c
index 1f98ff0..009e1d3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -928,18 +928,21 @@ save_excursion_restore (Lisp_Object info)
tem1 = BVAR (current_buffer, mark_active);
BVAR (current_buffer, mark_active) = tem;
- if (!NILP (Vrun_hooks))
+ /* If mark is active now, and either was not active
+ or was at a different place, run the activate hook. */
+ if (! NILP (tem))
{
- /* If mark is active now, and either was not active
- or was at a different place, run the activate hook. */
- if (! NILP (BVAR (current_buffer, mark_active)))
- {
- if (! EQ (omark, nmark))
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
- }
- /* If mark has ceased to be active, run deactivate hook. */
- else if (! NILP (tem1))
- call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
+ if (! EQ (omark, nmark))
+ {
+ tem = intern ("activate-mark-hook");
+ Frun_hooks (1, &tem);
+ }
+ }
+ /* If mark has ceased to be active, run deactivate hook. */
+ else if (! NILP (tem1))
+ {
+ tem = intern ("deactivate-mark-hook");
+ Frun_hooks (1, &tem);
}
/* If buffer was visible in a window, and a different window was
diff --git a/src/emacs.c b/src/emacs.c
index 052f22e..00a8f1c 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1972,14 +1972,15 @@ all of which are called before Emacs is actually killed. */)
(Lisp_Object arg)
{
struct gcpro gcpro1;
+ Lisp_Object hook;
GCPRO1 (arg);
if (feof (stdin))
arg = Qt;
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("kill-emacs-hook"));
+ hook = intern ("kill-emacs-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
diff --git a/src/fileio.c b/src/fileio.c
index 5d33fb9..14a2147 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5179,7 +5179,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
(Lisp_Object no_message, Lisp_Object current_only)
{
struct buffer *old = current_buffer, *b;
- Lisp_Object tail, buf;
+ Lisp_Object tail, buf, hook;
int auto_saved = 0;
int do_handled_files;
Lisp_Object oquit;
@@ -5209,8 +5209,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
/* No GCPRO needed, because (when it matters) all Lisp_Object variables
point to non-strings reached from Vbuffer_alist. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("auto-save-hook"));
+ hook = intern ("auto-save-hook");
+ Frun_hooks (1, &hook);
if (STRINGP (Vauto_save_list_file_name))
{
diff --git a/src/frame.c b/src/frame.c
index 05938f3..0b8689d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -890,7 +890,7 @@ to that frame. */)
{
/* Preserve prefix arg that the command loop just cleared. */
KVAR (current_kboard, Vprefix_arg) = Vcurrent_prefix_arg;
- call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+ Frun_hooks (1, &Qmouse_leave_buffer_hook);
return do_switch_frame (event, 0, 0, Qnil);
}
diff --git a/src/insdel.c b/src/insdel.c
index ad3460f..1cbe3de 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -2137,14 +2137,14 @@ signal_before_change (EMACS_INT start_int, EMACS_INT end_int,
specbind (Qinhibit_modification_hooks, Qt);
- /* If buffer is unmodified, run a special hook for that case. */
+ /* If buffer is unmodified, run a special hook for that case. The
+ check for Vfirst_change_hook is just a minor optimization. */
if (SAVE_MODIFF >= MODIFF
- && !NILP (Vfirst_change_hook)
- && !NILP (Vrun_hooks))
+ && !NILP (Vfirst_change_hook))
{
PRESERVE_VALUE;
PRESERVE_START_END;
- call1 (Vrun_hooks, Qfirst_change_hook);
+ Frun_hooks (1, &Qfirst_change_hook);
}
/* Now run the before-change-functions if any. */
diff --git a/src/keyboard.c b/src/keyboard.c
index fc8622d..39848ee 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1492,10 +1492,7 @@ command_loop_1 (void)
Vthis_command = cmd;
real_this_command = cmd;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
- safe_run_hooks (Qpre_command_hook);
+ safe_run_hooks (Qpre_command_hook);
already_adjusted = 0;
@@ -1541,18 +1538,14 @@ command_loop_1 (void)
}
KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg;
- /* Note that the value cell will never directly contain nil
- if the symbol is a local variable. */
- if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
- safe_run_hooks (Qpost_command_hook);
+ safe_run_hooks (Qpost_command_hook);
/* If displaying a message, resize the echo area window to fit
that message's size exactly. */
if (!NILP (echo_area_buffer[0]))
resize_echo_area_exactly ();
- if (!NILP (Vdeferred_action_list))
- safe_run_hooks (Qdeferred_action_function);
+ safe_run_hooks (Qdeferred_action_function);
/* If there is a prefix argument,
1) We don't want Vlast_command to be ``universal-argument''
@@ -1621,7 +1614,10 @@ command_loop_1 (void)
}
if (current_buffer != prev_buffer || MODIFF != prev_modiff)
- call1 (Vrun_hooks, intern ("activate-mark-hook"));
+ {
+ Lisp_Object hook = intern ("activate-mark-hook");
+ Frun_hooks (1, &hook);
+ }
}
Vsaved_region_selection = Qnil;
@@ -1819,9 +1815,7 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
static Lisp_Object
safe_run_hooks_1 (void)
{
- if (NILP (Vrun_hooks))
- return Qnil;
- return call1 (Vrun_hooks, Vinhibit_quit);
+ return Frun_hooks (1, &Vinhibit_quit);
}
/* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */
@@ -10129,11 +10123,11 @@ a special event, so ignore the prefix argument and don't clear it. */)
if (SYMBOLP (cmd))
{
tem = Fget (cmd, Qdisabled);
- if (!NILP (tem) && !NILP (Vrun_hooks))
+ if (!NILP (tem))
{
tem = Fsymbol_value (Qdisabled_command_function);
if (!NILP (tem))
- return call1 (Vrun_hooks, Qdisabled_command_function);
+ return Frun_hooks (1, &Qdisabled_command_function);
}
}
@@ -10617,6 +10611,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
int old_height, old_width;
int width, height;
struct gcpro gcpro1;
+ Lisp_Object hook;
if (tty_list && tty_list->next)
error ("There are other tty frames open; close them before suspending Emacs");
@@ -10625,8 +10620,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
CHECK_STRING (stuffstring);
/* Run the functions in suspend-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-hook"));
+ hook = intern ("suspend-hook");
+ Frun_hooks (1, &hook);
GCPRO1 (stuffstring);
get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
@@ -10650,8 +10645,8 @@ On such systems, Emacs starts a subshell instead of suspending. */)
change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
/* Run suspend-resume-hook. */
- if (!NILP (Vrun_hooks))
- call1 (Vrun_hooks, intern ("suspend-resume-hook"));
+ hook = intern ("suspend-resume-hook");
+ Frun_hooks (1, &hook);
UNGCPRO;
return Qnil;
diff --git a/src/minibuf.c b/src/minibuf.c
index b6b79be..7bed9bb 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -649,12 +649,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method)))
call1 (Qactivate_input_method, input_method);
- /* Run our hook, but not if it is empty.
- (run-hooks would do nothing if it is empty,
- but it's important to save time here in the usual case.) */
- if (!NILP (Vminibuffer_setup_hook) && !EQ (Vminibuffer_setup_hook, Qunbound)
- && !NILP (Vrun_hooks))
- call1 (Vrun_hooks, Qminibuffer_setup_hook);
+ Frun_hooks (1, &Qminibuffer_setup_hook);
/* Don't allow the user to undo past this point. */
BVAR (current_buffer, undo_list) = Qnil;
@@ -806,10 +801,7 @@ get_minibuffer (int depth)
static Lisp_Object
run_exit_minibuf_hook (Lisp_Object data)
{
- if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
- && !NILP (Vrun_hooks))
- safe_run_hooks (Qminibuffer_exit_hook);
-
+ safe_run_hooks (Qminibuffer_exit_hook);
return Qnil;
}
diff --git a/src/term.c b/src/term.c
index e84bbe1..b3392df 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2500,13 +2500,10 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
/* First run `suspend-tty-functions' and then clean up the tty
state because `suspend-tty-functions' might need to change
the tty state. */
- if (!NILP (Vrun_hooks))
- {
- Lisp_Object args[2];
- args[0] = intern ("suspend-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ Lisp_Object args[2];
+ args[0] = intern ("suspend-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
reset_sys_modes (t->display_info.tty);
delete_keyboard_wait_descriptor (fileno (f));
@@ -2596,14 +2593,13 @@ frame's terminal). */)
init_sys_modes (t->display_info.tty);
- /* Run `resume-tty-functions'. */
- if (!NILP (Vrun_hooks))
- {
- Lisp_Object args[2];
- args[0] = intern ("resume-tty-functions");
- XSETTERMINAL (args[1], t);
- Frun_hook_with_args (2, args);
- }
+ {
+ /* Run `resume-tty-functions'. */
+ Lisp_Object args[2];
+ args[0] = intern ("resume-tty-functions");
+ XSETTERMINAL (args[1], t);
+ Frun_hook_with_args (2, args);
+ }
}
set_tty_hooks (t);
diff --git a/src/window.c b/src/window.c
index eaa9105..9ab9fab 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3690,27 +3690,23 @@ temp_output_buffer_show (register Lisp_Object buf)
/* Run temp-buffer-show-hook, with the chosen window selected
and its buffer current. */
-
- if (!NILP (Vrun_hooks)
- && !NILP (Fboundp (Qtemp_buffer_show_hook))
- && !NILP (Fsymbol_value (Qtemp_buffer_show_hook)))
- {
- int count = SPECPDL_INDEX ();
- Lisp_Object prev_window, prev_buffer;
- prev_window = selected_window;
- XSETBUFFER (prev_buffer, old);
-
- /* Select the window that was chosen, for running the hook.
- Note: Both Fselect_window and select_window_norecord may
- set-buffer to the buffer displayed in the window,
- so we need to save the current buffer. --stef */
- record_unwind_protect (Fset_buffer, prev_buffer);
- record_unwind_protect (select_window_norecord, prev_window);
- Fselect_window (window, Qt);
- Fset_buffer (w->buffer);
- call1 (Vrun_hooks, Qtemp_buffer_show_hook);
- unbind_to (count, Qnil);
- }
+ {
+ int count = SPECPDL_INDEX ();
+ Lisp_Object prev_window, prev_buffer;
+ prev_window = selected_window;
+ XSETBUFFER (prev_buffer, old);
+
+ /* Select the window that was chosen, for running the hook.
+ Note: Both Fselect_window and select_window_norecord may
+ set-buffer to the buffer displayed in the window,
+ so we need to save the current buffer. --stef */
+ record_unwind_protect (Fset_buffer, prev_buffer);
+ record_unwind_protect (select_window_norecord, prev_window);
+ Fselect_window (window, Qt);
+ Fset_buffer (w->buffer);
+ Frun_hooks (1, &Qtemp_buffer_show_hook);
+ unbind_to (count, Qnil);
+ }
}
}
\f
--
1.7.4.1
[-- Attachment #1.4: Type: text/plain, Size: 53 bytes --]
--
Julien Danjou
❱ http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually
2011-03-18 17:39 ` Stefan Monnier
2011-03-21 14:35 ` Julien Danjou
@ 2011-03-23 10:20 ` Julien Danjou
1 sibling, 0 replies; 4+ messages in thread
From: Julien Danjou @ 2011-03-23 10:20 UTC (permalink / raw)
To: 8274-done
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
Patch merged, therefore I'm closing this bug.
revno: 103731
committer: Julien Danjou <julien@danjou.info>
branch nick: trunk
timestamp: Wed 2011-03-23 11:06:57 +0100
message:
Use Frun_hooks rather than calling Vrun_hooks manually
--
Julien Danjou
❱ http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-23 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 14:52 bug#8274: [PATCH] Use Frun_hooks rather than calling Vrun_hooks manually Julien Danjou
2011-03-18 17:39 ` Stefan Monnier
2011-03-21 14:35 ` Julien Danjou
2011-03-23 10:20 ` Julien Danjou
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).