* Ability to use a button to run interactive function
@ 2023-08-28 14:34 Heime
2023-08-28 14:45 ` Emanuel Berg
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Heime @ 2023-08-28 14:34 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
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") ))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ability to use a button to run interactive function
2023-08-28 14:34 Ability to use a button to run interactive function Heime
@ 2023-08-28 14:45 ` Emanuel Berg
2023-08-28 14:55 ` Stephen Berman
2023-08-28 15:28 ` Marcin Borkowski
2 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2023-08-28 14:45 UTC (permalink / raw)
To: help-gnu-emacs
Heime wrote:
> The following function does not allow me to call it via
> a button.
If we are talking buttons as in keys on a keyboard, they the
answer is you didn't bind the button to the function.
> Would this be possible, whilst also be allowed to call the
> function interactively using 'M-x maces-snapshot' ?
It is already callable like that since it is interactive (a
command).
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ability to use a button to run interactive function
2023-08-28 14:34 Ability to use a button to run interactive function Heime
2023-08-28 14:45 ` Emanuel Berg
@ 2023-08-28 14:55 ` Stephen Berman
2023-08-28 16:33 ` Heime
2023-08-28 15:28 ` Marcin Borkowski
2 siblings, 1 reply; 6+ messages in thread
From: Stephen Berman @ 2023-08-28 14:55 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ability to use a button to run interactive function
2023-08-28 14:34 Ability to use a button to run interactive function Heime
2023-08-28 14:45 ` Emanuel Berg
2023-08-28 14:55 ` Stephen Berman
@ 2023-08-28 15:28 ` Marcin Borkowski
2 siblings, 0 replies; 6+ messages in thread
From: Marcin Borkowski @ 2023-08-28 15:28 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
On 2023-08-28, at 16:34, 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") ))
Works for me. What did you do?
I evaled the defun first and then did M-x global-set-key.
Although, I'd probably use a hydra for things like that.
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ability to use a button to run interactive function
2023-08-28 14:55 ` Stephen Berman
@ 2023-08-28 16:33 ` Heime
2023-08-28 20:02 ` Stephen Berman
0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2023-08-28 16:33 UTC (permalink / raw)
To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor
------- 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Ability to use a button to run interactive function
2023-08-28 16:33 ` Heime
@ 2023-08-28 20:02 ` Stephen Berman
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Berman @ 2023-08-28 20:02 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-28 20:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 14:34 Ability to use a button to run interactive function Heime
2023-08-28 14:45 ` Emanuel Berg
2023-08-28 14:55 ` Stephen Berman
2023-08-28 16:33 ` Heime
2023-08-28 20:02 ` Stephen Berman
2023-08-28 15:28 ` Marcin Borkowski
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.