From: Mauro Aranda <maurooaranda@gmail.com>
To: 45831@debbugs.gnu.org
Subject: bug#45831: 28.0.50; list-colors-display callback arg needs to evaluate to a function?
Date: Tue, 12 Jan 2021 20:59:29 -0300 [thread overview]
Message-ID: <5ffe37e4.1c69fb81.411a.0f1c@mx.google.com> (raw)
In-Reply-To: <5ffe3063.1c69fb81.52f23.11a7@mx.google.com> (Mauro Aranda's message of "Tue, 12 Jan 2021 20:27:28 -0300")
[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch --]
[-- Type: text/x-patch, Size: 1314 bytes --]
From 3c68014cded797add3daa4030917ab9de299f57d Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@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)
---
| 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--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
next prev parent reply other threads:[~2021-01-12 23:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 23:27 bug#45831: 28.0.50; list-colors-display callback arg needs to evaluate to a function? Mauro Aranda
2021-01-12 23:59 ` Mauro Aranda [this message]
2021-01-15 22:04 ` Basil L. Contovounesios
2021-01-16 11:42 ` Mauro Aranda
2021-01-19 6:42 ` Lars Ingebrigtsen
2021-01-19 12:28 ` Mauro Aranda
[not found] <87sg2iyjdz.fsf@tbb.theblackbeard.org>
2021-05-25 19:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ffe37e4.1c69fb81.411a.0f1c@mx.google.com \
--to=maurooaranda@gmail.com \
--cc=45831@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).