From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: RE: [External] : Exiting from mapc Date: Wed, 01 Jan 2025 23:14:45 +0000 Message-ID: References: <7cSjmNb9wbuuXOPxnBml1e6cPaldn8EPTGZ2LZdnm-ZjIANwQBYOYq9a-nJDcaCG8QKkb09TGeUjlQ6vLFyFVzOPZfJniDINxCNXT1TW6vQ=@protonmail.com> Reply-To: Heime Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35382"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 02 00:15:59 2025 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 1tT7wT-00092U-U0 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 02 Jan 2025 00:15:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tT7vc-0003Oh-9i; Wed, 01 Jan 2025 18:15:04 -0500 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 1tT7vY-0003Ny-66 for help-gnu-emacs@gnu.org; Wed, 01 Jan 2025 18:15:00 -0500 Original-Received: from mail-40132.protonmail.ch ([185.70.40.132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tT7vT-0003ZP-0M for help-gnu-emacs@gnu.org; Wed, 01 Jan 2025 18:14:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1735773289; x=1736032489; bh=JyL6KPhtddC/wHb1ZWk4FBOTu1N0Y69FSdT6oa8xJf8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=HZthMBaQhayfCQYEzqLW1LSv9X166cPsVcSq+LI5W5stDT30MvsZjA4vA9vcZf37R rgA4LO8cHDnJddoNT7xCwb8s2VPmzfZFL7D+prIlc9RBGCXn8117MKuWo62i/lb4fW k0EsdO15bDYsgkrMWkUp5N36x2lk4KLqO0N60+y/RdBNGo61CPQewuusCVA4tgY3xG 0DoiQC78e5jEnfiz79dDr+H8KauG0CjlNYp9DpJPrC1Mx3bwu9AO71lPOm3pPRQFrF 5QnZkuTR+wn57UFxp3JhQ5iUm6bWtPQVzmFAs9DubCEHeCck7la2UOVz0lorfmjGph dIuuiuMi7ZQ9g== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 6078df94f2067e57a899e7c9452d5cb1e903fe8e Received-SPF: pass client-ip=185.70.40.132; envelope-from=heimeborgia@protonmail.com; helo=mail-40132.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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:149098 Archived-At: Sent with Proton Mail secure email. On Wednesday, January 1st, 2025 at 10:30 AM, Drew Adams wrote: > > > > How can I exit when encountering 'safg or 'nogo > > >=20 > > > As usual, wrap with a `catch', and` throw' to it whenever you like. > >=20 > > Does the catch statement belong before mapc? >=20 >=20 > Yes - "wrap". >=20 >=20 > (defun amazones-falkotr-kntlr (actm-seqr) > (catch 'RTFM > (mapc (lambda (...) > from anywhere here, to 'RTFM>) >=20 > actm-seqr)))) >=20 > 1. `C-h f catch' 2. https://www.gnu.org/software/emacs/manual/html_node/e= lisp/Catch-and-Throw.html Learning to use` catch' and `throw' with code suc= h as iteration is basic. And catch/throw is a building block for implementi= ng other iteration etc. constructs. The Elisp code that Emacs provides so f= reely to you is a great place to learn about Elisp. Grep for` catch' there.= .. >=20 > Here's a simple example: >=20 > (defmacro while-no-input (&rest body) > "..." > (declare (debug t) (indent 0)) > (let ((catch-sym (make-symbol "input"))) > `(with-local-quit > (catch ',catch-sym > (let ((throw-on-input ',catch-sym)) > (or (input-pending-p) > (progn ,@body))))))) >=20 > Here's another: >=20 > (defun get-window-with-predicate (predicate &optional minibuf all-frames = default) > "..." > (catch 'found > (dolist (window (window-list-1 > (next-window nil minibuf all-frames) > minibuf all-frames)) > (when (funcall predicate window) > (throw 'found window))) > default)) How can one get the result of the throw? With a let? =20 > The Elisp manual makes great bedtime reading. > Time better spent than asking help-gnu-emacs, > perhaps.