]> code.delx.au - gnu-emacs/commitdiff
* lisp/faces.el (faces--attribute-at-point): Fix an issue
authorArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 15 Nov 2015 18:42:20 +0000 (18:42 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 15 Nov 2015 18:43:28 +0000 (18:43 +0000)
Previous code would signal an error when the face at point was
a manually built list of attributes such as '(:foregroud "white").

* test/automated/faces-tests.el (faces--test-color-at-point): Add a test

lisp/faces.el
test/automated/faces-tests.el

index f96df057cbdc022587d8c24f779457c350c91026..d612461239e9b18e94da31638cfcea21f689c5ae 100644 (file)
@@ -1971,7 +1971,11 @@ unnamed faces (e.g, `foreground-color')."
                         (get-char-property (point) 'font-lock-face))
                    (get-char-property (point) 'face)))
         (found nil))
-    (dolist (face (if (listp faces) faces (list faces)))
+    ;; The attribute might be a face, a list of faces, or a list of
+    ;; attributes that make a face.  Normalize it to a list of faces.
+    (dolist (face (if (and (listp faces) (facep (car faces)))
+                      faces
+                    (list faces)))
       (cond (found)
             ((and face (symbolp face))
              (let ((value (face-attribute-specified-or
index 007bc805120ceaa91ded34a418c3cc3644544bde..ff9dfc53fbee6b3385809a2b991dfcfb65d1897d 100644 (file)
     (goto-char (point-min))
     (should (equal (background-color-at-point) "black"))
     (should (equal (foreground-color-at-point) "black")))
+  (with-temp-buffer
+    (insert (propertize "STRING" 'face '(:foreground "black" :background "black")))
+    (goto-char (point-min))
+    (should (equal (background-color-at-point) "black"))
+    (should (equal (foreground-color-at-point) "black")))
   (with-temp-buffer
     (emacs-lisp-mode)
     (setq-local font-lock-comment-face 'faces--test1)