emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 616b4c5 1/4: Let select-frame-by-name choose any


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 616b4c5 1/4: Let select-frame-by-name choose any frame when called from lisp (Bug#25521)
Date: Sun, 15 Oct 2017 14:16:28 -0400 (EDT)

branch: emacs-26
commit 616b4c59561c63b986634d666c45a73e95fac392
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 etc/NEWS      |  4 ++++
 lisp/frame.el | 16 ++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 2b2aa7c..d995a3d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1863,6 +1863,10 @@ For details see the section "(elisp) Mouse Window 
Auto-selection" in
 the ELisp manual.
 
 ---
+*** 'select-frame-by-name' now may return a frame on another display
+if it does not find a suitable one on the current display.
+
+---
 ** 'tcl-auto-fill-mode' is now declared obsolete.  Its functionality
 can be replicated simply by setting 'comment-auto-fill-only-comments'.
 
diff --git a/lisp/frame.el b/lisp/frame.el
index f8aa5c6..b6c0664 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -892,7 +892,8 @@ Calls `suspend-emacs' if invoked from the controlling tty 
device,
 
 (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 @@ If there is no frame by that name, signal an error."
      (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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]