From 846c5603a02544ef9b25f395c253b3621aea4984 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 1 Sep 2017 09:38:55 -0400 Subject: [PATCH 1/3] Let select-frame-by-name choose any frame when called from lisp (Bug#25521) * lisp/frame.el (select-frame-by-name): Choose from the whole list of frames in the non-interactive part, if not found on the current display. --- lisp/frame.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/frame.el b/lisp/frame.el index 76c1842455..a710360cdb 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -892,7 +892,8 @@ make-frame-names-alist (defvar frame-name-history nil) (defun select-frame-by-name (name) - "Select the frame on the current terminal whose name is NAME and raise it. + "Select the frame whose name is NAME and raise it. +Frames on the current terminal are checked first. If there is no frame by that name, signal an error." (interactive (let* ((frame-names-alist (make-frame-names-alist)) @@ -903,11 +904,14 @@ select-frame-by-name (if (= (length input) 0) (list default) (list input)))) - (let* ((frame-names-alist (make-frame-names-alist)) - (frame (cdr (assoc name frame-names-alist)))) - (if frame - (select-frame-set-input-focus frame) - (error "There is no frame named `%s'" name)))) + (select-frame-set-input-focus + ;; Prefer frames on the current display. + (or (cdr (assoc name (make-frame-names-alist))) + (catch 'done + (dolist (frame (frame-list)) + (when (equal (frame-parameter frame 'name) name) + (throw 'done frame)))) + (error "There is no frame named `%s'" name)))) ;;;; Background mode. -- 2.11.0