[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect advice how to restore previous window
From: |
Kim F. Storm |
Subject: |
Re: Incorrect advice how to restore previous window |
Date: |
Tue, 27 Feb 2007 10:47:34 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> IMO it is rather obscure that we have a hook (several in fact) which
> are run _after_ displaying a buffer in a window -- but no hook which
> is run before the change.
>
> Do you mean window-configuration-change-hook?
> I guess there is no harm in having another similar hook
> at the beginning of Fset_window_buffer.
That is exactly what I suggested.
*** window.c 11 Feb 2007 21:37:29 +0100 1.573
--- window.c 20 Feb 2007 17:11:57 +0100
***************
*** 201,207 ****
static int window_initialized;
! /* Hook to run when window config changes. */
Lisp_Object Qwindow_configuration_change_hook;
Lisp_Object Vwindow_configuration_change_hook;
--- 201,213 ----
static int window_initialized;
!
! /* Hook to run before setting window buffer. */
!
! Lisp_Object Qchange_window_buffer_functions;
! Lisp_Object Vchange_window_buffer_functions;
!
! /* Hook to run after window config changes. */
Lisp_Object Qwindow_configuration_change_hook;
Lisp_Object Vwindow_configuration_change_hook;
***************
*** 3275,3280 ****
--- 3281,3293 ----
struct buffer *b = XBUFFER (buffer);
int count = SPECPDL_INDEX ();
+ if (run_hooks_p
+ && BUFFERP (w->buffer)
+ && ! NILP (Vrun_hooks)
+ && ! NILP (Vchange_window_buffer_functions))
+ run_hook_with_args_2 (Qchange_window_buffer_functions,
+ window, buffer);
+
w->buffer = buffer;
if (EQ (window, selected_window))
***************
*** 7289,7294 ****
--- 7302,7311 ----
Qtemp_buffer_show_hook = intern ("temp-buffer-show-hook");
staticpro (&Qtemp_buffer_show_hook);
+ Qchange_window_buffer_functions
+ = intern ("change-window-buffer-functions");
+ staticpro (&Qchange_window_buffer_functions);
+
staticpro (&Vwindow_list);
minibuf_selected_window = Qnil;
***************
*** 7489,7494 ****
--- 7506,7518 ----
The selected frame is the one whose configuration has changed. */);
Vwindow_configuration_change_hook = Qnil;
+ DEFVAR_LISP ("change-window-buffer-functions",
+ &Vchange_window_buffer_functions,
+ doc: /* List of functions to call before changing buffer in window.
+ Each function is called with two arguments, the existing window and
+ its new buffer. */);
+ Vchange_window_buffer_functions = Qnil;
+
defsubr (&Sselected_window);
defsubr (&Sminibuffer_window);
defsubr (&Swindow_minibuffer_p);
--
Kim F. Storm <address@hidden> http://www.cua.dk