aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2012-01-16 10:34:41 +0100
committerMartin Rudalics2012-01-16 10:34:41 +0100
commit6a6ee00d123a940f5b8858e61a327cd9e183cb1a (patch)
tree971207c682aa8a8cb903a4dedad2d8e6fcd86211 /src
parent97912defd376ad75ac582d073851a5a7a4d3cc12 (diff)
downloademacs-6a6ee00d123a940f5b8858e61a327cd9e183cb1a.tar.gz
emacs-6a6ee00d123a940f5b8858e61a327cd9e183cb1a.zip
Provide persistent window parameters.
* window.c (Vwindow_persistent_parameters): New variable. (Fset_window_configuration, save_window_save): Handle persistent window parameters. * window.el (window-state-ignored-parameters): Remove variable. (window--state-get-1): Rename argument MARKERS to IGNORE. Handle persistent window parameters. Make copy of clone-of parameter only if requested. (Bug#10348) (window--state-put-2): Install a window parameter only if it has a non-nil value or an existing parameter shall be overwritten. * windows.texi (Window Configurations, Window Parameters): Describe persistent window parameters.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/window.c111
2 files changed, 110 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index eb03ef1357f..aa4e92b4134 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12012-01-16 Martin Rudalics <rudalics@gmx.at>
2
3 * window.c (Vwindow_persistent_parameters): New variable.
4 (Fset_window_configuration, save_window_save): Handle persistent
5 window parameters.
6
12012-01-14 Eli Zaretskii <eliz@gnu.org> 72012-01-14 Eli Zaretskii <eliz@gnu.org>
2 8
3 * w32fns.c (signal_user_input): Don't do a QUIT, to avoid 9 * w32fns.c (signal_user_input): Don't do a QUIT, to avoid
diff --git a/src/window.c b/src/window.c
index 39eaa1ec241..3dc6029d24d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -57,7 +57,7 @@ static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
57static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; 57static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
59static Lisp_Object Qsafe, Qabove, Qbelow; 59static Lisp_Object Qsafe, Qabove, Qbelow;
60static Lisp_Object Qauto_buffer_name; 60static Lisp_Object Qauto_buffer_name, Qclone_of, Qstate;
61 61
62static int displayed_window_lines (struct window *); 62static int displayed_window_lines (struct window *);
63static struct window *decode_window (Lisp_Object); 63static 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,60 @@ 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 whose cdr
5893 is either nil or t. */
5894 if (CONSP (pers) && (NILP (XCDR (pers)) || EQ (XCDR (pers), Qt)))
5895 {
5896 par = Fassq (XCAR (pers), w->window_parameters);
5897 if (NILP (par))
5898 /* If the window has no value for the parameter,
5899 make one. */
5900 p->window_parameters = Fcons (Fcons (XCAR (pers), Qnil),
5901 p->window_parameters);
5902 else
5903 /* If the window has a value for the parameter,
5904 save it. */
5905 p->window_parameters = Fcons (Fcons (XCAR (par),
5906 XCDR (par)),
5907 p->window_parameters);
5908 }
5909 }
5910 }
5911
5842 if (!NILP (w->buffer)) 5912 if (!NILP (w->buffer))
5843 { 5913 {
5844 /* Save w's value of point in the window configuration. 5914 /* 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 5915 is the selected window, then get the value of point from
5846 from the buffer; pointm is garbage in the selected window. */ 5916 the buffer; pointm is garbage in the selected window. */
5847 if (EQ (window, selected_window)) 5917 if (EQ (window, selected_window))
5848 { 5918 {
5849 p->pointm = Fmake_marker (); 5919 p->pointm = Fmake_marker ();
@@ -6433,6 +6503,8 @@ syms_of_window (void)
6433 DEFSYM (Qabove, "above"); 6503 DEFSYM (Qabove, "above");
6434 DEFSYM (Qbelow, "below"); 6504 DEFSYM (Qbelow, "below");
6435 DEFSYM (Qauto_buffer_name, "auto-buffer-name"); 6505 DEFSYM (Qauto_buffer_name, "auto-buffer-name");
6506 DEFSYM (Qclone_of, "clone-of");
6507 DEFSYM (Qstate, "state");
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
6542function `set-window-combination-limit'. */); 6614function `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.
6619Parameters in this list are saved by `current-window-configuration' and
6620`window-state-get' and subsequently restored to their previous values by
6621`set-window-configuration' and `window-state-put'.
6622
6623The car of each entry of this alist is the symbol specifying the
6624parameter. The cdr is one of the following:
6625
6626The symbol `state' means the parameter is saved by `window-state-get'
6627provided its IGNORE argument is nil. `current-window-configuration'
6628does not save this parameter.
6629
6630nil means the parameter is saved by `current-window-configuration' and,
6631provided its IGNORE argument is nil, by `window-state-get'.
6632
6633t means the parameter is saved unconditionally by both
6634`current-window-configuration' and `window-state-get'. Parameters
6635without read syntax (like windows or frames) should not use that.
6636
6637Parameters not saved by `current-window-configuration' or
6638`window-state-get' are left alone by `set-window-configuration'
6639respectively are not installed by `window-state-put'. */);
6640 Vwindow_persistent_parameters = list1 (Fcons (Qclone_of, Qstate));
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);