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: Fri, 02 Aug 2019 20:46:56 +0200 [thread overview]
Message-ID: <87mugro15r.fsf@mouse.gnus.org> (raw)
In-Reply-To: <878ssciemu.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 02 Aug 2019 03:40:09 +0300")
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
> (defun button-callback-action (button)
> "Call BUTTON's `button-callback' property."
> (apply #'funcall (button-get button 'button-callback)))
>
> (define-button-type 'rcirc-url
> 'face 'rcirc-url
> 'follow-link t
> 'action #'button-callback-action)
>
> (make-text-button start (point)
> 'type 'rcirc-url
> 'button-callback (list #'browse-url url))
>
> (Using define-button-type is optional, but encouraged.)
Button is such a nice and light-weight library (especially compared to
widget). Having to write these wrapper functions to do these trivial
transforms is the one bad thing in the API.
> Button action functions have until now expected a button as an argument,
> but now they may or may not be given a button, and this is determined by
> the presence or not of a button property. Why introduce this brittle
> backward incompatibility?
I don't see how it's brittle, and it's not backwards incompatible.
If you add a 'button-data 'foo to your buttons, then you presumably want
your action to get the data. Otherwise, why would you do it?
> Oh, we seem to be interpreting "naming collision" slightly differently.
>
> I took it to mean that a client of the button library has used a
> property name for one purpose, which is used for another purpose
> elsewhere.
>
> But what is happening here is that existing code is written with the
> assumption that button action functions receive a button as argument.
> This assumption now breaks down on buttons with a non-nil button-data
> property. Why make this unnecessary and backward-incompatible change?
I still don't understand what you mean here.
If somebody writes a new button that has 'button-data, how does that
affect the existing button? If you write a new button, and say
'button-data, then the 'action you've written takes that data as the
argument, not the button.
There's nobody randomly adding 'button-data to random existing code,
surely?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
prev parent reply other threads:[~2019-08-02 18:46 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mugro15r.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.