diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 28a9dde666c9dca49f7ec9ab258c3377a9b4c9c5..d2f03c153019d8a6cf207d997cdc343e451c2cf0 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 a29a30971aaab2633cb96e49a17c794a32949bb4..d5895a8de5707ee6e32a08b1eeab691b1c64d02f 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.