bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#19217: 25.0.50; `C-M-x' (`eval-defun') on a `defface' that is not to


From: Drew Adams
Subject: bug#19217: 25.0.50; `C-M-x' (`eval-defun') on a `defface' that is not top-level
Date: Sun, 30 Nov 2014 12:51:59 -0800 (PST)

> > > You can also move point to just after the closing ) and do C-x
> > > C-e (`eval-last-sexp').
> 
> > I too thought that was the case, but it does not seem to be.  I
> > just tried it, starting with emacs -Q in several Emacs versions
> > (22, 24.4, 25 dev build).
> 
> I've never had a problem with C-x C-e that I can remember, and that
> includes several times with point after a random ) inside a defun.
> What happens when you do C-x C-e with point just after the `defface'
> form?

As I said, nothing happens.

emacs -Q
Put this in *scratch*, and evaluate it:
(when t
  (defface foo '((((background dark)) (:foreground "#58DFFA4FFFFF"))
                 (t (:foreground "Firebrick")))
    "A face." :group 'help)
  )

`M-x customize-face' shows that it is defined as it should be.

Edit the definition, replacing "Firebrick" with "Blue".  Put point
just after the defface sexp and hit `C-x C-e'.  `M-x customize-face'
shows that no change was made.  Feel free to blow away the Customize
buffer completely, so you are sure that you're not just seeing what
was there before. ;-)

Edit the color to "Green".  Put point on the symbol `defface' and
hit `C-M-x' - likewise, still no change to the face.

> > > > How about letting users redefine a `defface' with `C-M-x' even
> > > > in this case?
> 
> > > How is Emacs to determine which depth of parenthesis is to be
> > > considered the opening one?  For example, if a defface is
> > > contained within a defmacro, which one is to be executed on C-M-x?
> 
> > I really don't care about corner cases, if in fact there are any.
> 
> What exactly are you suggesting?

See above.  (1) `C-x C-e' should work as you say it works.
(2) `C-M-x' with point inside a defface sexp should also work.
If the latter cannot easily be made to work with point anywhere
inside the sexp, then at least make it work with point on `defface'
or near it (e.g. at the same list level).

> That `defface' be made a special case,

If that's necessary, yes.  It should be made to work, whether that
means special-casing it or not.

Currently, `C-M-x' inside a defun that is not at top level does not
have the problem that defface has.  Repeat the above recipe, but
with (defun toto () "Toto." (forward-char)) in place of the defface
sexp.  Edit it after evalling, to use `backward-char', and use
`C-M-x' again.  Check the definition before and after editing, using
(symbol-function 'toto).  No problem.  Not so, for defface.

> and that if any of the sequence of enclosing (s opens a `defface'
> form, this should be the one chosen for execution?  Or should any
> defining function count?  What is special about `defface'?

No idea what you are going on about; sorry.

> > You could even require that point be on the symbol `defface' in
> > the sexp, for all I care.  Then it should be trivial to grab the
> > `defface' sexp (e.g., use `(list-at-point)').
> 
> > The point is to have some way to reevaluate the defface sexp.  If
> > `C-x C-e' worked, that would be enough, but AFAICT it does not
> > work.
> 
> What happens when you try it?

See above.  100% reproducible from emacs -Q.  What happens when
you try it? ;-)

> > > > Is there a good reason for doing this only at top-level?
> 
> > > I think it is to make it unambiguous, which form is to be
> > > evaluated.
> 
> > Dunno how `C-x C-e' could be ambiguous wrt the sexp that precedes
> > point.  If the sexp preceding point is ambiguous then I think
> > we're probably in a world of trouble. ;-)
> 
> Neither C-M-x not C-x C-e are ambiguous.  The first evaluates the
> top level form containing point, the second the sexp immediately
> preceding point.

They should.  But they do not, in the case of defface.  See above.
Try it.

> > Coming back to `C-M-x': Then don't seek perfection.  Require that
> > point be closer to the list enclosing `defface' than to another
> > list when you try `C-M-x', in order for it to unambiguously pick
> > up the right sexp.
> 
> I'm not sure how you're going to construe "closer", given that a
> list typically extends over many characters and when point is
> within it, that must count as distance zero.  Or something.

It's trivial to determine whether point is at the same list level
as the `defface' symbol.

> > What am I missing?
> 
> A detailed clear specification of what you want.

I don't think I'm (or you are) missing that.  Have you tried it?





reply via email to

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