[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to restore the layout?
From: |
Juanma Barranquero |
Subject: |
Re: How to restore the layout? |
Date: |
Tue, 25 Jun 2013 00:47:45 +0200 |
On Mon, Jun 24, 2013 at 10:57 PM, martin rudalics <address@hidden> wrote:
> Now could someone also implement the desktop stuff, pretty please?
> (IIUC it's mostly about writing good doc-strings for some trivial
> function changes and defcustoms.)
This is a first cut against 24.3; no docstrings, not tested other than
trivially.
Once window-state-(get|put) do work in the trunk we can try to massage
it into something better.
J
--- desktop.el.old 2013-01-01 21:37:17.000000000 +0100
+++ desktop.el 2013-06-25 00:45:16.773228800 +0200
@@ -273,6 +273,7 @@
(defcustom desktop-globals-to-save
'(desktop-missing-file-warning
+ desktop--window-state
tags-file-name
tags-table-list
search-ring
@@ -358,6 +359,12 @@
:type '(repeat symbol)
:group 'desktop)
+(defcustom desktop-save-windows t
+ "When non-nil, save window configuration to desktop file."
+ :type 'boolean
+ :group 'desktop
+ :version "24.4")
+
(defcustom desktop-file-name-format 'absolute
"Format in which desktop file names should be saved.
Possible values are:
@@ -539,6 +546,9 @@
(defvar desktop-delay-hook nil
"Hooks run after all buffers are loaded; intended for internal use.")
+(defvar desktop--window-state nil
+ "Internal use only.")
+
;; ----------------------------------------------------------------------------
;; Desktop file conflict detection
(defvar desktop-file-modtime nil
@@ -851,8 +861,15 @@
((eq desktop-file-name-format 'local) (file-relative-name
filename dirname))
(t (expand-file-name filename))))
-
;; ----------------------------------------------------------------------------
+
+(defun desktop--save-windows ()
+ (setq desktop--window-state
+ (and desktop-save-windows
+ (mapcar (lambda (frame)
+ (window-state-get (frame-root-window frame) t))
+ (frame-list)))))
+
;;;###autoload
(defun desktop-save (dirname &optional release)
"Save the desktop in a desktop file.
@@ -880,6 +897,8 @@
(desktop-release-lock)
(unless (and new-modtime (desktop-owner)) (desktop-claim-lock)))
+ (desktop--save-windows)
+
(with-temp-buffer
(insert
";; -*- mode: emacs-lisp; coding: emacs-mule; -*-\n"
@@ -940,6 +959,13 @@
(defvar desktop-lazy-timer nil)
+(defun desktop--read-windows ()
+ (when desktop--window-state
+ (window-state-put (car desktop--window-state)
+ (frame-root-window (selected-frame)))
+ (dolist (state (cdr desktop--window-state))
+ (window-state-put state (frame-root-window (make-frame))))))
+
;; ----------------------------------------------------------------------------
;;;###autoload
(defun desktop-read (&optional dirname)
@@ -1009,6 +1035,7 @@
(switch-to-buffer (car (buffer-list)))
(run-hooks 'desktop-delay-hook)
(setq desktop-delay-hook nil)
+ (desktop--read-windows)
(run-hooks 'desktop-after-read-hook)
(message "Desktop: %d buffer%s restored%s%s."
desktop-buffer-ok-count
- Re: How to restore the layout?, (continued)
- Re: How to restore the layout?, Stephen Berman, 2013/06/24
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/24
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/24
- Re: How to restore the layout?, Jambunathan K, 2013/06/24
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/24
- Re: How to restore the layout?, martin rudalics, 2013/06/24
- Re: How to restore the layout?,
Juanma Barranquero <=
- Re: How to restore the layout?, Juri Linkov, 2013/06/24
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/24
- Re: How to restore the layout?, Juri Linkov, 2013/06/25
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/25
- Re: How to restore the layout?, martin rudalics, 2013/06/25
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/25
- Re: How to restore the layout?, Stefan Monnier, 2013/06/25
- Re: How to restore the layout?, martin rudalics, 2013/06/25
- Re: How to restore the layout?, Juanma Barranquero, 2013/06/25
- Re: How to restore the layout?, Angelo Graziosi, 2013/06/25