bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53518: 29.0.50; em-extpipe breaks input of sharp-quoted Lisp symbols


From: Jim Porter
Subject: bug#53518: 29.0.50; em-extpipe breaks input of sharp-quoted Lisp symbols
Date: Tue, 25 Jan 2022 10:14:52 -0800

On 1/25/2022 12:50 AM, Sean Whitton wrote:
Hello again,

On Mon 24 Jan 2022 at 06:39pm -08, Jim Porter wrote:

I just noticed a small bit of breakage with this. It's no longer
possible to refer to Lisp functions in Eshell like so:

    #'upcase

Eshell explicitly supports this construct (see `eshell-lisp-regexp'),
though it doesn't appear to be documented in the manual. Currently, this
syntax is only occasionally useful, but I'm working on a patch series
where it'll likely become a lot more common. My patches will add support
for piping to Lisp functions, so that you can do the following, for example:

    $ echo hi | #'upcase
    HI

Out of curiosity, why is there a need for the sharpquote?  Why not just
'echo hi | upcase'?  Is it to do with requesting the new piping?

It becomes more relevant with my WIP patches to support piping to Lisp functions, but it means something different today too. "upcase" *calls* the function `upcase', whereas "#'upcase" evaluates to the function object itself. For example:

  $ upcase
  Wrong number of arguments: #<subr upcase>, 0
  $ #'upcase
  upcase

Or, for a slightly different, but more practical example today:

  $ mapcar upcase $(list "foo" "bar")
  Invalid function: "upcase"
  $ mapcar #'upcase $(list "foo" "bar")
  ("FOO" "BAR")

In this case, "upcase" in the first command is just the string "upcase", whereas "#'upcase" refers to the function as in the other case. The shortest other way I'm aware of to spell that using shell-like invocation would be:

  $ mapcar $(quote upcase) $(list "foo" "bar")
  ("FOO" "BAR")

For testing purposes, it would probably also be useful to ensure that Lisp syntax works too:

  $ (mapcar #'upcase '("foo" "bar"))
  ("FOO" "BAR")

Just for the sake of completeness, in my WIP patches, "echo hi | #'upcase" and "echo hi | upcase" will also do different things, following the above precedent. The former pipes the output of echo to the function upcase. The latter pipes the output of echo to the *result* of calling the function upcase with no arguments. In addition to being consistent with how Eshell currently works, this allows you to do things like "echo hi | less -N", where "less -N" is evaluated as an Eshell command and then returns a pseudo-pipe for echo to connect to.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]