From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master b75fb81 1/4: Extend button.el to take callback data
Date: Thu, 01 Aug 2019 18:12:51 +0200 [thread overview]
Message-ID: <877e7wlv98.fsf@mouse.gnus.org> (raw)
In-Reply-To: <87ef24vrpz.fsf@tcd.ie> (Basil L. Contovounesios's message of "Thu, 01 Aug 2019 18:19:04 +0300")
"Basil L. Contovounesios" <contovob@tcd.ie> 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
next prev parent reply other threads:[~2019-08-01 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190730132507.32385.70681@vcs0.savannah.gnu.org>
[not found] ` <20190730132509.77D2820C0A@vcs0.savannah.gnu.org>
2019-08-01 12:11 ` [Emacs-diffs] master b75fb81 1/4: Extend button.el to take callback data Basil L. Contovounesios
2019-08-01 12:22 ` Lars Ingebrigtsen
2019-08-01 15:19 ` Basil L. Contovounesios
2019-08-01 16:12 ` Lars Ingebrigtsen [this message]
2019-08-01 20:44 ` Stefan Monnier
2019-08-02 18:41 ` Lars Ingebrigtsen
2019-08-02 0:40 ` Basil L. Contovounesios
2019-08-02 18:46 ` Lars Ingebrigtsen
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=877e7wlv98.fsf@mouse.gnus.org \
--to=larsi@gnus.org \
--cc=contovob@tcd.ie \
--cc=emacs-devel@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).