unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* option for loading up a gui specific emacs daemon
@ 2016-12-13 23:02 Filipe Silva
  2016-12-13 23:14 ` Alex Hutcheson
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Filipe Silva @ 2016-12-13 23:02 UTC (permalink / raw)
  To: emacs-devel

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

Dear developers of the mighty emacs editor,

I'd like to load emacs with emacs --daemon=gui and then connect to it with
emacsclient -c --sever-file=gui.

This works almost right. The problem is that various popular packages make
extensive use of the (display-graphic-p) function/predicate to query frame
capabilities. For example, a theme package may query (display-graphic-p)
and assign gui or tty colors accordingly.

the thing is that(display-graphic-p) always returns nil in a emacs --deamon
type of loading, because emacs does not know if you are using emacsclient
with a gui or a tty.

Is there a way to say to emacs something like, "look, I'm starting you as a
daemon, but I promise I'll only connect to you with gui frames, so for all
intents and purposes, pretend that you are being started up as a gui".

If there is not a way to do that, maybe we could add that kind of option?

The impact of not having this options is that cosmetic packages that make
use of (display-graphic-p) always look off in a emacs --daemon loading
scenario.

thanks in advance,

Ninrod

[-- Attachment #2: Type: text/html, Size: 2422 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
@ 2016-12-13 23:14 ` Alex Hutcheson
  2016-12-14  0:02 ` Kaushal Modi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Alex Hutcheson @ 2016-12-13 23:14 UTC (permalink / raw)
  To: Filipe Silva; +Cc: emacs-devel

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

Have you tried starting emacs with:
emacsclient -c -a ""

That should start a daemon if one isn't already running. I can't easily
check the value of (display-graphic-p) during loadup right now, but it
would be easy to try.

On Tue, Dec 13, 2016 at 6:02 PM, Filipe Silva <filipe.silva@gmail.com>
wrote:

> Dear developers of the mighty emacs editor,
>
> I'd like to load emacs with emacs --daemon=gui and then connect to it with
> emacsclient -c --sever-file=gui.
>
> This works almost right. The problem is that various popular packages make
> extensive use of the (display-graphic-p) function/predicate to query frame
> capabilities. For example, a theme package may query (display-graphic-p)
> and assign gui or tty colors accordingly.
>
> the thing is that(display-graphic-p) always returns nil in a emacs
> --deamon type of loading, because emacs does not know if you are using
> emacsclient with a gui or a tty.
>
> Is there a way to say to emacs something like, "look, I'm starting you as
> a daemon, but I promise I'll only connect to you with gui frames, so for
> all intents and purposes, pretend that you are being started up as a gui".
>
> If there is not a way to do that, maybe we could add that kind of option?
>
> The impact of not having this options is that cosmetic packages that make
> use of (display-graphic-p) always look off in a emacs --daemon loading
> scenario.
>
> thanks in advance,
>
> Ninrod
>



-- 
Alex Hutcheson
alexhutcheson@google.com

[-- Attachment #2: Type: text/html, Size: 3445 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
  2016-12-13 23:14 ` Alex Hutcheson
