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

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

Re: Ability to use a button to run interactive function


From: Stephen Berman
Subject: Re: Ability to use a button to run interactive function
Date: Mon, 28 Aug 2023 22:02:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Mon, 28 Aug 2023 16:33:57 +0000 Heime <heimeborgia@protonmail.com> wrote:

> ------- Original Message -------
> On Tuesday, August 29th, 2023 at 2:55 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> On Mon, 28 Aug 2023 14:34:23 +0000 Heime heimeborgia@protonmail.com wrote:
>>
>> > The following function does not allow me to call it via a button. Would
>> > this be possible, whilst also be allowed to call the function interactively
>> > using 'M-x maces-snapshot' ?
>> >
>> > (defun maces-snapshot ()
>> > "Prints information about how to install emacs."
>> > (interactive)
>> >
>> > (with-help-window (help-buffer)
>> >
>> > (insert-button "[F5]" 'action 'action-snapshot
>> > 'follow-link t)
>> > (insert " A Snapshot Repository \n")
>> >
>> > (insert-button "[B5]" 'action 'action-snapshot
>> > 'follow-link t)
>> > (insert " Obtaining a Snapshot Repository with Git \n") ))
>>
>>
>> Yes, give maces-snapshot an optional argument:
>>
>> (defun maces-snapshot (&optional button)
>> ...
>>
>> Steve Berman
>
> Amazing ! Had thought that function with arguments could not be called
> interactively.

Invoking a command with a prefix argument, e.g. `C-5 M-x next-line'
(i.e. `C-5 C-n') is just a way of interactively passing it an argument
to a function when calling it.  Just invoking `M-x maces-snapshot' does
not pass an argument to the function, but that's fine here, since the
argument is optional.

Steve Berman



reply via email to

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