diff options
| author | Martin Rudalics | 2018-09-10 10:05:20 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2018-09-10 10:05:20 +0200 |
| commit | 6a00f2babf84f309fa00269bff3abef7eb502023 (patch) | |
| tree | 71c3b44a0e017e86cf0373f95631ea56d3cf2fac /src | |
| parent | a704bad5e69e278086ea895061be496287b5c277 (diff) | |
| download | emacs-6a00f2babf84f309fa00269bff3abef7eb502023.tar.gz emacs-6a00f2babf84f309fa00269bff3abef7eb502023.zip | |
Handle buffer-local 'window-size-change-functions' specially (Bug#32637)
* src/window.c (run_window_size_change_functions): Run a
buffer-local value once per each frame and only if at least
one window showing the buffer on that frame has changed its
size. (Bug#32637)
* doc/lispref/windows.texi (Window Hooks): Describe new
behavior of buffer-local 'window-size-change-functions'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/window.c b/src/window.c index 04de9656809..b81469b9d69 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3442,7 +3442,11 @@ run_window_size_change_functions (Lisp_Object frame) | |||
| 3442 | { | 3442 | { |
| 3443 | struct frame *f = XFRAME (frame); | 3443 | struct frame *f = XFRAME (frame); |
| 3444 | struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f)); | 3444 | struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 3445 | Lisp_Object functions = Vwindow_size_change_functions; | 3445 | |
| 3446 | if (NILP (Vrun_hooks) | ||
| 3447 | || !(f->can_x_set_window_size) | ||
| 3448 | || !(f->after_make_frame)) | ||
| 3449 | return; | ||
| 3446 | 3450 | ||
| 3447 | if (FRAME_WINDOW_CONFIGURATION_CHANGED (f) | 3451 | if (FRAME_WINDOW_CONFIGURATION_CHANGED (f) |
| 3448 | /* Here we implicitly exclude the possibility that the height of | 3452 | /* Here we implicitly exclude the possibility that the height of |
| @@ -3450,11 +3454,44 @@ run_window_size_change_functions (Lisp_Object frame) | |||
| 3450 | of FRAME's root window alone. */ | 3454 | of FRAME's root window alone. */ |
| 3451 | || window_size_changed (r)) | 3455 | || window_size_changed (r)) |
| 3452 | { | 3456 | { |
| 3453 | while (CONSP (functions)) | 3457 | Lisp_Object globals = Fdefault_value (Qwindow_size_change_functions); |
| 3458 | Lisp_Object windows = Fwindow_list (frame, Qlambda, Qnil); | ||
| 3459 | /* The buffers for which the local hook was already run. */ | ||
| 3460 | Lisp_Object buffers = Qnil; | ||
| 3461 | |||
| 3462 | for (; CONSP (windows); windows = XCDR (windows)) | ||
| 3463 | { | ||
| 3464 | Lisp_Object window = XCAR (windows); | ||
| 3465 | Lisp_Object buffer = Fwindow_buffer (window); | ||
| 3466 | |||
| 3467 | /* Run a buffer-local value only once for that buffer and | ||
| 3468 | only if at least one window showing that buffer on FRAME | ||
| 3469 | actually changed its size. Note that the function is run | ||
| 3470 | with FRAME as its argument and as such oblivious to the | ||
| 3471 | window checked below. */ | ||
| 3472 | if (window_size_changed (XWINDOW (window)) | ||
| 3473 | && !Fmemq (buffer, buffers) | ||
| 3474 | && Flocal_variable_p (Qwindow_size_change_functions, buffer)) | ||
| 3475 | { | ||
| 3476 | Lisp_Object locals | ||
| 3477 | = Fbuffer_local_value (Qwindow_size_change_functions, buffer); | ||
| 3478 | |||
| 3479 | while (CONSP (locals)) | ||
| 3480 | { | ||
| 3481 | if (!EQ (XCAR (locals), Qt)) | ||
| 3482 | safe_call1 (XCAR (locals), frame); | ||
| 3483 | locals = XCDR (locals); | ||
| 3484 | } | ||
| 3485 | |||
| 3486 | buffers = Fcons (buffer, buffers); | ||
| 3487 | } | ||
| 3488 | } | ||
| 3489 | |||
| 3490 | while (CONSP (globals)) | ||
| 3454 | { | 3491 | { |
| 3455 | if (!EQ (XCAR (functions), Qt)) | 3492 | if (!EQ (XCAR (globals), Qt)) |
| 3456 | safe_call1 (XCAR (functions), frame); | 3493 | safe_call1 (XCAR (globals), frame); |
| 3457 | functions = XCDR (functions); | 3494 | globals = XCDR (globals); |
| 3458 | } | 3495 | } |
| 3459 | 3496 | ||
| 3460 | window_set_before_size_change_sizes (r); | 3497 | window_set_before_size_change_sizes (r); |
| @@ -7556,6 +7593,7 @@ syms_of_window (void) | |||
| 7556 | Fput (Qscroll_down, Qscroll_command, Qt); | 7593 | Fput (Qscroll_down, Qscroll_command, Qt); |
| 7557 | 7594 | ||
| 7558 | DEFSYM (Qwindow_configuration_change_hook, "window-configuration-change-hook"); | 7595 | DEFSYM (Qwindow_configuration_change_hook, "window-configuration-change-hook"); |
| 7596 | DEFSYM (Qwindow_size_change_functions, "window-size-change-functions"); | ||
| 7559 | DEFSYM (Qwindowp, "windowp"); | 7597 | DEFSYM (Qwindowp, "windowp"); |
| 7560 | DEFSYM (Qwindow_configuration_p, "window-configuration-p"); | 7598 | DEFSYM (Qwindow_configuration_p, "window-configuration-p"); |
| 7561 | DEFSYM (Qwindow_live_p, "window-live-p"); | 7599 | DEFSYM (Qwindow_live_p, "window-live-p"); |