Re: [PATCH v7 3/3] git-jump: invoke emacs/emacsclient
- From
Jeff King <peff@peff.net>
- Date
- Nov 28, 2022, 05:10 UTC
- Message-ID
- <Y4RC3NZsiy5gXPoJ@coredump.intra.peff.net>
- In-Reply-To
- <221126.86h6ymmvyc.gmgdl@evledraar.gmail.com>
On Sat, Nov 26, 2022 at 12:52:50AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 14 quoted lines
> > Second, there is a difficulty passing arbitrary arguments properly to > > Emacs Lisp properly. > > For example, your version will cause error with > > git jump grep "hello world" > > My early patch was doing something similar. But the second problem was > > hard to deal with, > > so I switched to using a temporary file. > > To the extent that that's painful couldn't we write the grep expression > / arguments to the tempfile, then feed the tempfile to the ad-hoc elisp > code? > > It would then read it, get the argument to grep for, and we'd call (grep > that-argument).
You'd still need to quote the arguments, since you'll be reading potentially multiple arguments out of the bytestream of the file[1].
If you're not going to quote, the simplest thing is to generate the line-oriented output and read that.
If you are going to quote, then you don't need the tempfile at all. You can shove the command into the eval, as if git-jump were run from emacs directly (but you want to use the --stdout mode introduced in this series, and not the git commands directly, because of course they're non-trivial).
I showed how to do the quoting earlier in the thread. But it is ugly, and this tempfile hack should work (modulo the gross wait loop afterwards).
-Peff
[1] Of course you could have a stripped-down version that only greps and
only takes one argument, but then why are you using git-jump in the
first place?