emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r116911: Fix bug #16378 with mishandling of empty


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 r116911: Fix bug #16378 with mishandling of empty faces.
Date: Sat, 05 Apr 2014 07:27:13 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116911
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/16378
author: Matthias Dahl <address@hidden>
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Sat 2014-04-05 10:25:52 +0300
message:
  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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/faces.el                  faces.el-20091113204419-o5vbwnq5f7feedwu-562
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-04-05 07:15:11 +0000
+++ b/lisp/ChangeLog    2014-04-05 07:25:52 +0000
@@ -3,6 +3,10 @@
        * faces.el (face-spec-recalc): Call make-face-x-resource-internal
        only when inhibit-x-resources is nil, and do that earlier in the
        function.  Doc fix.  (Bug#16694)
+       (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.  (Bug#16378)
 
 2014-04-04  Tassilo Horn  <address@hidden>
 

=== modified file 'lisp/faces.el'
--- a/lisp/faces.el     2014-04-05 07:15:11 +0000
+++ b/lisp/faces.el     2014-04-05 07:25:52 +0000
@@ -1512,13 +1512,15 @@
     match))
 
 
-(defun face-spec-choose (spec &optional frame)
-  "Choose the proper attributes for FRAME, out of SPEC.
-If SPEC is nil, return nil."
+(defun face-spec-choose (spec &optional frame no-match-retval)
+  "Return the proper attributes for FRAME, out of SPEC.
+
+If no match is found or SPEC is nil, return nil, unless NO-MATCH-RETVAL
+is given, in which case return its value instead."
   (unless frame
     (setq frame (selected-frame)))
   (let ((tail spec)
-       result defaults)
+       result defaults match-found)
     (while tail
       (let* ((entry (pop tail))
             (display (car entry))
@@ -1538,9 +1540,18 @@
            (setq defaults thisval)
          ;; Otherwise, if it matches, use it.
          (when (face-spec-set-match-display display frame)
-           (setq result thisval)
-           (setq tail nil)))))
-    (if defaults (append result defaults) result)))
+           (setq result thisval
+                 tail nil
+                 match-found t)))))
+    ;; If defaults have been found, it's safe to just append those to the 
result
+    ;; list (which at this point will be either nil or contain actual specs) 
and
+    ;; return it to the caller. Since there will most definitely be something 
to
+    ;; return in this case, there's no need to know/check if a match was found.
+    (if defaults
+       (append result defaults)
+      (if match-found
+         result
+       no-match-retval))))
 
 
 (defun face-spec-reset-face (face &optional frame)
@@ -1635,11 +1646,12 @@
   ;; If FACE is customized or themed, set the custom spec from
   ;; `theme-face' records.
   (let ((theme-faces (get face 'theme-face))
+       (no-match-found 0)
        spec theme-face-applied)
     (if theme-faces
        (dolist (elt (reverse theme-faces))
-         (setq spec (face-spec-choose (cadr elt) frame))
-         (when spec
+         (setq spec (face-spec-choose (cadr elt) frame no-match-found))
+         (unless (eq spec no-match-found)
            (face-spec-set-2 face frame spec)
            (setq theme-face-applied t))))
     ;; If there was a spec applicable to FRAME, that overrides the


reply via email to

[Prev in Thread] Current Thread [Next in Thread]