diff options
Diffstat (limited to 'lisp/window.el')
| -rw-r--r-- | lisp/window.el | 78 |
1 files changed, 36 insertions, 42 deletions
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. |
| 3648 | WINDOW can be any window and defaults to the root window of the | 3641 | WINDOW can be any window and defaults to the root window of the |
| 3649 | selected frame. | 3642 | selected frame. |
| 3650 | 3643 | ||
| 3651 | Optional argument IGNORE non-nil means do not use markers for | 3644 | Optional argument WRITABLE non-nil means do not use markers for |
| 3652 | sampling positions like `window-point' or `window-start' and do | 3645 | sampling `window-point' and `window-start'. Together, WRITABLE |
| 3653 | not record parameters unless `window-persistent-parameters' | 3646 | and the variable `window-persistent-parameters' specify which |
| 3654 | requests it. IGNORE should be non-nil when the return value | 3647 | window parameters are saved by this function. WRITABLE should be |
| 3655 | shall be written to a file and read back in another session. | 3648 | non-nil when the return value shall be written to a file and read |
| 3649 | back in another session. Otherwise, an application may run into | ||
| 3650 | an `invalid-read-syntax' error while attempting to read back the | ||
| 3651 | value from file. | ||
| 3656 | 3652 | ||
| 3657 | The return value can be used as argument for `window-state-put' | 3653 | The return value can be used as argument for `window-state-put' |
| 3658 | to put the state recorded here into an arbitrary window. The | 3654 | to 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 |