@ 2016-12-14  0:02 ` Kaushal Modi
  2016-12-14 11:22   ` Filipe Silva
  2016-12-14  1:34 ` Noam Postavsky
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Kaushal Modi @ 2016-12-14  0:02 UTC (permalink / raw)
  To: Filipe Silva, emacs-devel

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

On Wed, Dec 14, 2016, 4:33 AM Filipe Silva <filipe.silva@gmail.com> wrote:

> The problem is that various popular packages make extensive use of the
> (display-graphic-p) function/predicate to query frame capabilities. For
> example, a theme package may query (display-graphic-p) and assign gui or
> tty colors accordingly.
>

Which packages are those, how can one recreate the issue you are seeing in
an emacs -Q session (for the case of emacsclient, I am aware that emacs -Q
does not help, so one would need to temporarily move their ~/.emacs.d/ dir
to something else, and use a minimal config that just starts the server)
after loading those packages?

> --

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1310 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
  2016-12-13 23:14 ` Alex Hutcheson
  2016-12-14  0:02 ` Kaushal Modi
@ 2016-12-14  1:34 ` Noam Postavsky
  2016-12-14 11:11   ` Filipe Silva
  2016-12-14 15:47 ` Eli Zaretskii
  2016-12-15 13:10 ` Ken Raeburn
  4 siblings, 1 reply; 9+ messages in thread
From: Noam Postavsky @ 2016-12-14  1:34 UTC (permalink / raw)
  To: Filipe Silva; +Cc: Emacs developers

On Tue, Dec 13, 2016 at 6:02 PM, Filipe Silva <filipe.silva@gmail.com> wrote:
>
> Is there a way to say to emacs something like, "look, I'm starting you as a
> daemon, but I promise I'll only connect to you with gui frames, so for all
> intents and purposes, pretend that you are being started up as a gui".

Advise display-graphic-p?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-14  1:34 ` Noam Postavsky
@ 2016-12-14 11:11   ` Filipe Silva
  2016-12-14 15:59     ` Noam Postavsky
  0 siblings, 1 reply; 9+ messages in thread
From: Filipe Silva @ 2016-12-14 11:11 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Emacs developers

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

Noam, that looks promising. Is there a way to advise display-graphic-p to
always return true but only if I started emacs as emacs --daemon=gui?

On Tue, Dec 13, 2016 at 11:34 PM, Noam Postavsky <
npostavs@users.sourceforge.net> wrote:

> On Tue, Dec 13, 2016 at 6:02 PM, Filipe Silva <filipe.silva@gmail.com>
> wrote:
> >
> > Is there a way to say to emacs something like, "look, I'm starting you
> as a
> > daemon, but I promise I'll only connect to you with gui frames, so for
> all
> > intents and purposes, pretend that you are being started up as a gui".
>
> Advise display-graphic-p?
>

