From d58d31fbe7f1ee045f2040ac65c3b7f8797b30fc Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Fri, 26 Jul 2013 19:49:52 +0200 Subject: [PATCH] lisp/desktop.el (desktop--select-frame): Try harder to reuse the initial frame. --- lisp/ChangeLog | 5 +++++ lisp/desktop.el | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 28a9dde666c..d2f03c15301 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-07-26 Juanma Barranquero + + * desktop.el (desktop--select-frame): + Try harder to reuse the initial frame. + 2013-07-26 Stefan Monnier * emacs-lisp/edebug.el: Use backtrace-eval to handle lexical variables. diff --git a/lisp/desktop.el b/lisp/desktop.el index a29a30971aa..d5895a8de57 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -1235,10 +1235,20 @@ is the parameter list of the frame being restored. Internal use only." ;; If the frame has its own minibuffer, let's see whether ;; that frame has already been loaded (which can happen after ;; M-x desktop-read). - (setq frame (or (desktop--find-frame - (lambda (f m) - (equal (frame-parameter f 'desktop--mini) m)) - display mini)))) + (setq frame (desktop--find-frame + (lambda (f m) + (equal (frame-parameter f 'desktop--mini) m)) + display mini)) + ;; If it has not been loaded, and it is not a minibuffer-only frame, + ;; let's look for an existing non-minibuffer-only frame to reuse. + (unless (or frame (eq (cdr (assq 'minibuffer frame-cfg)) 'only)) + (setq frame (desktop--find-frame + (lambda (f) + (let ((w (frame-parameter f 'minibuffer))) + (and (window-live-p w) + (window-minibuffer-p w) + (eq (window-frame w) f)))) + display)))) (mini ;; For minibufferless frames, check whether they already exist, ;; and that they are linked to the right minibuffer frame. -- 2.39.2