From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: How to restore the layout? Date: Tue, 25 Jun 2013 00:47:45 +0200 Message-ID: References: <51C5AA68.4000204@alice.it> <51C6B138.50903@gmx.at> <51C6CF57.9030203@alice.it> <51C87C3E.90904@gmx.at> <83ehbrju1d.fsf@gnu.org> <87r4frcq9v.fsf@rosalinde.fritz.box> <87vc5345t3.fsf@gmail.com> <51C8B2C8.4000803@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1372114117 14256 80.91.229.3 (24 Jun 2013 22:48:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Jun 2013 22:48:37 +0000 (UTC) Cc: Eli Zaretskii , Stephen Berman , Jambunathan K , Angelo Graziosi , Emacs developers To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 25 00:48:38 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UrFYq-0002Xq-HS for ged-emacs-devel@m.gmane.org; Tue, 25 Jun 2013 00:48:36 +0200 Original-Received: from localhost ([::1]:42111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrFYp-0007xc-Ua for ged-emacs-devel@m.gmane.org; Mon, 24 Jun 2013 18:48:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrFYl-0007xI-UC for emacs-devel@gnu.org; Mon, 24 Jun 2013 18:48:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrFYk-000469-MK for emacs-devel@gnu.org; Mon, 24 Jun 2013 18:48:31 -0400 Original-Received: from mail-ie0-x232.google.com ([2607:f8b0:4001:c03::232]:53458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrFYg-00044i-Em; Mon, 24 Jun 2013 18:48:26 -0400 Original-Received: by mail-ie0-f178.google.com with SMTP id u16so25234890iet.23 for ; Mon, 24 Jun 2013 15:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2sDFswbB+YZA4IJb7sXJWtziouOSF/01pUuGw7dRcXs=; b=gep00wHmXb7BkUxRE52AZRl05XAX83Q/B4gD6eYZXQuip5IAeTkt67nDpcewHvOzmb dxQInqipaCEkLok3H/mSulJ8FgjDYss1McX0+OS8fd0tX3xBGVugLrtug5AvLdW1iAk/ Ku8QxU1NA/8S4GRftGHoI1JBlxUVt5pGr0FzJU7+WZzQ2VB1G1uDDJmTlprqpNuEId+J WoOS1KvYKXV5+YfTbqCZ90XA7OqGOg4NdIdwyhxw+OAH3taGX/ZGNDCagRgqM4EjSKx6 VffsxyQmy8rp8oGghNOPvYq7vSbQl64nucmyrQUeCbaxOS3Jv8ulGKbhiv9yH/XYTPtS MWqg== X-Received: by 10.50.2.67 with SMTP id 3mr7073895igs.11.1372114105790; Mon, 24 Jun 2013 15:48:25 -0700 (PDT) Original-Received: by 10.64.126.161 with HTTP; Mon, 24 Jun 2013 15:47:45 -0700 (PDT) In-Reply-To: <51C8B2C8.4000803@gmx.at> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160992 Archived-At: On Mon, Jun 24, 2013 at 10:57 PM, martin rudalics 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