[-- Attachment #2: Type: text/html, Size: 1109 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-14  0:02 ` Kaushal Modi
@ 2016-12-14 11:22   ` Filipe Silva
  0 siblings, 0 replies; 9+ messages in thread
From: Filipe Silva @ 2016-12-14 11:22 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Emacs developers

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

Kaushal, the zerodark theme by Nicolas Petton, for example:

https://github.com/NicolasPetton/zerodark-theme/blob/master/zerodark-theme.el#L158-L162

It is difficult to write a reproducible procedure because if you don't know
the theme, you think that colors are right. But they are not.

One would have to install the theme, load up emacs gui normally, and then
load up emacs with --daemon and compare the differences.



On Tue, Dec 13, 2016 at 10:02 PM, Kaushal Modi <kaushal.modi@gmail.com>
wrote:

>
>
> On Wed, Dec 14, 2016, 4:33 AM Filipe Silva <filipe.silva@gmail.com> wrote:
>
>> The problem is that various popular packages make extensive use of the
>> (display-graphic-p) function/predicate to query frame capabilities. For
>> example, a theme package may query (display-graphic-p) and assign gui or
>> tty colors accordingly.
>>
>
> Which packages are those, how can one recreate the issue you are seeing in
> an emacs -Q session (for the case of emacsclient, I am aware that emacs -Q
> does not help, so one would need to temporarily move their ~/.emacs.d/ dir
> to something else, and use a minimal config that just starts the server)
> after loading those packages?
>
>> --
>
> Kaushal Modi
>

[-- Attachment #2: Type: text/html, Size: 3081 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
                   ` (2 preceding siblings ...)
  2016-12-14  1:34 ` Noam Postavsky
@ 2016-12-14 15:47 ` Eli Zaretskii
  2016-12-15 13:10 ` Ken Raeburn
  4 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-14 15:47 UTC (permalink / raw)
  To: Filipe Silva; +Cc: emacs-devel

> From: Filipe Silva <filipe.silva@gmail.com>
> Date: Tue, 13 Dec 2016 21:02:15 -0200
> 
> I'd like to load emacs with emacs --daemon=gui and then connect to it with emacsclient -c --sever-file=gui.
> 
> This works almost right. The problem is that various popular packages make extensive use of the
> (display-graphic-p) function/predicate to query frame capabilities. For example, a theme package may query
> (display-graphic-p) and assign gui or tty colors accordingly. 
> 
> the thing is that(display-graphic-p) always returns nil in a emacs --deamon type of loading, because emacs
> does not know if you are using emacsclient with a gui or a tty. 

If you remove the test from those packages, does everything else in
the package work correctly without signaling any errors?

You see, these tests are supposed to be made before calling APIs that
would otherwise signal an error or otherwise barf on non-GUI frames.
If removing the tests makes the package work fine in the daemon mode
or on a text-mode frame, it means the test is redundant and should
simply be removed.  Very few Emacs features really require GUI frames,
so it could be that these tests, or at least some of them, are
remnants from distant past, when many more features would only work in
GUI mode.

OTOH, if these tests are indeed required, then making them work in the
daemon will not provide any relief for you, because it will just delay
the error until later.

Does the above make sense?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-14 11:11   ` Filipe Silva
@ 2016-12-14 15:59     ` Noam Postavsky
  0 siblings, 0 replies; 9+ messages in thread
From: Noam Postavsky @ 2016-12-14 15:59 UTC (permalink / raw)
  To: Filipe Silva; +Cc: Emacs developers

On Wed, Dec 14, 2016 at 6:11 AM, Filipe Silva <filipe.silva@gmail.com> wrote:
> Noam, that looks promising. Is there a way to advise display-graphic-p to
> always return true but only if I started emacs as emacs --daemon=gui?
>

(Untested)

(defun gui-daemon-or-other-p (other &rest args)
  (if (equal (daemonp) "gui") t
    (apply other args)))
(advice-add 'display-graphic-p :around #'gui-daemon-or-other-p)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: option for loading up a gui specific emacs daemon
  2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
                   ` (3 preceding siblings ...)
  2016-12-14 15:47 ` Eli Zaretskii
@ 2016-12-15 13:10 ` Ken Raeburn
  4 siblings, 0 replies; 9+ messages in thread
From: Ken Raeburn @ 2016-12-15 13:10 UTC (permalink / raw)
  To: Filipe Silva; +Cc: emacs-devel

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


On Dec 13, 2016, at 18:02, Filipe Silva <filipe.silva@gmail.com> wrote:

> Dear developers of the mighty emacs editor, 
> 
> I'd like to load emacs with emacs --daemon=gui and then connect to it with emacsclient -c --sever-file=gui.
> 
> This works almost right. The problem is that various popular packages make extensive use of the (display-graphic-p) function/predicate to query frame capabilities. For example, a theme package may query (display-graphic-p) and assign gui or tty colors accordingly. 
> 
> the thing is that(display-graphic-p) always returns nil in a emacs --deamon type of loading, because emacs does not know if you are using emacsclient with a gui or a tty.

Daemon mode isn’t the only time a graphical display can be added when one wasn’t initially in use.  A tty-mode Emacs can still run M-x make-frame-on-display or run a server.

If a package is assuming that the characteristics of the current frame (like the result of display-graphic-p) when the package is loaded will apply to every frame ever in that Emacs session, the package has a bug….

Ken

[-- Attachment #2: Type: text/html, Size: 2204 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-12-15 13:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 23:02 option for loading up a gui specific emacs daemon Filipe Silva
2016-12-13 23:14 ` Alex Hutcheson
2016-12-14  0:02 ` Kaushal Modi
2016-12-14 11:22   ` Filipe Silva
2016-12-14  1:34 ` Noam Postavsky
2016-12-14 11:11   ` Filipe Silva
2016-12-14 15:59     ` Noam Postavsky
2016-12-14 15:47 ` Eli Zaretskii
2016-12-15 13:10 ` Ken Raeburn

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).