From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Mauro Aranda <maurooaranda@gmail.com>
Cc: 45831@debbugs.gnu.org
Subject: bug#45831: 28.0.50; list-colors-display callback arg needs to evaluate to a function?
Date: Fri, 15 Jan 2021 22:04:39 +0000 [thread overview]
Message-ID: <87bldphn60.fsf@tcd.ie> (raw)
In-Reply-To: <5ffe37e4.1c69fb81.411a.0f1c@mx.google.com> (Mauro Aranda's message of "Tue, 12 Jan 2021 20:59:29 -0300")
Mauro Aranda <maurooaranda@gmail.com> writes:
> (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)))))))
Why not a single evaluated closure, e.g. like the following?
(let ((callback-fn
(when callback
;; Expect CALLBACK to be a function, but allow it to be a form that
;; evaluates to a function, for backward-compatibility (bug#45831).
(or (functionp callback)
(setq callback (eval callback lexical-binding)))
(lambda (button)
(funcall callback (button-get button 'color-name))))))
...)
Thanks,
--
Basil
next prev parent reply other threads:[~2021-01-15 22:04 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
2021-01-15 22:04 ` Basil L. Contovounesios [this message]
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=87bldphn60.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=45831@debbugs.gnu.org \
--cc=maurooaranda@gmail.com \
/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).