all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eliza Velasquez via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 25547@debbugs.gnu.org, Alex Hutcheson <alexhutcheson@google.com>
Subject: bug#25547: 25.1.91; emacsclient -c creates frames on the wrong display
Date: Thu, 5 Nov 2020 15:41:08 -0800	[thread overview]
Message-ID: <CAK1djOoquVkX19Re7Bf=FhFO0ZYUFXDXq_diie+tseeoU5wxMg@mail.gmail.com> (raw)
In-Reply-To: <jwvk0v0mnce.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

Oops, forgot to reply all on my last message. Attached is the patch.

On Wed, Nov 4, 2020 at 8:44 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > It looks like I was able to make progress today. Just by modifying
> > server.el, I've gotten `emacsclient -ce "..."` to create a new frame
> > based on the currently selected frame's terminal when called in a dumb
> > terminal.
>
> Great!
>
> > Unfortunately, the command for calling ediff is still very
> > unpleasant:
> >
> > emacsclient -ucF "((delete-frame-on-ediff-quit . t))" \
> >   -e "(ediff-merge-with-ancestor \"${local}\" \"${other}\" \"${base}\"
> > nil \"${output}\")" \
> >   -e "(add-hook 'ediff-quit-hook (lambda () (when (frame-parameter nil
> > 'delete-frame-on-ediff-quit) (delete-frame))))"
>
> I think the problem is that emacsclient lacks the equivalent of `-f`,
> i.e. calling a particular ELisp function where the remaining arguments
> can be consumed by that function.  That would solve the problem of
> quoting (your above script will stumble when encountering
> a file name with quotes in it or with a final backslash).
>
> > So perhaps introducing a wrapper script for ediff merges would still be useful.
>
> We should be able to add a convenience `batch-ediff-merge-with-ancestor`.
> Bonus points if you manage to make it work with `emacs --batch -f` as
> well as with `emacsclient --<newflag>`.
>
>
>         Stefan
>

[-- Attachment #2: 25547.patch --]
[-- Type: application/octet-stream, Size: 2286 bytes --]

diff --git a/lisp/server.el b/lisp/server.el
index a660deab8e..b6d0136d51 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -354,9 +354,11 @@ server-delete-client
 
       (setq server-clients (delq proc server-clients))
 
-      ;; Delete the client's tty, except on Windows (both GUI and console),
-      ;; where there's only one terminal and does not make sense to delete it.
-      (unless (eq system-type 'windows-nt)
+      ;; Delete the client's tty, except on Windows (both GUI and
+      ;; console), where there's only one terminal and does not make
+      ;; sense to delete it, or if we are explicitly told not.
+      (unless (or (eq system-type 'windows-nt)
+                  (process-get proc 'no-delete-terminal))
 	(let ((terminal (process-get proc 'terminal)))
 	  ;; Only delete the terminal if it is non-nil.
 	  (when (and terminal (eq (terminal-live-p terminal) t))
@@ -918,6 +920,19 @@ server-create-window-system-frame
            (server-send-string proc "-window-system-unsupported \n")
            nil))))
 
+(defun server-create-frame (nowait proc &optional parameters)
+  (add-to-list 'frame-inherited-parameters 'client)
+  (let ((frame (make-frame `((client . ,(if nowait 'nowait proc))
+                             ;; This is a leftover, see above.
+                             (environment . ,(process-get proc 'env))
+                             ,@parameters))))
+    (server-log (format "%s created" frame) proc)
+    (select-frame frame)
+    (process-put proc 'frame frame)
+    (process-put proc 'terminal (frame-terminal frame))
+    (process-put proc 'no-delete-terminal t)
+    frame))
+
 (defun server-goto-toplevel (proc)
   (condition-case nil
       ;; If we're running isearch, we must abort it to allow Emacs to
@@ -1264,6 +1279,10 @@ server-process-filter
 					   terminal-frame)))))
 		    (setq tty-name nil tty-type nil)
 		    (if display (server-select-display display)))
+                   ((equal tty-type "dumb")
+                    ;; Dumb terminals should create frames without
+                    ;; preference for tty or window system (bug#25547)
+                    (server-create-frame nowait proc frame-parameters))
 		   ((or (and (eq system-type 'windows-nt)
 			     (daemonp)
 			     (setq display "w32"))

  reply	other threads:[~2020-11-05 23:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-26 18:09 bug#25547: 25.1.91; emacsclient -c creates frames on the wrong display Alex Hutcheson
2020-11-02 22:37 ` Stefan Monnier
     [not found]   ` <CAK1djOorpaeoMU-gtd+hQnWWK8tOaER6OPYgukYrn=V1cDh+aQ@mail.gmail.com>
     [not found]     ` <jwvsg9rtghs.fsf-monnier+emacs@gnu.org>
2020-11-03 18:36       ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-05  2:00         ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-05  4:44           ` Stefan Monnier
2020-11-05 23:41             ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-11-06  0:55               ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-06  5:39               ` Eli Zaretskii
2020-11-06 19:14                 ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-06 22:07                   ` Stefan Monnier
2020-11-07  8:04                   ` Eli Zaretskii
2020-11-10  0:14                     ` Eliza Velasquez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-11  3:14                       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK1djOoquVkX19Re7Bf=FhFO0ZYUFXDXq_diie+tseeoU5wxMg@mail.gmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=25547@debbugs.gnu.org \
    --cc=alexhutcheson@google.com \
    --cc=exv@google.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.