From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Using button-label in pcase Date: Tue, 25 Jul 2023 00:36:00 +0200 Message-ID: <87h6ptvsxb.fsf@gmx.net> References: <87pm4hvztc.fsf@gmx.net> <87lef5vuzf.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21696"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: uzibalqa via Users list for the GNU Emacs text editor To: uzibalqa Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 25 00:37:03 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qO4Ao-0005Sw-Pk for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Jul 2023 00:37:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qO49x-0005wn-TQ; Mon, 24 Jul 2023 18:36:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qO49v-0005wC-7d for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 18:36:07 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qO49s-0006uc-O7 for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 18:36:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1690238161; x=1690842961; i=stephen.berman@gmx.net; bh=rQo3Qz35CwGTPyiDsEbb0d2u+yqU7+ZscxbXz7edNbo=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=JVupUjwOiDhEEWdhEODw5MBryODnuUpARd8lyter+y9DagIFHTWdwiGHH21x0bB5/0JVffT wBrQSMRI/Wv+8cDZH8S6BsOo2cZt2lDsicLZ//mCey3nP5Hmk0ttpF39HrOqktj31dFHwkQbQ dm0rscW+Ln5qOT0mlmth07vBX8v5gyFjguWiLdo5KPNT0V2q3MbzKCt5I7IS1ezztrn+CJcj2 S324nsyx/fV4T8A3WhUpLJ59feOojyrBXHvYFg4gBmLnfDB1AYG/6owMHITtZOmBWJtp2ALGD oJuekOP6G+vNC5E/m1R7XsokeJb9yh54L/CfolMQNmqoJliDGXAw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([94.134.196.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MmDIu-1pfteT0Qsa-00i8ft; Tue, 25 Jul 2023 00:36:01 +0200 In-Reply-To: (uzibalqa@proton.me's message of "Mon, 24 Jul 2023 22:24:33 +0000") X-Provags-ID: V03:K1:iFVP5lhahpk/sn4QLjaonLR2wSvNZGvuTOoQbFkXu2GsrIOmzFg /c5jqLqm0paA5MIRB37Tl+EtkmptZQNDGT746xmoglYBdKiqtude8BCOnFg7Ps8ABh3yW3J R8Z0Bcu8pAUNTfAy4O0NGPfDMctWjPm6tDKAkSepX0uWs5MpFemhIrUzaCgeK+3++9H0yVl DRfz6fxLPQP14ki7VTRCQ== UI-OutboundReport: notjunk:1;M01:P0:ugc71O/K2gE=;xOlAf5zCpy4wyLb1M38pMW4f5LG /Pg2Z6keaSkKXNq6DYa5TE3aZvOkcP2EFfcdz1UFHp39Ih/UIwTyZAR2wOgWOZAHVQEFIGDWE t5hyhGB10cwfzRNHIB4/zO5/3t70UiwqPn+TvWiwArMkgSv7YlZQ1F4hCNxDzICe3YajSRQL4 5vxGILqjJCmzqaQh68/Ro8pFnd4TK4bnMvhGY3m++ooOfhsSwsAWQ2KhUT8WHJLKxYLSX7/9T u7WcdOjJE++J+ffh78QNQF6yfiTw5SgSFvhQW6nEo8+y/ndThfNhKX7qHGVlIoJrCX1n1aRp4 1DR6AFrX1JH8Q4NC2uZwpgLci9Ad2gjxf5XgbJFsKDn3gXxJkC2MtQbxy1lh1sMmYz071wfzR NeQ0KzxyQ9q5q5ALmXOv9Rel50Wqgc4V9T+8itEuBfQELenUMOR4Di5PwIuhYaGCjGIeY+fuD qZcx/MTdFAAfR/op5pAs8bsXUp5fQxOmYww9MWY3cScU+W9DvT7gkohSTBZmTZFKnLpFzi4zd k3/AAq3/K+pI15rijW6y2alDeLqmNULFO9F7QMnN6BOqfPnOb74OxsKjPgyPrebYEB3AHiMPf 20YUb4f4XE+ytUqV/YbIVX6sJ54qFu6WJWlyQM11+DDzaw9IrD2TL2FER7jK/DyOlYUtF4LHQ lGFhejlISGWkvLPj/ks+B8rR1O3k0HSAB2ZRQT+4qr8pkgNHkb6fraglO/5OKQTebR8UlCLya Ij15IMborRpTxNtWgW9Z/DuExlHX0213/GU5zExryLCm8dCEYH+hZ7IUplXhFtZFLCeZ8IEh Received-SPF: pass client-ip=212.227.17.22; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:144431 Archived-At: On Mon, 24 Jul 2023 22:24:33 +0000 uzibalqa wrote: > ------- Original Message ------- > On Tuesday, July 25th, 2023 at 9:51 AM, Stephen Berman > 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 wrot= e: >> > > >> > > > Want to print some text as a result of clicking a button. With th= e code below >> > > > I end up with >> > > > >> > > > (wrong-type-argument integer-or-marker-p nil) >> > > > buffer-substring-no-properties(nil nil) >> > > > button-label(#) >> > > > (let* ((val (button-label button))) (if (equal val '"[FA]") (let = nil >> > > > (insert qrh-c)))) >> > > > (closure ((button . #)) nil (let* ((val >> > > > (button-label button))) (if (equal val '"[FA]") (let nil (insert >> > > > qrh-c)))))() >> > > > help--window-setup("Help" (closure ((button . #)) >> > > > nil (let* ((val (button-label button))) (if (equal val '"[FA]") (= let nil >> > > > (insert qrh-c)))))) >> > > > qrh-b(#) >> > > > button-activate(# 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 H= elp >> > > 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 t= o >> > > 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 refer= ring 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: #". > >> 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