]> code.delx.au - gnu-emacs/commitdiff
Fix 'face property handling in facemenu-add-face.
authorIvan Shmakov <ivan@siamics.net>
Thu, 26 Feb 2015 18:09:48 +0000 (18:09 +0000)
committerIvan Shmakov <ivan@siamics.net>
Thu, 26 Feb 2015 18:09:48 +0000 (18:09 +0000)
* lisp/faces.el (face-list-p): Split from face-at-point.
(face-at-point): Use it.
* lisp/facemenu.el (facemenu-add-face): Likewise.

Fixes: debbugs:19912
lisp/ChangeLog
lisp/facemenu.el
lisp/faces.el

index c8e307b213bad4c4389ada4e063a4885f14d7a4c..e9f62365f038bcf29a331ed99144cb4966647b05 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-26  Ivan Shmakov  <ivan@siamics.net>
+
+       * faces.el (face-list-p): Split from face-at-point.
+       (face-at-point): Use it.
+       * facemenu.el (facemenu-add-face): Likewise.  (Bug#19912)
+
 2015-02-26  Oscar Fuentes  <ofv@wanadoo.es>
 
        * vc/vc.el (vc-annotate-switches): New defcustom.
index 1a765f9ebdb97b68c21091b0b51f7a9e87a03fea..2c246b44d546a079eb34158c57eb80f87d1f8602 100644 (file)
@@ -732,7 +732,7 @@ effect.  See `facemenu-remove-face-function'."
                                  face
                                (facemenu-active-faces
                                 (cons face
-                                      (if (listp prev)
+                                      (if (face-list-p prev)
                                           prev
                                         (list prev)))
                                 ;; Specify the selected frame
index ce74c728474d229d30640561963191a57f950cf8..54e444b730ad01dc6d69e10f640008de94946eac 100644 (file)
@@ -273,6 +273,17 @@ If FRAME is omitted or nil, use the selected frame."
   (not (internal-lisp-face-empty-p face frame)))
 
 
+(defun face-list-p (face-or-list)
+  "True if FACE-OR-LIST is a list of faces.
+Return nil if FACE-OR-LIST is a non-nil atom, or a cons cell whose car
+is either 'foreground-color, 'background-color, or a keyword."
+  ;; The logic of merge_face_ref (xfaces.c) is recreated here.
+  (and (listp face-or-list)
+       (not (memq (car face-or-list)
+                 '(foreground-color background-color)))
+       (not (keywordp (car face-or-list)))))
+
+
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Setting face attributes from X resources.
@@ -1922,11 +1933,7 @@ Return nil if there is no face."
                         (get-char-property (point) 'face))))
       (cond ((facep faceprop)
              (push faceprop faces))
-            ((and (listp faceprop)
-                  ;; Don't treat an attribute spec as a list of faces.
-                  (not (keywordp (car faceprop)))
-                  (not (memq (car faceprop)
-                             '(foreground-color background-color))))
+            ((face-list-p faceprop)
              (dolist (face faceprop)
                (if (facep face)
                    (push face faces))))))