all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Milan Zimmermann <milan.zimmermann@gmail.com>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 59612@debbugs.gnu.org
Subject: bug#59612: 29.0.50; Eshell: The behavior of conditionals depends on whitespace
Date: Sun, 27 Nov 2022 00:07:40 -0500	[thread overview]
Message-ID: <CAEc2VK0EuGVKUbYoyO9f-2c+r58Rk-H4dd5WSUVAJpUv0xuQwQ@mail.gmail.com> (raw)
In-Reply-To: <7f19f7fa-6573-23de-e0b9-81683dd3b61c@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2667 bytes --]

These are all great ideas (implementing else on if as a kind of joining
commands, adding eshell-functions, adding ability to invoke Eshell
commands/functions from the elisp blocks).

Thanks for sharing the details. I would love to offer help to dig into some
of it, but I need to restrain myself from overpromising.

In the meantime, I will continue to report bugs or things that do not feel
right, hope that is ok. (I decided this third time to use eshell as my main
shell at least for personal projects will succeed at least in a limited
way.)



On Sat, Nov 26, 2022 at 10:13 PM Jim Porter <jporterbugs@gmail.com> wrote:

> On 11/26/2022 6:16 PM, Milan Zimmermann wrote:
> > Jim, thanks for the follow-up. Please feel free to close this.
>
> I think it would be reasonable to leave this open to track adding
> support for some kind of "command re-joining" logic that things like
> if/else forms could use. Then something like this would just work:
>
>    if { condition }
>    { true-case }
>    else
>    { false-case }
>
> At a high level, I'm thinking something like this:
>
> 1. Enhance 'eshell-rewrite-if-command' to support "if"/"else if"/"else"
> forms.
>
> 2. Add some top-level command-rewriting logic that lets you join
> multiple separate commands back into one. I think Eshell splits the
> commands up line-by-line pretty early in the process, so re-joining them
> later might be the least-invasive way to do this. It'll take some
> further diagnosis though.
>
> > Yes, I agree. From the way of thinking "whitespace should not matter" it
> > is a surprising behavior though.
>
> Yeah, it's a strange result, and possibly a sign that the syntax for
> Eshell conditionals wasn't the ideal way to do things. But it is what it
> is now, and hopefully there are ways to make it less surprising without
> making a major incompatible change to syntax.
>
> > BTW, a slightly related question if I may: A further diversion of
> > lisp-iness, I do not suppose there is a way to do a "return"? In bash,
> > the ability to "return" from sourced bash scripts or functions allows us
> > to deal with errors at the beginning, then process the main logic.
>
> I think this is related to a TODO in the Eshell manual to add a
> Bash-like "function" command, which would let you write whole functions
> in Eshell command form. I've also thought about the idea of adding
> syntax in Eshell so you can write stuff in Lisp forms but then go back
> out to writing command forms. Something like:
>
>    (defun some-function ()
>      (do-stuff)
>      ($ "echo $foobar") ;; Invoke an Eshell command.
>      )
>
> That might be tricky to get all the plumbing working though.
>

[-- Attachment #2: Type: text/html, Size: 3482 bytes --]

      reply	other threads:[~2022-11-27  5:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-26 15:52 bug#59612: 29.0.50; Eshell: The behavior of conditionals depends on whitespace Milan Zimmermann
2022-11-26 15:59 ` bug#59612: A comment line in example change Milan Zimmermann
2022-11-26 16:19 ` bug#59612: Incorrect behavior also with ${CONDITION} Milan Zimmermann
2022-11-26 18:28   ` Jim Porter
2022-11-26 19:32     ` Jim Porter
2022-11-26 18:42 ` bug#59612: 29.0.50; Eshell: The behavior of conditionals depends on whitespace Jim Porter
2022-11-27  0:39   ` Jim Porter
2022-11-27  2:16   ` Milan Zimmermann
2022-11-27  3:13     ` Jim Porter
2022-11-27  5:07       ` Milan Zimmermann [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=CAEc2VK0EuGVKUbYoyO9f-2c+r58Rk-H4dd5WSUVAJpUv0xuQwQ@mail.gmail.com \
    --to=milan.zimmermann@gmail.com \
    --cc=59612@debbugs.gnu.org \
    --cc=jporterbugs@gmail.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.
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.