diff options
| author | Martin Rudalics | 2012-01-16 10:34:41 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2012-01-16 10:34:41 +0100 |
| commit | 6a6ee00d123a940f5b8858e61a327cd9e183cb1a (patch) | |
| tree | 971207c682aa8a8cb903a4dedad2d8e6fcd86211 | |
| parent | 97912defd376ad75ac582d073851a5a7a4d3cc12 (diff) | |
| download | emacs-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.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 93 | ||||
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/window.el | 64 | ||||
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/window.c | 111 |
6 files changed, 241 insertions, 47 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index f69eeeaadd4..8304554ace6 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-01-16 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * windows.texi (Window Configurations, Window Parameters): | ||
| 4 | Describe persistent window parameters. | ||
| 5 | |||
| 1 | 2011-12-27 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2011-12-27 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * variables.texi (Creating Buffer-Local): Warn against misuses of | 8 | * variables.texi (Creating Buffer-Local): Warn against misuses of |
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 85e1b9340fc..5f4e530089d 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -3104,7 +3104,9 @@ window configuration; see @ref{Frame Configurations}. | |||
| 3104 | @defun current-window-configuration &optional frame | 3104 | @defun current-window-configuration &optional frame |
| 3105 | This function returns a new object representing @var{frame}'s current | 3105 | This function returns a new object representing @var{frame}'s current |
| 3106 | window configuration. The default for @var{frame} is the selected | 3106 | window configuration. The default for @var{frame} is the selected |
| 3107 | frame. | 3107 | frame. This function saves copies of window parameters listed by the |
| 3108 | variable @code{window-persistent-parameters}, see @ref{Window | ||
| 3109 | Parameters} for details. | ||
| 3108 | @end defun | 3110 | @end defun |
| 3109 | 3111 | ||
| 3110 | @defun set-window-configuration configuration | 3112 | @defun set-window-configuration configuration |
| @@ -3206,24 +3208,30 @@ configurations. | |||
| 3206 | 3208 | ||
| 3207 | The objects returned by @code{current-window-configuration} die | 3209 | The objects returned by @code{current-window-configuration} die |
| 3208 | together with the Emacs process. In order to store a window | 3210 | together with the Emacs process. In order to store a window |
| 3209 | configuration on disk and read it back in another Emacs session the | 3211 | configuration on disk and read it back in another Emacs session, the |
| 3210 | following two functions can be used. | 3212 | functions described next can be used. These functions are also useful |
| 3213 | to clone the state of a frame into an arbitrary live window | ||
| 3214 | (@code{set-window-configuration} effectively clones the windows of a | ||
| 3215 | frame into the root window of that very frame only). | ||
| 3211 | 3216 | ||
| 3212 | @defun window-state-get &optional window markers | 3217 | @defun window-state-get &optional window ignore |
| 3213 | This function returns the state of @var{window} as a Lisp object. The | 3218 | This function returns the state of @var{window} as a Lisp object. The |
| 3214 | argument @var{window} can be any window and defaults to the root window | 3219 | argument @var{window} can be any window and defaults to the root window |
| 3215 | of the selected frame. | 3220 | of the selected frame. |
| 3216 | 3221 | ||
| 3217 | The optional argument @var{markers} non-@code{nil} means to use markers | 3222 | If the optional argument @var{ignore} is non-@code{nil}, this means to |
| 3218 | for sampling positions like @code{window-point} or @code{window-start}. | 3223 | not use markers for sampling positions like @code{window-point} or |
| 3219 | This argument should be non-@code{nil} only if the value is used for | 3224 | @code{window-start}. This argument should be non-@code{nil} when the |
| 3220 | putting the state back in the same session since markers slow down | 3225 | state shall be written on disk and read back in another session. |
| 3221 | processing. | 3226 | |
| 3227 | The variable @code{window-persistent-parameters} specifies whether and | ||
| 3228 | which window parameters are saved by this function, see @ref{Window | ||
| 3229 | Parameters} for details. | ||
| 3222 | @end defun | 3230 | @end defun |
| 3223 | 3231 | ||
| 3224 | The value returned by @code{window-state-get} can be converted by using | 3232 | The value returned by @code{window-state-get} can be converted, using |
| 3225 | one of the functions defined by Desktop Save Mode (@pxref{Desktop Save | 3233 | one of the functions defined by Desktop Save Mode (@pxref{Desktop Save |
| 3226 | Mode}) to an object that can be written to a file. Such objects can be | 3234 | Mode}), to an object that can be written to a file. Such objects can be |
| 3227 | read back and converted to a Lisp object representing the state of the | 3235 | read back and converted to a Lisp object representing the state of the |
| 3228 | window. That Lisp object can be used as argument for the following | 3236 | window. That Lisp object can be used as argument for the following |
| 3229 | function in order to restore the state window in another window. | 3237 | function in order to restore the state window in another window. |
| @@ -3268,6 +3276,51 @@ This function sets @var{window}'s value of @var{parameter} to | |||
| 3268 | is the selected window. | 3276 | is the selected window. |
| 3269 | @end defun | 3277 | @end defun |
| 3270 | 3278 | ||
| 3279 | By default, functions saving and restoring window configurations or the | ||
| 3280 | states of windows (@xref{Window Configurations}) do not care about | ||
| 3281 | window parameters. This means, that when you change the value of a | ||
| 3282 | parameter within the body of a @code{save-window-excursion}, the | ||
| 3283 | previous value is not restored upon exit of that macro. It also means | ||
| 3284 | that when you clone via @code{window-state-put} a window state saved | ||
| 3285 | earlier by @code{window-state-get}, the cloned windows come up with no | ||
| 3286 | parameters at all. The following variable allows to override the | ||
| 3287 | standard behavior. | ||
| 3288 | |||
| 3289 | @defvar window-persistent-parameters | ||
| 3290 | This variable is an alist specifying which parameters get saved by | ||
| 3291 | @code{current-window-configuration} and @code{window-state-get} and | ||
| 3292 | subsequently restored by @code{set-window-configuration} and | ||
| 3293 | @code{window-state-put}, see @ref{Window Configurations}. | ||
| 3294 | |||
| 3295 | The @sc{car} of each entry of this alist is the symbol specifying the | ||
| 3296 | parameter. The @sc{cdr} must be one of the following: | ||
| 3297 | |||
| 3298 | @table @asis | ||
| 3299 | @item @code{state} | ||
| 3300 | This value means the parameter is saved by @code{window-state-get} | ||
| 3301 | provided its @var{ignore} argument is @code{nil}. The function | ||
| 3302 | @code{current-window-configuration} does not save this parameter. | ||
| 3303 | |||
| 3304 | @item @code{nil} | ||
| 3305 | This value specifies that the parameter is saved by | ||
| 3306 | @code{current-window-configuration} and, provided its @var{ignore} | ||
| 3307 | argument is @code{nil}, by @code{window-state-get}. | ||
| 3308 | |||
| 3309 | @item @code{t} | ||
| 3310 | This means that the parameter is saved unconditionally by both | ||
| 3311 | @code{current-window-configuration} and @code{window-state-get}. This | ||
| 3312 | value should not be used for parameters whose values do not have a read | ||
| 3313 | syntax. Otherwise, invoking @code{window-state-put} in another session | ||
| 3314 | may fail with an @code{invalid-read-syntax} error. | ||
| 3315 | @end table | ||
| 3316 | |||
| 3317 | Parameters 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 | ||
| 3320 | alone by @code{set-window-configuration} respectively are not installed | ||
| 3321 | by @code{window-state-put}. | ||
| 3322 | @end defvar | ||
| 3323 | |||
| 3271 | Some functions, notably @code{delete-window}, | 3324 | Some functions, notably @code{delete-window}, |
| 3272 | @code{delete-other-windows} and @code{split-window} may behave specially | 3325 | @code{delete-other-windows} and @code{split-window} may behave specially |
| 3273 | when their @var{window} argument has a parameter set. You can override | 3326 | when their @var{window} argument has a parameter set. You can override |
| @@ -3287,7 +3340,7 @@ windows when exiting that function. | |||
| 3287 | @end defvar | 3340 | @end defvar |
| 3288 | 3341 | ||
| 3289 | The following parameters are currently used by the window management | 3342 | The following parameters are currently used by the window management |
| 3290 | code. | 3343 | code: |
| 3291 | 3344 | ||
| 3292 | @table @asis | 3345 | @table @asis |
| 3293 | @item @code{delete-window} | 3346 | @item @code{delete-window} |
| @@ -3309,14 +3362,20 @@ This parameter affects the execution of @code{other-window} | |||
| 3309 | @item @code{no-other-window} | 3362 | @item @code{no-other-window} |
| 3310 | This parameter marks the window as not selectable by @code{other-window} | 3363 | This parameter marks the window as not selectable by @code{other-window} |
| 3311 | (@pxref{Cyclic Window Ordering}). | 3364 | (@pxref{Cyclic Window Ordering}). |
| 3365 | |||
| 3366 | @item @code{clone-of} | ||
| 3367 | This parameter specifies the window this one has been cloned from and is | ||
| 3368 | installed by @code{window-state-get}, see @ref{Window Configurations}. | ||
| 3369 | |||
| 3370 | @item @code{quit-restore} | ||
| 3371 | This parameter tells how to proceed with a window when the buffer it | ||
| 3372 | shows is no more needed. It is installed by the buffer display | ||
| 3373 | functions (@pxref{Choosing Window}) and consulted by the function | ||
| 3374 | @code{quit-window} (@pxref{Quitting Windows}). | ||
| 3312 | @end table | 3375 | @end table |
| 3313 | 3376 | ||
| 3314 | In addition, the parameters @code{window-atom} and @code{window-side} | 3377 | In addition, the parameters @code{window-atom} and @code{window-side} |
| 3315 | are reserved and should not be used by applications. The | 3378 | are reserved and should not be used by applications. |
| 3316 | @code{quit-restore} parameter tells how to proceed with a window when | ||
| 3317 | the buffer it shows is no more needed. This parameter is installed by | ||
| 3318 | the buffer display functions (@pxref{Choosing Window}) and consulted by | ||
| 3319 | the function @code{quit-window} (@pxref{Quitting Windows}). | ||
| 3320 | 3379 | ||
| 3321 | 3380 | ||
| 3322 | @node Window Hooks | 3381 | @node Window Hooks |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e40d43ee8b9..676f767ae42 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-01-16 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (window-state-ignored-parameters): Remove variable. | ||
| 4 | (window--state-get-1): Rename argument MARKERS to IGNORE. | ||
| 5 | Handle persistent window parameters. Make copy of clone-of | ||
| 6 | parameter only if requested. (Bug#10348) | ||
| 7 | (window--state-put-2): Install a window parameter only if it has | ||
| 8 | a non-nil value or an existing parameter shall be overwritten. | ||
| 9 | |||
| 1 | 2012-01-15 Michael Albinus <michael.albinus@gmx.de> | 10 | 2012-01-15 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 11 | ||
| 3 | * net/tramp-sh.el (tramp-remote-path): Set tramp-autoload cookie. | 12 | * net/tramp-sh.el (tramp-remote-path): Set tramp-autoload cookie. |
diff --git a/lisp/window.el b/lisp/window.el index 8eb0ac3575b..54e5ec9c74c 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -3568,10 +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 | (defvar window-state-ignored-parameters '(quit-restore) | 3571 | (defun window--state-get-1 (window &optional ignore) |
| 3572 | "List of window parameters ignored by `window-state-get'.") | ||
| 3573 | |||
| 3574 | (defun window--state-get-1 (window &optional markers) | ||
| 3575 | "Helper function for `window-state-get'." | 3572 | "Helper function for `window-state-get'." |
| 3576 | (let* ((type | 3573 | (let* ((type |
| 3577 | (cond | 3574 | (cond |
| @@ -3589,12 +3586,27 @@ specific buffers." | |||
| 3589 | (normal-width . ,(window-normal-size window t)) | 3586 | (normal-width . ,(window-normal-size window t)) |
| 3590 | (combination-limit . ,(window-combination-limit window)) | 3587 | (combination-limit . ,(window-combination-limit window)) |
| 3591 | ,@(let (list) | 3588 | ,@(let (list) |
| 3592 | (dolist (parameter (window-parameters window)) | 3589 | ;; Make copies of persistent window parameters whose cdr |
| 3593 | (unless (memq (car parameter) | 3590 | ;; is either t or, when IGNORE is non-nil, is either nil |
| 3594 | window-state-ignored-parameters) | 3591 | ;; or `state'. |
| 3595 | (setq list (cons parameter list)))) | 3592 | (dolist (pers window-persistent-parameters) |
| 3596 | (unless (window-parameter window 'clone-of) | 3593 | (when (and (consp pers) |
| 3597 | ;; Make a clone-of parameter. | 3594 | (or (eq (cdr pers) t) |
| 3595 | (and (memq (cdr pers) '(state nil)) | ||
| 3596 | (not ignore)))) | ||
| 3597 | (let ((par (assq (car pers) (window-parameters window)))) | ||
| 3598 | (setq list (cons (cons (car pers) (when par (cdr par))) | ||
| 3599 | list))))) | ||
| 3600 | ;; Save `clone-of' parameter unless IGNORE or | ||
| 3601 | ;; `window-persistent-parameters' prevail. | ||
| 3602 | (when (and (not (assq 'clone-of (window-parameters window))) | ||
| 3603 | (let ((clone-of | ||
| 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)))))) | ||
| 3598 | (setq list (cons (cons 'clone-of window) list))) | 3610 | (setq list (cons (cons 'clone-of window) list))) |
| 3599 | (when list | 3611 | (when list |
| 3600 | `((parameters . ,list)))) | 3612 | `((parameters . ,list)))) |
| @@ -3616,30 +3628,31 @@ specific buffers." | |||
| 3616 | (scroll-bars . ,(window-scroll-bars window)) | 3628 | (scroll-bars . ,(window-scroll-bars window)) |
| 3617 | (vscroll . ,(window-vscroll window)) | 3629 | (vscroll . ,(window-vscroll window)) |
| 3618 | (dedicated . ,(window-dedicated-p window)) | 3630 | (dedicated . ,(window-dedicated-p window)) |
| 3619 | (point . ,(if markers (copy-marker point) point)) | 3631 | (point . ,(if ignore point (copy-marker point))) |
| 3620 | (start . ,(if markers (copy-marker start) start)) | 3632 | (start . ,(if ignore start (copy-marker start))) |
| 3621 | ,@(when mark | 3633 | ,@(when mark |
| 3622 | `((mark . ,(if markers | 3634 | `((mark . ,(if ignore |
| 3623 | (copy-marker mark) mark))))))))))) | 3635 | mark (copy-marker mark)))))))))))) |
| 3624 | (tail | 3636 | (tail |
| 3625 | (when (memq type '(vc hc)) | 3637 | (when (memq type '(vc hc)) |
| 3626 | (let (list) | 3638 | (let (list) |
| 3627 | (setq window (window-child window)) | 3639 | (setq window (window-child window)) |
| 3628 | (while window | 3640 | (while window |
| 3629 | (setq list (cons (window--state-get-1 window markers) list)) | 3641 | (setq list (cons (window--state-get-1 window ignore) list)) |
| 3630 | (setq window (window-right window))) | 3642 | (setq window (window-right window))) |
| 3631 | (nreverse list))))) | 3643 | (nreverse list))))) |
| 3632 | (append head tail))) | 3644 | (append head tail))) |
| 3633 | 3645 | ||
| 3634 | (defun window-state-get (&optional window markers) | 3646 | (defun window-state-get (&optional window ignore) |
| 3635 | "Return state of WINDOW as a Lisp object. | 3647 | "Return state of WINDOW as a Lisp object. |
| 3636 | WINDOW can be any window and defaults to the root window of the | 3648 | WINDOW can be any window and defaults to the root window of the |
| 3637 | selected frame. | 3649 | selected frame. |
| 3638 | 3650 | ||
| 3639 | Optional argument MARKERS non-nil means use markers for sampling | 3651 | Optional argument IGNORE non-nil means do not use markers for |
| 3640 | positions like `window-point' or `window-start'. MARKERS should | 3652 | sampling positions like `window-point' or `window-start' and do |
| 3641 | be non-nil only if the value is used for putting the state back | 3653 | not record parameters unless `window-persistent-parameters' |
| 3642 | in the same session (note that markers slow down processing). | 3654 | requests it. IGNORE should be non-nil when the return value |
| 3655 | shall be written to a file and read back in another session. | ||
| 3643 | 3656 | ||
| 3644 | The return value can be used as argument for `window-state-put' | 3657 | The return value can be used as argument for `window-state-put' |
| 3645 | to put the state recorded here into an arbitrary window. The | 3658 | to put the state recorded here into an arbitrary window. The |
| @@ -3665,7 +3678,7 @@ value can be also stored on disk and read back in a new session." | |||
| 3665 | ;; These are probably not needed. | 3678 | ;; These are probably not needed. |
| 3666 | ,@(when (window-size-fixed-p window) `((fixed-height . t))) | 3679 | ,@(when (window-size-fixed-p window) `((fixed-height . t))) |
| 3667 | ,@(when (window-size-fixed-p window t) `((fixed-width . t)))) | 3680 | ,@(when (window-size-fixed-p window t) `((fixed-width . t)))) |
| 3668 | (window--state-get-1 window markers))) | 3681 | (window--state-get-1 window ignore))) |
| 3669 | 3682 | ||
| 3670 | (defvar window-state-put-list nil | 3683 | (defvar window-state-put-list nil |
| 3671 | "Helper variable for `window-state-put'.") | 3684 | "Helper variable for `window-state-put'.") |
| @@ -3744,10 +3757,15 @@ value can be also stored on disk and read back in a new session." | |||
| 3744 | (state (cdr (assq 'buffer item)))) | 3757 | (state (cdr (assq 'buffer item)))) |
| 3745 | (when combination-limit | 3758 | (when combination-limit |
| 3746 | (set-window-combination-limit window combination-limit)) | 3759 | (set-window-combination-limit window combination-limit)) |
| 3747 | ;; Process parameters. | 3760 | ;; Assign saved window parameters. If a parameter's value is nil, |
| 3761 | ;; don't assign it unless the new window has it set already (which | ||
| 3762 | ;; shouldn't happen unless some `window-configuration-change-hook' | ||
| 3763 | ;; function installed it). | ||
| 3748 | (when parameters | 3764 | (when parameters |
| 3749 | (dolist (parameter parameters) | 3765 | (dolist (parameter parameters) |
| 3750 | (set-window-parameter window (car parameter) (cdr parameter)))) | 3766 | (when (or (cdr parameter) |
| 3767 | (window-parameter window (car parameter))) | ||
| 3768 | (set-window-parameter window (car parameter) (cdr parameter))))) | ||
| 3751 | ;; Process buffer related state. | 3769 | ;; Process buffer related state. |
| 3752 | (when state | 3770 | (when state |
| 3753 | ;; We don't want to raise an error here so we create a buffer if | 3771 | ;; We don't want to raise an error here so we create a buffer if |
diff --git a/src/ChangeLog b/src/ChangeLog index eb03ef1357f..aa4e92b4134 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-01-14 Eli Zaretskii <eliz@gnu.org> | 7 | 2012-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; | |||
| 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, Qstate; |
| 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,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 | |||
| 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 | Parameters 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 | |||
| 6623 | The car of each entry of this alist is the symbol specifying the | ||
| 6624 | parameter. The cdr is one of the following: | ||
| 6625 | |||
| 6626 | The symbol `state' means the parameter is saved by `window-state-get' | ||
| 6627 | provided its IGNORE argument is nil. `current-window-configuration' | ||
| 6628 | does not save this parameter. | ||
| 6629 | |||
| 6630 | nil means the parameter is saved by `current-window-configuration' and, | ||
| 6631 | provided its IGNORE argument is nil, by `window-state-get'. | ||
| 6632 | |||
| 6633 | t means the parameter is saved unconditionally by both | ||
| 6634 | `current-window-configuration' and `window-state-get'. Parameters | ||
| 6635 | without read syntax (like windows or frames) should not use that. | ||
| 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, 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); |