* Using button-label in pcase
@ 2023-07-24 19:14 uzibalqa
2023-07-24 20:07 ` Stephen Berman
0 siblings, 1 reply; 9+ messages in thread
From: uzibalqa @ 2023-07-24 19:14 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
Want to print some text as a result of clicking a button. With the code below
I end up with
(wrong-type-argument integer-or-marker-p nil)
buffer-substring-no-properties(nil nil)
button-label(#<overlay in no buffer>)
(let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))
(closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c)))))()
help--window-setup("*Help*" (closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))))
qrh-b(#<overlay in no buffer>)
button-activate(#<overlay in no buffer> t)
push-button(3 t)
What is going on. Is there a fix?
(defconst qrh-c "[FA] Some Text")
(defun qrh-b (button)
"Prints information about how to install emacs."
(with-help-window (help-buffer)
(pcase (button-label button)
("[FA]" (insert qrh-c))) ))
(defun qrh-a ()
"Prints information about how to install emacs."
(interactive)
(with-help-window (help-buffer)
(insert-button "[FC]"
'action 'qrh-b 'follow-link t) ))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 19:14 Using button-label in pcase uzibalqa
@ 2023-07-24 20:07 ` Stephen Berman
2023-07-24 21:35 ` uzibalqa
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2023-07-24 20:07 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa <uzibalqa@proton.me> wrote:
> Want to print some text as a result of clicking a button. With the code below
> I end up with
>
> (wrong-type-argument integer-or-marker-p nil)
> buffer-substring-no-properties(nil nil)
> button-label(#<overlay in no buffer>)
> (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))
> (closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c)))))()
> help--window-setup("*Help*" (closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))))
> qrh-b(#<overlay in no buffer>)
> button-activate(#<overlay in no buffer> t)
> push-button(3 t)
>
> What is going on. Is there a fix?
>
> (defconst qrh-c "[FA] Some Text")
>
> (defun qrh-b (button)
> "Prints information about how to install emacs."
> (with-help-window (help-buffer)
> (pcase (button-label button)
> ("[FA]" (insert qrh-c))) ))
>
> (defun qrh-a ()
> "Prints information about how to install emacs."
> (interactive)
> (with-help-window (help-buffer)
> (insert-button "[FC]"
> 'action 'qrh-b 'follow-link t) ))
The error is raised because qrh-b calls with-help-window with the *Help*
buffer current, but with-help-window erases the buffer, so when
`(button-label button)' is evaluated, there is no button and this
signals the error.
If you want to use the existing *Help* buffer, just remove the call to
with-help-window in qrh-b. However, *Help* buffers are read-only, so
trying to insert text will raise another error. To avoid this, you can
let-bind buffer-read-only in qrh-b. However, since qrh-a inserts "[FC]"
but qrh-b tries to match "[FA]", the match will fail, so the insertion
in qrh-b will not happen.
Steve Berman
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 20:07 ` Stephen Berman
@ 2023-07-24 21:35 ` uzibalqa
2023-07-24 21:51 ` Stephen Berman
0 siblings, 1 reply; 9+ messages in thread
From: uzibalqa @ 2023-07-24 21:35 UTC (permalink / raw)
To: Stephen Berman; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
>
> > Want to print some text as a result of clicking a button. With the code below
> > I end up with
> >
> > (wrong-type-argument integer-or-marker-p nil)
> > buffer-substring-no-properties(nil nil)
> > button-label(#<overlay in no buffer>)
> > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))
> > (closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c)))))()
> > help--window-setup("Help" (closure ((button . #<overlay in no buffer>)) nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil (insert qrh-c))))))
> > qrh-b(#<overlay in no buffer>)
> > button-activate(#<overlay in no buffer> t)
> > push-button(3 t)
> >
> > What is going on. Is there a fix?
> >
> > (defconst qrh-c "[FA] Some Text")
> >
> > (defun qrh-b (button)
> > "Prints information about how to install emacs."
> > (with-help-window (help-buffer)
> > (pcase (button-label button)
> > ("[FA]" (insert qrh-c))) ))
> >
> > (defun qrh-a ()
> > "Prints information about how to install emacs."
> > (interactive)
> > (with-help-window (help-buffer)
> > (insert-button "[FC]"
> > 'action 'qrh-b 'follow-link t) ))
>
> The error is raised because qrh-b calls with-help-window with the Help
> buffer current, but with-help-window erases the buffer, so when
> `(button-label button)' is evaluated, there is no button and this
> signals the error.
That what was wrong then.
> If you want to use the existing Help buffer, just remove the call to
> with-help-window in qrh-b.
> However, Help buffers are read-only, so
> trying to insert text will raise another error. To avoid this, you can
> let-bind buffer-read-only in qrh-b.
I do not experience the problem you mention. What error are you referring to,
and how can it be triggered ?
> However, since qrh-a inserts "[FC]"
> but qrh-b tries to match "[FA]", the match will fail, so the insertion
> in qrh-b will not happen. - Steve Berman
That was an error from my part.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 21:35 ` uzibalqa
@ 2023-07-24 21:51 ` Stephen Berman
2023-07-24 22:24 ` uzibalqa
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2023-07-24 21:51 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa <uzibalqa@proton.me> wrote:
> ------- Original Message -------
> On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>
>> On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
>>
>> > Want to print some text as a result of clicking a button. With the code below
>> > I end up with
>> >
>> > (wrong-type-argument integer-or-marker-p nil)
>> > buffer-substring-no-properties(nil nil)
>> > button-label(#<overlay in no buffer>)
>> > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > (insert qrh-c))))
>> > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
>> > (button-label button))) (if (equal val '"[FA]") (let nil (insert
>> > qrh-c)))))()
>> > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
>> > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > (insert qrh-c))))))
>> > qrh-b(#<overlay in no buffer>)
>> > button-activate(#<overlay in no buffer> t)
>> > push-button(3 t)
>> >
>> > What is going on. Is there a fix?
>> >
>> > (defconst qrh-c "[FA] Some Text")
>> >
>> > (defun qrh-b (button)
>> > "Prints information about how to install emacs."
>> > (with-help-window (help-buffer)
>> > (pcase (button-label button)
>> > ("[FA]" (insert qrh-c))) ))
>> >
>> > (defun qrh-a ()
>> > "Prints information about how to install emacs."
>> > (interactive)
>> > (with-help-window (help-buffer)
>> > (insert-button "[FC]"
>> > 'action 'qrh-b 'follow-link t) ))
>>
>> The error is raised because qrh-b calls with-help-window with the Help
>> buffer current, but with-help-window erases the buffer, so when
>> `(button-label button)' is evaluated, there is no button and this
>> signals the error.
>
> That what was wrong then.
That there was no button. When you execute your command qrh-a and then
in the resulting *Help* buffer press the button, it disappears.
>> If you want to use the existing Help buffer, just remove the call to
>> with-help-window in qrh-b.
>
>
>> However, Help buffers are read-only, so
>> trying to insert text will raise another error. To avoid this, you can
>> let-bind buffer-read-only in qrh-b.
>
> I do not experience the problem you mention. What error are you referring to,
> and how can it be triggered ?
Did you remove the call the with-help-window in qrh-b and correct the
match condtion (or change the string in qrh-a to match the one in
qrh-b)? If so, then when you press the button in the *Help* buffer, you
will get the error "Buffer is read-only: #<buffer *Help*>".
Steve Berman
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 21:51 ` Stephen Berman
@ 2023-07-24 22:24 ` uzibalqa
2023-07-24 22:36 ` Stephen Berman
0 siblings, 1 reply; 9+ messages in thread
From: uzibalqa @ 2023-07-24 22:24 UTC (permalink / raw)
To: Stephen Berman; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa uzibalqa@proton.me wrote:
>
> > ------- Original Message -------
> > On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> >
> > > On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
> > >
> > > > Want to print some text as a result of clicking a button. With the code below
> > > > I end up with
> > > >
> > > > (wrong-type-argument integer-or-marker-p nil)
> > > > buffer-substring-no-properties(nil nil)
> > > > button-label(#<overlay in no buffer>)
> > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > (insert qrh-c))))
> > > > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
> > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert
> > > > qrh-c)))))()
> > > > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
> > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > (insert qrh-c))))))
> > > > qrh-b(#<overlay in no buffer>)
> > > > button-activate(#<overlay in no buffer> t)
> > > > push-button(3 t)
> > > >
> > > > What is going on. Is there a fix?
> > > >
> > > > (defconst qrh-c "[FA] Some Text")
> > > >
> > > > (defun qrh-b (button)
> > > > "Prints information about how to install emacs."
> > > > (with-help-window (help-buffer)
> > > > (pcase (button-label button)
> > > > ("[FA]" (insert qrh-c))) ))
> > > >
> > > > (defun qrh-a ()
> > > > "Prints information about how to install emacs."
> > > > (interactive)
> > > > (with-help-window (help-buffer)
> > > > (insert-button "[FC]"
> > > > 'action 'qrh-b 'follow-link t) ))
> > >
> > > The error is raised because qrh-b calls with-help-window with the Help
> > > buffer current, but with-help-window erases the buffer, so when
> > > `(button-label button)' is evaluated, there is no button and this
> > > signals the error.
> >
> > That what was wrong then.
>
>
> That there was no button. When you execute your command qrh-a and then
> in the resulting Help buffer press the button, it disappears.
>
> > > If you want to use the existing Help buffer, just remove the call to
> > > with-help-window in qrh-b.
> >
> > > However, Help buffers are read-only, so
> > > trying to insert text will raise another error. To avoid this, you can
> > > let-bind buffer-read-only in qrh-b.
> >
> > I do not experience the problem you mention. What error are you referring to,
> > and how can it be triggered ?
>
> Did you remove the call the with-help-window in qrh-b and correct the
> match condtion (or change the string in qrh-a to match the one in
> qrh-b)? If so, then when you press the button in the Help buffer, you
> will get the error "Buffer is read-only: #<buffer Help>".
> Steve Berman
I did the changes and have the following
(pcase (button-label button)
("[FA]"
(with-help-window (help-buffer) ; Print in help buffer
(insert qrh-c)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 22:24 ` uzibalqa
@ 2023-07-24 22:36 ` Stephen Berman
2023-07-24 22:40 ` uzibalqa
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2023-07-24 22:36 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
On Mon, 24 Jul 2023 22:24:33 +0000 uzibalqa <uzibalqa@proton.me> wrote:
> ------- Original Message -------
> On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>
>> On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa uzibalqa@proton.me wrote:
>>
>> > ------- Original Message -------
>> > On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
>> > stephen.berman@gmx.net wrote:
>> >
>> > > On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
>> > >
>> > > > Want to print some text as a result of clicking a button. With the code below
>> > > > I end up with
>> > > >
>> > > > (wrong-type-argument integer-or-marker-p nil)
>> > > > buffer-substring-no-properties(nil nil)
>> > > > button-label(#<overlay in no buffer>)
>> > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > > > (insert qrh-c))))
>> > > > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
>> > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert
>> > > > qrh-c)))))()
>> > > > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
>> > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > > > (insert qrh-c))))))
>> > > > qrh-b(#<overlay in no buffer>)
>> > > > button-activate(#<overlay in no buffer> t)
>> > > > push-button(3 t)
>> > > >
>> > > > What is going on. Is there a fix?
>> > > >
>> > > > (defconst qrh-c "[FA] Some Text")
>> > > >
>> > > > (defun qrh-b (button)
>> > > > "Prints information about how to install emacs."
>> > > > (with-help-window (help-buffer)
>> > > > (pcase (button-label button)
>> > > > ("[FA]" (insert qrh-c))) ))
>> > > >
>> > > > (defun qrh-a ()
>> > > > "Prints information about how to install emacs."
>> > > > (interactive)
>> > > > (with-help-window (help-buffer)
>> > > > (insert-button "[FC]"
>> > > > 'action 'qrh-b 'follow-link t) ))
>> > >
>> > > The error is raised because qrh-b calls with-help-window with the Help
>> > > buffer current, but with-help-window erases the buffer, so when
>> > > `(button-label button)' is evaluated, there is no button and this
>> > > signals the error.
>> >
>> > That what was wrong then.
>>
>>
>> That there was no button. When you execute your command qrh-a and then
>> in the resulting Help buffer press the button, it disappears.
>>
>> > > If you want to use the existing Help buffer, just remove the call to
>> > > with-help-window in qrh-b.
>> >
>> > > However, Help buffers are read-only, so
>> > > trying to insert text will raise another error. To avoid this, you can
>> > > let-bind buffer-read-only in qrh-b.
>> >
>> > I do not experience the problem you mention. What error are you referring to,
>> > and how can it be triggered ?
>>
>> Did you remove the call the with-help-window in qrh-b and correct the
>> match condtion (or change the string in qrh-a to match the one in
>> qrh-b)? If so, then when you press the button in the Help buffer, you
>> will get the error "Buffer is read-only: #<buffer Help>".
>
>> Steve Berman
>
> I did the changes and have the following
>
> (pcase (button-label button)
> ("[FA]"
> (with-help-window (help-buffer) ; Print in help buffer
> (insert qrh-c)))
Sure, that's a fine way to avoid the problem with the read-only state of
the *Help* buffer.
Steve Berman
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 22:36 ` Stephen Berman
@ 2023-07-24 22:40 ` uzibalqa
2023-07-24 22:53 ` Stephen Berman
0 siblings, 1 reply; 9+ messages in thread
From: uzibalqa @ 2023-07-24 22:40 UTC (permalink / raw)
To: Stephen Berman; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Tuesday, July 25th, 2023 at 10:36 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 24 Jul 2023 22:24:33 +0000 uzibalqa uzibalqa@proton.me wrote:
>
> > ------- Original Message -------
> > On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> >
> > > On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa uzibalqa@proton.me wrote:
> > >
> > > > ------- Original Message -------
> > > > On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
> > > > stephen.berman@gmx.net wrote:
> > > >
> > > > > On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
> > > > >
> > > > > > Want to print some text as a result of clicking a button. With the code below
> > > > > > I end up with
> > > > > >
> > > > > > (wrong-type-argument integer-or-marker-p nil)
> > > > > > buffer-substring-no-properties(nil nil)
> > > > > > button-label(#<overlay in no buffer>)
> > > > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > > > (insert qrh-c))))
> > > > > > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
> > > > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert
> > > > > > qrh-c)))))()
> > > > > > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
> > > > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > > > (insert qrh-c))))))
> > > > > > qrh-b(#<overlay in no buffer>)
> > > > > > button-activate(#<overlay in no buffer> t)
> > > > > > push-button(3 t)
> > > > > >
> > > > > > What is going on. Is there a fix?
> > > > > >
> > > > > > (defconst qrh-c "[FA] Some Text")
> > > > > >
> > > > > > (defun qrh-b (button)
> > > > > > "Prints information about how to install emacs."
> > > > > > (with-help-window (help-buffer)
> > > > > > (pcase (button-label button)
> > > > > > ("[FA]" (insert qrh-c))) ))
> > > > > >
> > > > > > (defun qrh-a ()
> > > > > > "Prints information about how to install emacs."
> > > > > > (interactive)
> > > > > > (with-help-window (help-buffer)
> > > > > > (insert-button "[FC]"
> > > > > > 'action 'qrh-b 'follow-link t) ))
> > > > >
> > > > > The error is raised because qrh-b calls with-help-window with the Help
> > > > > buffer current, but with-help-window erases the buffer, so when
> > > > > `(button-label button)' is evaluated, there is no button and this
> > > > > signals the error.
> > > >
> > > > That what was wrong then.
> > >
> > > That there was no button. When you execute your command qrh-a and then
> > > in the resulting Help buffer press the button, it disappears.
> > >
> > > > > If you want to use the existing Help buffer, just remove the call to
> > > > > with-help-window in qrh-b.
> > > >
> > > > > However, Help buffers are read-only, so
> > > > > trying to insert text will raise another error. To avoid this, you can
> > > > > let-bind buffer-read-only in qrh-b.
> > > >
> > > > I do not experience the problem you mention. What error are you referring to,
> > > > and how can it be triggered ?
> > >
> > > Did you remove the call the with-help-window in qrh-b and correct the
> > > match condtion (or change the string in qrh-a to match the one in
> > > qrh-b)? If so, then when you press the button in the Help buffer, you
> > > will get the error "Buffer is read-only: #<buffer Help>".
> >
> > > Steve Berman
> >
> > I did the changes and have the following
> >
> > (pcase (button-label button)
> > ("[FA]"
> > (with-help-window (help-buffer) ; Print in help buffer
> > (insert qrh-c)))
>
>
> Sure, that's a fine way to avoid the problem with the read-only state of
> the Help buffer.
>
> Steve Berman
I replicated the error you mentioned though. Why does it happen ? Is that because
the insert would be within an (with-help-window (help-buffer) ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 22:40 ` uzibalqa
@ 2023-07-24 22:53 ` Stephen Berman
2023-07-24 23:40 ` uzibalqa
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman @ 2023-07-24 22:53 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
On Mon, 24 Jul 2023 22:40:03 +0000 uzibalqa <uzibalqa@proton.me> wrote:
> ------- Original Message -------
> On Tuesday, July 25th, 2023 at 10:36 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>
>> On Mon, 24 Jul 2023 22:24:33 +0000 uzibalqa uzibalqa@proton.me wrote:
>>
>> > ------- Original Message -------
>> > On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman
>> > stephen.berman@gmx.net wrote:
>> >
>> > > On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa uzibalqa@proton.me wrote:
>> > >
>> > > > ------- Original Message -------
>> > > > On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
>> > > > stephen.berman@gmx.net wrote:
>> > > >
>> > > > > On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
>> > > > >
>> > > > > > Want to print some text as a result of clicking a button. With the
>> > > > > > code below
>> > > > > > I end up with
>> > > > > >
>> > > > > > (wrong-type-argument integer-or-marker-p nil)
>> > > > > > buffer-substring-no-properties(nil nil)
>> > > > > > button-label(#<overlay in no buffer>)
>> > > > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > > > > > (insert qrh-c))))
>> > > > > > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
>> > > > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert
>> > > > > > qrh-c)))))()
>> > > > > > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
>> > > > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
>> > > > > > (insert qrh-c))))))
>> > > > > > qrh-b(#<overlay in no buffer>)
>> > > > > > button-activate(#<overlay in no buffer> t)
>> > > > > > push-button(3 t)
>> > > > > >
>> > > > > > What is going on. Is there a fix?
>> > > > > >
>> > > > > > (defconst qrh-c "[FA] Some Text")
>> > > > > >
>> > > > > > (defun qrh-b (button)
>> > > > > > "Prints information about how to install emacs."
>> > > > > > (with-help-window (help-buffer)
>> > > > > > (pcase (button-label button)
>> > > > > > ("[FA]" (insert qrh-c))) ))
>> > > > > >
>> > > > > > (defun qrh-a ()
>> > > > > > "Prints information about how to install emacs."
>> > > > > > (interactive)
>> > > > > > (with-help-window (help-buffer)
>> > > > > > (insert-button "[FC]"
>> > > > > > 'action 'qrh-b 'follow-link t) ))
>> > > > >
>> > > > > The error is raised because qrh-b calls with-help-window with the Help
>> > > > > buffer current, but with-help-window erases the buffer, so when
>> > > > > `(button-label button)' is evaluated, there is no button and this
>> > > > > signals the error.
>> > > >
>> > > > That what was wrong then.
>> > >
>> > > That there was no button. When you execute your command qrh-a and then
>> > > in the resulting Help buffer press the button, it disappears.
>> > >
>> > > > > If you want to use the existing Help buffer, just remove the call to
>> > > > > with-help-window in qrh-b.
>> > > >
>> > > > > However, Help buffers are read-only, so
>> > > > > trying to insert text will raise another error. To avoid this, you can
>> > > > > let-bind buffer-read-only in qrh-b.
>> > > >
>> > > > I do not experience the problem you mention. What error are you referring to,
>> > > > and how can it be triggered ?
>> > >
>> > > Did you remove the call the with-help-window in qrh-b and correct the
>> > > match condtion (or change the string in qrh-a to match the one in
>> > > qrh-b)? If so, then when you press the button in the Help buffer, you
>> > > will get the error "Buffer is read-only: #<buffer Help>".
>> >
>> > > Steve Berman
>> >
>> > I did the changes and have the following
>> >
>> > (pcase (button-label button)
>> > ("[FA]"
>> > (with-help-window (help-buffer) ; Print in help buffer
>> > (insert qrh-c)))
>>
>>
>> Sure, that's a fine way to avoid the problem with the read-only state of
>> the Help buffer.
>>
>> Steve Berman
>
> I replicated the error you mentioned though. Why does it happen ? Is that because
> the insert would be within an (with-help-window (help-buffer) ?
I get no error using the last code snippet you provided, because the
button-label is evaluated before with-help-window erases the buffer, and
with-help-window makes the *Help* buffer temporarily writeable.
Steve Berman
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using button-label in pcase
2023-07-24 22:53 ` Stephen Berman
@ 2023-07-24 23:40 ` uzibalqa
0 siblings, 0 replies; 9+ messages in thread
From: uzibalqa @ 2023-07-24 23:40 UTC (permalink / raw)
To: Stephen Berman; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- Original Message -------
On Tuesday, July 25th, 2023 at 10:53 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 24 Jul 2023 22:40:03 +0000 uzibalqa uzibalqa@proton.me wrote:
>
> > ------- Original Message -------
> > On Tuesday, July 25th, 2023 at 10:36 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> >
> > > On Mon, 24 Jul 2023 22:24:33 +0000 uzibalqa uzibalqa@proton.me wrote:
> > >
> > > > ------- Original Message -------
> > > > On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman
> > > > stephen.berman@gmx.net wrote:
> > > >
> > > > > On Mon, 24 Jul 2023 21:35:44 +0000 uzibalqa uzibalqa@proton.me wrote:
> > > > >
> > > > > > ------- Original Message -------
> > > > > > On Tuesday, July 25th, 2023 at 8:07 AM, Stephen Berman
> > > > > > stephen.berman@gmx.net wrote:
> > > > > >
> > > > > > > On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa uzibalqa@proton.me wrote:
> > > > > > >
> > > > > > > > Want to print some text as a result of clicking a button. With the
> > > > > > > > code below
> > > > > > > > I end up with
> > > > > > > >
> > > > > > > > (wrong-type-argument integer-or-marker-p nil)
> > > > > > > > buffer-substring-no-properties(nil nil)
> > > > > > > > button-label(#<overlay in no buffer>)
> > > > > > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > > > > > (insert qrh-c))))
> > > > > > > > (closure ((button . #<overlay in no buffer>)) nil (let* ((val
> > > > > > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert
> > > > > > > > qrh-c)))))()
> > > > > > > > help--window-setup("Help" (closure ((button . #<overlay in no buffer>))
> > > > > > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (let nil
> > > > > > > > (insert qrh-c))))))
> > > > > > > > qrh-b(#<overlay in no buffer>)
> > > > > > > > button-activate(#<overlay in no buffer> t)
> > > > > > > > push-button(3 t)
> > > > > > > >
> > > > > > > > What is going on. Is there a fix?
> > > > > > > >
> > > > > > > > (defconst qrh-c "[FA] Some Text")
> > > > > > > >
> > > > > > > > (defun qrh-b (button)
> > > > > > > > "Prints information about how to install emacs."
> > > > > > > > (with-help-window (help-buffer)
> > > > > > > > (pcase (button-label button)
> > > > > > > > ("[FA]" (insert qrh-c))) ))
> > > > > > > >
> > > > > > > > (defun qrh-a ()
> > > > > > > > "Prints information about how to install emacs."
> > > > > > > > (interactive)
> > > > > > > > (with-help-window (help-buffer)
> > > > > > > > (insert-button "[FC]"
> > > > > > > > 'action 'qrh-b 'follow-link t) ))
> > > > > > >
> > > > > > > The error is raised because qrh-b calls with-help-window with the Help
> > > > > > > buffer current, but with-help-window erases the buffer, so when
> > > > > > > `(button-label button)' is evaluated, there is no button and this
> > > > > > > signals the error.
> > > > > >
> > > > > > That what was wrong then.
> > > > >
> > > > > That there was no button. When you execute your command qrh-a and then
> > > > > in the resulting Help buffer press the button, it disappears.
> > > > >
> > > > > > > If you want to use the existing Help buffer, just remove the call to
> > > > > > > with-help-window in qrh-b.
> > > > > >
> > > > > > > However, Help buffers are read-only, so
> > > > > > > trying to insert text will raise another error. To avoid this, you can
> > > > > > > let-bind buffer-read-only in qrh-b.
> > > > > >
> > > > > > I do not experience the problem you mention. What error are you referring to,
> > > > > > and how can it be triggered ?
> > > > >
> > > > > Did you remove the call the with-help-window in qrh-b and correct the
> > > > > match condtion (or change the string in qrh-a to match the one in
> > > > > qrh-b)? If so, then when you press the button in the Help buffer, you
> > > > > will get the error "Buffer is read-only: #<buffer Help>".
> > > >
> > > > > Steve Berman
> > > >
> > > > I did the changes and have the following
> > > >
> > > > (pcase (button-label button)
> > > > ("[FA]"
> > > > (with-help-window (help-buffer) ; Print in help buffer
> > > > (insert qrh-c)))
> > >
> > > Sure, that's a fine way to avoid the problem with the read-only state of
> > > the Help buffer.
> > >
> > > Steve Berman
> >
> > I replicated the error you mentioned though. Why does it happen ? Is that because
> > the insert would be within an (with-help-window (help-buffer) ?
>
>
> I get no error using the last code snippet you provided, because the
> button-label is evaluated before with-help-window erases the buffer, and
> with-help-window makes the Help buffer temporarily writeable.
>
> Steve Berman
It's all good then. Felicitations.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-07-24 23:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 19:14 Using button-label in pcase uzibalqa
2023-07-24 20:07 ` Stephen Berman
2023-07-24 21:35 ` uzibalqa
2023-07-24 21:51 ` Stephen Berman
2023-07-24 22:24 ` uzibalqa
2023-07-24 22:36 ` Stephen Berman
2023-07-24 22:40 ` uzibalqa
2023-07-24 22:53 ` Stephen Berman
2023-07-24 23:40 ` uzibalqa
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.