diff options
| author | Lars Ingebrigtsen | 2020-09-29 16:21:17 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-09-29 16:21:17 +0200 |
| commit | 7f2c35d02874129723cc5e89d54cc3ab5bf07a31 (patch) | |
| tree | 5ec0395277f9158c0dc7a1eb6e3f18b27588b84c | |
| parent | 07f748da431b67353767a7494083c10a2d17d7c4 (diff) | |
| download | emacs-7f2c35d02874129723cc5e89d54cc3ab5bf07a31.tar.gz emacs-7f2c35d02874129723cc5e89d54cc3ab5bf07a31.zip | |
Fix emacsclient -c foo.txt behaviour with many frames
* lisp/server.el (server-execute): Pass in whether we opened a new
frame or not (bug#43645).
(server-switch-buffer): Use this to switch to the requested buffer
in the new frame if we have "emacsclient -c foo.txt", and retain
the old behaviour if it's "emacsclient foo.txt".
| -rw-r--r-- | lisp/server.el | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/server.el b/lisp/server.el index 436a6ca0c70..a660deab8e8 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -1338,7 +1338,13 @@ The following commands are accepted by the client: | |||
| 1338 | "When done with this frame, type \\[delete-frame]"))) | 1338 | "When done with this frame, type \\[delete-frame]"))) |
| 1339 | ((not (null buffers)) | 1339 | ((not (null buffers)) |
| 1340 | (run-hooks 'server-after-make-frame-hook) | 1340 | (run-hooks 'server-after-make-frame-hook) |
| 1341 | (server-switch-buffer (car buffers) nil (cdr (car files))) | 1341 | (server-switch-buffer |
| 1342 | (car buffers) nil (cdr (car files)) | ||
| 1343 | ;; When triggered from "emacsclient -c", we popped up a | ||
| 1344 | ;; new frame. Ensure that we switch to the requested | ||
| 1345 | ;; buffer in that frame, and not in some other frame | ||
| 1346 | ;; where it may be displayed. | ||
| 1347 | (plist-get (process-plist proc) 'frame)) | ||
| 1342 | (run-hooks 'server-switch-hook) | 1348 | (run-hooks 'server-switch-hook) |
| 1343 | (unless nowait | 1349 | (unless nowait |
| 1344 | (message "%s" (substitute-command-keys | 1350 | (message "%s" (substitute-command-keys |
| @@ -1568,7 +1574,8 @@ starts server process and that is all. Invoked by \\[server-edit]." | |||
| 1568 | (server-clients (apply #'server-switch-buffer (server-done))) | 1574 | (server-clients (apply #'server-switch-buffer (server-done))) |
| 1569 | (t (message "No server editing buffers exist")))) | 1575 | (t (message "No server editing buffers exist")))) |
| 1570 | 1576 | ||
| 1571 | (defun server-switch-buffer (&optional next-buffer killed-one filepos) | 1577 | (defun server-switch-buffer (&optional next-buffer killed-one filepos |
| 1578 | this-frame-only) | ||
| 1572 | "Switch to another buffer, preferably one that has a client. | 1579 | "Switch to another buffer, preferably one that has a client. |
| 1573 | Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it. | 1580 | Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it. |
| 1574 | 1581 | ||
| @@ -1602,7 +1609,8 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)." | |||
| 1602 | ;; OK, we know next-buffer is live, let's display and select it. | 1609 | ;; OK, we know next-buffer is live, let's display and select it. |
| 1603 | (if (functionp server-window) | 1610 | (if (functionp server-window) |
| 1604 | (funcall server-window next-buffer) | 1611 | (funcall server-window next-buffer) |
| 1605 | (let ((win (get-buffer-window next-buffer 0))) | 1612 | (let ((win (get-buffer-window next-buffer |
| 1613 | (if this-frame-only nil 0)))) | ||
| 1606 | (if (and win (not server-window)) | 1614 | (if (and win (not server-window)) |
| 1607 | ;; The buffer is already displayed: just reuse the | 1615 | ;; The buffer is already displayed: just reuse the |
| 1608 | ;; window. If FILEPOS is non-nil, use it to replace the | 1616 | ;; window. If FILEPOS is non-nil, use it to replace the |
| @@ -1620,7 +1628,8 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)." | |||
| 1620 | (setq server-window (make-frame))) | 1628 | (setq server-window (make-frame))) |
| 1621 | (select-window (frame-selected-window server-window)))) | 1629 | (select-window (frame-selected-window server-window)))) |
| 1622 | (when (window-minibuffer-p) | 1630 | (when (window-minibuffer-p) |
| 1623 | (select-window (next-window nil 'nomini 0))) | 1631 | (select-window (next-window nil 'nomini |
| 1632 | (if this-frame-only nil 0)))) | ||
| 1624 | ;; Move to a non-dedicated window, if we have one. | 1633 | ;; Move to a non-dedicated window, if we have one. |
| 1625 | (when (window-dedicated-p) | 1634 | (when (window-dedicated-p) |
| 1626 | (select-window | 1635 | (select-window |