all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Buttons in help buffer that displays contents of variables
@ 2023-07-22 14:40 Heime
  2023-07-22 19:18 ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 14:40 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I want to use a button to display the contents of a variable inside
a help buffer, but the following gives

(wrong-number-of-arguments ((t) nil "Function to be executed when the button is clicked..." (interactive) (message "Button clicked!")) 1)
  my-action(#<overlay from 1 to 8 in *Help*>)


(defconst myvar "Text of Front A")

(defun my-action ()
  "Function to be executed when the button is clicked."
  (interactive)
  (message "%s" myvar))

(defun qrh ()
  "Some description."

  (interactive)

  (with-help-window (help-buffer)
    (insert-button "Front A" 'action 'my-action 'follow-link t)))




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 14:40 Buttons in help buffer that displays contents of variables Heime
@ 2023-07-22 19:18 ` Heime
  2023-07-22 20:14   ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 19:18 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Sunday, July 23rd, 2023 at 2:40 AM, Heime <heimeborgia@protonmail.com> wrote:


> I want to use a button to display the contents of a variable inside
> a help buffer, but the following gives
> 
> (wrong-number-of-arguments ((t) nil "Function to be executed when the button is clicked..." (interactive) (message "Button clicked!")) 1)
> my-action(#<overlay from 1 to 8 in Help>)
> 

Why does pressing the button give me such error ?
 
> 
> (defconst myvar "Text of Front A")
> 
> (defun my-action ()
> "Function to be executed when the button is clicked."
> (interactive)
> (message "%s" myvar))
> 
> (defun qrh ()
> "Some description."
> 
> (interactive)
> 
> (with-help-window (help-buffer)
> (insert-button "Front A" 'action 'my-action 'follow-link t)))





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 19:18 ` Heime
@ 2023-07-22 20:14   ` Stephen Berman
  2023-07-22 20:24     ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Berman @ 2023-07-22 20:14 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, 22 Jul 2023 19:18:03 +0000 Heime <heimeborgia@protonmail.com> wrote:

> ------- Original Message -------
> On Sunday, July 23rd, 2023 at 2:40 AM, Heime <heimeborgia@protonmail.com> wrote:
>
>
>> I want to use a button to display the contents of a variable inside
>> a help buffer, but the following gives
>>
>> (wrong-number-of-arguments ((t) nil "Function to be executed when the button
>> is clicked..." (interactive) (message "Button clicked!")) 1)
>> my-action(#<overlay from 1 to 8 in Help>)
>>
>
> Why does pressing the button give me such error ?
>
>>
>> (defconst myvar "Text of Front A")
>>
>> (defun my-action ()
>> "Function to be executed when the button is clicked."
>> (interactive)
>> (message "%s" myvar))
>>
>> (defun qrh ()
>> "Some description."
>>
>> (interactive)
>>
>> (with-help-window (help-buffer)
>> (insert-button "Front A" 'action 'my-action 'follow-link t)))

The error says the function my-action expects one argument, but you
defined it with an empty argument list.  If you don't want to use the
argument, you can use `_' as a placeholder for the required argument,
which will be ignored by the byte compiler:

(defun my-action (_)
  "Function to be executed when the button is clicked."
  (interactive)
  (message "%s" myvar))

Steve Berman



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 20:14   ` Stephen Berman
@ 2023-07-22 20:24     ` Heime
  2023-07-22 20:48       ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 20:24 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > ------- Original Message -------
> > On Sunday, July 23rd, 2023 at 2:40 AM, Heime heimeborgia@protonmail.com wrote:
> > 
> > > I want to use a button to display the contents of a variable inside
> > > a help buffer, but the following gives
> > > 
> > > (wrong-number-of-arguments ((t) nil "Function to be executed when the button
> > > is clicked..." (interactive) (message "Button clicked!")) 1)
> > > my-action(#<overlay from 1 to 8 in Help>)
> > 
> > Why does pressing the button give me such error ?
> > 
> > > (defconst myvar "Text of Front A")
> > > 
> > > (defun my-action ()
> > > "Function to be executed when the button is clicked."
> > > (interactive)
> > > (message "%s" myvar))
> > > 
> > > (defun qrh ()
> > > "Some description."
> > > 
> > > (interactive)
> > > 
> > > (with-help-window (help-buffer)
> > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
> 
> 
> The error says the function my-action expects one argument, but you
> defined it with an empty argument list. If you don't want to use the
> argument, you can use `' as a placeholder for the required argument,
> which will be ignored by the byte compiler:
> 
> (defun my-action ()
> "Function to be executed when the button is clicked."
> (interactive)
> (message "%s" myvar))
> 
> Steve Berman

I do not understand the reason it expects an argument.  Would there be
a more suitable way to print some text after pressing the button ?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 20:24     ` Heime
@ 2023-07-22 20:48       ` Stephen Berman
  2023-07-22 21:24         ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Berman @ 2023-07-22 20:48 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, 22 Jul 2023 20:24:16 +0000 Heime <heimeborgia@protonmail.com> wrote:

> ------- Original Message -------
> On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
>
>
>> On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
>> 
>> > ------- Original Message -------
>> > On Sunday, July 23rd, 2023 at 2:40 AM, Heime heimeborgia@protonmail.com wrote:
>> > 
>> > > I want to use a button to display the contents of a variable inside
>> > > a help buffer, but the following gives
>> > > 
>> > > (wrong-number-of-arguments ((t) nil "Function to be executed when the button
>> > > is clicked..." (interactive) (message "Button clicked!")) 1)
>> > > my-action(#<overlay from 1 to 8 in Help>)
>> > 
>> > Why does pressing the button give me such error ?
>> > 
>> > > (defconst myvar "Text of Front A")
>> > > 
>> > > (defun my-action ()
>> > > "Function to be executed when the button is clicked."
>> > > (interactive)
>> > > (message "%s" myvar))
>> > > 
>> > > (defun qrh ()
>> > > "Some description."
>> > > 
>> > > (interactive)
>> > > 
>> > > (with-help-window (help-buffer)
>> > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
>> 
>> 
>> The error says the function my-action expects one argument, but you
>> defined it with an empty argument list. If you don't want to use the
>> argument, you can use `' as a placeholder for the required argument,
>> which will be ignored by the byte compiler:
>> 
>> (defun my-action ()
>> "Function to be executed when the button is clicked."
>> (interactive)
>> (message "%s" myvar))
>> 
>> Steve Berman
>
> I do not understand the reason it expects an argument.

In the Emacs Lisp info manual there is the node `(elisp) Buttons', whose
first subnode is `(elisp) Button Properties', whose first entry is the
`action' property:

‘action’
     The function to call when the user invokes the button, which is
     passed the single argument BUTTON.  By default this is ‘ignore’,
     which does nothing.

>                                                         Would there be
> a more suitable way to print some text after pressing the button ?

If you want to use a button, then I guess not, since it needs an action
(or mouse-action) property to do something on pressing the button.

Steve Berman



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 20:48       ` Stephen Berman
@ 2023-07-22 21:24         ` Heime
  2023-07-22 21:46           ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 21:24 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Sunday, July 23rd, 2023 at 8:48 AM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sat, 22 Jul 2023 20:24:16 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > ------- Original Message -------
> > On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman stephen.berman@gmx.net wrote:
> > 
> > > On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
> > > 
> > > > ------- Original Message -------
> > > > On Sunday, July 23rd, 2023 at 2:40 AM, Heime heimeborgia@protonmail.com wrote:
> > > > 
> > > > > I want to use a button to display the contents of a variable inside
> > > > > a help buffer, but the following gives
> > > > > 
> > > > > (wrong-number-of-arguments ((t) nil "Function to be executed when the button
> > > > > is clicked..." (interactive) (message "Button clicked!")) 1)
> > > > > my-action(#<overlay from 1 to 8 in Help>)
> > > > 
> > > > Why does pressing the button give me such error ?
> > > > 
> > > > > (defconst myvar "Text of Front A")
> > > > > 
> > > > > (defun my-action ()
> > > > > "Function to be executed when the button is clicked."
> > > > > (interactive)
> > > > > (message "%s" myvar))
> > > > > 
> > > > > (defun qrh ()
> > > > > "Some description."
> > > > > 
> > > > > (interactive)
> > > > > 
> > > > > (with-help-window (help-buffer)
> > > > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
> > > 
> > > The error says the function my-action expects one argument, but you
> > > defined it with an empty argument list. If you don't want to use the
> > > argument, you can use `' as a placeholder for the required argument,
> > > which will be ignored by the byte compiler:
> > > 
> > > (defun my-action ()
> > > "Function to be executed when the button is clicked."
> > > (interactive)
> > > (message "%s" myvar))
> > > 
> > > Steve Berman
> > 
> > I do not understand the reason it expects an argument.
> 
> 
> In the Emacs Lisp info manual there is the node `(elisp) Buttons', whose first subnode is` (elisp) Button Properties', whose first entry is the
> `action' property:
> 
> ‘action’
> The function to call when the user invokes the button, which is
> passed the single argument BUTTON. By default this is ‘ignore’,
> which does nothing.
> 
> > Would there be
> > a more suitable way to print some text after pressing the button ?
> 
> 
> If you want to use a button, then I guess not, since it needs an action
> (or mouse-action) property to do something on pressing the button.
> 
> Steve Berman

In other words, insert-button needs a function with a single argument so it can
pass ignore.  Yes ?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 21:24         ` Heime
@ 2023-07-22 21:46           ` Stephen Berman
  2023-07-22 22:02             ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Berman @ 2023-07-22 21:46 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, 22 Jul 2023 21:24:39 +0000 Heime <heimeborgia@protonmail.com> wrote:

> ------- Original Message -------
> On Sunday, July 23rd, 2023 at 8:48 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
>
>
>> On Sat, 22 Jul 2023 20:24:16 +0000 Heime heimeborgia@protonmail.com wrote:
>> 
>> > ------- Original Message -------
>> > On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman
>> > stephen.berman@gmx.net wrote:
>> > 
>> > > On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
>> > > 
>> > > > ------- Original Message -------
>> > > > On Sunday, July 23rd, 2023 at 2:40 AM, Heime
>> > > > heimeborgia@protonmail.com wrote:
>> > > > 
>> > > > > I want to use a button to display the contents of a variable inside
>> > > > > a help buffer, but the following gives
>> > > > > 
>> > > > > (wrong-number-of-arguments ((t) nil "Function to be executed when
>> > > > > the button
>> > > > > is clicked..." (interactive) (message "Button clicked!")) 1)
>> > > > > my-action(#<overlay from 1 to 8 in Help>)
>> > > > 
>> > > > Why does pressing the button give me such error ?
>> > > > 
>> > > > > (defconst myvar "Text of Front A")
>> > > > > 
>> > > > > (defun my-action ()
>> > > > > "Function to be executed when the button is clicked."
>> > > > > (interactive)
>> > > > > (message "%s" myvar))
>> > > > > 
>> > > > > (defun qrh ()
>> > > > > "Some description."
>> > > > > 
>> > > > > (interactive)
>> > > > > 
>> > > > > (with-help-window (help-buffer)
>> > > > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
>> > > 
>> > > The error says the function my-action expects one argument, but you
>> > > defined it with an empty argument list. If you don't want to use the
>> > > argument, you can use `' as a placeholder for the required argument,
>> > > which will be ignored by the byte compiler:
>> > > 
>> > > (defun my-action ()
>> > > "Function to be executed when the button is clicked."
>> > > (interactive)
>> > > (message "%s" myvar))
>> > > 
>> > > Steve Berman
>> > 
>> > I do not understand the reason it expects an argument.
>> 
>> 
>> In the Emacs Lisp info manual there is the node `(elisp) Buttons', whose
>> first subnode is` (elisp) Button Properties', whose first entry is the
>> `action' property:
>> 
>> ‘action’
>> The function to call when the user invokes the button, which is
>> passed the single argument BUTTON. By default this is ‘ignore’,
>> which does nothing.
>> 
>> > Would there be
>> > a more suitable way to print some text after pressing the button ?
>> 
>> 
>> If you want to use a button, then I guess not, since it needs an action
>> (or mouse-action) property to do something on pressing the button.
>> 
>> Steve Berman
>
> In other words, insert-button needs a function with a single argument so it can
> pass ignore.  Yes ?

No.  `ignore' is the function that is the default value of the `action'
property of `insert-button', so if you want pressing the button to do
nothing you can just evaluate e.g. `(insert-button "Front A")'.  But if
you want pressing the button to do something, you have to pass the
`action' property to `insert-button' with a suitable function of one
argument as its value.

Steve Berman



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 21:46           ` Stephen Berman
@ 2023-07-22 22:02             ` Heime
  2023-07-22 22:13               ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 22:02 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Sunday, July 23rd, 2023 at 9:46 AM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sat, 22 Jul 2023 21:24:39 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > ------- Original Message -------
> > On Sunday, July 23rd, 2023 at 8:48 AM, Stephen Berman stephen.berman@gmx.net wrote:
> > 
> > > On Sat, 22 Jul 2023 20:24:16 +0000 Heime heimeborgia@protonmail.com wrote:
> > > 
> > > > ------- Original Message -------
> > > > On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman
> > > > stephen.berman@gmx.net wrote:
> > > > 
> > > > > On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
> > > > > 
> > > > > > ------- Original Message -------
> > > > > > On Sunday, July 23rd, 2023 at 2:40 AM, Heime
> > > > > > heimeborgia@protonmail.com wrote:
> > > > > > 
> > > > > > > I want to use a button to display the contents of a variable inside
> > > > > > > a help buffer, but the following gives
> > > > > > > 
> > > > > > > (wrong-number-of-arguments ((t) nil "Function to be executed when
> > > > > > > the button
> > > > > > > is clicked..." (interactive) (message "Button clicked!")) 1)
> > > > > > > my-action(#<overlay from 1 to 8 in Help>)
> > > > > > 
> > > > > > Why does pressing the button give me such error ?
> > > > > > 
> > > > > > > (defconst myvar "Text of Front A")
> > > > > > > 
> > > > > > > (defun my-action ()
> > > > > > > "Function to be executed when the button is clicked."
> > > > > > > (interactive)
> > > > > > > (message "%s" myvar))
> > > > > > > 
> > > > > > > (defun qrh ()
> > > > > > > "Some description."
> > > > > > > 
> > > > > > > (interactive)
> > > > > > > 
> > > > > > > (with-help-window (help-buffer)
> > > > > > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
> > > > > 
> > > > > The error says the function my-action expects one argument, but you
> > > > > defined it with an empty argument list. If you don't want to use the
> > > > > argument, you can use `' as a placeholder for the required argument,
> > > > > which will be ignored by the byte compiler:
> > > > > 
> > > > > (defun my-action ()
> > > > > "Function to be executed when the button is clicked."
> > > > > (interactive)
> > > > > (message "%s" myvar))
> > > > > 
> > > > > Steve Berman
> > > > 
> > > > I do not understand the reason it expects an argument.
> > > 
> > > In the Emacs Lisp info manual there is the node `(elisp) Buttons', whose first subnode is` (elisp) Button Properties', whose first entry is the
> > > `action' property:
> > > 
> > > ‘action’
> > > The function to call when the user invokes the button, which is
> > > passed the single argument BUTTON. By default this is ‘ignore’,
> > > which does nothing.
> > > 
> > > > Would there be
> > > > a more suitable way to print some text after pressing the button ?
> > > 
> > > If you want to use a button, then I guess not, since it needs an action
> > > (or mouse-action) property to do something on pressing the button.
> > > 
> > > Steve Berman
> > 
> > In other words, insert-button needs a function with a single argument so it can
> > pass ignore. Yes ?
> 
> 
> No. `ignore' is the function that is the default value of the` action'
> property of `insert-button', so if you want pressing the button to do nothing you can just evaluate e.g.` (insert-button "Front A")'. But if
> you want pressing the button to do something, you have to pass the
> `action' property to` insert-button' with a suitable function of one
> argument as its value.
> 
> Steve Berman

That explains it.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 22:02             ` Heime
@ 2023-07-22 22:13               ` Heime
  2023-07-22 22:28                 ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 22:13 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Sunday, July 23rd, 2023 at 10:02 AM, Heime <heimeborgia@protonmail.com> wrote:


> ------- Original Message -------
> On Sunday, July 23rd, 2023 at 9:46 AM, Stephen Berman stephen.berman@gmx.net wrote:
> 
> 
> 
> > On Sat, 22 Jul 2023 21:24:39 +0000 Heime heimeborgia@protonmail.com wrote:
> > 
> > > ------- Original Message -------
> > > On Sunday, July 23rd, 2023 at 8:48 AM, Stephen Berman stephen.berman@gmx.net wrote:
> > > 
> > > > On Sat, 22 Jul 2023 20:24:16 +0000 Heime heimeborgia@protonmail.com wrote:
> > > > 
> > > > > ------- Original Message -------
> > > > > On Sunday, July 23rd, 2023 at 8:14 AM, Stephen Berman
> > > > > stephen.berman@gmx.net wrote:
> > > > > 
> > > > > > On Sat, 22 Jul 2023 19:18:03 +0000 Heime heimeborgia@protonmail.com wrote:
> > > > > > 
> > > > > > > ------- Original Message -------
> > > > > > > On Sunday, July 23rd, 2023 at 2:40 AM, Heime
> > > > > > > heimeborgia@protonmail.com wrote:
> > > > > > > 
> > > > > > > > I want to use a button to display the contents of a variable inside
> > > > > > > > a help buffer, but the following gives
> > > > > > > > 
> > > > > > > > (wrong-number-of-arguments ((t) nil "Function to be executed when
> > > > > > > > the button
> > > > > > > > is clicked..." (interactive) (message "Button clicked!")) 1)
> > > > > > > > my-action(#<overlay from 1 to 8 in Help>)
> > > > > > > 
> > > > > > > Why does pressing the button give me such error ?
> > > > > > > 
> > > > > > > > (defconst myvar "Text of Front A")
> > > > > > > > 
> > > > > > > > (defun my-action ()
> > > > > > > > "Function to be executed when the button is clicked."
> > > > > > > > (interactive)
> > > > > > > > (message "%s" myvar))
> > > > > > > > 
> > > > > > > > (defun qrh ()
> > > > > > > > "Some description."
> > > > > > > > 
> > > > > > > > (interactive)
> > > > > > > > 
> > > > > > > > (with-help-window (help-buffer)
> > > > > > > > (insert-button "Front A" 'action 'my-action 'follow-link t)))
> > > > > > 
> > > > > > The error says the function my-action expects one argument, but you
> > > > > > defined it with an empty argument list. If you don't want to use the
> > > > > > argument, you can use `' as a placeholder for the required argument,
> > > > > > which will be ignored by the byte compiler:
> > > > > > 
> > > > > > (defun my-action ()
> > > > > > "Function to be executed when the button is clicked."
> > > > > > (interactive)
> > > > > > (message "%s" myvar))
> > > > > > 
> > > > > > Steve Berman
> > > > > 

Do you know what the single argument is used for ?
> > > > > I do not understand the reason it expects an argument.
> > > > 
> > > > In the Emacs Lisp info manual there is the node `(elisp) Buttons', whose first subnode is` (elisp) Button Properties', whose first entry is the
> > > > `action' property:
> > > > 
> > > > ‘action’
> > > > The function to call when the user invokes the button, which is
> > > > passed the single argument BUTTON. By default this is ‘ignore’,
> > > > which does nothing.
> > > > 
> > > > > Would there be
> > > > > a more suitable way to print some text after pressing the button ?
> > > > 
> > > > If you want to use a button, then I guess not, since it needs an action
> > > > (or mouse-action) property to do something on pressing the button.
> > > > 
> > > > Steve Berman
> > > 
> > > In other words, insert-button needs a function with a single argument so it can
> > > pass ignore. Yes ?
> > 
> > No. `ignore' is the function that is the default value of the` action'
> > property of `insert-button', so if you want pressing the button to do nothing you can just evaluate e.g.` (insert-button "Front A")'. But if
> > you want pressing the button to do something, you have to pass the
> > `action' property to` insert-button' with a suitable function of one
> > argument as its value.
> > 
> > Steve Berman
> 
> 
> That explains it.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 22:13               ` Heime
@ 2023-07-22 22:28                 ` Stephen Berman
  2023-07-22 22:42                   ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Berman @ 2023-07-22 22:28 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, 22 Jul 2023 22:13:25 +0000 Heime <heimeborgia@protonmail.com> wrote:

[...]
>> > > > > > The error says the function my-action expects one argument, but you
>> > > > > > defined it with an empty argument list. If you don't want to use the
>> > > > > > argument, you can use `' as a placeholder for the required argument,
>> > > > > > which will be ignored by the byte compiler:
>> > > > > > 
>> > > > > > (defun my-action ()
>> > > > > > "Function to be executed when the button is clicked."
>> > > > > > (interactive)
>> > > > > > (message "%s" myvar))
>> > > > > > 
>> > > > > > Steve Berman
>> > > > > 
>
> Do you know what the single argument is used for ?

This is explained in the Info node `(elisp) Manipulating Buttons':

     Where a BUTTON parameter is specified, it means an object referring
  to a specific button, either an overlay (for overlay buttons), or a
  buffer-position or marker (for text property buttons).  Such an object
  is passed as the first argument to a button’s invocation function when
  it is invoked.

See also the function `button-activate' described in that node.

Steve Berman



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 22:28                 ` Stephen Berman
@ 2023-07-22 22:42                   ` Heime
  2023-07-22 22:50                     ` Stephen Berman
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 22:42 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Sunday, July 23rd, 2023 at 10:28 AM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sat, 22 Jul 2023 22:13:25 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> 
> [...]
> 
> > > > > > > > The error says the function my-action expects one argument, but you
> > > > > > > > defined it with an empty argument list. If you don't want to use the
> > > > > > > > argument, you can use `' as a placeholder for the required argument,
> > > > > > > > which will be ignored by the byte compiler:
> > > > > > > > 
> > > > > > > > (defun my-action ()
> > > > > > > > "Function to be executed when the button is clicked."
> > > > > > > > (interactive)
> > > > > > > > (message "%s" myvar))
> > > > > > > > 
> > > > > > > > Steve Berman
> > 
> > Do you know what the single argument is used for ?
> 
> 
> This is explained in the Info node `(elisp) Manipulating Buttons': Where a BUTTON parameter is specified, it means an object referring to a specific button, either an overlay (for overlay buttons), or a buffer-position or marker (for text property buttons). Such an object is passed as the first argument to a button’s invocation function when it is invoked. See also the function` button-activate' described in that node.
> 
> Steve Berman

What would be the actual object name passed to the function ?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 22:42                   ` Heime
@ 2023-07-22 22:50                     ` Stephen Berman
  2023-07-22 23:13                       ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Berman @ 2023-07-22 22:50 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, 22 Jul 2023 22:42:55 +0000 Heime <heimeborgia@protonmail.com> wrote:

> ------- Original Message -------
> On Sunday, July 23rd, 2023 at 10:28 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>
>> On Sat, 22 Jul 2023 22:13:25 +0000 Heime heimeborgia@protonmail.com wrote:
>> 
>> 
>> [...]
>> 
>> > > > > > > > The error says the function my-action expects one argument, but you
>> > > > > > > > defined it with an empty argument list. If you don't want to use the
>> > > > > > > > argument, you can use `' as a placeholder for the required argument,
>> > > > > > > > which will be ignored by the byte compiler:
>> > > > > > > > 
>> > > > > > > > (defun my-action ()
>> > > > > > > > "Function to be executed when the button is clicked."
>> > > > > > > > (interactive)
>> > > > > > > > (message "%s" myvar))
>> > > > > > > > 
>> > > > > > > > Steve Berman
>> > 
>> > Do you know what the single argument is used for ?
>> 
>> 
>> This is explained in the Info node `(elisp) Manipulating Buttons': Where a
>> BUTTON parameter is specified, it means an object referring to a specific
>> button, either an overlay (for overlay buttons), or a buffer-position or
>> marker (for text property buttons). Such an object is passed as the first
>> argument to a button’s invocation function when it is invoked. See also the
>> function` button-activate' described in that node.
>> 
>> Steve Berman
>
> What would be the actual object name passed to the function ?

I'm not sure what you mean by "actual object name", but since the
parameter is a local variable of the function, you can use any name for
it you like, including, as noted above, the underscore `_' (which seems
to have been removed by your mail program in the above citation), if you
don't use it in the body of the function.

Steve Berman



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 22:50                     ` Stephen Berman
@ 2023-07-22 23:13                       ` Heime
  2023-07-23  7:45                         ` Yuri Khan
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-22 23:13 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Sunday, July 23rd, 2023 at 10:50 AM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sat, 22 Jul 2023 22:42:55 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > ------- Original Message -------
> > On Sunday, July 23rd, 2023 at 10:28 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> > 
> > > On Sat, 22 Jul 2023 22:13:25 +0000 Heime heimeborgia@protonmail.com wrote:
> > > 
> > > [...]
> > > 
> > > > > > > > > > The error says the function my-action expects one argument, but you
> > > > > > > > > > defined it with an empty argument list. If you don't want to use the
> > > > > > > > > > argument, you can use `' as a placeholder for the required argument,
> > > > > > > > > > which will be ignored by the byte compiler:
> > > > > > > > > > 
> > > > > > > > > > (defun my-action ()
> > > > > > > > > > "Function to be executed when the button is clicked."
> > > > > > > > > > (interactive)
> > > > > > > > > > (message "%s" myvar))
> > > > > > > > > > 
> > > > > > > > > > Steve Berman
> > > > 
> > > > Do you know what the single argument is used for ?
> > > 
> > > This is explained in the Info node `(elisp) Manipulating Buttons': Where a BUTTON parameter is specified, it means an object referring to a specific button, either an overlay (for overlay buttons), or a buffer-position or marker (for text property buttons). Such an object is passed as the first argument to a button’s invocation function when it is invoked. See also the function` button-activate' described in that node.
> > > 
> > > Steve Berman
> > 
> > What would be the actual object name passed to the function ?
> 
> 
> I'm not sure what you mean by "actual object name", but since the
> parameter is a local variable of the function, you can use any name for
> it you like, including, as noted above, the underscore `_' (which seems
> to have been removed by your mail program in the above citation), if you
> don't use it in the body of the function.
> 
> Steve Berman

What does the button.el use as object to push to the action associated function
that would be sensible.  Would it be "action" ?



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-22 23:13                       ` Heime
@ 2023-07-23  7:45                         ` Yuri Khan
  2023-07-23 19:34                           ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Yuri Khan @ 2023-07-23  7:45 UTC (permalink / raw)
  To: Heime; +Cc: Stephen Berman,
	Heime via Users list for the GNU Emacs text editor

On Sun, 23 Jul 2023 at 06:14, Heime <heimeborgia@protonmail.com> wrote:

> What does the button.el use as object to push to the action associated function
> that would be sensible.  Would it be "action" ?

The documentation quoted upthread states the argument is named BUTTON.
It is easy to conclude that the action function, when called, will
receive as its argument a reference to the button object that was
clicked.

This pattern is widespread in GUI frameworks. It lets you create a
bunch of slightly different buttons and assign them all the same
single action, and it will be able to do slightly different things for
each button.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-23  7:45                         ` Yuri Khan
@ 2023-07-23 19:34                           ` Heime
  2023-07-23 19:57                             ` Yuri Khan
  0 siblings, 1 reply; 17+ messages in thread
From: Heime @ 2023-07-23 19:34 UTC (permalink / raw)
  To: Yuri Khan
  Cc: Stephen Berman,
	Heime via Users list for the GNU Emacs text editor

----- Original Message -------
On Sunday, July 23rd, 2023 at 7:45 PM, Yuri Khan <yuri.v.khan@gmail.com> wrote:


> On Sun, 23 Jul 2023 at 06:14, Heime heimeborgia@protonmail.com wrote:
> 
> > What does the button.el use as object to push to the action associated function
> > that would be sensible. Would it be "action" ?

Does the function associated with the button be restricted to a single argument,
meaning that users cannot pass any additional data to it ?
 
> The documentation quoted upthread states the argument is named BUTTON.
> It is easy to conclude that the action function, when called, will
> receive as its argument a reference to the button object that was
> clicked.
> 
> This pattern is widespread in GUI frameworks. It lets you create a
> bunch of slightly different buttons and assign them all the same
> single action, and it will be able to do slightly different things for
> each button.





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-23 19:34                           ` Heime
@ 2023-07-23 19:57                             ` Yuri Khan
  2023-07-23 20:05                               ` Heime
  0 siblings, 1 reply; 17+ messages in thread
From: Yuri Khan @ 2023-07-23 19:57 UTC (permalink / raw)
  To: Heime; +Cc: Stephen Berman,
	Heime via Users list for the GNU Emacs text editor

On Mon, 24 Jul 2023 at 02:34, Heime <heimeborgia@protonmail.com> wrote:

> Does the function associated with the button be restricted to a single argument,
> meaning that users cannot pass any additional data to it ?

Passing the button is sufficiently general. An action can reach into
the button’s properties and/or use the button’s identity or one of its
properties to look up in an external alist. And, of course, you can
always create lexical closures over a multi-argument function,
adapting it to the action interface.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Buttons in help buffer that displays contents of variables
  2023-07-23 19:57                             ` Yuri Khan
@ 2023-07-23 20:05                               ` Heime
  0 siblings, 0 replies; 17+ messages in thread
From: Heime @ 2023-07-23 20:05 UTC (permalink / raw)
  To: Yuri Khan
  Cc: Stephen Berman,
	Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Monday, July 24th, 2023 at 7:57 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:


> On Mon, 24 Jul 2023 at 02:34, Heime heimeborgia@protonmail.com wrote:
> 
> > Does the function associated with the button be restricted to a single argument,
> > meaning that users cannot pass any additional data to it ?
> 
> 
> Passing the button is sufficiently general. An action can reach into
> the button’s properties and/or use the button’s identity or one of its
> properties to look up in an external alist. And, of course, you can
> always create lexical closures over a multi-argument function,
> adapting it to the action interface.

Are the things you describe done often with buttons in emacs source code ?



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-07-23 20:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22 14:40 Buttons in help buffer that displays contents of variables Heime
2023-07-22 19:18 ` Heime
2023-07-22 20:14   ` Stephen Berman
2023-07-22 20:24     ` Heime
2023-07-22 20:48       ` Stephen Berman
2023-07-22 21:24         ` Heime
2023-07-22 21:46           ` Stephen Berman
2023-07-22 22:02             ` Heime
2023-07-22 22:13               ` Heime
2023-07-22 22:28                 ` Stephen Berman
2023-07-22 22:42                   ` Heime
2023-07-22 22:50                     ` Stephen Berman
2023-07-22 23:13                       ` Heime
2023-07-23  7:45                         ` Yuri Khan
2023-07-23 19:34                           ` Heime
2023-07-23 19:57                             ` Yuri Khan
2023-07-23 20:05                               ` Heime

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.