Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
7e07a66d
Commit
7e07a66d
authored
Jun 04, 2004
by
Miles Bader
Browse files
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369
Rewrite face-differs-from-default-p
parent
421c91e5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
23 deletions
+47
-23
etc/NEWS
etc/NEWS
+4
-0
lisp/ChangeLog
lisp/ChangeLog
+6
-0
lisp/faces.el
lisp/faces.el
+35
-19
lispref/display.texi
lispref/display.texi
+2
-4
No files found.
etc/NEWS
View file @
7e07a66d
...
...
@@ -3032,6 +3032,10 @@ A new predicate `supports' has also been added to the `defface' face
specification language, which can be used to do this test for faces
defined with defface.
** The function face-differs-from-default-p now truly checks whether the
given face displays differently from the default face or not (previously
it did only a very cursory check).
+++
** face-attribute, face-foreground, face-background, and face-stipple now
accept a new optional argument, INHERIT, which controls how face
...
...
lisp/ChangeLog
View file @
7e07a66d
2004-06-04 Miles Bader <miles@gnu.org>
* faces.el (face-differs-from-default-p): Use a different
implementation, so we can really check whether FACE displays
differently or not.
2004-06-04 Miles Bader <miles@gnu.org>
* faces.el (display-supports-face-attributes-p): Implement a
...
...
lisp/faces.el
View file @
7e07a66d
...
...
@@ -240,27 +240,43 @@ If FRAME is omitted or nil, use the selected frame."
(
defun
face-differs-from-default-p
(
face
&optional
frame
)
"
N
on-nil if FACE displays differently from the default face.
"
Return n
on-nil if FACE displays differently from the default face.
If the optional argument FRAME is given, report on face FACE in that frame.
If FRAME is t, report on the defaults for face FACE (for new frames).
If FRAME is omitted or nil, use the selected frame.
A face is considered to be ``the same'' as the default face if it is
actually specified in the same way (equal attributes) or if it is
fully-unspecified, and thus inherits the attributes of any face it
is displayed on top of."
(
cond
((
eq
frame
t
)
(
setq
frame
nil
))
((
null
frame
)
(
setq
frame
(
selected-frame
))))
(
let*
((
v1
(
internal-lisp-face-p
face
frame
))
(
n
(
if
v1
(
length
v1
)
0
))
(
v2
(
internal-lisp-face-p
'default
frame
))
(
i
1
))
(
unless
v1
(
error
"Not a face: %S"
face
))
(
while
(
and
(
<
i
n
)
(
or
(
eq
'unspecified
(
aref
v1
i
))
(
equal
(
aref
v1
i
)
(
aref
v2
i
))))
(
setq
i
(
1+
i
)))
(
<
i
n
)))
If FRAME is omitted or nil, use the selected frame."
(
if
(
not
(
equal
(
face-font
face
frame
)
(
face-font
'default
frame
)))
;; The font is different from the default face's font, so clearly it
;; differs. This only really works on window-systems; on ttys, the
;; "font" is a constant, with attributes layered on top of it.
:font
;; General face attribute check. On graphical displays
;; `display-supports-face-attributes-p' just checks whether each
;; attribute is different that the default face, so we just check to
;; make sure each attribute of the merged face is not `unspecified';
;; we already checked the font above, so font-related attributes are
;; omitted for that reason. On a tty,
;; display-supports-face-attributes-p actually does do further
;; checks, and correctly deals with the display's capabilities, so
;; we use it to check all attributes.
(
let
((
attrs
(
if
(
memq
(
framep
(
or
frame
(
selected-frame
)))
'
(
x
w32
mac
))
;; Omit font-related attributes on a window-system
'
(
:foreground
:foreground
:background
:underline
:overline
:strike-through
:box
:inverse-video
:stipple
)
;; On a tty, check all attributes
'
(
:family
:width
:height
:weight
:slant
:foreground
:foreground
:background
:underline
:overline
:strike-through
:box
:inverse-video
:stipple
)))
(
differs
nil
))
(
while
(
and
attrs
(
not
differs
))
(
let*
((
attr
(
pop
attrs
))
(
attr-val
(
face-attribute
face
attr
frame
t
)))
(
when
(
and
(
not
(
eq
attr-val
'unspecified
))
(
display-supports-face-attributes-p
(
list
attr
attr-val
)
frame
))
(
setq
differs
attr
))))
differs
)))
(
defun
face-nontrivial-p
(
face
&optional
frame
)
...
...
lispref/display.texi
View file @
7e07a66d
...
...
@@ -2288,10 +2288,8 @@ same attributes for display.
@
end
defun
@
defun
face
-
differs
-
from
-
default
-
p
face
&
optional
frame
This
returns
@
code
{
t
}
if
the
face
@
var
{
face
}
displays
differently
from
the
default
face
.
A
face
is
considered
to
be
``
the
same
''
as
the
default
face
if
each
attribute
is
either
the
same
as
that
of
the
default
face
,
or
unspecified
(
meaning
to
inherit
from
the
default
).
This
returns
non
-@
code
{
nil
}
if
the
face
@
var
{
face
}
displays
differently
from
the
default
face
.
@
end
defun
@
node
Auto
Faces
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment