emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Renaming non-X x_* identifiers


From: Eli Zaretskii
Subject: Re: [PATCH] Renaming non-X x_* identifiers
Date: Sat, 13 Apr 2019 22:00:16 +0300

> From: Alex Gramiak <address@hidden>
> Cc: address@hidden,  address@hidden
> Date: Sat, 13 Apr 2019 12:43:10 -0600
> 
> > I think we should soon push these to a scratch branch, so that people
> > could try that and provide feedback.  It's hard to work with such
> > large changes otherwise.
> 
> Sure. What's the policy is for rebasing on scratch branches?

Not sure I understand what you mean by "policy".  Rebasing or not in
general is up to you, but maybe you are asking about something more
specific.

> I pushed the branch as scratch/x_emacs.

That's okay, thanks.

> > Some frame hooks are called after first making sure they are non-NULL,
> > others skip the test.  Is there a reason for this inconsistency?
> 
> The ones with no checks are in HAVE_WINDOW_SYSTEM and are assumed to
> exist, while the ones with checks are outside of HAVE_WINDOW_SYSTEM.
> Though it appears that I also checked a few that are in
> HAVE_WINDOW_SYSTEM. Would you prefer all of them to be checked, or just
> the ones outside of HAVE_WINDOW_SYSTEM?

If every window-system is required to provide these hooks, then I
think it will be enough to test only those which also have
implementations on TTY frames.

> >>      store_frame_param (f, prop, val);
> >>  
> >> -    param_index = Fget (prop, Qx_frame_parameter);
> >> +    param_index = Fget (prop, Qframe_parameter_pos);
> >
> > The x-frame-parameter property is visible from Lisp, no?  You are here
> > replacing it with a different symbol, which is a backward-incompatible
> > change.
> 
> While it is visible from Lisp, I don't see why anyone would change it
> considering that AFAIU it's used as an internal value in frame.c.
> frame.c sets it and uses the value of the property to call the
> appropriate element in frame_parm_table, which Lisp-code should not rely
> on.
> 
> Then again, apparently cedet/semantic/util-modes.el accesses this
> property, but that could be changed.

Anything that gets put into frame-parameters can have some Lisp out
there using it.  So I think we have 2 alternatives:

  1) leave those symbols alone
  2) declare them obsolete, but meanwhile put both the new and the old
     symbols into frame-parameters

The above assumes that if a Lisp program does something with one of
these parameters, that will have no effect, i.e. that these parameters
are one-way communications from the Emacs internals to Lisp, as far as
Lisp programs are concerned.  If the communications are two-way, then
I don't see how we can change these names; do you have any ideas?

> >>  /* Store F's background color into *BGCOLOR.  */
> >>  static void
> >> -x_query_frame_background_color (struct frame *f, XColor *bgcolor)
> >> +gui_query_frame_background_color (struct frame *f, XColor *bgcolor)
> >>  {
> >> -#ifndef HAVE_NS
> >> -  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
> >> -  x_query_color (f, bgcolor);
> >> +#ifdef HAVE_NS
> >> +  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, true);
> >>  #else
> >> -  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, 1);
> >> +  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
> >> +# ifdef HAVE_NTGUI
> >> +  w32_query_colors (f, bgcolor, 1);
> >> +# else
> >> +  x_query_colors (f, bgcolor, 1);
> >> +# endif /* HAVE_NTGUI */
> >>  #endif
> >
> > Why didn't you convert this to a terminal hook?
> 
> In some cases I decided to leave some terminal hooks for a later patch
> to implement, just to make it easier to get this one accepted. I can add
> a hook for this if you'd like.

It's okay to do that in a followup, but please do that soon.  I don't
want to risk leaving an unfinished job in the sources.

> > Any reason why some x_* functions in image.c were renamed image_*,
> > while others gui_* ?
> 
> My intention is for the HAVE_WINDOW_SYSTEM-only procedures to be gui_*
> and the others to be image_*. I decided on this later on, so I may have
> a few gui_* procedures that should be image_*.

I think using image_* for all the functions in image.c would be
better.

> >> -  (f, Qx_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
> >> +  (f, Qgui_set_fullscreen, 0, 0, list2 (old_value, fullscreen));
> >
> > This is also visible from Lisp, right?  So renaming the symbol would
> > be an incompatible change.
> 
> I believe frame_size_history_add only uses the symbols as a
> visual/debugging aid, so I don't believe this is, meaningfully, an
> incompatible change.

Are they in frame-parameters?  If so, they are visible.

> >> diff --git a/src/menu.h b/src/menu.h
> >> index 0321c27454..4412948224 100644
> >> --- a/src/menu.h
> >> +++ b/src/menu.h
> >> @@ -47,14 +47,17 @@ extern widget_value *digest_single_submenu (int, int, 
> >> bool);
> >>  #if defined (HAVE_X_WINDOWS) || defined (MSDOS)
> >>  extern Lisp_Object x_menu_show (struct frame *, int, int, int,
> >>                            Lisp_Object, const char **);
> >> +extern void x_activate_menubar (struct frame *);
> >>  #endif
> >>  #ifdef HAVE_NTGUI
> >>  extern Lisp_Object w32_menu_show (struct frame *, int, int, int,
> >>                              Lisp_Object, const char **);
> >> +extern void w32_activate_menubar (struct frame *);
> >>  #endif
> >>  #ifdef HAVE_NS
> >>  extern Lisp_Object ns_menu_show (struct frame *, int, int, int,
> >>                             Lisp_Object, const char **);
> >> +extern void ns_activate_menubar (struct frame *);
> >
> > Since you introduced activate_menubar_hook, why do we need to declare
> > prototypes for its implementation on menu.h, which is a
> > system-independent header?
> 
> The implementations are defined in the *menu.c files, but are added as
> terminal hooks in the *term.c files.

I'm not sure I understand the answer.  I didn't ask about the
implementations, I asked about the prototypes.  Since these are hooks,
their names are not visible outside the corresponding *term.c file,
right?  Then why do we need the prototypes of w32_activate_menubar,
ns_activate_menubar, etc. in menu.h?

> >> +/* Wrapper for defined_color_hook to support the extra argument in
> >> +   ns_defined_color. */
> >
> > If the extra parameter is the only problem, we could add it to all the
> > terminal types, and just ignore it where it is not needed.  Then we
> > won't need a wrapper.
> 
> I wanted to avoid that (see my earlier thread about ns_defined_color),
> but if you prefer it I'll change it.

Yes, I think avoiding it makes the code less clean than having an
unused argument.

Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]