aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Dahl2014-04-05 10:25:52 +0300
committerEli Zaretskii2014-04-05 10:25:52 +0300
commitfdafd487a90fbd4febe853971f238c5395c12542 (patch)
treec9bdfaa3aee04e2cd021d093ab30b46b4a80ebf0
parenteb7a03cc7672f8179b9d1a403bb019e753ed907f (diff)
downloademacs-fdafd487a90fbd4febe853971f238c5395c12542.tar.gz
emacs-fdafd487a90fbd4febe853971f238c5395c12542.zip
Fix bug #16378 with mishandling of empty faces.
lisp/faces.el (face-spec-choose): Accept additional optional argument, whose value is returned if no matching attributes are found. (face-spec-recalc): Use the new optional argument when calling face-spec-choose.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/faces.el30
2 files changed, 25 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a74e121c6bd..bb283ab84df 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,10 @@
3 * faces.el (face-spec-recalc): Call make-face-x-resource-internal 3 * faces.el (face-spec-recalc): Call make-face-x-resource-internal
4 only when inhibit-x-resources is nil, and do that earlier in the 4 only when inhibit-x-resources is nil, and do that earlier in the
5 function. Doc fix. (Bug#16694) 5 function. Doc fix. (Bug#16694)
6 (face-spec-choose): Accept additional optional argument, whose
7 value is returned if no matching attributes are found.
8 (face-spec-recalc): Use the new optional argument when calling
9 face-spec-choose. (Bug#16378)
6 10
72014-04-04 Tassilo Horn <tsdh@gnu.org> 112014-04-04 Tassilo Horn <tsdh@gnu.org>
8 12
diff --git a/lisp/faces.el b/lisp/faces.el
index c6dd8d7a2d5..1255d7c9ff7 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1512,13 +1512,15 @@ If FRAME is nil, the current FRAME is used."
1512 match)) 1512 match))
1513 1513
1514 1514
1515(defun face-spec-choose (spec &optional frame) 1515(defun face-spec-choose (spec &optional frame no-match-retval)
1516 "Choose the proper attributes for FRAME, out of SPEC. 1516 "Return the proper attributes for FRAME, out of SPEC.
1517If SPEC is nil, return nil." 1517
1518If no match is found or SPEC is nil, return nil, unless NO-MATCH-RETVAL
1519is given, in which case return its value instead."
1518 (unless frame 1520 (unless frame
1519 (setq frame (selected-frame))) 1521 (setq frame (selected-frame)))
1520 (let ((tail spec) 1522 (let ((tail spec)
1521 result defaults) 1523 result defaults match-found)
1522 (while tail 1524 (while tail
1523 (let* ((entry (pop tail)) 1525 (let* ((entry (pop tail))
1524 (display (car entry)) 1526 (display (car entry))
@@ -1538,9 +1540,18 @@ If SPEC is nil, return nil."
1538 (setq defaults thisval) 1540 (setq defaults thisval)
1539 ;; Otherwise, if it matches, use it. 1541 ;; Otherwise, if it matches, use it.
1540 (when (face-spec-set-match-display display frame) 1542 (when (face-spec-set-match-display display frame)
1541 (setq result thisval) 1543 (setq result thisval
1542 (setq tail nil))))) 1544 tail nil
1543 (if defaults (append result defaults) result))) 1545 match-found t)))))
1546 ;; If defaults have been found, it's safe to just append those to the result
1547 ;; list (which at this point will be either nil or contain actual specs) and
1548 ;; return it to the caller. Since there will most definitely be something to
1549 ;; return in this case, there's no need to know/check if a match was found.
1550 (if defaults
1551 (append result defaults)
1552 (if match-found
1553 result
1554 no-match-retval))))
1544 1555
1545 1556
1546(defun face-spec-reset-face (face &optional frame) 1557(defun face-spec-reset-face (face &optional frame)
@@ -1635,11 +1646,12 @@ After the reset, the specs are applied from the following sources in this order:
1635 ;; If FACE is customized or themed, set the custom spec from 1646 ;; If FACE is customized or themed, set the custom spec from
1636 ;; `theme-face' records. 1647 ;; `theme-face' records.
1637 (let ((theme-faces (get face 'theme-face)) 1648 (let ((theme-faces (get face 'theme-face))
1649 (no-match-found 0)
1638 spec theme-face-applied) 1650 spec theme-face-applied)
1639 (if theme-faces 1651 (if theme-faces
1640 (dolist (elt (reverse theme-faces)) 1652 (dolist (elt (reverse theme-faces))
1641 (setq spec (face-spec-choose (cadr elt) frame)) 1653 (setq spec (face-spec-choose (cadr elt) frame no-match-found))
1642 (when spec 1654 (unless (eq spec no-match-found)
1643 (face-spec-set-2 face frame spec) 1655 (face-spec-set-2 face frame spec)
1644 (setq theme-face-applied t)))) 1656 (setq theme-face-applied t))))
1645 ;; If there was a spec applicable to FRAME, that overrides the 1657 ;; If there was a spec applicable to FRAME, that overrides the