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:53:23 +0200 Message-ID: <87cz0gx6os.fsf@gmx.net> References: <87pm4hvztc.fsf@gmx.net> <87lef5vuzf.fsf@gmx.net> <87h6ptvsxb.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="23301"; 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:54:11 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 1qO4RM-0005pk-SF for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 25 Jul 2023 00:54:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qO4Qk-0008Lv-PX; Mon, 24 Jul 2023 18:53:30 -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 1qO4Qj-0008LX-8J for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 18:53:29 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qO4Qh-0001SD-8Q for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 18:53:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1690239204; x=1690844004; i=stephen.berman@gmx.net; bh=mL5yDUvgFo4i8mF/CalxZzOJqM6jCW9fIM9FY/ITbsw=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=rlCCDTZDL6oxkkq0+A0afZupy13iGlgo0cpwz5uYYS2ZqbFQMOrgDSh+TYyDBh3dNCrGZi7 0PpUjHiSOOu98GyG/GlwomhJb57yITnNh20F8eSYdxAbfjPOcgm7HNDMgDHyJUQEJen83iAxl zIiHC7frGzfHMSMkAJSKFxRYe0jg6A6lfzuzq9OIVApKONLXiekxWXVS3l4QMJT9I5Zp5m28i nMgkTrTSHw40KzxyZYOs254l9UIoeY81/Y8jw77r2r3xlmgfUotdbThJ5z+DOW4QQI7Nw+XaP ORQprNH72O45/tnF94u5zF3RRP5umaYxbLrfZtRouVoz/S3YLDiA== 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 1M2wKq-1qKmds13Km-003Laz; Tue, 25 Jul 2023 00:53:24 +0200 In-Reply-To: (uzibalqa@proton.me's message of "Mon, 24 Jul 2023 22:40:03 +0000") X-Provags-ID: V03:K1:U7AZnwd7YjLPmRX/CuJNJo5Ch/5NS5ACBm0J8/fX9ErvyKIcw9+ 7hHtMMsUIO4dMosSy13lIqSj61xVr6ETWiR83WLUeTslk4M5iKJNG8qbNe2L4OP8vrVGxgM GCI/zXyhHbMdSMD2H7+J3t+lzTs67huBy/TA0WgvBLA1LzdPSsLlKHM32WunHFAshPAeleD pBV/L7o3qGK7oCxXjFqzA== UI-OutboundReport: notjunk:1;M01:P0:3qFw0dQMiFU=;RH8JM2hG+PRoliRjJWA7+OK2bmp f59dJ/HtO7pfLH4mlJ1fTdc6RsXOGFX6Y2nIclDQ1JZ6ar8Fp7+A6zg/kORMKWKN2cayRnlIm LSgv4Z70HOJdg/DQOwCbmUCVmi5dxHBG3RJdfSkBls7PZ3jfXJssJvbSHCJEtvAPoXF8zq2TK ZlDmioDoDCaj09XD4Bh2IfH7UfHrQfMM7QKU6KiV6EdnJYJAdGpLarEMl+ZcKU8W6joL40d4T rZyruFJowJdvYGQv8Z9K6KYHmp/UvIcN2ifoCUXdyadC0k56tGN5UvEvzDfrPUYnaejX1dIdi OsL/UjgyWp8Zz4fnuEf6pJQI2k7ZdIPDcRKIyvztEGGnLqGXu7KlLH/Wbfrph1CyPILXT9BIP 6MmW+maXKagFZz7YPg7sQov/PplIiATrP1XbhjoxZLER0PMz9s+ju1JlOZYM4noXCwa3Nbimz vd4oeJB8E3spoWnA8OPPLyOnoucfBVBmAt0vMyPRuVS1fba72GDL1YeAjRqpu95M3yfchaEHd GCLZe5j2vIxtWxXcI6/sltZZVxukwSkM/vFA7DRVae4k9s/GyKo+dD+uHKSQT9vylYnVWB6eV yoezluPz8ljQmxW6kAdJFk5kg/EZdErCEjmPehKOlueYl/uBa0yiXMR3UOGWGmF3+TxtFG9qE Ool/5LDrD9lxENVKI65l5UNHkcGUSDDoANMFs5xfW1Anfv35RAGbwMi6n6BJX4wdW8G64XaWE 8ntUKaQnAptxuESEg9a2sAD9M/tYboBOGlDkX65myiEMwthXh++4vSIiJgWD388ApuHF6IfQ Received-SPF: pass client-ip=212.227.17.21; 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, 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:144433 Archived-At: On Mon, 24 Jul 2023 22:40:03 +0000 uzibalqa wrote: > ------- Original Message ------- > On Tuesday, July 25th, 2023 at 10:36 AM, Stephen Berman > 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 wrot= e: >> > > >> > > > ------- 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. Wit= h the >> > > > > > 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 (ins= ert >> > > > > > 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 t= he Help >> > > > > buffer current, but with-help-window erases the buffer, so when >> > > > > `(button-label button)' is evaluated, there is no button and th= is >> > > > > signals the error. >> > > > >> > > > That what was wrong then. >> > > >> > > That there was no button. When you execute your command qrh-a and t= hen >> > > in the resulting Help buffer press the button, it disappears. >> > > >> > > > > If you want to use the existing Help buffer, just remove the ca= ll 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 r= eferring to, >> > > > and how can it be triggered ? >> > > >> > > Did you remove the call the with-help-window in qrh-b and correct t= he >> > > 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, y= ou >> > > 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 o= f >> the Help buffer. >> >> Steve Berman > > I replicated the error you mentioned though. Why does it happen ? Is t= hat 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