GNU bug report logs - #19217
25.0.50; `C-M-x' (`eval-defun') on a `defface' that is not top-level

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sat, 29 Nov 2014 18:15:02 UTC

Severity: wishlist

Tags: fixed

Found in version 25.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #47 received at 19217 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Stefan Monnier <monnier <at> IRO.UMontreal.CA>,
 Drew Adams <drew.adams <at> oracle.com>, 19217 <at> debbugs.gnu.org
Subject: Re: bug#19217: 25.0.50;	`C-M-x' (`eval-defun') on a `defface' that
 is not top-level
Date: Fri, 18 Sep 2020 15:36:31 +0200
Alan Mackenzie <acm <at> muc.de> writes:

> OK.  I've hacked the following patch together, which wasn't actually all
> that difficult.  I've tested it out on a defvar, and it works there.  It
> gives C-x C-e the same special handling that C-M-x has for defvar's,
> defcustom's, defface's, etc.  It's incomplete (no documentation has been
> changed), but it might do what you need.  Please try it out.

The patch no longer applies to Emacs 28, so I've respun it:

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 72b94a57b4..7682e099f5 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1190,7 +1190,8 @@ elisp--eval-last-sexp
     ;; Setup the lexical environment if lexical-binding is enabled.
     (elisp--eval-last-sexp-print-value
      (eval (macroexpand-all
-            (eval-sexp-add-defvars (elisp--preceding-sexp)))
+            (eval-sexp-add-defvars
+             (elisp--eval-defun-1 (macroexpand (elisp--preceding-sexp)))))
            lexical-binding)
      (if insert-value (current-buffer) t) no-truncate char-print-limit)))
 
To recap, this allows `C-x C-e' on defvar/defface to work the same as
`C-M-x' on those (when they are top-level).

That these two work differently is a source of frustration, so I think
it makes conceptual sense, but I'm not sure what the repercussions would
be otherwise...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.