From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: How to restore the layout? Date: Tue, 02 Jul 2013 12:38:57 +0200 Message-ID: <51D2ADC1.5060902@gmx.at> References: <51C5AA68.4000204@alice.it> <51CD6324.2040504@gmx.at> <834ncifkq9.fsf@gnu.org> <83zjuae19s.fsf@gnu.org> <83r4fmdsw5.fsf@gnu.org> <85k3ldtion.fsf@member.fsf.org> <4E4C522D-DBCC-4133-A764-82C9CCE81E2D@swipnet.se> <8913208E-7FE2-41F5-AC93-000108413C47@swipnet.se> <51D126A4.50402@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1372761557 5006 80.91.229.3 (2 Jul 2013 10:39:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Jul 2013 10:39:17 +0000 (UTC) Cc: Emacs developers To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 02 12:39:15 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 1UtxzO-0001zZ-34 for ged-emacs-devel@m.gmane.org; Tue, 02 Jul 2013 12:39:14 +0200 Original-Received: from localhost ([::1]:58331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtxzN-0004ZE-Ox for ged-emacs-devel@m.gmane.org; Tue, 02 Jul 2013 06:39:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtxzI-0004WU-Qf for emacs-devel@gnu.org; Tue, 02 Jul 2013 06:39:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtxzG-0006Vx-V2 for emacs-devel@gnu.org; Tue, 02 Jul 2013 06:39:08 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:64479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtxzG-0006Ug-LU for emacs-devel@gnu.org; Tue, 02 Jul 2013 06:39:06 -0400 Original-Received: from mailout-de.gmx.net ([10.1.76.4]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0M8cOb-1TyRac2esl-00wHrV for ; Tue, 02 Jul 2013 12:39:05 +0200 Original-Received: (qmail invoked by alias); 02 Jul 2013 10:39:05 -0000 Original-Received: from 62-47-41-213.adsl.highway.telekom.at (EHLO [62.47.41.213]) [62.47.41.213] by mail.gmx.net (mp004) with SMTP; 02 Jul 2013 12:39:05 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+9C9wh/KK9k4BsDAzHdsse3dGx+NpKwk6dPmQOCs 4EQzr+UQXA3YS0 In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.18 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:161441 Archived-At: > I don't know whether minibuffer-less frames are unusual > (frequency-wise), but they are documented on the manual, and have > built-in support, so they should work (wrt saving&restoring) out of > the box. The problem is what to do when we initially have a minibuffer-equipped frame and the state we restore contains only minibuffer-less and minibuffer-only frames. In that case we'd have to delete the initial frame :-( > We can add desktop-* frame parameters easily with all kind of > information we need (as long as it can be read back). A first, untested stab is below: Frames get a desktop-mini parameter which is a cons. The car is t if the frame has a minibuffer and nil if not. For a t-car frame the cdr is its number. For a nil-car frame cdr t means use the default minibuffer frame and a number use the minibuffer frame whose desktop-mini cdr has that number. Now restoring the desktop has to scan the dekstop-mini parameters first: If a t-car one is found, make the frame. Next process the nil-car ones and make them. If it's got a number-cdr, find the frame with that number in its desktop-mini cdr and set the minibuffer-window parameter of the frame we just process to the minibuffer window of the frame we have found. But I'm not sure how to do handle the problem sketched above so I didn't write the restoration part. martin (defun desktop--save-minibuffer-frames () "Save window/frame state, as a global variable. Intended to be called from `desktop-save'. Internal use only." (let ((frame-list (frame-list)) (count 0) minibuffer-window minibuffer-frame) (dolist (frame frame-list) ;; For all frames reset desktop-mini parameter if set. (when (frame-parameter frame 'desktop-mini) (set-frame-parameter frame 'desktop-mini nil))) (dolist (frame frame-list) ;; Set minibuffer-frame to this frame's minibuffer frame. (let ((minibuffer-frame (window-frame (minibuffer-window frame)))) (cond ;; Process minibuffer-window frame parameter if present. ((and (setq minibuffer-window (frame-parameter frame 'minibuffer-window)) (window-minibuffer-p minibuffer-window)) (setq minibuffer-frame (window-frame minibuffer-window)) (let ((default (eq minibuffer-frame default-minibuffer-frame)) (this-count (cdr (frame-parameter minibuffer-frame 'desktop-mini)))) (unless this-count ;; Make desktop-mini entry for minibuffer frame. (setq count (1+ count) this-count count) (set-frame-parameter minibuffer-frame 'desktop-mini (cons t count))) ;; Make desktop-mini entry for frame processed. (set-frame-parameter frame 'desktop-mini (cons nil this-count)))) ;; Do nothig if we are our own minibuffer frame. ((eq minibuffer-frame frame)) ;; Use default-minibuffer-frame otherwise. (t (let ((this-count (cdr (frame-parameter default-minibuffer-frame 'desktop-mini)))) (unless this-count ;; Make desktop-mini entry for minibuffer frame. (setq count (1+ count) this-count count) (set-frame-parameter default-minibuffer-frame 'desktop-mini (cons t count))) ;; Make desktop-mini entry for frame processed. (set-frame-parameter frame 'desktop-mini (cons nil t)))))))))