GNU bug report logs -
#45831
28.0.50; list-colors-display callback arg needs to evaluate to a function?
Previous Next
Reported by: Mauro Aranda <maurooaranda <at> gmail.com>
Date: Tue, 12 Jan 2021 23:28:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: Mauro Aranda <maurooaranda <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 45831 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 45831 patch
quit
Backward-compatible change attached. With this change, all of the
following work:
(list-colors-display nil nil
(let ((cbuf (current-buffer)))
(lambda (color)
(when (buffer-live-p cbuf)
(message "Picked color %s for buffer %s"
color (buffer-name cbuf))))))
(list-colors-display nil nil
(let ((cbuf (current-buffer)))
`(function ,(lambda (color)
(when (buffer-live-p cbuf)
(message "Picked color %s for buffer %s"
color (buffer-name cbuf)))))))
(list-colors-display nil nil
(let ((cbuf (current-buffer)))
`(lambda (color)
(when (buffer-live-p ,cbuf)
(message "Picked color %s for buffer %s"
color (buffer-name ,cbuf))))))
(list-colors-display nil nil
(let ((cbuf (current-buffer)))
#'(lambda (color)
(when (buffer-live-p cbuf)
(message "Picked color %s for buffer %s"
color (buffer-name cbuf))))))
Feel free to drop the 2nd cond clause if backward-compatibility is not
deemed too important here.
[0001-Fix-list-colors-print-handling-of-callback-arg.patch (text/x-patch, inline)]
From 3c68014cded797add3daa4030917ab9de299f57d Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda <at> gmail.com>
Date: Tue, 12 Jan 2021 20:41:49 -0300
Subject: [PATCH] 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 2609397b0d..dc5f8f46ab 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -606,9 +606,14 @@ list-colors-display
(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)
--
2.29.2
This bug report was last modified 3 years and 358 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.