* C-M-x should reset defface forms
@ 2004-06-03 18:46 Johan Bockgård
2004-06-05 1:03 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Johan Bockgård @ 2004-06-03 18:46 UTC (permalink / raw)
[In GNU Emacs 21.2.1 (sparc-sun-solaris2.8, X toolkit)]
C-M-x (eval-defun/edebug-eval-defun) on a defface form should reset
the face using the initial value expression, like it does with defvar
and defcustom.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C-M-x should reset defface forms
2004-06-03 18:46 C-M-x should reset defface forms Johan Bockgård
@ 2004-06-05 1:03 ` Juri Linkov
2004-06-05 22:50 ` Richard Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2004-06-05 1:03 UTC (permalink / raw)
Cc: emacs-devel
bojohan@dd.chalmers.se (Johan Bockgård) writes in bug-gnu-emacs:
> C-M-x (eval-defun/edebug-eval-defun) on a defface form should reset
> the face using the initial value expression, like it does with defvar
> and defcustom.
This would be very useful! Since no one responded to this request,
I looked a bit, and it seems the following patch does it. I don't know
if it is the right way to implement this. I simply made things work.
So, specialists in face customization, please tell if it is wrong.
Index: lisp/cus-face.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-face.el,v
retrieving revision 1.33
diff -u -r1.33 cus-face.el
--- lisp/cus-face.el 1 Sep 2003 15:45:09 -0000 1.33
+++ lisp/cus-face.el 5 Jun 2004 00:42:59 -0000
@@ -35,7 +35,16 @@
;;;###autoload
(defun custom-declare-face (face spec doc &rest args)
"Like `defface', but FACE is evaluated as a normal argument."
- (unless (get face 'face-defface-spec)
+ (if (get face 'face-defface-spec)
+ (when (not (equal (get face 'face-defface-spec) spec))
+ (let ((frames (frame-list))
+ frame)
+ (while frames
+ (setq frame (car frames)
+ frames (cdr frames))
+ (face-spec-set face spec frame)))
+ (put face 'saved-face spec)
+ (put face 'face-defface-spec spec))
(when (fboundp 'facep)
(unless (facep face)
;; If the user has already created the face, respect that.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C-M-x should reset defface forms
2004-06-05 1:03 ` Juri Linkov
@ 2004-06-05 22:50 ` Richard Stallman
2004-06-07 6:33 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2004-06-05 22:50 UTC (permalink / raw)
Cc: bojohan, emacs-devel
This would be very useful! Since no one responded to this request,
I looked a bit, and it seems the following patch does it. I don't know
if it is the right way to implement this. I simply made things work.
So, specialists in face customization, please tell if it is wrong.
Your change is not limited to C-M-x. It makes ALL evaluation of
a defface reinitialize the face. That's a change I don't think
we want to make.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C-M-x should reset defface forms
2004-06-05 22:50 ` Richard Stallman
@ 2004-06-07 6:33 ` Juri Linkov
0 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2004-06-07 6:33 UTC (permalink / raw)
Cc: bojohan, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> Your change is not limited to C-M-x. It makes ALL evaluation of
> a defface reinitialize the face. That's a change I don't think
> we want to make.
To limit it only to C-M-x, changes can be made only in `eval-defun'
instead of `custom-declare-face'.
Index: lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.159
diff -u -r1.159 lisp-mode.el
--- lisp/emacs-lisp/lisp-mode.el 29 May 2004 15:33:30 -0000 1.159
+++ lisp/emacs-lisp/lisp-mode.el 6 Jun 2004 23:54:45 -0000
@@ -589,6 +589,13 @@
;; Force variable to be bound.
(set-default (eval (nth 1 form)) (eval (nth 1 (nth 2 form))))
form)
+ ;; `defface' is macroexpanded to `custom-declare-face'.
+ ((eq (car form) 'custom-declare-face)
+ ;; Clear defface spec.
+ (put (eval (nth 1 form)) 'face-defface-spec nil)
+ (setq face-new-frame-defaults
+ (assq-delete-all (eval (nth 1 form)) face-new-frame-defaults))
+ form)
((eq (car form) 'progn)
(cons 'progn (mapcar 'eval-defun-1 (cdr form))))
(t form)))
Index: lisp/emacs-lisp/edebug.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/edebug.el,v
retrieving revision 3.68
diff -u -r3.68 edebug.el
--- lisp/emacs-lisp/edebug.el 28 May 2004 21:03:53 -0000 3.68
+++ lisp/emacs-lisp/edebug.el 6 Jun 2004 23:54:45 -0000
@@ -507,7 +507,13 @@
((and (eq (car form) 'defcustom)
(default-boundp (nth 1 form)))
;; Force variable to be bound.
- (set-default (nth 1 form) (eval (nth 2 form)))))
+ (set-default (nth 1 form) (eval (nth 2 form))))
+ ((eq (car form) 'defface)
+ ;; Clear defface spec.
+ (put (nth 1 form) 'face-defface-spec nil)
+ (setq face-new-frame-defaults
+ (assq-delete-all (nth 1 form) face-new-frame-defaults))
+ form))
(setq edebug-result (eval form))
(if (not edebugging)
(princ edebug-result)
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-07 6:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-03 18:46 C-M-x should reset defface forms Johan Bockgård
2004-06-05 1:03 ` Juri Linkov
2004-06-05 22:50 ` Richard Stallman
2004-06-07 6:33 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.