From patchwork Fri Nov 25 03:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13055480 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 1DB09C433FE for ; Fri, 25 Nov 2022 03:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiKYDhU (ORCPT ); Thu, 24 Nov 2022 22:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbiKYDhH (ORCPT ); Thu, 24 Nov 2022 22:37:07 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FE822B181 for ; Thu, 24 Nov 2022 19:37:06 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id bs21so4977876wrb.4 for ; Thu, 24 Nov 2022 19:37:06 -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=Y6CPvZkIqNKmNPNsqW+Y7QhSxe7sW9px4gyH+DnpcwPp6xrzpwfSFtSH7liRiBwE0A h6w00QRcMvRlfkwQbAcCYCrnvEyVBc4YgShEIuJIn0AbF+cRw2L2sU6GdXMQtB4v/dqT Iw0rCUvVOesV4E+xaZmbgMC5L5/qX8C2z3Zr7ojAalyAKZ6Eg+3+AeROjOWh4Cl4Ffvf pLi/QX4ojqm8wpo6AO5Dy5Bdyl0NLFLOEdw8ozb+TC6jsMD2J6tTlqGQN5TvHtrc60mH 0BD0N+NPVrQfdVN+halaeyl2XzWzd+qqU8gHjB9EXfvRCqqer40bIYBUaZTEFAWPtSWP p5cA== 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=nfaq1C2yCNmYjcXzO52CqhtgaEIuHq3o57jzijLkVGqMkYQL5rJrJGCHJFdq4YADXI sjKGV1oIYm9eWqgqfuMi/MXR6NU2NIbgE80HQ54134kjMu16DZ5O2bh3f/f7lwX0R+7y nbEvKZW9R6e5IdV1olgx/gDQ+MpUosSwjEkH3rkQ5+7xtLsAG8DMDx7mp0/ND83gWjYd dSYDtoEP8WvSrP/WMLHmO8tWGxLjb2Oa8OsBqLj9sXeN9QdAFZq+k4eQqpJeHkkMFKsV 7KV1wEp2xzmOgxErkVI0sUUTSWKl8IbqeSj5GlVg2Qb+TzQnGNnLVGlwC1vIYG5qJHk4 eRgA== X-Gm-Message-State: ANoB5pmWTmRoprvRbOKKdENCe3QkA/9XktFIZ3MCmbly4O3xMGgUh/Cw GUmgiaLJR90yOdVk9nCcdZXFVu7volE= X-Google-Smtp-Source: AA0mqf6lUynq7j97DE/VBdebKNJY8QZQVBpemLraK3sg1fVIsIrI37PTwyz9k1N+24NfO/hBaz6pUg== X-Received: by 2002:a5d:5948:0:b0:241:e929:fc44 with SMTP id e8-20020a5d5948000000b00241e929fc44mr7452742wri.27.1669347424685; Thu, 24 Nov 2022 19:37:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c4f1600b003cffd3c3d6csm4074950wmq.12.2022.11.24.19.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 19:37:04 -0800 (PST) Message-Id: <446777d300d73498bd7da709fad75731a13d0d59.1669347422.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 25 Nov 2022 03:36:59 +0000 Subject: [PATCH v7 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 Fri Nov 25 03:37:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13055481 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 9BF01C43217 for ; Fri, 25 Nov 2022 03:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbiKYDhW (ORCPT ); Thu, 24 Nov 2022 22:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbiKYDhJ (ORCPT ); Thu, 24 Nov 2022 22:37:09 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15EA2B240 for ; Thu, 24 Nov 2022 19:37:07 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id t1so2515972wmi.4 for ; Thu, 24 Nov 2022 19:37:07 -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=CS8Hk/nVj6kQILHgXbz9WH3R+PDkMij8j0NTE9uqGvqVcQvRusLWG+2SKt5OSTdta3 EGoig4p9lQ0lZOO1ctwCLNjiJFSzHY7QBnn24ZOVLN0JB4+pB01n9RjcA7yZ7TVTUQpU CLvfJxmOozkGggfgHUV253ES6UeSofT11ZvqditMIV4eixhvyKd43GOU8JGnuexyjYET eotKhmCwRK9fBOUkhIqVJw7uSMEhyUlJ9z7W3SKQaGT9DApCuf3r1Ky1vW03kpJSEG4L QqwXqOqmfgfbqBFd0wjcUervGjIPwisZtC8Ru8V30NsqLQrCC1uVPZqr/+q9/chl3WDH SmsQ== 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=l57EYbyhNNtpFJIAFceJP4FjubCivAmUgldkXHsZm3Vb4Ap830wBCpKNMupV624My4 wPvQ2/denNFAJGzo8DmPLfsPhTFlkc1dxF27jMkJWOYD0MBgXDniIbRYgUY+LtJPQJHJ gHzXo8wn/vCYkFdhnqsQ9f2wtFD8yeM4N7p8HbfD4E6t8SRcT1fnWG/WhOtvIi/0zLxq +Tjj2I1ZWCfWlBGiioP4O7cmTE3EUWNr7jsQETyuX5An6WfX8HJo0VNDHj4YzkWeDr3d qucjzwJhCTK0LTjunizTOBfH2xgHZwHNNcpbTrA7RdEuibVV8z4b0IwKBEgznIhUsATo YDwQ== X-Gm-Message-State: ANoB5pkRcDv5MqKGdOGrfTwFi5j+S2ia8KiceUrwS5slL4bA0Iqd+wqo ohB00q4fApovS+zisEN/eHVuuhQjrnk= X-Google-Smtp-Source: AA0mqf7asXCtQ0rlubVyrLj+qjPgpUc0X2G+Mke6tvi1otGuoBInZWg2K4SIbniz0bSZr5JeqbMExQ== X-Received: by 2002:a1c:770a:0:b0:3cf:ab80:b558 with SMTP id t10-20020a1c770a000000b003cfab80b558mr29008042wmi.155.1669347426156; Thu, 24 Nov 2022 19:37:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m1-20020a05600c4f4100b003b4fe03c881sm7241239wmq.48.2022.11.24.19.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 19:37:05 -0800 (PST) Message-Id: <972d51888ba015a6697475025466432218efa6dd.1669347422.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 25 Nov 2022 03:37:00 +0000 Subject: [PATCH v7 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 Fri Nov 25 03:37:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13055482 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 C7A48C4332F for ; Fri, 25 Nov 2022 03:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiKYDhW (ORCPT ); Thu, 24 Nov 2022 22:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbiKYDhJ (ORCPT ); Thu, 24 Nov 2022 22:37:09 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A0E32B258 for ; Thu, 24 Nov 2022 19:37:08 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id q7so4091608wrr.8 for ; Thu, 24 Nov 2022 19:37:08 -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=1WHX8dViAKAfzjWn2u4AO+TH2XgCSQ4rv550DeLvV58=; b=j15UIrE86IK0AcQ5S8iA3kxiLsLLb1Qr+2L5Xra7fyse8W3rbWLnI+WW/R4ZpKPzwC mV4A7oT7/PyVVGljz5eMEXEK2N56u9/fjc7uxbvalSXHUjfdPk/rXYh4yAt9jwDKCu+A Q2p5m1XgFYAuYgY/G4OQIIT6TpU86Gu3XNyKlBiNEyWMpXugFOS77xpKIIQBMZUgsNyv EsQhb2YL1UWosLHFxuN9RaFwnsVLiWiA6U81kY8PwCrpvK4AaNR2qs+/u2efdnH8hgJc pntwYZj7jtQ+HUfwtj1REkCfY7RS+zXonBvrsMNRKNZ/8SUG1984Y7/ZRy1xAjqqUHOv wU2g== 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=1WHX8dViAKAfzjWn2u4AO+TH2XgCSQ4rv550DeLvV58=; b=7TYixmqGu1YqsBZO4d1XtB+p1eteR20jQuZdGJaaVPkNKZceY/BIQ2//jf7spIeIx0 XxiGCRR4LH6GFFtwX5XcUtlokyfk/DUEuCSzNXRKwMfn3cbE8DejBTjHcjgd3UPasWK8 QcfdJJtta5gRF3Kr3fteN7FkcNV/re/MonxYK1xgDV3uqEvTzeI85AoklZYaatzEUvLL S1c0mg+ipaOrg5tgBe53lE45EgpoX/FvFzPpoaDnB/m9EIfWh0NBFzTWUNOd+G2LkEry nHNeGY96Eh+hTXndljOOFyuJc8EAhyDlaRPgYoxU48jGGQh39kbgqGqS27dVAkt2FxZV Z0CQ== X-Gm-Message-State: ANoB5pksIolPeI4tvV17hYxytfOcx4uPXP9aw70oTwgmbewQmJXdmZ5G PhE/AytI1MZ1lyTSsRBmTgfG+gH2oz8= X-Google-Smtp-Source: AA0mqf5vdzQ439L2j+pPy7DNf1cQ2ZXDNrfysP8rqn0aUt9MirsmQgwJTDYY4RZ2cRr9LlKSPkWcmw== X-Received: by 2002:a5d:440b:0:b0:241:f901:a7e3 with SMTP id z11-20020a5d440b000000b00241f901a7e3mr4565650wrq.511.1669347426996; Thu, 24 Nov 2022 19:37:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s10-20020a1cf20a000000b003cfe1376f68sm3546851wmc.9.2022.11.24.19.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 19:37:06 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 25 Nov 2022 03:37:01 +0000 Subject: [PATCH v7 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..eef9cda832f 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 \$1\\\" '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() {