diff options
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 115 |
1 files changed, 106 insertions, 9 deletions
diff --git a/src/window.c b/src/window.c index ef61d668499..324689498ae 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Window creation, deletion and examination for GNU Emacs. | 1 | /* Window creation, deletion and examination for GNU Emacs. |
| 2 | Does not include redisplay. | 2 | Does not include redisplay. |
| 3 | Copyright (C) 1985-1987, 1993-1998, 2000-2011 | 3 | Copyright (C) 1985-1987, 1993-1998, 2000-2012 |
| 4 | Free Software Foundation, Inc. | 4 | Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| @@ -57,7 +57,7 @@ static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; | |||
| 57 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; | 57 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; |
| 58 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; | 58 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; |
| 59 | static Lisp_Object Qsafe, Qabove, Qbelow; | 59 | static Lisp_Object Qsafe, Qabove, Qbelow; |
| 60 | static Lisp_Object Qauto_buffer_name; | 60 | static Lisp_Object Qauto_buffer_name, Qclone_of; |
| 61 | 61 | ||
| 62 | static int displayed_window_lines (struct window *); | 62 | static int displayed_window_lines (struct window *); |
| 63 | static struct window *decode_window (Lisp_Object); | 63 | static struct window *decode_window (Lisp_Object); |
| @@ -5410,6 +5410,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5410 | { | 5410 | { |
| 5411 | Lisp_Object window; | 5411 | Lisp_Object window; |
| 5412 | Lisp_Object dead_windows = Qnil; | 5412 | Lisp_Object dead_windows = Qnil; |
| 5413 | register Lisp_Object tem, par, pers; | ||
| 5413 | register struct window *w; | 5414 | register struct window *w; |
| 5414 | register struct saved_window *p; | 5415 | register struct saved_window *p; |
| 5415 | struct window *root_window; | 5416 | struct window *root_window; |
| @@ -5543,7 +5544,28 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5543 | w->vertical_scroll_bar_type = p->vertical_scroll_bar_type; | 5544 | w->vertical_scroll_bar_type = p->vertical_scroll_bar_type; |
| 5544 | w->dedicated = p->dedicated; | 5545 | w->dedicated = p->dedicated; |
| 5545 | w->combination_limit = p->combination_limit; | 5546 | w->combination_limit = p->combination_limit; |
| 5546 | w->window_parameters = p->window_parameters; | 5547 | /* Restore any window parameters that have been saved. |
| 5548 | Parameters that have not been saved are left alone. */ | ||
| 5549 | for (tem = p->window_parameters; CONSP (tem); tem = XCDR (tem)) | ||
| 5550 | { | ||
| 5551 | pers = XCAR (tem); | ||
| 5552 | if (CONSP (pers)) | ||
| 5553 | { | ||
| 5554 | if (NILP (XCDR (pers))) | ||
| 5555 | { | ||
| 5556 | par = Fassq (XCAR (pers), w->window_parameters); | ||
| 5557 | if (CONSP (par) && !NILP (XCDR (par))) | ||
| 5558 | /* Reset a parameter to nil if and only if it | ||
| 5559 | has a non-nil association. Don't make new | ||
| 5560 | associations. */ | ||
| 5561 | Fsetcdr (par, Qnil); | ||
| 5562 | } | ||
| 5563 | else | ||
| 5564 | /* Always restore a non-nil value. */ | ||
| 5565 | Fset_window_parameter (window, XCAR (pers), XCDR (pers)); | ||
| 5566 | } | ||
| 5567 | } | ||
| 5568 | |||
| 5547 | XSETFASTINT (w->last_modified, 0); | 5569 | XSETFASTINT (w->last_modified, 0); |
| 5548 | XSETFASTINT (w->last_overlay_modified, 0); | 5570 | XSETFASTINT (w->last_overlay_modified, 0); |
| 5549 | 5571 | ||
| @@ -5810,7 +5832,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5810 | { | 5832 | { |
| 5811 | register struct saved_window *p; | 5833 | register struct saved_window *p; |
| 5812 | register struct window *w; | 5834 | register struct window *w; |
| 5813 | register Lisp_Object tem; | 5835 | register Lisp_Object tem, pers, par; |
| 5814 | 5836 | ||
| 5815 | for (;!NILP (window); window = w->next) | 5837 | for (;!NILP (window); window = w->next) |
| 5816 | { | 5838 | { |
| @@ -5838,12 +5860,59 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5838 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; | 5860 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; |
| 5839 | p->dedicated = w->dedicated; | 5861 | p->dedicated = w->dedicated; |
| 5840 | p->combination_limit = w->combination_limit; | 5862 | p->combination_limit = w->combination_limit; |
| 5841 | p->window_parameters = w->window_parameters; | 5863 | p->window_parameters = Qnil; |
| 5864 | |||
| 5865 | if (!NILP (Vwindow_persistent_parameters)) | ||
| 5866 | { | ||
| 5867 | /* Run cycle detection on Vwindow_persistent_parameters. */ | ||
| 5868 | Lisp_Object tortoise, hare; | ||
| 5869 | |||
| 5870 | hare = tortoise = Vwindow_persistent_parameters; | ||
| 5871 | while (CONSP (hare)) | ||
| 5872 | { | ||
| 5873 | hare = XCDR (hare); | ||
| 5874 | if (!CONSP (hare)) | ||
| 5875 | break; | ||
| 5876 | |||
| 5877 | hare = XCDR (hare); | ||
| 5878 | tortoise = XCDR (tortoise); | ||
| 5879 | |||
| 5880 | if (EQ (hare, tortoise)) | ||
| 5881 | /* Reset Vwindow_persistent_parameters to Qnil. */ | ||
| 5882 | { | ||
| 5883 | Vwindow_persistent_parameters = Qnil; | ||
| 5884 | break; | ||
| 5885 | } | ||
| 5886 | } | ||
| 5887 | |||
| 5888 | for (tem = Vwindow_persistent_parameters; CONSP (tem); | ||
| 5889 | tem = XCDR (tem)) | ||
| 5890 | { | ||
| 5891 | pers = XCAR (tem); | ||
| 5892 | /* Save values for persistent window parameters. */ | ||
| 5893 | if (CONSP (pers) && !NILP (XCDR (pers))) | ||
| 5894 | { | ||
| 5895 | par = Fassq (XCAR (pers), w->window_parameters); | ||
| 5896 | if (NILP (par)) | ||
| 5897 | /* If the window has no value for the parameter, | ||
| 5898 | make one. */ | ||
| 5899 | p->window_parameters = Fcons (Fcons (XCAR (pers), Qnil), | ||
| 5900 | p->window_parameters); | ||
| 5901 | else | ||
| 5902 | /* If the window has a value for the parameter, | ||
| 5903 | save it. */ | ||
| 5904 | p->window_parameters = Fcons (Fcons (XCAR (par), | ||
| 5905 | XCDR (par)), | ||
| 5906 | p->window_parameters); | ||
| 5907 | } | ||
| 5908 | } | ||
| 5909 | } | ||
| 5910 | |||
| 5842 | if (!NILP (w->buffer)) | 5911 | if (!NILP (w->buffer)) |
| 5843 | { | 5912 | { |
| 5844 | /* Save w's value of point in the window configuration. | 5913 | /* Save w's value of point in the window configuration. If w |
| 5845 | If w is the selected window, then get the value of point | 5914 | is the selected window, then get the value of point from |
| 5846 | from the buffer; pointm is garbage in the selected window. */ | 5915 | the buffer; pointm is garbage in the selected window. */ |
| 5847 | if (EQ (window, selected_window)) | 5916 | if (EQ (window, selected_window)) |
| 5848 | { | 5917 | { |
| 5849 | p->pointm = Fmake_marker (); | 5918 | p->pointm = Fmake_marker (); |
| @@ -5896,7 +5965,9 @@ and for each displayed buffer, where display starts, and the positions of | |||
| 5896 | point and mark. An exception is made for point in the current buffer: | 5965 | point and mark. An exception is made for point in the current buffer: |
| 5897 | its value is -not- saved. | 5966 | its value is -not- saved. |
| 5898 | This also records the currently selected frame, and FRAME's focus | 5967 | This also records the currently selected frame, and FRAME's focus |
| 5899 | redirection (see `redirect-frame-focus'). */) | 5968 | redirection (see `redirect-frame-focus'). The variable |
| 5969 | `window-persistent-parameters' specifies which window parameters are | ||
| 5970 | saved by this function. */) | ||
| 5900 | (Lisp_Object frame) | 5971 | (Lisp_Object frame) |
| 5901 | { | 5972 | { |
| 5902 | register Lisp_Object tem; | 5973 | register Lisp_Object tem; |
| @@ -6433,6 +6504,7 @@ syms_of_window (void) | |||
| 6433 | DEFSYM (Qabove, "above"); | 6504 | DEFSYM (Qabove, "above"); |
| 6434 | DEFSYM (Qbelow, "below"); | 6505 | DEFSYM (Qbelow, "below"); |
| 6435 | DEFSYM (Qauto_buffer_name, "auto-buffer-name"); | 6506 | DEFSYM (Qauto_buffer_name, "auto-buffer-name"); |
| 6507 | DEFSYM (Qclone_of, "clone-of"); | ||
| 6436 | 6508 | ||
| 6437 | staticpro (&Vwindow_list); | 6509 | staticpro (&Vwindow_list); |
| 6438 | 6510 | ||
| @@ -6542,6 +6614,31 @@ retrieved via the function `window-combination-limit' and altered by the | |||
| 6542 | function `set-window-combination-limit'. */); | 6614 | function `set-window-combination-limit'. */); |
| 6543 | Vwindow_combination_limit = Qnil; | 6615 | Vwindow_combination_limit = Qnil; |
| 6544 | 6616 | ||
| 6617 | DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, | ||
| 6618 | doc: /* Alist of persistent window parameters. | ||
| 6619 | This alist specifies which window parameters shall get saved by | ||
| 6620 | `current-window-configuration' and `window-state-get' and subsequently | ||
| 6621 | restored to their previous values by `set-window-configuration' and | ||
| 6622 | `window-state-put'. | ||
| 6623 | |||
| 6624 | The car of each entry of this alist is the symbol specifying the | ||
| 6625 | parameter. The cdr is one of the following: | ||
| 6626 | |||
| 6627 | nil means the parameter is neither saved by `window-state-get' nor by | ||
| 6628 | `current-window-configuration'. | ||
| 6629 | |||
| 6630 | t means the parameter is saved by `current-window-configuration' and, | ||
| 6631 | provided its WRITABLE argument is nil, by `window-state-get'. | ||
| 6632 | |||
| 6633 | The symbol `writable' means the parameter is saved unconditionally by | ||
| 6634 | both `current-window-configuration' and `window-state-get'. Do not use | ||
| 6635 | this value for parameters without read syntax (like windows or frames). | ||
| 6636 | |||
| 6637 | Parameters not saved by `current-window-configuration' or | ||
| 6638 | `window-state-get' are left alone by `set-window-configuration' | ||
| 6639 | respectively are not installed by `window-state-put'. */); | ||
| 6640 | Vwindow_persistent_parameters = list1 (Fcons (Qclone_of, Qt)); | ||
| 6641 | |||
| 6545 | defsubr (&Sselected_window); | 6642 | defsubr (&Sselected_window); |
| 6546 | defsubr (&Sminibuffer_window); | 6643 | defsubr (&Sminibuffer_window); |
| 6547 | defsubr (&Swindow_minibuffer_p); | 6644 | defsubr (&Swindow_minibuffer_p); |