unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Buttons in help buffer that displays contents of variables
Date: Sat, 22 Jul 2023 22:13:25 +0000	[thread overview]
Message-ID: <IvsFg7sy9z-HHdbQ9qDQ7AHJKefqigrf4nBTa2CJX8eIJoGEZnudL35kXqK0tvr1IG5qyxyLSvFzUvV2WXEK6vfl4jYeLfpDPfFbGFa5r38=@protonmail.com> (raw)
In-Reply-To: <AI2-iDr_g3LiuvCZ3P1vPghdGRGh1DcxKf0BS-5zYmek_OWrOGQ3Iz9YFd9AwSykX7SM_8pcSSTc58TooiNv4NQQJcW2EVA5BeA7tdT5_gI=@protonmail.com>

------- 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.



  reply	other threads:[~2023-07-22 22:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='IvsFg7sy9z-HHdbQ9qDQ7AHJKefqigrf4nBTa2CJX8eIJoGEZnudL35kXqK0tvr1IG5qyxyLSvFzUvV2WXEK6vfl4jYeLfpDPfFbGFa5r38=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=stephen.berman@gmx.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).