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

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

Re: Buttons in help buffer that displays contents of variables


From: Stephen Berman
Subject: Re: Buttons in help buffer that displays contents of variables
Date: Sat, 22 Jul 2023 22:48:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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



reply via email to

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