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: Alan Mackenzie
Subject: bug#19217: 25.0.50; `C-M-x' (`eval-defun') on a `defface' that is not top-level
Date: Sun, 30 Nov 2014 23:20:03 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Drew.

On Sun, Nov 30, 2014 at 12:51:59PM -0800, Drew Adams wrote:
> > > > 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.

Ah.  Yes, `defface' is like `defvar', in that if you defface a face
twice, the second try does not overwrite the first.  I had to look at the
fine source to see this, the documentation being somewhat suboptimal.

There's presumably some way of deleting a face, but I'm dashed if I can
find it in the info pages.  Something like `makunbound', but for faces.
I suspect that this will also be only to be found by perusal of the fine
source, possibly the C source.  <A bit later>  I've had a look at
xfaces.c, and it would seem there is no way to delete a face.  Faces are
simply stored in an array of Lisp_object's, starting at element 0, and
counting up from there each time you add a new face.

It was also said, somewhere, that C-M-x takes special action for a
variable, customisable something-or-other, or face.  So how does it do
this?  Well, a bit of digging around, and the answer's in `eval-defun-1'
in lisp-mode.el.

So I now see what you're complaining about, and I think would too, if I
were doing anything at all with faces.  Having defined a face with
`defface', the _ONLY_ way to tweak it at the source code level, is either
to restart Emacs or use C-M-x.  And for the latter, you need the opening
paren at top level.  If I were you, I'd hack something together for my
own use based on what's in lisp-mode.el.

Phew!

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

> > What exactly are you suggesting?

> See above.  (1) `C-x C-e' should work as you say it works.

You could probably fix this with a bit of advice (whether old-style or
new-style ;-).

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

Given how much of a special case faces already are, in terms of
awkwardness and inflexibility, maybe that's not too much to ask for.  But
beware of what you're asking for - you might get it.  Then when you do
C-M-x, expecting to evaluate a defun, you accidentally get a face defined
instead, which you then can't get rid of.

[ .... ]

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

That would indeed be one way of doing it.

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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