[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109656: Allow face-remapping using :
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109656: Allow face-remapping using :font, and use it in mouse-appearance-menu. |
Date: |
Fri, 17 Aug 2012 17:10:31 +0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109656
fixes bug: http://debbugs.gnu.org/3228
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Fri 2012-08-17 17:10:31 +0800
message:
Allow face-remapping using :font, and use it in mouse-appearance-menu.
* mouse.el (mouse-appearance-menu): If x-select-font returns a
font spec, set the font directly.
* xfaces.c (merge_face_vectors): If the target font specfies a
font spec, make the font's attributes take precedence over
directly-specified attributes.
(merge_face_ref): Recognize :font.
modified:
lisp/ChangeLog
lisp/mouse.el
src/ChangeLog
src/xfaces.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-17 06:01:17 +0000
+++ b/lisp/ChangeLog 2012-08-17 09:10:31 +0000
@@ -1,3 +1,8 @@
+2012-08-17 Chong Yidong <address@hidden>
+
+ * mouse.el (mouse-appearance-menu): If x-select-font returns a
+ font spec, set the font directly (Bug#3228).
+
2012-08-17 Martin Rudalics <address@hidden>
* window.el (delete-window): Fix last fix.
=== modified file 'lisp/mouse.el'
--- a/lisp/mouse.el 2012-08-10 14:47:12 +0000
+++ b/lisp/mouse.el 2012-08-17 09:10:31 +0000
@@ -1951,12 +1951,14 @@
(choice
;; Either choice == 'x-select-font, or choice is a
;; symbol whose name is a font.
- (buffer-face-mode-invoke (font-face-attributes
- (if (eq choice 'x-select-font)
- (x-select-font)
- (symbol-name choice)))
- t
- (called-interactively-p
'interactive))))))))
+ (let ((font (if (eq choice 'x-select-font)
+ (x-select-font)
+ (symbol-name choice))))
+ (buffer-face-mode-invoke
+ (if (fontp font 'font-spec)
+ (list :font font)
+ (font-face-attributes font))
+ t (called-interactively-p 'interactive)))))))))
;;; Bindings for mouse commands.
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-08-17 05:35:39 +0000
+++ b/src/ChangeLog 2012-08-17 09:10:31 +0000
@@ -1,3 +1,10 @@
+2012-08-17 Chong Yidong <address@hidden>
+
+ * xfaces.c (merge_face_vectors): If the target font specfies a
+ font spec, make the font's attributes take precedence over
+ directly-specified attributes.
+ (merge_face_ref): Recognize :font.
+
2012-08-17 Dmitry Antipov <address@hidden>
Do not use memcpy for copying intervals.
=== modified file 'src/xfaces.c'
--- a/src/xfaces.c 2012-08-16 21:58:44 +0000
+++ b/src/xfaces.c 2012-08-17 09:10:31 +0000
@@ -2281,6 +2281,7 @@
struct named_merge_point *named_merge_points)
{
int i;
+ Lisp_Object font = Qnil;
/* If FROM inherits from some other faces, merge their attributes into
TO before merging FROM's direct attributes. Note that an :inherit
@@ -2291,24 +2292,13 @@
&& !NILP (from[LFACE_INHERIT_INDEX]))
merge_face_ref (f, from[LFACE_INHERIT_INDEX], to, 0, named_merge_points);
- i = LFACE_FONT_INDEX;
- if (!UNSPECIFIEDP (from[i]))
+ if (FONT_SPEC_P (from[LFACE_FONT_INDEX]))
{
- if (!UNSPECIFIEDP (to[i]))
- to[i] = merge_font_spec (from[i], to[i]);
+ if (!UNSPECIFIEDP (to[LFACE_FONT_INDEX]))
+ font = merge_font_spec (from[LFACE_FONT_INDEX], to[LFACE_FONT_INDEX]);
else
- to[i] = copy_font_spec (from[i]);
- if (! NILP (AREF (to[i], FONT_FOUNDRY_INDEX)))
- to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (to[i],
FONT_FOUNDRY_INDEX));
- if (! NILP (AREF (to[i], FONT_FAMILY_INDEX)))
- to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (to[i], FONT_FAMILY_INDEX));
- if (! NILP (AREF (to[i], FONT_WEIGHT_INDEX)))
- to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (to[i]);
- if (! NILP (AREF (to[i], FONT_SLANT_INDEX)))
- to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (to[i]);
- if (! NILP (AREF (to[i], FONT_WIDTH_INDEX)))
- to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (to[i]);
- ASET (to[i], FONT_SIZE_INDEX, Qnil);
+ font = copy_font_spec (from[LFACE_FONT_INDEX]);
+ to[LFACE_FONT_INDEX] = font;
}
for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
@@ -2319,8 +2309,7 @@
to[i] = merge_face_heights (from[i], to[i], to[i]);
font_clear_prop (to, FONT_SIZE_INDEX);
}
- else if (i != LFACE_FONT_INDEX
- && ! EQ (to[i], from[i]))
+ else if (i != LFACE_FONT_INDEX && ! EQ (to[i], from[i]))
{
to[i] = from[i];
if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX)
@@ -2334,6 +2323,25 @@
}
}
+ /* If FROM specifies a font spec, make its contents take precedence
+ over :family and other attributes. This is needed for face
+ remapping using :font to work. */
+
+ if (!NILP (font))
+ {
+ if (! NILP (AREF (font, FONT_FOUNDRY_INDEX)))
+ to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FOUNDRY_INDEX));
+ if (! NILP (AREF (font, FONT_FAMILY_INDEX)))
+ to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX));
+ if (! NILP (AREF (font, FONT_WEIGHT_INDEX)))
+ to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (font);
+ if (! NILP (AREF (font, FONT_SLANT_INDEX)))
+ to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (font);
+ if (! NILP (AREF (font, FONT_WIDTH_INDEX)))
+ to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (font);
+ ASET (font, FONT_SIZE_INDEX, Qnil);
+ }
+
/* TO is always an absolute face, which should inherit from nothing.
We blindly copy the :inherit attribute above and fix it up here. */
to[LFACE_INHERIT_INDEX] = Qnil;
@@ -2575,6 +2583,13 @@
else
err = 1;
}
+ else if (EQ (keyword, QCfont))
+ {
+ if (FONTP (value))
+ to[LFACE_FONT_INDEX] = value;
+ else
+ err = 1;
+ }
else if (EQ (keyword, QCinherit))
{
/* This is not really very useful; it's just like a
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109656: Allow face-remapping using :font, and use it in mouse-appearance-menu.,
Chong Yidong <=