From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 97FCE1F910 for ; Mon, 28 Nov 2022 05:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiK1FK6 (ORCPT ); Mon, 28 Nov 2022 00:10:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbiK1FK4 (ORCPT ); Mon, 28 Nov 2022 00:10:56 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70A5E12D24 for ; Sun, 27 Nov 2022 21:10:53 -0800 (PST) Received: (qmail 7022 invoked by uid 109); 28 Nov 2022 05:10:53 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 28 Nov 2022 05:10:53 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 330 invoked by uid 111); 28 Nov 2022 05:10:54 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 28 Nov 2022 00:10:54 -0500 Authentication-Results: peff.net; auth=none Date: Mon, 28 Nov 2022 00:10:52 -0500 From: Jeff King To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: Yoichi Nakayama , Yoichi Nakayama via GitGitGadget , git@vger.kernel.org Subject: Re: [PATCH v7 3/3] git-jump: invoke emacs/emacsclient Message-ID: References: <221125.8635a7o123.gmgdl@evledraar.gmail.com> <221126.86h6ymmvyc.gmgdl@evledraar.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <221126.86h6ymmvyc.gmgdl@evledraar.gmail.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sat, Nov 26, 2022 at 12:52:50AM +0100, Ævar Arnfjörð Bjarmason wrote: > > 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?