unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: RE: [External] : Exiting from mapc
Date: Wed, 01 Jan 2025 23:14:45 +0000	[thread overview]
Message-ID: <jmirkZGqJQeK8mfQWIZypEsikAsU5tRp61e2P1hNzMkrhpzmOfdgeM8xAWh3xwoN8xqJWADSFTVnHa5TPG-PuI7IWb9gKW3-6qnMi02IOt4=@protonmail.com> (raw)
In-Reply-To: <BLAPR10MB5219799D1F5207C3D060B4ECF30A2@BLAPR10MB5219.namprd10.prod.outlook.com>






Sent with Proton Mail secure email.

On Wednesday, January 1st, 2025 at 10:30 AM, Drew Adams <drew.adams@oracle.com> wrote:

> > > > How can I exit when encountering 'safg or 'nogo
> > > 
> > > As usual, wrap with a `catch', and` throw' to it whenever you like.
> > 
> > Does the catch statement belong before mapc?
> 
> 
> Yes - "wrap".
> 
> 
> (defun amazones-falkotr-kntlr (actm-seqr)
> (catch 'RTFM
> (mapc (lambda (...)
> <Do whatever, and `throw' any value,
> from anywhere here, to 'RTFM>)
> 
> actm-seqr))))
> 
> 1. `C-h f catch' 2. https://www.gnu.org/software/emacs/manual/html_node/elisp/Catch-and-Throw.html Learning to use` catch' and `throw' with code such as iteration is basic. And catch/throw is a building block for implementing other iteration etc. constructs. The Elisp code that Emacs provides so freely to you is a great place to learn about Elisp. Grep for` catch' there...
> 
> Here's a simple example:
> 
> (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)))))))
> 
> Here's another:
> 
> (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?
 
> The Elisp manual makes great bedtime reading.
> Time better spent than asking help-gnu-emacs,
> perhaps.



  reply	other threads:[~2025-01-01 23:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-31 19:35 Exiting from mapc Heime via Users list for the GNU Emacs text editor
2024-12-31 20:13 ` [External] : " Drew Adams
2024-12-31 20:20   ` Heime via Users list for the GNU Emacs text editor
2024-12-31 22:30     ` Drew Adams
2025-01-01 23:14       ` Heime via Users list for the GNU Emacs text editor [this message]
2025-01-02  0:31         ` Joel Reicher
2025-01-02 10:33           ` Jean Louis
2025-01-03  0:23             ` Joel Reicher
2025-01-02  0:33         ` Drew Adams
2025-01-02  2:21         ` Eduardo Ochs
2025-01-01  1:53   ` Björn Bidar
     [not found]   ` <87wmffwb8w.fsf@>
2025-01-01  2:02     ` Drew Adams
2025-01-01 19:40       ` Björn Bidar
     [not found]       ` <874j2iwcff.fsf@>
2025-01-01 20:00         ` Drew Adams
2025-01-01 21:09           ` Björn Bidar
     [not found]           ` <87a5cautqb.fsf@>
2025-01-01 21:59             ` Drew Adams
2025-01-02 10:53 ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='jmirkZGqJQeK8mfQWIZypEsikAsU5tRp61e2P1hNzMkrhpzmOfdgeM8xAWh3xwoN8xqJWADSFTVnHa5TPG-PuI7IWb9gKW3-6qnMi02IOt4=@protonmail.com' \
    --to=help-gnu-emacs@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=heimeborgia@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).