diff options
| author | Stefan Monnier | 2008-03-19 15:18:30 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-03-19 15:18:30 +0000 |
| commit | 6a44ffb3b4347e5b5f8168fd6df26278abde69aa (patch) | |
| tree | 4090a24e47bca9ca342c6f3357a5855ca704f564 /src/window.c | |
| parent | 6355802033d202c63f6fff4b77bf2b0c7aecceef (diff) | |
| download | emacs-6a44ffb3b4347e5b5f8168fd6df26278abde69aa.tar.gz emacs-6a44ffb3b4347e5b5f8168fd6df26278abde69aa.zip | |
(run_funs): New fun.
(run_window_configuration_change_hook): Use it to run the buffer-local
and the global part of the hook.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/src/window.c b/src/window.c index bceb41faf06..8cf2a45e6f2 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3306,25 +3306,62 @@ Fset_window_buffer_unwind (obuf) | |||
| 3306 | EXFUN (Fset_window_fringes, 4); | 3306 | EXFUN (Fset_window_fringes, 4); |
| 3307 | EXFUN (Fset_window_scroll_bars, 4); | 3307 | EXFUN (Fset_window_scroll_bars, 4); |
| 3308 | 3308 | ||
| 3309 | static void | ||
| 3310 | run_funs (Lisp_Object funs) | ||
| 3311 | { | ||
| 3312 | for (; CONSP (funs); funs = XCDR (funs)) | ||
| 3313 | if (!EQ (XCAR (funs), Qt)) | ||
| 3314 | call0 (XCAR (funs)); | ||
| 3315 | } | ||
| 3316 | |||
| 3317 | static Lisp_Object select_window_norecord (Lisp_Object window); | ||
| 3318 | |||
| 3309 | void | 3319 | void |
| 3310 | run_window_configuration_change_hook (struct frame *f) | 3320 | run_window_configuration_change_hook (struct frame *f) |
| 3311 | { | 3321 | { |
| 3312 | /* FIXME: buffer-local values of Vwindow_configuration_change_hook | ||
| 3313 | aren't handled properly. */ | ||
| 3314 | if (! NILP (Vwindow_configuration_change_hook) | ||
| 3315 | && ! NILP (Vrun_hooks)) | ||
| 3316 | { | ||
| 3317 | int count = SPECPDL_INDEX (); | 3322 | int count = SPECPDL_INDEX (); |
| 3323 | Lisp_Object frame, global_wcch | ||
| 3324 | = Fdefault_value (Qwindow_configuration_change_hook); | ||
| 3325 | XSETFRAME (frame, f); | ||
| 3326 | |||
| 3327 | if (NILP (Vrun_hooks)) | ||
| 3328 | return; | ||
| 3329 | |||
| 3318 | if (SELECTED_FRAME () != f) | 3330 | if (SELECTED_FRAME () != f) |
| 3319 | { | 3331 | { |
| 3320 | Lisp_Object frame; | ||
| 3321 | XSETFRAME (frame, f); | ||
| 3322 | record_unwind_protect (Fselect_frame, Fselected_frame ()); | 3332 | record_unwind_protect (Fselect_frame, Fselected_frame ()); |
| 3323 | Fselect_frame (frame); | 3333 | Fselect_frame (frame); |
| 3324 | } | 3334 | } |
| 3325 | call1 (Vrun_hooks, Qwindow_configuration_change_hook); | 3335 | |
| 3336 | /* Use the right buffer. Matters when running the local hooks. */ | ||
| 3337 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) | ||
| 3338 | { | ||
| 3339 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | ||
| 3340 | Fset_buffer (Fwindow_buffer (Qnil)); | ||
| 3341 | } | ||
| 3342 | |||
| 3343 | /* Look for buffer-local values. */ | ||
| 3344 | { | ||
| 3345 | Lisp_Object windows = Fwindow_list (frame, Qlambda, Qnil); | ||
| 3346 | for (; CONSP (windows); windows = XCDR (windows)) | ||
| 3347 | { | ||
| 3348 | Lisp_Object window = XCAR (windows); | ||
| 3349 | Lisp_Object buffer = Fwindow_buffer (window); | ||
| 3350 | if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook, | ||
| 3351 | buffer))) | ||
| 3352 | { | ||
| 3353 | int count = SPECPDL_INDEX (); | ||
| 3354 | record_unwind_protect (select_window_norecord, Fselected_window ()); | ||
| 3355 | select_window_norecord (window); | ||
| 3356 | run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, | ||
| 3357 | buffer)); | ||
| 3326 | unbind_to (count, Qnil); | 3358 | unbind_to (count, Qnil); |
| 3327 | } | 3359 | } |
| 3360 | } | ||
| 3361 | } | ||
| 3362 | |||
| 3363 | run_funs (global_wcch); | ||
| 3364 | unbind_to (count, Qnil); | ||
| 3328 | } | 3365 | } |
| 3329 | 3366 | ||
| 3330 | /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero | 3367 | /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero |
| @@ -7586,7 +7623,9 @@ Any other value means point always keeps its screen position. */); | |||
| 7586 | DEFVAR_LISP ("window-configuration-change-hook", | 7623 | DEFVAR_LISP ("window-configuration-change-hook", |
| 7587 | &Vwindow_configuration_change_hook, | 7624 | &Vwindow_configuration_change_hook, |
| 7588 | doc: /* Functions to call when window configuration changes. | 7625 | doc: /* Functions to call when window configuration changes. |
| 7589 | The selected frame is the one whose configuration has changed. */); | 7626 | The buffer-local part is run once per window, with the relevant window |
| 7627 | selected; while the global part is run only once for the modified frame, | ||
| 7628 | with the relevant frame selected. */); | ||
| 7590 | Vwindow_configuration_change_hook = Qnil; | 7629 | Vwindow_configuration_change_hook = Qnil; |
| 7591 | 7630 | ||
| 7592 | defsubr (&Sselected_window); | 7631 | defsubr (&Sselected_window); |