From patchwork Thu Nov 24 03:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13054580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15539C4332F for ; Thu, 24 Nov 2022 03:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbiKXDrd (ORCPT ); Wed, 23 Nov 2022 22:47:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbiKXDra (ORCPT ); Wed, 23 Nov 2022 22:47:30 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F6DB21 for ; Wed, 23 Nov 2022 19:47:27 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id cl5so635063wrb.9 for ; Wed, 23 Nov 2022 19:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=hG7afdG0COHOmfVOMrCXQbc2WjB03eSnuN/yf/YSMAs=; b=jryhdvXO5oogpifAalaLfO5haujwD/s/MJgrTiifznC8NbT3Pig2aR4rkx0za1/heY LnnklLAfCZK+metYjALHFSjF2khfmk3XaIs4SIejh4Xigfa+VVda0vXTm99aET2QWNfW mfswDS1ZzFFvB22lIJDmkcfGqiPDwkOf6X7Sp+WZKFJLfPjT1ax9WJ5Mz0uX8jrvQ+Ku OhXrg9bBsWZP2o1WiOFX5f1Yast7ax5+Djv69UQ2lf0z377intVZ7Dty3ff/f3rNun+h QlAFd4H8qe4xOH3nMxt8Dbzjzb09mKdbnfBsev048WTP3RYxZq6Qp9Z6P9mbS6/rkg8+ 9jjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hG7afdG0COHOmfVOMrCXQbc2WjB03eSnuN/yf/YSMAs=; b=WeDijd14trg4fMfpzVVnaZMLNtRAzVV+ixygJPuHjHZjTGvtI/qreyqxfjENQ4KDHa JFDhB51WD9zbyT+C1JiYXWIwP1uOgldx+hQ/o/hgbv00iWbbl8D5qq0923+O++k09ZGW XQnUiCxNo03oRM5HgZpONalvXNXqpfL8g9AHfW8eBz9dcbQRdItFg6KEb2wapFp6/73O XEBp4kwYgGcquxE6aImhlOlSJta4C69iXSbGOBv5EOCWU+aA4fxq7G49DDnZTJzg7JTa ViptpdfNORLG0MbPDsf4g1uraK0JzSMSf+0Vm2PfiFuiwDXbzVIAWDSmXYXMUK1wc2uS 3irA== X-Gm-Message-State: ANoB5pltE8/CWMXN+B0q1I6WLatkRSeeAyPuVt9Ql4Ne/mr6EA8YivOl 2Ft/2dMbntbf3peBzyNP74vxskN0B28= X-Google-Smtp-Source: AA0mqf4h03ZsVlvqRxeDR4T+fQ17M+B16kYWV9N8pukZ3o0kfbHaOizZKyqrtWsDHKDDQ2SZhxlMfg== X-Received: by 2002:adf:e50b:0:b0:240:e14:cfa8 with SMTP id j11-20020adfe50b000000b002400e14cfa8mr18581635wrm.63.1669261645432; Wed, 23 Nov 2022 19:47:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n2-20020a5d4002000000b00241727795c4sm107491wrp.63.2022.11.23.19.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 19:47:24 -0800 (PST) Message-Id: <446777d300d73498bd7da709fad75731a13d0d59.1669261642.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 24 Nov 2022 03:47:20 +0000 Subject: [PATCH v6 1/3] git-jump: add an optional argument '--stdout' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , Yoichi NAKAYAMA , Yoichi Nakayama Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Yoichi Nakayama From: Yoichi Nakayama It can be used with M-x grep on Emacs. Signed-off-by: Yoichi Nakayama --- contrib/git-jump/README | 10 +++++++++- contrib/git-jump/git-jump | 25 ++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 8bcace29d21..3211841305f 100644 --- a/contrib/git-jump/README +++ b/contrib/git-jump/README @@ -79,6 +79,14 @@ git jump grep -i foo_bar git config jump.grepCmd "ag --column" -------------------------------------------------- +You can use the optional argument '--stdout' to print the listing to +standard output instead of feeding it to the editor. You can use the +argument with M-x grep on Emacs: + +-------------------------------------------------- +# In Emacs, M-x grep and invoke "git jump --stdout " +M-x grepgit jump --stdout diff +-------------------------------------------------- Related Programs ---------------- @@ -100,7 +108,7 @@ Limitations ----------- This script was written and tested with vim. Given that the quickfix -format is the same as what gcc produces, I expect emacs users have a +format is the same as what gcc produces, I expect other tools have a similar feature for iterating through the list, but I know nothing about how to activate it. diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index 92dbd4cde18..babb3b5c68d 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -2,7 +2,7 @@ usage() { cat <<\EOF -usage: git jump [] +usage: git jump [--stdout] [] Jump to interesting elements in an editor. The parameter is one of: @@ -15,6 +15,9 @@ grep: elements are grep hits. Arguments are given to git grep or, if configured, to the command in `jump.grepCmd`. ws: elements are whitespace errors. Arguments are given to diff --check. + +If the optional argument `--stdout` is given, print the quickfix +lines to standard output instead of feeding it to the editor. EOF } @@ -64,11 +67,31 @@ mode_ws() { git diff --check "$@" } +use_stdout= +while test $# -gt 0; do + case "$1" in + --stdout) + use_stdout=t + shift + ;; + --*) + usage >&2 + exit 1 + ;; + *) + break + ;; + esac +done if test $# -lt 1; then usage >&2 exit 1 fi mode=$1; shift +if test "$use_stdout" = "t"; then + "mode_$mode" "$@" + exit 0 +fi trap 'rm -f "$tmp"' 0 1 2 3 15 tmp=`mktemp -t git-jump.XXXXXX` || exit 1 From patchwork Thu Nov 24 03:47:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13054581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9572AC43217 for ; Thu, 24 Nov 2022 03:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229988AbiKXDrf (ORCPT ); Wed, 23 Nov 2022 22:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbiKXDra (ORCPT ); Wed, 23 Nov 2022 22:47:30 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0934EB02 for ; Wed, 23 Nov 2022 19:47:28 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id o7-20020a05600c510700b003cffc0b3374so395116wms.0 for ; Wed, 23 Nov 2022 19:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=T20WUS5qp99rV0Hisl6yaxm2LFHkUrNcM5zt2P+1fnA=; b=pHjSpIN1VLdmXzwatAap0YsmbGKZxpT3KZHuuy3E4MeGarEdKC/qYiGgDlSUIVwB1S ScfbgqtGfOR4aPN6ROMLhRk5dJvcnhJyFk+6/wCvgEJ6qNA0O3RILOjmt8Hl8wZ+5bKl hlhZzDfnwTaBFdm15UHWkkeSGPP+5zSq0MdfUsgPI/jyDSvAxbLqMF8HU8LMO+HaNRnA jZ9AoJLefeBD6Um/+FLzVlaLhXiJ3QDcxqhbjyxQGYQsHrWS43aRrhL8H33YqgKUdBRG lHnDnI1O8MUM18OLMA/fMWYG3/033lER+o9E8jWP/4rzes3THPwc6NEgc3d4ELW55vp8 yC8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T20WUS5qp99rV0Hisl6yaxm2LFHkUrNcM5zt2P+1fnA=; b=P9kMJ6mkEOV2pALptWX+T8/8zskjOyZ5vXAbHXvz8zFqoqKZmNNGTSkaW0mn9QI060 4UyEGr3jMeN6fKFTagVJDe61W1pk4Mku4iogyragD2tGeYCpjCF6TEQMJHUurK/Ko6fp rxAwARWBSpSDTOpeHJX7Z6dr6HCu8tOObVGdO8jropDO/3BkjGckSQB9BwhMI+odMoEe yNUmW2sjV0Ub85+8dFCn7oezEfc6kiJbd+6/GuoD+hdnhcvsJcDk6b37bumSxbV5aFSk NMneO1DmXrvqvPgrhfbkoD7gMLMBenLr9B6lAY0T5Qz40JCHdEj+8idUkSyp0iAO2ZeC QcSw== X-Gm-Message-State: ANoB5pmsLMsNOeAK/WNMo3KRYk6rqdP7g8eDVhfofFnJOpBz5dwRjAxo oHnMUdzdu4QqLPMrIqEE2PefOu7OSMk= X-Google-Smtp-Source: AA0mqf7GVWyiQSuwP1npdEEXCP3Ougwg6ZTke+LFtNXRDLpp++1zaS0tcJzovVUnchfVI35q3ZnpCw== X-Received: by 2002:a05:600c:210c:b0:3cf:6af4:c4fa with SMTP id u12-20020a05600c210c00b003cf6af4c4famr22543327wml.117.1669261646386; Wed, 23 Nov 2022 19:47:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm4130423wmb.12.2022.11.23.19.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 19:47:25 -0800 (PST) Message-Id: <972d51888ba015a6697475025466432218efa6dd.1669261642.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 24 Nov 2022 03:47:21 +0000 Subject: [PATCH v6 2/3] git-jump: move valid-mode check earlier Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , Yoichi NAKAYAMA , Jeff King Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King From: Jeff King We check if the "mode" argument supplied by the user is valid by seeing if we have a mode_$mode function defined. But we don't do that until after creating the tempfile. This is wasteful (we create a tempfile but never use it), and makes it harder to add new options (the recent stdout option exits before creating the tempfile, so it misses the check and "git jump --stdout foo" will produce "git-jump: 92: mode_foo: not found" rather than the regular usage message). Signed-off-by: Jeff King --- contrib/git-jump/git-jump | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index babb3b5c68d..cc97b0dcf02 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -88,6 +88,8 @@ if test $# -lt 1; then exit 1 fi mode=$1; shift +type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; } + if test "$use_stdout" = "t"; then "mode_$mode" "$@" exit 0 @@ -95,7 +97,6 @@ fi trap 'rm -f "$tmp"' 0 1 2 3 15 tmp=`mktemp -t git-jump.XXXXXX` || exit 1 -type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; } "mode_$mode" "$@" >"$tmp" test -s "$tmp" || exit 0 open_editor "$tmp" From patchwork Thu Nov 24 03:47:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13054582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDC04C4332F for ; Thu, 24 Nov 2022 03:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiKXDrh (ORCPT ); Wed, 23 Nov 2022 22:47:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiKXDra (ORCPT ); Wed, 23 Nov 2022 22:47:30 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D623BAF for ; Wed, 23 Nov 2022 19:47:29 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id s5so680179wru.1 for ; Wed, 23 Nov 2022 19:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=6uf9DkTwuWm9kCiDidgkl63KBPnZt6u/Bc4Thv5onLY=; b=KPRWEk53PXryBqIUymG8kt9piAiaGUZtHnH4eQveewngRcoZjoTnRHYB+jykgrwczt zUhMk/Cn5VlU1bg7z4F6vVoEYpN/bksaMMfNtlJxgj83RytdBwE95TAig7JbUBXUuSlo PeMfesFFA4RiXcw9zaudehh56PsJr8Zi5+Ymy+H3JTOmziARQyAY2JUEikqt4nscEADY Jt99k2x9LD8JqUUvJNJ6PECJY3qvw142u7H/UgQh71yKGjXVP2zWrKMu86VYmU8fbfJW aUCP9FE2Ol+KUQbGCclX5PmBL7E5G2KaN7iEnDox5DlnCnT8weeuk1drMUguqtT0aRXy Sg4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6uf9DkTwuWm9kCiDidgkl63KBPnZt6u/Bc4Thv5onLY=; b=Cqyx5EykmqgqxPrOGe810pLQs+Kf1CQckFM91WPIEooR1+5Fyfk2kEU0kDABNCu+Gj ulAsIQWJdCc+fVSw0PAxdWIoUbqv9yoqKokiQQ3tZKzcuYQRS2r7Og7BiM1H4h3bpOen O7cotX/+DWIEWaKXvFZK49AjAKmGDraTFGXJLLdhZj6QwNA5I07t6SftGOGTx+EIauME 4JKpn+nqvXPm9RoH4wRP7q1kAMuxnaJaAEKTnq24u4cd14dMyLdVOJpCWUbIW3oxZiRp +FguO7RQXmyiI9ZrRlaTaayYt5r/NPm1aPhvMj8MMcrWDvtfVODojLf4aU3lgdZl6BWQ bXXw== X-Gm-Message-State: ANoB5pmVuQ5TmvOKcCjn7bPqkPjyqIhmpqL/FJycU9SEszmNDYQpNc+g BcNX9MZ6RC5Wc+hkWFq9TKxlkxfj7LM= X-Google-Smtp-Source: AA0mqf6OjzZIjdYzgxfR5kpdUOvSfUqXa50O5Aaqy9yn/499AJgv6+6BNZ5rKWdavRBWdYLaxs0zFg== X-Received: by 2002:adf:ce0b:0:b0:235:a4a5:8e91 with SMTP id p11-20020adfce0b000000b00235a4a58e91mr19385752wrn.404.1669261647565; Wed, 23 Nov 2022 19:47:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j14-20020a05600c190e00b003b47e75b401sm4973879wmq.37.2022.11.23.19.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 19:47:26 -0800 (PST) Message-Id: <446d39f62fb90658149cae2f6046e1a292969531.1669261642.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 24 Nov 2022 03:47:22 +0000 Subject: [PATCH v6 3/3] git-jump: invoke emacs/emacsclient Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jeff King , Yoichi NAKAYAMA , Yoichi Nakayama Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Yoichi Nakayama From: Yoichi Nakayama It works with GIT_EDITOR="emacs", "emacsclient" or "emacsclient -t" Signed-off-by: Yoichi Nakayama --- contrib/git-jump/git-jump | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index cc97b0dcf02..3e3911b1f9d 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -23,7 +23,22 @@ EOF open_editor() { editor=`git var GIT_EDITOR` - eval "$editor -q \$1" + case "$editor" in + *emacs*) + # Supported editor values are: + # - emacs + # - emacsclient + # - emacsclient -t + # + # Wait for completion of the asynchronously executed process + # to avoid race conditions in case of "emacsclient". + eval "$editor --eval \"(let ((buf (compilation-start \\\"cat $@\\\" 'grep-mode))) (pop-to-buffer buf) (select-frame-set-input-focus (selected-frame)) (while (get-buffer-process buf) (sleep-for 0.1)))\"" + ;; + *) + # assume anything else is vi-compatible + eval "$editor -q \$1" + ;; + esac } mode_diff() {