Subject: Multi-monitor frame sets
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Sun, 17 Feb 2019 21:34:19 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Shouldn't frame.el provide a command like make-frame-on-display,
but to make a frame on the specified monitor instead of display?

Isn't the following patch the right way to do this?
(It also adds completion for the existing command):

diff --git a/lisp/frame.el b/lisp/frame.el
index dc81302939..38f2653905 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -644,9 +644,33 @@ window-system-for-display
 (defun make-frame-on-display (display &optional parameters)
   "Make a frame on display DISPLAY.
 The optional argument PARAMETERS specifies additional frame parameters."
-  (interactive "sMake frame on display: ")
+  (interactive (list (completing-read
+                      (format "Make frame on display: ")
+                      (delete-dups
+                       (mapcar (lambda (frame)
+                                 (frame-parameter frame 'display))
+                               (frame-list))))))
   (make-frame (cons (cons 'display display) parameters)))
 
+(defun make-frame-on-monitor (monitor &optional parameters)
+  "Make a frame on monitor MONITOR.
+The optional argument PARAMETERS specifies additional frame parameters."
+  (interactive (list (completing-read
+                      (format "Make frame on monitor: ")
+                      (mapcar (lambda (a)
+                                (cdr (assq 'name a)))
+                              (display-monitor-attributes-list)))))
+  (let ((geometry (car (delq nil (mapcar (lambda (a)
+                                           (when (equal (cdr (assq 'name a)) monitor)
+                                             (cdr (assq 'geometry a))))
+                                         (display-monitor-attributes-list))))))
+    (make-frame (append (x-parse-geometry (format "%dx%d+%d+%d"
+                                                  (nth 2 geometry)
+                                                  (nth 3 geometry)
+                                                  (nth 0 geometry)
+                                                  (nth 1 geometry)))
+                        parameters))))
+
 (declare-function x-close-connection "xfns.c" (terminal))
 
 (defun close-display-connection (display)