aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2012-01-19 11:38:31 +0100
committerMartin Rudalics2012-01-19 11:38:31 +0100
commit34a02f46dce0136ef10deb0f632330c76babbd9c (patch)
tree928147730736112abdb14aeef620c783f9fe43d3
parent1259009aa17da6dc038afff96963f6d9bbd3b8e1 (diff)
downloademacs-34a02f46dce0136ef10deb0f632330c76babbd9c.tar.gz
emacs-34a02f46dce0136ef10deb0f632330c76babbd9c.zip
Fix handling of persistent window parameters.
* window.c (save_window_save, Fcurrent_window_configuration) (Vwindow_persistent_parameters): Do not use Qstate. Rewrite doc-strings. * window.el (window--state-get-1, window-state-get): Do not use special state value for window-persistent-parameters. Rename argument IGNORE to WRITABLE. Rewrite doc-string. (window--state-put-2): Reset all window parameters to nil before assigning values of persistent parameters. * windows.texi (Window Configurations): Rewrite references to persistent window parameters. (Window Parameters): Fix description of persistent window parameters.
-rw-r--r--doc/lispref/ChangeLog7
-rw-r--r--doc/lispref/windows.texi57
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/window.el78
-rw-r--r--src/ChangeLog6
-rw-r--r--src/window.c36
6 files changed, 99 insertions, 93 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 4b9531c0e6c..44467d5f51b 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,10 @@
12012-01-19 Martin Rudalics <rudalics@gmx.at>
2
3 * windows.texi (Window Configurations): Rewrite references to
4 persistent window parameters.
5 (Window Parameters): Fix description of persistent window
6 parameters.
7
12012-01-16 Juanma Barranquero <lekktu@gmail.com> 82012-01-16 Juanma Barranquero <lekktu@gmail.com>
2 9
3 * windows.texi (Window Parameters): Use @pxref. 10 * windows.texi (Window Parameters): Use @pxref.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 1bff30e45e1..a0f8b61ddfe 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -3104,9 +3104,9 @@ window configuration; see @ref{Frame Configurations}.
3104@defun current-window-configuration &optional frame 3104@defun current-window-configuration &optional frame
3105This function returns a new object representing @var{frame}'s current 3105This function returns a new object representing @var{frame}'s current
3106window configuration. The default for @var{frame} is the selected 3106window configuration. The default for @var{frame} is the selected
3107frame. This function saves copies of window parameters listed by the 3107frame. The variable @code{window-persistent-parameters} specifies
3108variable @code{window-persistent-parameters}, see @ref{Window 3108whether and which window parameters are saved by this function, see
3109Parameters} for details. 3109@ref{Window Parameters} for details.
3110@end defun 3110@end defun
3111 3111
3112@defun set-window-configuration configuration 3112@defun set-window-configuration configuration
@@ -3214,27 +3214,25 @@ to clone the state of a frame into an arbitrary live window
3214(@code{set-window-configuration} effectively clones the windows of a 3214(@code{set-window-configuration} effectively clones the windows of a
3215frame into the root window of that very frame only). 3215frame into the root window of that very frame only).
3216 3216
3217@defun window-state-get &optional window ignore 3217@defun window-state-get &optional window writable
3218This function returns the state of @var{window} as a Lisp object. The 3218This function returns the state of @var{window} as a Lisp object. The
3219argument @var{window} can be any window and defaults to the root window 3219argument @var{window} can be any window and defaults to the root window
3220of the selected frame. 3220of the selected frame.
3221 3221
3222If the optional argument @var{ignore} is non-@code{nil}, this means to 3222If the optional argument @var{writable} is non-@code{nil}, this means to
3223not use markers for sampling positions like @code{window-point} or 3223not use markers for sampling positions like @code{window-point} or
3224@code{window-start}. This argument should be non-@code{nil} when the 3224@code{window-start}. This argument should be non-@code{nil} when the
3225state shall be written on disk and read back in another session. 3225state shall be written to disk and read back in another session.
3226 3226
3227The variable @code{window-persistent-parameters} specifies whether and 3227Together, the argument @var{writable} and the variable
3228which window parameters are saved by this function, see @ref{Window 3228@code{window-persistent-parameters} specify which window parameters are
3229Parameters} for details. 3229saved by this function, see @ref{Window Parameters} for details.
3230@end defun 3230@end defun
3231 3231
3232The value returned by @code{window-state-get} can be converted, using 3232The value returned by @code{window-state-get} can be used in the same
3233one of the functions defined by Desktop Save Mode (@pxref{Desktop Save 3233session to make a clone of a window in another window. It can be also
3234Mode}), to an object that can be written to a file. Such objects can be 3234written to disk and read back in another session. In either case, use
3235read back and converted to a Lisp object representing the state of the 3235the function described next to restore the state of the window.
3236window. That Lisp object can be used as argument for the following
3237function in order to restore the state window in another window.
3238 3236
3239@defun window-state-put state &optional window ignore 3237@defun window-state-put state &optional window ignore
3240This function puts the window state @var{state} into @var{window}. The 3238This function puts the window state @var{state} into @var{window}. The
@@ -3281,10 +3279,10 @@ states of windows (@pxref{Window Configurations}) do not care about
3281window parameters. This means, that when you change the value of a 3279window parameters. This means, that when you change the value of a
3282parameter within the body of a @code{save-window-excursion}, the 3280parameter within the body of a @code{save-window-excursion}, the
3283previous value is not restored upon exit of that macro. It also means 3281previous value is not restored upon exit of that macro. It also means
3284that when you clone via @code{window-state-put} a window state saved 3282that when you restore via @code{window-state-put} a window state saved
3285earlier by @code{window-state-get}, the cloned windows come up with no 3283earlier by @code{window-state-get}, all cloned windows have their
3286parameters at all. The following variable allows to override the 3284parameters reset to @code{nil}. The following variable allows to
3287standard behavior. 3285override the standard behavior.
3288 3286
3289@defvar window-persistent-parameters 3287@defvar window-persistent-parameters
3290This variable is an alist specifying which parameters get saved by 3288This variable is an alist specifying which parameters get saved by
@@ -3293,32 +3291,25 @@ subsequently restored by @code{set-window-configuration} and
3293@code{window-state-put}, see @ref{Window Configurations}. 3291@code{window-state-put}, see @ref{Window Configurations}.
3294 3292
3295The @sc{car} of each entry of this alist is the symbol specifying the 3293The @sc{car} of each entry of this alist is the symbol specifying the
3296parameter. The @sc{cdr} must be one of the following: 3294parameter. The @sc{cdr} should be one of the following:
3297 3295
3298@table @asis 3296@table @asis
3299@item @code{state}
3300This value means the parameter is saved by @code{window-state-get}
3301provided its @var{ignore} argument is @code{nil}. The function
3302@code{current-window-configuration} does not save this parameter.
3303
3304@item @code{nil} 3297@item @code{nil}
3298This value means the parameter is neither saved by
3299@code{window-state-get} nor by @code{current-window-configuration}.
3300
3301@item @code{t}
3305This value specifies that the parameter is saved by 3302This value specifies that the parameter is saved by
3306@code{current-window-configuration} and, provided its @var{ignore} 3303@code{current-window-configuration} and, provided its @var{writable}
3307argument is @code{nil}, by @code{window-state-get}. 3304argument is @code{nil}, by @code{window-state-get}.
3308 3305
3309@item @code{t} 3306@item @code{writable}
3310This means that the parameter is saved unconditionally by both 3307This means that the parameter is saved unconditionally by both
3311@code{current-window-configuration} and @code{window-state-get}. This 3308@code{current-window-configuration} and @code{window-state-get}. This
3312value should not be used for parameters whose values do not have a read 3309value should not be used for parameters whose values do not have a read
3313syntax. Otherwise, invoking @code{window-state-put} in another session 3310syntax. Otherwise, invoking @code{window-state-put} in another session
3314may fail with an @code{invalid-read-syntax} error. 3311may fail with an @code{invalid-read-syntax} error.
3315@end table 3312@end table
3316
3317Parameters that have been saved are restored to their previous values by
3318@code{set-window-configuration} respectively are installed by
3319@code{window-state-put}. Parameters that have not been saved are left
3320alone by @code{set-window-configuration} respectively are not installed
3321by @code{window-state-put}.
3322@end defvar 3313@end defvar
3323 3314
3324Some functions, notably @code{delete-window}, 3315Some functions, notably @code{delete-window},
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0fea6a47b08..8fa8031d125 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-01-19 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (window--state-get-1, window-state-get): Do not use
4 special state value for window-persistent-parameters. Rename
5 argument IGNORE to WRITABLE. Rewrite doc-string.
6 (window--state-put-2): Reset all window parameters to nil before
7 assigning values of persistent parameters.
8
12012-01-18 Alan Mackenzie <acm@muc.de> 92012-01-18 Alan Mackenzie <acm@muc.de>
2 10
3 Eliminate sluggishness and hangs in fontification of "semicolon 11 Eliminate sluggishness and hangs in fontification of "semicolon
diff --git a/lisp/window.el b/lisp/window.el
index 54e5ec9c74c..9122904b0bb 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -3568,7 +3568,7 @@ specific buffers."
3568 )) 3568 ))
3569 3569
3570;;; Window states, how to get them and how to put them in a window. 3570;;; Window states, how to get them and how to put them in a window.
3571(defun window--state-get-1 (window &optional ignore) 3571(defun window--state-get-1 (window &optional writable)
3572 "Helper function for `window-state-get'." 3572 "Helper function for `window-state-get'."
3573 (let* ((type 3573 (let* ((type
3574 (cond 3574 (cond
@@ -3585,29 +3585,22 @@ specific buffers."
3585 (normal-height . ,(window-normal-size window)) 3585 (normal-height . ,(window-normal-size window))
3586 (normal-width . ,(window-normal-size window t)) 3586 (normal-width . ,(window-normal-size window t))
3587 (combination-limit . ,(window-combination-limit window)) 3587 (combination-limit . ,(window-combination-limit window))
3588 ,@(let (list) 3588 ,@(let ((parameters (window-parameters window))
3589 ;; Make copies of persistent window parameters whose cdr 3589 list)
3590 ;; is either t or, when IGNORE is non-nil, is either nil 3590 ;; Make copies of those window parameters whose
3591 ;; or `state'. 3591 ;; persistence property is `writable' if WRITABLE is
3592 (dolist (pers window-persistent-parameters) 3592 ;; non-nil and non-nil if WRITABLE is nil.
3593 (when (and (consp pers) 3593 (dolist (par parameters)
3594 (or (eq (cdr pers) t) 3594 (let ((pers (cdr (assq (car par)
3595 (and (memq (cdr pers) '(state nil)) 3595 window-persistent-parameters))))
3596 (not ignore)))) 3596 (when (and pers (or (not writable) (eq pers 'writable)))
3597 (let ((par (assq (car pers) (window-parameters window)))) 3597 (setq list (cons (cons (car par) (cdr par)) list)))))
3598 (setq list (cons (cons (car pers) (when par (cdr par))) 3598 ;; Add `clone-of' parameter if necessary.
3599 list))))) 3599 (let ((pers (cdr (assq 'clone-of
3600 ;; Save `clone-of' parameter unless IGNORE or 3600 window-persistent-parameters))))
3601 ;; `window-persistent-parameters' prevail. 3601 (when (and pers (or (not writable) (eq pers 'writable))
3602 (when (and (not (assq 'clone-of (window-parameters window))) 3602 (not (assq 'clone-of list)))
3603 (let ((clone-of 3603 (setq list (cons (cons 'clone-of window) list))))
3604 (assq 'clone-of
3605 window-persistent-parameters)))
3606 (when clone-of
3607 (if ignore
3608 (eq (cdr clone-of) t)
3609 (memq (cdr clone-of) '(state nil))))))
3610 (setq list (cons (cons 'clone-of window) list)))
3611 (when list 3604 (when list
3612 `((parameters . ,list)))) 3605 `((parameters . ,list))))
3613 ,@(when buffer 3606 ,@(when buffer
@@ -3628,31 +3621,34 @@ specific buffers."
3628 (scroll-bars . ,(window-scroll-bars window)) 3621 (scroll-bars . ,(window-scroll-bars window))
3629 (vscroll . ,(window-vscroll window)) 3622 (vscroll . ,(window-vscroll window))
3630 (dedicated . ,(window-dedicated-p window)) 3623 (dedicated . ,(window-dedicated-p window))
3631 (point . ,(if ignore point (copy-marker point))) 3624 (point . ,(if writable point (copy-marker point)))
3632 (start . ,(if ignore start (copy-marker start))) 3625 (start . ,(if writable start (copy-marker start)))
3633 ,@(when mark 3626 ,@(when mark
3634 `((mark . ,(if ignore 3627 `((mark . ,(if writable
3635 mark (copy-marker mark)))))))))))) 3628 mark (copy-marker mark))))))))))))
3636 (tail 3629 (tail
3637 (when (memq type '(vc hc)) 3630 (when (memq type '(vc hc))
3638 (let (list) 3631 (let (list)
3639 (setq window (window-child window)) 3632 (setq window (window-child window))
3640 (while window 3633 (while window
3641 (setq list (cons (window--state-get-1 window ignore) list)) 3634 (setq list (cons (window--state-get-1 window writable) list))
3642 (setq window (window-right window))) 3635 (setq window (window-right window)))
3643 (nreverse list))))) 3636 (nreverse list)))))
3644 (append head tail))) 3637 (append head tail)))
3645 3638
3646(defun window-state-get (&optional window ignore) 3639(defun window-state-get (&optional window writable)
3647 "Return state of WINDOW as a Lisp object. 3640 "Return state of WINDOW as a Lisp object.
3648WINDOW can be any window and defaults to the root window of the 3641WINDOW can be any window and defaults to the root window of the
3649selected frame. 3642selected frame.
3650 3643
3651Optional argument IGNORE non-nil means do not use markers for 3644Optional argument WRITABLE non-nil means do not use markers for
3652sampling positions like `window-point' or `window-start' and do 3645sampling `window-point' and `window-start'. Together, WRITABLE
3653not record parameters unless `window-persistent-parameters' 3646and the variable `window-persistent-parameters' specify which
3654requests it. IGNORE should be non-nil when the return value 3647window parameters are saved by this function. WRITABLE should be
3655shall be written to a file and read back in another session. 3648non-nil when the return value shall be written to a file and read
3649back in another session. Otherwise, an application may run into
3650an `invalid-read-syntax' error while attempting to read back the
3651value from file.
3656 3652
3657The return value can be used as argument for `window-state-put' 3653The return value can be used as argument for `window-state-put'
3658to put the state recorded here into an arbitrary window. The 3654to put the state recorded here into an arbitrary window. The
@@ -3678,7 +3674,7 @@ value can be also stored on disk and read back in a new session."
3678 ;; These are probably not needed. 3674 ;; These are probably not needed.
3679 ,@(when (window-size-fixed-p window) `((fixed-height . t))) 3675 ,@(when (window-size-fixed-p window) `((fixed-height . t)))
3680 ,@(when (window-size-fixed-p window t) `((fixed-width . t)))) 3676 ,@(when (window-size-fixed-p window t) `((fixed-width . t))))
3681 (window--state-get-1 window ignore))) 3677 (window--state-get-1 window writable)))
3682 3678
3683(defvar window-state-put-list nil 3679(defvar window-state-put-list nil
3684 "Helper variable for `window-state-put'.") 3680 "Helper variable for `window-state-put'.")
@@ -3757,15 +3753,13 @@ value can be also stored on disk and read back in a new session."
3757 (state (cdr (assq 'buffer item)))) 3753 (state (cdr (assq 'buffer item))))
3758 (when combination-limit 3754 (when combination-limit
3759 (set-window-combination-limit window combination-limit)) 3755 (set-window-combination-limit window combination-limit))
3760 ;; Assign saved window parameters. If a parameter's value is nil, 3756 ;; Reset window's parameters and assign saved ones (we might want
3761 ;; don't assign it unless the new window has it set already (which 3757 ;; a `remove-window-parameters' function here).
3762 ;; shouldn't happen unless some `window-configuration-change-hook' 3758 (dolist (parameter (window-parameters window))
3763 ;; function installed it). 3759 (set-window-parameter window (car parameter) nil))
3764 (when parameters 3760 (when parameters
3765 (dolist (parameter parameters) 3761 (dolist (parameter parameters)
3766 (when (or (cdr parameter) 3762 (set-window-parameter window (car parameter) (cdr parameter))))
3767 (window-parameter window (car parameter)))
3768 (set-window-parameter window (car parameter) (cdr parameter)))))
3769 ;; Process buffer related state. 3763 ;; Process buffer related state.
3770 (when state 3764 (when state
3771 ;; We don't want to raise an error here so we create a buffer if 3765 ;; We don't want to raise an error here so we create a buffer if
diff --git a/src/ChangeLog b/src/ChangeLog
index 3a6e31eede4..faaea4057c5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12012-01-19 Martin Rudalics <rudalics@gmx.at>
2
3 * window.c (save_window_save, Fcurrent_window_configuration)
4 (Vwindow_persistent_parameters): Do not use Qstate. Rewrite
5 doc-strings.
6
12012-01-19 Kenichi Handa <handa@m17n.org> 72012-01-19 Kenichi Handa <handa@m17n.org>
2 8
3 * character.c (char_width): New function. 9 * character.c (char_width): New function.
diff --git a/src/window.c b/src/window.c
index 3dc6029d24d..324689498ae 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, Qclone_of, Qstate; 60static Lisp_Object Qauto_buffer_name, Qclone_of;
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);
@@ -5889,9 +5889,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5889 tem = XCDR (tem)) 5889 tem = XCDR (tem))
5890 { 5890 {
5891 pers = XCAR (tem); 5891 pers = XCAR (tem);
5892 /* Save values for persistent window parameters whose cdr 5892 /* Save values for persistent window parameters. */
5893 is either nil or t. */ 5893 if (CONSP (pers) && !NILP (XCDR (pers)))
5894 if (CONSP (pers) && (NILP (XCDR (pers)) || EQ (XCDR (pers), Qt)))
5895 { 5894 {
5896 par = Fassq (XCAR (pers), w->window_parameters); 5895 par = Fassq (XCAR (pers), w->window_parameters);
5897 if (NILP (par)) 5896 if (NILP (par))
@@ -5966,7 +5965,9 @@ and for each displayed buffer, where display starts, and the positions of
5966point and mark. An exception is made for point in the current buffer: 5965point and mark. An exception is made for point in the current buffer:
5967its value is -not- saved. 5966its value is -not- saved.
5968This also records the currently selected frame, and FRAME's focus 5967This also records the currently selected frame, and FRAME's focus
5969redirection (see `redirect-frame-focus'). */) 5968redirection (see `redirect-frame-focus'). The variable
5969`window-persistent-parameters' specifies which window parameters are
5970saved by this function. */)
5970 (Lisp_Object frame) 5971 (Lisp_Object frame)
5971{ 5972{
5972 register Lisp_Object tem; 5973 register Lisp_Object tem;
@@ -6504,7 +6505,6 @@ syms_of_window (void)
6504 DEFSYM (Qbelow, "below"); 6505 DEFSYM (Qbelow, "below");
6505 DEFSYM (Qauto_buffer_name, "auto-buffer-name"); 6506 DEFSYM (Qauto_buffer_name, "auto-buffer-name");
6506 DEFSYM (Qclone_of, "clone-of"); 6507 DEFSYM (Qclone_of, "clone-of");
6507 DEFSYM (Qstate, "state");
6508 6508
6509 staticpro (&Vwindow_list); 6509 staticpro (&Vwindow_list);
6510 6510
@@ -6616,28 +6616,28 @@ function `set-window-combination-limit'. */);
6616 6616
6617 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, 6617 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters,
6618 doc: /* Alist of persistent window parameters. 6618 doc: /* Alist of persistent window parameters.
6619Parameters in this list are saved by `current-window-configuration' and 6619This alist specifies which window parameters shall get saved by
6620`window-state-get' and subsequently restored to their previous values by 6620`current-window-configuration' and `window-state-get' and subsequently
6621`set-window-configuration' and `window-state-put'. 6621restored to their previous values by `set-window-configuration' and
6622`window-state-put'.
6622 6623
6623The car of each entry of this alist is the symbol specifying the 6624The car of each entry of this alist is the symbol specifying the
6624parameter. The cdr is one of the following: 6625parameter. The cdr is one of the following:
6625 6626
6626The symbol `state' means the parameter is saved by `window-state-get' 6627nil means the parameter is neither saved by `window-state-get' nor by
6627provided its IGNORE argument is nil. `current-window-configuration' 6628`current-window-configuration'.
6628does not save this parameter.
6629 6629
6630nil means the parameter is saved by `current-window-configuration' and, 6630t means the parameter is saved by `current-window-configuration' and,
6631provided its IGNORE argument is nil, by `window-state-get'. 6631provided its WRITABLE argument is nil, by `window-state-get'.
6632 6632
6633t means the parameter is saved unconditionally by both 6633The symbol `writable' means the parameter is saved unconditionally by
6634`current-window-configuration' and `window-state-get'. Parameters 6634both `current-window-configuration' and `window-state-get'. Do not use
6635without read syntax (like windows or frames) should not use that. 6635this value for parameters without read syntax (like windows or frames).
6636 6636
6637Parameters not saved by `current-window-configuration' or 6637Parameters not saved by `current-window-configuration' or
6638`window-state-get' are left alone by `set-window-configuration' 6638`window-state-get' are left alone by `set-window-configuration'
6639respectively are not installed by `window-state-put'. */); 6639respectively are not installed by `window-state-put'. */);
6640 Vwindow_persistent_parameters = list1 (Fcons (Qclone_of, Qstate)); 6640 Vwindow_persistent_parameters = list1 (Fcons (Qclone_of, Qt));
6641 6641
6642 defsubr (&Sselected_window); 6642 defsubr (&Sselected_window);
6643 defsubr (&Sminibuffer_window); 6643 defsubr (&Sminibuffer_window);