From: Mauro Aranda <maurooaranda@gmail.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: 45831@debbugs.gnu.org
Subject: bug#45831: 28.0.50; list-colors-display callback arg needs to evaluate to a function?
Date: Sat, 16 Jan 2021 08:42:19 -0300 [thread overview]
Message-ID: <6002d11e.1c69fb81.33032.dc74@mx.google.com> (raw)
In-Reply-To: <87bldphn60.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 15 Jan 2021 22:04:39 +0000")
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
> 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))))))
> ...)
Just because I didn't want to change the original code too much, in case
someone thought the backward-compatible change wasn't necessary. But of
course, your sample code looks better.
> Thanks,
Thanks for taking a look.
next prev parent reply other threads:[~2021-01-16 11:42 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
2021-01-16 11:42 ` Mauro Aranda [this message]
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=6002d11e.1c69fb81.33032.dc74@mx.google.com \
--to=maurooaranda@gmail.com \
--cc=45831@debbugs.gnu.org \
--cc=contovob@tcd.ie \
/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).