Subject: Re: [PATCH v7 3/3] git-jump: invoke emacs/emacsclient

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Sat, 26 Nov 2022 00:52:50 +0100

On Sat, Nov 26 2022, Yoichi Nakayama wrote:

> On Fri, Nov 25, 2022 at 6:08 PM Ævar Arnfjörð Bjarmason
> <[email-masked]> wrote:
>> I'd really like to have some closer and smarter emacs integration like
>> this.
>>
>> But I don't see why we need to run the grep ourselves, pipe it to a
>> temporary file, and then discover that we're using emacs, and --eval
>> code into it to switch to that buffer, and fake up a "M-x grep" command
>> with a compilation buffer to make it look like we ran M-x grep in the
>> first place.
>>
>> Let's just ... run M-x grep earlier? Then we can skip all the earlier
>> steps.
>
> There are two reasons.
>
> First, I want to reuse the modes that git-jump already have. In
> addition to mode_grep,
> mode_{diff,merge,ws} exist, and if we re-implement each for editor
> support, I think it will be
> difficult to maintain.

Yeah, maybe that'll be painful. I haven't poked much at it...

> 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).