From patchwork Wed Nov 23 07:04:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13053147 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 8F072C433FE for ; Wed, 23 Nov 2022 07:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236199AbiKWHEW (ORCPT ); Wed, 23 Nov 2022 02:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236160AbiKWHEU (ORCPT ); Wed, 23 Nov 2022 02:04:20 -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 18533F2412 for ; Tue, 22 Nov 2022 23:04:18 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id j5-20020a05600c410500b003cfa9c0ea76so638611wmi.3 for ; Tue, 22 Nov 2022 23:04:18 -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=XnL2WmY9qaCwawjNGnwUVQn2IgY79iahJ1BRcUFTVa+zSxxV/HpSBcqFBVfVsVh+2K h5Zaej2mD/ljv3hZUTu7u86JeQM7BqcWhIp0Ho/ZMM3tYi9sHwK4ty+bNFPtLsbpDjb0 VElyGT8dOeZCI1tbSCmSl4/BUJiGtzxPg81AqCHNXS+b1HX11b2/gLO06hZ9eCnoRJcT N6q2Rfmiiyo6xRpnA4WFN6+NrFTnZb/ukQclJOuTPWjI+kKyrW/6pOQvCGdU7lA5aIUg lcikOqPq+SS2GtVGRoDMgAWNjhW4or83ykCfvOsQsXUm2ML+gMHi/YBHxIkllnK6V3d5 fWOQ== 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=LLL6Wb3WURq47AcFg5hoaT3KBR1dyMyzA3cDZIVV/UQePMAXl6V913eIOFYo/gGo38 N31UXTdKf+cFfDnEmry0Wtaslqk2tt0BmG3OKwlQjMS7TKDsBcsi4uzjrQiSrX3kOJDx gzNElSddVQpclkHQAwgfB4iaCJdKaLP/0SrmhUiCNRLtIYcR81AeiLydQZg4JE9ghd+v DUkC+/9WMS7qW2uzyrhCQcVkUDomCyNT/o4QTXtt8FMPYhO5UIeKuRXKmX1D/bcFqN0I HEep/+5SwaNOuxoUZbM6tFUF1JpvrJxzmfpMI27B8rGOSBwDw9jbQWA/MOtnmEibza3U LJqA== X-Gm-Message-State: ANoB5pn8dX0NCnPdbkr7Ey7RUAZxhKzgZD7PiLizGRXOHSiexOysz/Tr 1m6LRzBuU7Z0oTirbUA64eddV5Q/+O8= X-Google-Smtp-Source: AA0mqf6B0J4nUiSKM9977WG/9tfZ+S6ci/tkcQLyf/eVIMNhni4COGsft1h7OCPK0iugItFwJcwGjw== X-Received: by 2002:a7b:c8d0:0:b0:3cf:ca91:7094 with SMTP id f16-20020a7bc8d0000000b003cfca917094mr18834606wml.24.1669187056221; Tue, 22 Nov 2022 23:04:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bi14-20020a05600c3d8e00b003cf6e1df4a8sm1169889wmb.15.2022.11.22.23.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:04:15 -0800 (PST) Message-Id: <446777d300d73498bd7da709fad75731a13d0d59.1669187053.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 23 Nov 2022 07:04:11 +0000 Subject: [PATCH v5 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 Wed Nov 23 07:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13053148 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 E2A07C4332F for ; Wed, 23 Nov 2022 07:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236203AbiKWHEZ (ORCPT ); Wed, 23 Nov 2022 02:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236166AbiKWHEU (ORCPT ); Wed, 23 Nov 2022 02:04:20 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF7BCF2414 for ; Tue, 22 Nov 2022 23:04:18 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id p16so12399393wmc.3 for ; Tue, 22 Nov 2022 23:04:18 -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=ElrcFDAqme3Y6/PkTfVn/QE7o2X5aUH5FhKx1iURAi3/QpvJfGEDfQS/eRHCZPl3TO 711gkmagv8i+KgRSYUmGBjBTb/+iXHM04BOcFBv5Z+ZF11bQl+1H6SUKRFnPmfcZtUSo /YCGUYI+WpES2IQzbwRzMRS5c0sX65EDI7gPmRtv7Ne5kc8RlEBMp2ItrJM3OAIEFEb3 Mz6QcVoKS+aIrmAbBsIqx1lcAz9UMywfO30WLsDqAe1NUqkQODhKqMp4ONYv0K9kPWXQ ZxWeiBevT083wKw+U3j3/CFQCcernCAnIFbfA3aIh5susrmWawylF4L2JufpbusAxL7Y 5uhA== 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=Aq+Z8a2khJu6T4NZk9A2XRPVvyED8HQqmcViNSM4fKsnvJh2i4BbFWoEVQUQdxkhPb 80Z1FHAs8trm4LEmB8LH7HBQQem/3Ppyx23cnqSaWLwstkjmBnisWdaiOM8aJ3cmh1M6 X+kO540p3wW6AYiqymwTFLBqFwT70YQlWFNY4LhQS6Hs+2vwfO9nY+YHqEJPCFsWEW2E QEYMiRnPI+qLp5VS8ztqVpLxWsVkcEVnhqbcb7vZ/HVSemlN2KYcd5QODhNs4TwFteZ6 Jz3RfHVsg+MKZ3Uc9Yaf46URlkg4TOYinsReehRaePC/Qz6ERfv9Bi2hH6yPxJZxnkdg inXw== X-Gm-Message-State: ANoB5pl6cA93KuX7yAqsLxmtnqVuXgf+iWg2wnmyfW7BgIYxf+Zo/OLW dU04eima9JXhQmdoD4r96ez7YJLjRxE= X-Google-Smtp-Source: AA0mqf6DBvK5c/iEGVuSovBkweYLDoUwe+WrvLbZ5NsmRpZ/J3+3BMPCvLGBXSJnkAso4OcAaH2TVg== X-Received: by 2002:a7b:cc91:0:b0:3c6:c1d5:ab81 with SMTP id p17-20020a7bcc91000000b003c6c1d5ab81mr22115911wma.192.1669187057115; Tue, 22 Nov 2022 23:04:17 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l11-20020a1c790b000000b003b4a699ce8esm1202131wme.6.2022.11.22.23.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:04:16 -0800 (PST) Message-Id: <972d51888ba015a6697475025466432218efa6dd.1669187053.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 23 Nov 2022 07:04:12 +0000 Subject: [PATCH v5 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 Wed Nov 23 07:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13053150 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 6F003C433FE for ; Wed, 23 Nov 2022 07:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236166AbiKWHEa (ORCPT ); Wed, 23 Nov 2022 02:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236167AbiKWHEU (ORCPT ); Wed, 23 Nov 2022 02:04:20 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A0FF2403 for ; Tue, 22 Nov 2022 23:04:19 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so730387wmb.2 for ; Tue, 22 Nov 2022 23:04:19 -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=1/P0AU/hj8ovLE91ZnMdOceYR+zm3x/+e3ggdCVTAyo=; b=W74su8Wy8oVC7jOXr8X7aLseFcJneDrsYFXlfUyV+1PA6XTkdFuiR5UiLJWPNIbNl1 bBy9lNjTNSQ8uCCKYO8AwhRsRFi3o9Q2cRIxL/mSc3j+SC045ASce4tsZ60E4OvRt3Qb 2zVA7IqlQKzgQLjNrFNXE/GFjjuLJPbJxe0zvqgjSPp7f3l6OeS1lSM14MP6A4GqgFBx apTU/V54sRsRMrjWJfcP1JVz6fsN8KX4PVpOwlMuMkOtnPCD9lpSJgYXicd14+P0GWqz +O+DGgWXIwRddUCwJav8dPDElqOvB1n5GtZePAbftu06DChIs+7QhtFraDHad2foH2Ta lijg== 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=1/P0AU/hj8ovLE91ZnMdOceYR+zm3x/+e3ggdCVTAyo=; b=01yORNZJHpM07E8Hq+Z3WdKfmUx7C+mdL1rmJgZ1q08Z0FwHk7Rj8afSZSeN2C7Iry PMHOEab+j5skc2KCVPVWhk5KJgQfjdYhKhoQ/7+aJJxE6L5ebbKiP5+CvrddtFXWauws 3iYk0dQBVo4L7ffOU9CYhr0WTO05YEkvl+JLCzb3AO2odDRwaMK1tqBRo70vCvixhrQ1 1ChV2XPY662ItkHguVEwyav/TeWQOJeuw3Sgd5hRvO1/1NttouCw/WV1x+MYjAvYXmqj F7H/bSRwjUgJtuqnUR2tENkP8wnkMo4YwupbTuem5ZH9VaLl9mUMp5f78icXb54fPOND sBBw== X-Gm-Message-State: ANoB5pkZuzXHNi0Ijz5kVn9mz8PWZUmDhSTRP2yByyhWxE/NVC4DrSKu 8JCwYYBcpHAXyIkgfu4SY4BL6ymR3Hs= X-Google-Smtp-Source: AA0mqf5JFMUJzxQiFcocu7y8ssBpI+zFDEqKVLYtzF21DuBm0eoURWPEqUpmcb5kU+mU+mv7thVHPA== X-Received: by 2002:a05:600c:5014:b0:3cf:72d9:10b0 with SMTP id n20-20020a05600c501400b003cf72d910b0mr5106044wmr.26.1669187058005; Tue, 22 Nov 2022 23:04:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b003cf57329221sm1218701wms.14.2022.11.22.23.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:04:17 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 23 Nov 2022 07:04:13 +0000 Subject: [PATCH v5 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..316e9628725 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 \"(prog1 (pop-to-buffer (compilation-start \\\"cat $@\\\" 'grep-mode)) (while (get-buffer-process (current-buffer)) (sleep-for 0.1)) (select-frame-set-input-focus (selected-frame)))\"" + ;; + *) + # assume anything else is vi-compatible + eval "$editor -q \$1" + ;; + esac } mode_diff() {