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: Mon, 24 Jul 2023 22:07:11 +0200 Message-ID: <87pm4hvztc.fsf@gmx.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28609"; 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 Mon Jul 24 22:08:02 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 1qO1qa-0007A2-Lp for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 24 Jul 2023 22:08:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qO1pw-0006kL-Jn; Mon, 24 Jul 2023 16:07:20 -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 1qO1pv-0006jw-FO for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 16:07:19 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qO1pt-0003Lr-NJ for help-gnu-emacs@gnu.org; Mon, 24 Jul 2023 16:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1690229232; x=1690834032; i=stephen.berman@gmx.net; bh=sEV7AYskiojWrPJu/dn6ZuKp7PB5Mf7uxscfBNHYeD8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=YT86xdzOI4W/rNlSGFHYlF2zzly3uSpn3C8P5qUDIOKBj8qhi0lM1XYi2aMIOVuUXGKzYkI YFnSyTZ+dn10GenjVdJyjDDI2sxKELZKVFFwWgelA4EgFZrnbJxLUnJS7Jjsg/1C//kDsQCgs v1LO0agyg0ZMRpU/cVGT3GI0wqkK3O0sO0NjPJ5mgoeI+tJm5pV7TWxatdeQhwWwGPmYNLrir P09iFLNH0iU/yveC6jv2bFhZ3ID7I/8AJnTydZ2bOUjyuRQZz6NSueJrfG/NOjHu9NNYAA4Y6 /uObD48caQoRVPhaYfejlCD/Avm1RglCuAWzDBfYaMS2vv0EN2hg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([94.134.196.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MMXQ5-1qeBmB1VzD-00Jcxv; Mon, 24 Jul 2023 22:07:12 +0200 In-Reply-To: (uzibalqa@proton.me's message of "Mon, 24 Jul 2023 19:14:27 +0000") X-Provags-ID: V03:K1:+EyGrBc+jKSEkZzRQ3g7tpHIdkQoH6ACI+axB1iVs8nqva/E/kU lpEuCPzWkw2i6tdv449Q2P3C3xUW4levncOkV6qBjJ+VJ+wcKGJIoksI5W6DNxLhiLPDNcT RJifPdvTi/+ONFHtWp30lZuEFjH8crBKTP3EgmhZlh5xornHC9lOynDecmq/FchSJwEdCxU gDTbUYpC7HbAtw5U6liMQ== UI-OutboundReport: notjunk:1;M01:P0:pSwliRN/UKE=;8Z4SegKeqBaI/0TWzDjsbyRMtLr S01Fyatsql59gp0A0/zducruRmZtcLxg5q1thzk66JJAGXWYTvfKSCwGvlxx4EZOENVEvWkVy Oh9W+6MsRhc1V54VI5HHhRyYuFT2X1Jd1N4m4W6LbHbYKVLsd57E0rhMYvaIDiSOkWiAysBq5 Dj6LpYEkBTlPLyTBfTkkcYAm0Uue4eqa1ZLySMtxsZtRWPa3UOuM0uJp1aAUpGQcZGwPiwTz2 4zi2RnA8Yir9d4nuGBt1fHNTiMEScso8uWv41IXEn4cibY4Iiip8Hal9JWFv4fIqN+RGRHUDB Lfmd7yep8Cutf5NR3f0albjCCwFR1AKDq3avRjDWSASFII8cGI/br5QtoZDm9FBBVDh2vfgrt BRb/I96wOsnmIcqgxUj/h5SIQ3fIjM0QYZL8A/1p7vWxHyxRzCob3fO6HKcDxtivFcKpEkGCn ZkiXy1BCDzglZmYWbOMG9TNHRoSi45NdqDYylDTSsfyjFax1Nue2bBeivPMd9SgN+MWXjXhwn +kYI90tdaLxe6KZVE85cLs8t1pbEiYCy4BLu0s2cBoQFflJPr5hQG5jM/FxiV0JUav9n2/puS 1zgWlSMXXUyWxjYgCaKgEFx5kdk0V85Jd5nzGZRebZQOqY23cLFtViQPO/n+3sXKQfyzrjRRc o+SHejsL9gT0iwg0EpSIeqS0i4MaCgbAMDLG0EiaQkZv9HVydNtDu0Z2RKYYcbSYqgNo1M2uh MQc/XNcpfTWkShuNMw19PeQirQwgGpZv14RSum60+6TwXEphVLKv1QzTXuhatWuK6sjH71cS Received-SPF: pass client-ip=212.227.15.18; 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_H2=-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:144427 Archived-At: On Mon, 24 Jul 2023 19:14:27 +0000 uzibalqa 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(#) > (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 *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