unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Use of `window-system' as a predicate is deprecated.  Why?
@ 2022-07-09 12:22 Alan Mackenzie
  2022-07-09 12:36 ` Po Lu
  2022-07-09 12:40 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Mackenzie @ 2022-07-09 12:22 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs.

The doc string for window-system and its Elisp manual entry say that the
function should not be used.  The manual entry says:

   Do _not_ use `window-system' and `initial-window-system' as predicates
   or boolean flag variables, if you want to write code that works
   differently on text terminals and graphic displays.  That is because
   `window-system' is not a good indicator of Emacs capabilities on a
   given display type.  Instead, use `display-graphic-p' or any of the
   other `display-*-p' predicates described in Display Feature Testing.

..  I am amending minibuf.c and wish to know only whether the current
terminal->focus_frame_hook is validly set.

The manual entry seems to be to be unnecessarily patronising.  It
insinuates that the only possible "capabilities" a user could be
interested in are graphic capabilities.

Surely I should not have to go such ridiculous lengths as calling a lisp
function which has nothing to do with what I need, and then interpreting
its result.

So, how should I find out whether terminal->focus_frame_hook is valid or
not, if I'm not allowed to use Fwindow_system?

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: Use of `window-system' as a predicate is deprecated.  Why?
  2022-07-09 12:22 Use of `window-system' as a predicate is deprecated. Why? Alan Mackenzie
@ 2022-07-09 12:36 ` Po Lu
  2022-07-09 12:37   ` Po Lu
  2022-07-09 12:40 ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Po Lu @ 2022-07-09 12:36 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

Alan Mackenzie <acm@muc.de> writes:

> Hello, Emacs.
>
> The doc string for window-system and its Elisp manual entry say that the
> function should not be used.  The manual entry says:
>
>    Do _not_ use `window-system' and `initial-window-system' as predicates
>    or boolean flag variables, if you want to write code that works
>    differently on text terminals and graphic displays.  That is because
>    `window-system' is not a good indicator of Emacs capabilities on a
>    given display type.  Instead, use `display-graphic-p' or any of the
>    other `display-*-p' predicates described in Display Feature Testing.
>
> ..  I am amending minibuf.c and wish to know only whether the current
> terminal->focus_frame_hook is validly set.

Can't you simply test whether or not `term->focus_frame_hook' is set?

> The manual entry seems to be to be unnecessarily patronising.  It
> insinuates that the only possible "capabilities" a user could be
> interested in are graphic capabilities.
>
> Surely I should not have to go such ridiculous lengths as calling a lisp
> function which has nothing to do with what I need, and then interpreting
> its result.
>
> So, how should I find out whether terminal->focus_frame_hook is valid or
> not, if I'm not allowed to use Fwindow_system?

OTOH, I agree with you completely here.



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

* Re: Use of `window-system' as a predicate is deprecated.  Why?
  2022-07-09 12:36 ` Po Lu
@ 2022-07-09 12:37   ` Po Lu
  0 siblings, 0 replies; 5+ messages in thread
From: Po Lu @ 2022-07-09 12:37 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

Po Lu <luangruo@yahoo.com> writes:

> Can't you simply test whether or not `term->focus_frame_hook' is set?

Though do keep in mind that we also have `FRAME_WINDOW_P', which might
be the better option here.



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

* Re: Use of `window-system' as a predicate is deprecated.  Why?
  2022-07-09 12:22 Use of `window-system' as a predicate is deprecated. Why? Alan Mackenzie
  2022-07-09 12:36 ` Po Lu
@ 2022-07-09 12:40 ` Eli Zaretskii
  2022-07-09 13:27   ` Alan Mackenzie
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-07-09 12:40 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> Date: Sat, 9 Jul 2022 12:22:41 +0000
> From: Alan Mackenzie <acm@muc.de>
> 
>    Do _not_ use `window-system' and `initial-window-system' as predicates
>    or boolean flag variables, if you want to write code that works
>    differently on text terminals and graphic displays.  That is because
>    `window-system' is not a good indicator of Emacs capabilities on a
>    given display type.  Instead, use `display-graphic-p' or any of the
>    other `display-*-p' predicates described in Display Feature Testing.
> 
> ..  I am amending minibuf.c and wish to know only whether the current
> terminal->focus_frame_hook is validly set.
> 
> The manual entry seems to be to be unnecessarily patronising.  It
> insinuates that the only possible "capabilities" a user could be
> interested in are graphic capabilities.

The ELisp reference manual is written for Lisp programmers, not for
people who work on the C sources.

To check whether terminal->focus_frame_hook is set, test it for being
non-NULL.  More generally, if you want to know whether a frame is on a
window-system, use the FRAME_WINDOW_P macro.



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

* Re: Use of `window-system' as a predicate is deprecated.  Why?
  2022-07-09 12:40 ` Eli Zaretskii
@ 2022-07-09 13:27   ` Alan Mackenzie
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Mackenzie @ 2022-07-09 13:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Hello, Eli.

On Sat, Jul 09, 2022 at 15:40:42 +0300, Eli Zaretskii wrote:
> > Date: Sat, 9 Jul 2022 12:22:41 +0000
> > From: Alan Mackenzie <acm@muc.de>

> >    Do _not_ use `window-system' and `initial-window-system' as predicates
> >    or boolean flag variables, if you want to write code that works
> >    differently on text terminals and graphic displays.  That is because
> >    `window-system' is not a good indicator of Emacs capabilities on a
> >    given display type.  Instead, use `display-graphic-p' or any of the
> >    other `display-*-p' predicates described in Display Feature Testing.

> > ..  I am amending minibuf.c and wish to know only whether the current
> > terminal->focus_frame_hook is validly set.

> > The manual entry seems to be to be unnecessarily patronising.  It
> > insinuates that the only possible "capabilities" a user could be
> > interested in are graphic capabilities.

> The ELisp reference manual is written for Lisp programmers, not for
> people who work on the C sources.

:-)

> To check whether terminal->focus_frame_hook is set, test it for being
> non-NULL.

I think I did at one time, and it was set to x_focus_frame, even though I
was on a linux tty.  But maybe I'm mistaken.  Anyway, that doesn't really
matter, because ....

> More generally, if you want to know whether a frame is on a
> window-system, use the FRAME_WINDOW_P macro.

This indeed works well, on a linux tty, and in X Windows, both with and
without -nw.  Thanks!

Just as a matter of interest, I think we're nearly there with bug #56305
"29.0.50; 'yes-or-no-p' deselects minibuffer frame".  There are just one
or two things to clear up with Martin.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

end of thread, other threads:[~2022-07-09 13:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 12:22 Use of `window-system' as a predicate is deprecated. Why? Alan Mackenzie
2022-07-09 12:36 ` Po Lu
2022-07-09 12:37   ` Po Lu
2022-07-09 12:40 ` Eli Zaretskii
2022-07-09 13:27   ` Alan Mackenzie

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).