all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* question about `display-graphic-p' and emacs daemon
@ 2012-11-21 15:16 Drew Adams
  2012-11-21 15:31 ` Christopher Schmidt
  2012-11-21 18:05 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2012-11-21 15:16 UTC (permalink / raw)
  To: emacs-devel

My main question here is #1.  #2 is about the doc I looked up while trying to
find an answer to #1.

1. I have a defcustom that has this as the initial value:

(and (fboundp 'image-file-name-regexp)
     (if (fboundp 'display-graphic-p)
         (display-graphic-p)
       window-system)
     t)

With emacs daemon, loading the file with that sexp raises an error, because it
is eval'd before the first frame is displayed.

As a workaround, I can remove the `display-graphic-p'/`window-system' test and
do that only at runtime (after a frame has been displayed).

But shouldn't it be possible for Emacs to determine the display type without
actually displaying a frame?  Naive question, but I'm ignorant.  If that is
possible, what is the test to do it?

If it is not possible, and things like `display-graphic-p' should not be invoked
before displaying a frame, including from Emacs daemon, shouldn't that be
documented (in particular in connection with the daemon)?  Is it normal that one
needs to change source code this way to take into account the possibility of
using Emacs daemon?

I hope I'm just missing something simple.

2. While looking for the answer, I checked the doc for `display-graphic-p'.  It
says that argument DISPLAY can be a display name, as an alternative to being a
frame name or nil.  But it says nothing about what a "display name" means wrt
Emacs Lisp.

What form does it take?  Is it a Unix/Linux X-Window display name?  What about
on MS Windows?

The entire node (elisp) `Display Feature Testing' talks about "display" without
saying what it means for Emacs Lisp or giving any example of a DISPLAY arg
(other than a frame or nil).

That node is a subsection of the section `Frames', which describes "display" in
general terms, without giving any example of a DISPLAY value (other than a
frame).

The closest I found to describing DISPLAY is in `Multiple Terminals'.  It
describes X-Window displays as having names of the form HOST:SERVER.SCREEN.
What about non X-Window displays?  And there is mention in that node of init
option `--display' and env var `DISPLAY', which refer readers (eventually) to
node `Display X', which describes more of the same.  What about non X-Window
displays? 

If I eval (x-display-list) on MS Windows I see ("w32"), but I don't see that
form of DISPLAY described anywhere.  And I see that (framep (selected-frame))
returns `w32' (a symbol this time).




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

* Re: question about `display-graphic-p' and emacs daemon
  2012-11-21 15:16 question about `display-graphic-p' and emacs daemon Drew Adams
@ 2012-11-21 15:31 ` Christopher Schmidt
  2012-11-21 16:27   ` Drew Adams
  2012-11-21 18:05 ` Eli Zaretskii
  1 sibling, 1 reply; 4+ messages in thread
From: Christopher Schmidt @ 2012-11-21 15:31 UTC (permalink / raw)
  To: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> 1. I have a defcustom that has this as the initial value:
>
> (and (fboundp 'image-file-name-regexp)
>      (if (fboundp 'display-graphic-p)
>          (display-graphic-p)
>        window-system)
>      t)
>
> With emacs daemon, loading the file with that sexp raises an error,
> because it is eval'd before the first frame is displayed.

I think this form evals just fine - (display-graphic-p) is always nil,
though.

> As a workaround, I can remove the `display-graphic-p'/`window-system'
> test and do that only at runtime (after a frame has been displayed).
>
> But shouldn't it be possible for Emacs to determine the display type
> without actually displaying a frame?  Naive question, but I'm
> ignorant.  If that is possible, what is the test to do it?

A daemonized Emacs can have multiple frames that use either a window
system or a terminal - at the same time!  That is (display-graphic-p)
can eval to either t or nil within the same Emacs process, depending on
the selected frame.

        Christopher



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

* RE: question about `display-graphic-p' and emacs daemon
  2012-11-21 15:31 ` Christopher Schmidt
@ 2012-11-21 16:27   ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2012-11-21 16:27 UTC (permalink / raw)
  To: 'Christopher Schmidt', emacs-devel

> > 1. I have a defcustom that has this as the initial value:
> >
> > (and (fboundp 'image-file-name-regexp)
> >      (if (fboundp 'display-graphic-p)
> >          (display-graphic-p)
> >        window-system)
> >      t)
> >
> > With emacs daemon, loading the file with that sexp raises an error,
> > because it is eval'd before the first frame is displayed.
> 
> I think this form evals just fine - (display-graphic-p) is always nil,
> though.

Ah, then I misunderstood the problem, which Christopher reported originally.  I
thought an error was raised.

> > As a workaround, I can remove the `display-graphic-p'/`window-system'
> > test and do that only at runtime (after a frame has been displayed).
> >
> > But shouldn't it be possible for Emacs to determine the display type
> > without actually displaying a frame?  Naive question, but I'm
> > ignorant.  If that is possible, what is the test to do it?
> 
> A daemonized Emacs can have multiple frames that use either a window
> system or a terminal - at the same time!  That is (display-graphic-p)
> can eval to either t or nil within the same Emacs process, 
> depending on the selected frame.

Got it.  So I will use both the original defcustom sexp and a runtime,
frame-specific check.  Thx.

(My questions about the doc of "display" remain, however.)




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

* Re: question about `display-graphic-p' and emacs daemon
  2012-11-21 15:16 question about `display-graphic-p' and emacs daemon Drew Adams
  2012-11-21 15:31 ` Christopher Schmidt
@ 2012-11-21 18:05 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2012-11-21 18:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Wed, 21 Nov 2012 07:16:16 -0800
> 
> But shouldn't it be possible for Emacs to determine the display type without
> actually displaying a frame?

Why do you need that?  The display-*-P functions are mainly for
testing what the current frame can or cannot do, so that Lisp
applications could fall back on alternative methods if the best
alternative cannot be supported.  E.g., if fringes are not available,
a Lisp program could display something in an overlay or in margins.

If you want to know whether the current Emacs executable can do
something, it is better to use fboundp and featurep instead.

> 2. While looking for the answer, I checked the doc for `display-graphic-p'.  It
> says that argument DISPLAY can be a display name, as an alternative to being a
> frame name or nil.  But it says nothing about what a "display name" means wrt
> Emacs Lisp.
> 
> What form does it take?  Is it a Unix/Linux X-Window display name?

Yes.  A cross reference to "Multiple Terminals" would be good there.

> What about on MS Windows?

The Windows build does not support multiple displays.

> The closest I found to describing DISPLAY is in `Multiple Terminals'.  It
> describes X-Window displays as having names of the form HOST:SERVER.SCREEN.
> What about non X-Window displays?

There are none; X-Window displays are the only ones Emacs supports.

> If I eval (x-display-list) on MS Windows I see ("w32"), but I don't see that
> form of DISPLAY described anywhere.

That's a fake name, just so that code that looks at this will have
some string to play with.  It has no meaning.

> And I see that (framep (selected-frame)) returns `w32' (a symbol
> this time).

Yes, and that one _is_ documented.



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

end of thread, other threads:[~2012-11-21 18:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-21 15:16 question about `display-graphic-p' and emacs daemon Drew Adams
2012-11-21 15:31 ` Christopher Schmidt
2012-11-21 16:27   ` Drew Adams
2012-11-21 18:05 ` Eli Zaretskii

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.