aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMartin Rudalics2012-01-16 10:34:41 +0100
committerMartin Rudalics2012-01-16 10:34:41 +0100
commit6a6ee00d123a940f5b8858e61a327cd9e183cb1a (patch)
tree971207c682aa8a8cb903a4dedad2d8e6fcd86211 /lisp
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 'lisp')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/window.el64
2 files changed, 50 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e40d43ee8b9..676f767ae42 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12012-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
12012-01-15 Michael Albinus <michael.albinus@gmx.de> 102012-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.
3636WINDOW can be any window and defaults to the root window of the 3648WINDOW can be any window and defaults to the root window of the
3637selected frame. 3649selected frame.
3638 3650
3639Optional argument MARKERS non-nil means use markers for sampling 3651Optional argument IGNORE non-nil means do not use markers for
3640positions like `window-point' or `window-start'. MARKERS should 3652sampling positions like `window-point' or `window-start' and do
3641be non-nil only if the value is used for putting the state back 3653not record parameters unless `window-persistent-parameters'
3642in the same session (note that markers slow down processing). 3654requests it. IGNORE should be non-nil when the return value
3655shall be written to a file and read back in another session.
3643 3656
3644The return value can be used as argument for `window-state-put' 3657The return value can be used as argument for `window-state-put'
3645to put the state recorded here into an arbitrary window. The 3658to 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