emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master b75fb81 1/4: Extend button.el to take callback


From: Lars Ingebrigtsen
Subject: Re: [Emacs-diffs] master b75fb81 1/4: Extend button.el to take callback data
Date: Thu, 01 Aug 2019 18:12:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

"Basil L. Contovounesios" <address@hidden> writes:

> I don't understand what you mean by "recreate the data" or "looking at
> the extent of the buttons".
>
> If an action function depends on some data associated with its button,
> then it is up to the creator or modifier of the button to tag it with
> that data.  The action function then need only do a property lookup via
> button-get. 

Here's a typical usage:

      (make-text-button start (point)
                        'face 'rcirc-url
                        'follow-link t
                        'rcirc-url url
                        'action (lambda (button)
                                  (browse-url (button-get button 'rcirc-url))))

with the "button knows the data" change, it's:

      (make-text-button start (point)
                        'face 'rcirc-url
                        'follow-link t
                        'burron-data url
                        'action #'browse-url)

That looks like an interface improvement to me.

> Alternatively, action functions can also be closures.

They can be, in lexical packages.

> I don't mind the name 'button-data', and I wasn't worried about naming
> collisions.
>
> What I'm worried about is the existence of buttons in the wild, whose
> existing action functions will break if said buttons happen to be given
> a button-data property.  This seems unnecessarily brittle and
> backward-incompatible, in exchange for what seems like an insufficiently
> useful convenience.  Unless I'm missing something, that is.

But you said you're not worried about naming collisions?   How would
these buttons then "happen to be given" that property?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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