[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
defface syntax
From: |
Miles Bader |
Subject: |
defface syntax |
Date: |
Tue, 24 Oct 2000 14:35:31 +0900 (JST) |
I've always been slightly annoyed at the face-spec syntax used by
defface. In particular, each clause has the syntax `(TESTS ATTRS)',
whereas I think a more reasonable syntax would be `(TEST ATTR...)'.
Not only is it more lispy (compare it, for instance, to `cond'), but it
eliminates a pair of parens in an area that is way overburdened with
them (I still consistently make mistakes when writing new face
definitions, because of all those parentheses), and most importantly,
gets indented sanely by emacs.
As an example, here's a defface using the current syntax:
(defface tool-bar
'((((type x w32 mac) (class color))
(:box (:line-width 1 :style released-button)
:background "grey75" :foreground "black"))
(((type x) (class mono))
(:box (:line-width 1 :style released-button)
:background "grey" :foreground "black"))
(t
()))
"...")
and here's the same one with the new syntax:
(defface tool-bar
'((((type x w32 mac) (class color))
:box (:line-width 1 :style released-button)
:background "grey75" :foreground "black")
(((type x) (class mono))
:box (:line-width 1 :style released-button)
:background "grey" :foreground "black")
(t))
"...")
Not the greatest difference in the world, I guess, but somehow subtly
more satisfying, and I think more readable.
So I'd like to apply the following patch, which changes the syntax, and
is completely compatible with the old syntax, so that nothing else needs
to be done:
2000-10-24 Miles Bader <address@hidden>
* faces.el (face-spec-choose): Change syntax so that the list of
attribute-value pairs is now the cdr of each clause, not the cadr.
Detect old-style entries, and handle them. Use pop.
diff -uwBp lisp/faces.el.\~3\~ lisp/faces.el
--- lisp/faces.el.~3~ Tue Oct 24 13:49:14 2000
+++ lisp/faces.el Tue Oct 24 14:29:21 2000
@@ -1158,12 +1158,16 @@ If SPEC is nil, return nil."
(let ((tail spec)
result)
(while tail
- (let* ((entry (car tail))
- (display (nth 0 entry))
- (attrs (nth 1 entry)))
- (setq tail (cdr tail))
+ (let* ((entry (pop tail))
+ (display (car entry))
+ (attrs (cdr entry)))
(when (face-spec-set-match-display display frame)
- (setq result attrs tail nil))))
+ (setq result (if (listp (car attrs))
+ ;; Old-style entry, the attribute list is the
+ ;; first element.
+ (car attrs)
+ attrs)
+ tail nil))))
result))
Any comments/flames?
-Miles
--
Love is a snowmobile racing across the tundra. Suddenly it flips over,
pinning you underneath. At night the ice weasels come. --Nietzsche
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- defface syntax,
Miles Bader <=