all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: lekktu@gmail.com, cyd@stupidchicken.com, emacs-devel@gnu.org
Subject: Re: emacsclient's option decoding code
Date: Wed, 12 Nov 2008 21:36:33 +0200	[thread overview]
Message-ID: <ufxlwpwhq.fsf@gnu.org> (raw)
In-Reply-To: <jwvprl1n0jp.fsf-monnier+emacs@gnu.org>

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Juanma Barranquero <lekktu@gmail.com>,  cyd@stupidchicken.com,  emacs-devel@gnu.org
> Date: Tue, 11 Nov 2008 21:31:59 -0500
> 
> >> Chong has already explained the assumption. And IMO that assumption is
> >> correct for POSIX
> 
> > I can't say I see why such an assumption should be made for Posix,
> > either.
> 
> Because it mimicks the behavior of Emacs itself (if you start it with
> a $DISPLAY, it defaults to using an X11 frame and if there's no
> $DISPLAY it uses the tty).

But this is guesswork at best, and cannot possibly DTRT in every
possible use-case, because emacsclient have no way of knowing what the
Emacs server can or cannot do.  For example, the server could have
been built with no X11 support, or the "current terminal" specified by
the --tty option could be unavailable.  Or you could be talking to a
remote Emacs, in which case there's no reason to believe the client
will know anything about $DISPLAY on the remote machine.

IOW, unlike with launching Emacs itself, where we always know what we
can or cannot do (since it's the same single program), when
emacsclient is invoked, it currently tries to second-guess
capabilities of another program, and there just aren't any good means
to do that reliably.

The upshot is, or so it seems, that there's no reliable way of making
sure the client's request will be served as well as possible.

So I propose a different strategy: given a specific request from a
client, let's have the server try to serve the request in the best
possible way it can.  For example:

  . if --display=DISPLAY was specified, try the given DISPLAY, if that
    fails, try ":0.0", if that fails, try using a tty;

  . if -c was specified, try creating a GUI frame, and failing that,
    try a tty frame;

  . if --tty was specified, try make-frame-on-tty, if it fails, try
    using the current tty or a 	GUI frame.

This could be implemented simply by catching errors thrown by
make-frame-on-tty etc. and falling back on safer methods as outlined
above.

The advantages are that (1) it will work more reliably (basically, if
some kind of frame is possible, it will be used); (2) server.el does
not need to be littered by ugly system-dependent conditions, it could
assume Posix semantics and let less-capable platforms use the first
supported fallback; and (3) emacsclient's code that parses the
command-line options can be much simpler, since it needs not guess
what Emacs can or cannot do.

> > platforms, as much as possible.  In this case, "as much as possible"
> > means that emacsclient should be able on Windows to create a GUI frame
> > if a GUI Emacs is running and a tty frame if a tty Emacs is running.
> 
> That could make sense for -c indeed, altough it's not what happens under
> X11: under X11 a "-c" with no $DISPLAY is equivalent to -t, i.e. it
> uses the tty from where "emacsclient" is run, rather than using the tty
> where the Emacs server is currently running.

We could try to use emacsclient's tty, and if that fails, fall back on
the one where Emacs is running.

> > Would it be better to return "0.0" instead of nil or ""?
> 
> I don't like using nil for "the w32 window system", indeed.  I think the
> "" we currently use is better.  Can't we just make make-frame-on-display
> accept an argument "" to mean "the w32 window system"?

With my suggestion, none of this trickery is needed.




  parent reply	other threads:[~2008-11-12 19:36 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-01 14:04 emacsclient's option decoding code Eli Zaretskii
2008-11-02  2:13 ` Stefan Monnier
2008-11-02 21:45 ` Chong Yidong
2008-11-02 22:00   ` Juanma Barranquero
2008-11-02 23:18     ` Chong Yidong
2008-11-03  0:50       ` Juanma Barranquero
2008-11-03  4:14         ` Eli Zaretskii
2008-11-03 12:12           ` Juanma Barranquero
2008-11-03 20:06             ` Eli Zaretskii
2008-11-03 20:19               ` Chong Yidong
2008-11-04  4:20                 ` Eli Zaretskii
2008-11-04 16:40                   ` Chong Yidong
2008-11-06 11:56                     ` Juanma Barranquero
2008-11-03 21:26               ` Juanma Barranquero
2008-11-04  4:19                 ` Eli Zaretskii
2008-11-06 12:08                   ` Juanma Barranquero
2008-11-07  9:53                     ` Eli Zaretskii
2008-11-07 11:42                       ` Juanma Barranquero
2008-11-07 11:47                         ` Juanma Barranquero
2008-11-07 14:36                           ` Eli Zaretskii
2008-11-07 14:42                             ` Juanma Barranquero
2008-11-10 18:22                               ` Juanma Barranquero
2008-11-10 18:36                                 ` Chong Yidong
2008-11-10 23:33                                   ` Juanma Barranquero
2008-11-11  4:09                                 ` Eli Zaretskii
2008-11-11  4:14                                   ` Chong Yidong
2008-11-11 21:16                                     ` Eli Zaretskii
2008-11-11  9:39                                   ` Juanma Barranquero
2008-11-11 15:37                                     ` Juanma Barranquero
2008-11-11 21:24                                     ` Eli Zaretskii
2008-11-11 23:36                                       ` Juanma Barranquero
2008-11-12  4:22                                         ` Eli Zaretskii
2008-11-12  9:41                                           ` Juanma Barranquero
2008-11-12 19:14                                             ` Eli Zaretskii
2008-11-12 21:05                                               ` Juanma Barranquero
2008-11-13  4:12                                                 ` Eli Zaretskii
2008-11-13  8:34                                                   ` Juanma Barranquero
2008-11-12 19:37                                         ` Eli Zaretskii
2008-11-12  2:31                                       ` Stefan Monnier
2008-11-12  9:33                                         ` Juanma Barranquero
2008-11-12 15:56                                           ` Stefan Monnier
2008-11-12 16:37                                             ` Juanma Barranquero
2008-11-12 17:13                                               ` Stefan Monnier
2008-11-13  1:16                                               ` Lennart Borgman
2008-11-13  4:18                                                 ` Eli Zaretskii
2008-11-13  9:00                                               ` Juanma Barranquero
2008-11-13 15:45                                                 ` Dan Nicolaescu
2008-11-13 16:05                                                   ` Juanma Barranquero
2008-11-13 16:05                                                     ` Juanma Barranquero
2008-11-13 16:08                                                     ` Dan Nicolaescu
2008-11-12 19:36                                         ` Eli Zaretskii [this message]
2008-11-12 20:56                                           ` Stefan Monnier
2008-11-13  4:10                                             ` Eli Zaretskii
2008-11-13  4:29                                               ` mail
2008-11-13 20:54                                                 ` Eli Zaretskii
2008-11-13 21:27                                                   ` mail
2008-11-13 22:30                                                     ` Eli Zaretskii
2008-11-13 23:54                                                       ` mail
2008-11-13 20:03                                           ` Juri Linkov
2008-11-13 20:40                                             ` mail
2008-11-13 21:08                                               ` Thorsten Bonow
2008-11-13 22:01                                               ` Thorsten Bonow
2008-11-15  2:58                               ` Evil Boris
2008-11-07 14:35                         ` Eli Zaretskii
2008-11-03 14:45           ` Juanma Barranquero
2008-11-03 19:59             ` Eli Zaretskii
2008-11-03 20:03             ` Eli Zaretskii

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=ufxlwpwhq.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.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.