bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#45831: 28.0.50; list-colors-display callback arg needs to evaluate t


From: Basil L. Contovounesios
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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





reply via email to

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