emacs-diffs
[Top][All Lists]
Advanced

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

master f2f06b0: Fix list-colors-print handling of callback arg


From: Mauro Aranda
Subject: master f2f06b0: Fix list-colors-print handling of callback arg
Date: Tue, 19 Jan 2021 07:25:49 -0500 (EST)

branch: master
commit f2f06b020904e7d53af1e686a441887f24fb589c
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Mauro Aranda <maurooaranda@gmail.com>

    Fix list-colors-print handling of callback arg
    
    * lisp/facemenu.el (list-colors-print): Keeping
    backward-compatibility, don't fail when passed a closure object as
    CALLBACK.  (Bug#45831)
---
 lisp/facemenu.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index 2609397..dc5f8f4 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -606,9 +606,14 @@ color.  The function should accept a single argument, the 
color name."
 
 (defun list-colors-print (list &optional callback)
   (let ((callback-fn
-        (if callback
-            `(lambda (button)
-               (funcall ,callback (button-get button 'color-name))))))
+         ;; Expect CALLBACK to be a function, but allow it to be a form that
+         ;; evaluates to a function, for backward-compatibility.  (Bug#45831)
+         (cond ((functionp callback)
+                (lambda (button)
+                  (funcall callback (button-get button 'color-name))))
+               (callback
+                `(lambda (button)
+                  (funcall ,callback (button-get button 'color-name)))))))
     (dolist (color list)
       (if (consp color)
          (if (cdr color)



reply via email to

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