summaryrefslogtreecommitdiff
path: root/lisp/frame.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>1997-12-01 14:22:04 +0000
committerEli Zaretskii <eliz@gnu.org>1997-12-01 14:22:04 +0000
commit845cde06cd0e21689c48f854a819e8a4de4e5f5a (patch)
tree10b6e22715a924c117e85e1d0da7896f0f5f6fae /lisp/frame.el
parent59c14ec62db0a72733e90945dd6b5560dc0b8d75 (diff)
downloademacs-845cde06cd0e21689c48f854a819e8a4de4e5f5a.tar.gz
(make-frame-names-alist, select-frame-by-name): New
functions, support frame selection by name with completion and history. (frame-name-history, frame-names-alist): New variables.
Diffstat (limited to 'lisp/frame.el')
-rw-r--r--lisp/frame.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index e4531a3d15a..14da34c822e 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -520,6 +520,43 @@ A negative ARG moves in the opposite order."
(if (eq window-system 'w32)
(w32-focus-frame frame)
(set-mouse-position (selected-frame) (1- (frame-width)) 0))))
+
+(defun make-frame-names-alist ()
+ (let* ((current-frame (selected-frame))
+ (falist
+ (cons
+ (cons (frame-parameter current-frame 'name) current-frame) nil))
+ (frame (next-frame nil t)))
+ (while (not (eq frame current-frame))
+ (progn
+ (setq falist (cons (cons (frame-parameter frame 'name) frame) falist))
+ (setq frame (next-frame frame t))))
+ falist))
+
+(defvar frame-name-history nil)
+(defvar frame-names-alist nil)
+(defun select-frame-by-name (name)
+ "Select the frame whose name is NAME and raise it.
+If there is no frame by that name, signal an error."
+ (interactive
+ (let (input default)
+ (setq frame-names-alist (make-frame-names-alist))
+ (setq default (car (car frame-names-alist)))
+ (setq input
+ (completing-read
+ (format "Select Frame (default %s): " default)
+ frame-names-alist nil t nil 'frame-name-history))
+ (if (= (length input) 0)
+ (list default)
+ (list input))))
+ (or (interactive-p)
+ (setq frame-names-alist (make-frame-names-alist)))
+ (let ((frame (cdr (assoc name frame-names-alist))))
+ (or frame
+ (error "There is no frame named `%s'" name))
+ (make-frame-visible frame)
+ (raise-frame frame)
+ (select-frame frame)))
;;;; Frame configurations