all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Howard <christopher@librehacker.com>
To: emacs-devel@gnu.org
Subject: Re: eshell lisp errors
Date: Thu, 26 Sep 2024 07:00:19 -0800	[thread overview]
Message-ID: <871q16sbng.fsf@librehacker.com> (raw)
In-Reply-To: <87v7yjtubn.fsf@dataswamp.org> (Emanuel Berg's message of "Wed, 25 Sep 2024 21:19:24 +0200")

Emanuel Berg <incal@dataswamp.org> writes:

>
> When you say "in eshell", you mean something else than
> in Elisp
>
> (condition-case nil
>     (funcall next)
>   (error (goto-char end)))

Hi, to be honest I'm not sure sure that I properly understand the question, so I'm not sure how to respond.

Maybe I can try to restate/clarify my motivation: I found out, when writing my own eshell script, that it is possible for commands I have entered — in command form — to throw an elisp error. Conceivably any command that involves an eshell built-in, or that specifies a list function as the command, could throw an elisp error, and so I might want to have some kind of handling/logic depending on the type of error or the significance of the command. Currently what happens is, depending on the debugging settings, either the script just continues on (with an error message reported) or it gets thrown to the debugger, where the user has to decide to quit or continue.

One could, I suppose, just replace the command form with an elisp form that includes error handling. But if you wanted to somehow preserve the convenience of the command form, you would have to wrap the command form up in an eshell-command call or something.

I suppose maybe what I am wanting is something like a command you can enter in a script that sets things up so that if the following X set of commands throws an error, then the error is inspected, some arbitrary thing can be done, and also it can decide whether or not to abort the script. Or perhaps something like the "trap" command in bash (https://phoenixnap.com/kb/bash-trap-command).

But maybe this is just asking too much of eshell, or trying to make things too complicated. In traditional system shells, you aren't dealing with handling exceptions, properly speaking — only with processing the return value from the previous program call. And handling process signals is not really the same thing as lisp exception handling.

Looking now, I see Emacs 30 has an eshell-trap-errors macro and an eshell-this-command-hook but I'm not sure if/how they are meant to be used by these user.

Hopefully my rambling here is somehow heading in a useful direction...

-- 
Christopher Howard



      reply	other threads:[~2024-09-26 15:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 19:06 eshell lisp errors Christopher Howard
2024-09-25 19:19 ` Emanuel Berg
2024-09-26 15:00   ` Christopher Howard [this message]

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

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

  git send-email \
    --in-reply-to=871q16sbng.fsf@librehacker.com \
    --to=christopher@librehacker.com \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.