From patchwork Mon Nov 21 12:26: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: 13050826 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 274C3C433FE for ; Mon, 21 Nov 2022 12:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiKUM1I (ORCPT ); Mon, 21 Nov 2022 07:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiKUM1F (ORCPT ); Mon, 21 Nov 2022 07:27:05 -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 C05E2AB0E3 for ; Mon, 21 Nov 2022 04:27:04 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id 5so8348957wmo.1 for ; Mon, 21 Nov 2022 04:27:04 -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=0YwOlPmIHMAu0LfcxnbRTtYAhc+Rl9hkoE7IllTJtFg=; b=RhhVUETKGuIZyGu8CHSAGrKuS/X3xdpREk+TF50Yab4jzidzIijQOrL80H0cRWd42i nqDJ164X1/nWkkoqCHaiT3Musnzksf2JPzKbCPXkW8yamMcnrnwXVTxF2lKIJ/iudhul nHPDrvytTfvHMlbcG2UPRvVsF319eVaZPNBvgrXo0OMSpjEzRX8caCa0FMPHQ4AEsmmP B32Nvxgxon/Dc4ovIBUlt7s12u6fDUOuTKQs4McSeSsz2FZ4tnM2FYGCvzMAGzxO6V8b UEUjj02mrO7s4voA6KwVfkUWVQE4Q8I12geC0NPAkG25aCeZD2x0qzw9yE74Y/Nagvke B6hQ== 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=0YwOlPmIHMAu0LfcxnbRTtYAhc+Rl9hkoE7IllTJtFg=; b=tsxQdNmwWeKYF1zoWpF2pgDjhEqwlV8U44tz7oK53vCmpVFdZukmOZ4rW53WWiW+ZU jOiSehxNeCkALPsFe4wdVY+xq1WfAWbqUtzzxiqxli3bFZyX3QC84iCPqx/YxIWdineU 1aN+cf0F+sLkMUfmtRyG3881TOTTwlRu85hJJXzlEFU7/epvzE7408zRT8vzGIvUJ/k4 HY36F2lGxujeXzEbjz/eeR+0fKxZn1qWcO0sDf/6rlw54VwTklatdkq4njptLWdIrf39 fdsSagvKtpnWVr+7Q82w/vTV+WPtJvaUd2H/ARebRJGpor8ReWzxhoOidiZR6hoXOKhP KvEA== X-Gm-Message-State: ANoB5pkqz8tUdNGXaxf62tqBRBH3lX2SIeEI7EFOdQ8z8cU9Sf6BgiU1 Iyx6Xa8AKELqCYXRNioK5FeZ87aNsjQ= X-Google-Smtp-Source: AA0mqf5ib7xNfcbHfYdu0HubYYwghuq4N7uepYeWBkDLOQcSbW1bE4TLxYDn3EQnYYuyV1tFxOnuRg== X-Received: by 2002:a05:600c:22c4:b0:3cf:71b7:7a41 with SMTP id 4-20020a05600c22c400b003cf71b77a41mr12925396wmg.31.1669033623022; Mon, 21 Nov 2022 04:27:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id iv7-20020a05600c548700b003cf87623c16sm20712034wmb.4.2022.11.21.04.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 04:27:02 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 21 Nov 2022 12:26:59 +0000 Subject: [PATCH v3 1/2] 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 | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 8bcace29d21..0340980959b 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 " +Run grep (like this): git 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..091d1add0ec 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 } @@ -69,6 +72,12 @@ if test $# -lt 1; then exit 1 fi mode=$1; shift +if test "$mode" = "--stdout"; then + mode=$1; shift + type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; } + "mode_$mode" "$@" 2>/dev/null + exit 0 +fi trap 'rm -f "$tmp"' 0 1 2 3 15 tmp=`mktemp -t git-jump.XXXXXX` || exit 1 From patchwork Mon Nov 21 12:27:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13050827 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 CC5E7C4332F for ; Mon, 21 Nov 2022 12:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbiKUM1K (ORCPT ); Mon, 21 Nov 2022 07:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiKUM1G (ORCPT ); Mon, 21 Nov 2022 07:27:06 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B331A65AC for ; Mon, 21 Nov 2022 04:27:05 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id i12so15749990wrb.0 for ; Mon, 21 Nov 2022 04:27:05 -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=3262lZ52ZMZtwpYyi+qe9OFvgFhcdOvlz0V2RAS9bIA=; b=OkHcU7vTAHlhWl/FZClkZxMzI9ahIfwRIJYtaiiAcsykBu/Jx7R3LZp6LiOVtxCsXD ZbRZoKZXRhLSb/gQ8AnF95C7QWCYuBVXwcLVamnAwzkJZdSraggCLwA0NKhUgLCoLKyl lHLU/Ir0s/0QjpK5CxCUSFwAb4HLb28a+pwkpGxrpFxSKVDbYWLB3bAQDA7ctDkL+hKY nUwWwTBQylyBYZ0uXRVuBq725wkpplAyUk7J7SvNFRUbFFbk8Y+6MEHIo9Y7QDvkULMs zu8wOvhZEGS/5yRTn/E/FzjrxvrTzOGFsTaAnGGuSSx2Hp0vNGt/qY3lk/cskCDayA+Q Xl7w== 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=3262lZ52ZMZtwpYyi+qe9OFvgFhcdOvlz0V2RAS9bIA=; b=OhM17/Ehab9IOzCKZ6ogcPECoxYEGRsQXnAwLEgt0sMqoXQQmsp2js54iEoneFYD0K vnbTMrbT7IjaYmyIIZBzqxqtoPQOrmsgzQsng6MimPb8n69HmK9ZkSaNuuTx6MzGn9Zv /2cSdi5AfeW3DyxZwSPuJU0TJFKUFkxQ5LtzsLqDoeE2keOsylOERkb9mPye07T5e7CP TWjsihUzlY6RlW5kD8x1vy+lcxHsVv6xi6IKAoVcCx2DJNHiWQIuoDMs/UM4VoN05m2M plxsO9aYN3tGVKEXP+yAZ5Zkb9+uwIbSdUg2lrS1KISWJRLn98aZRjQfCaBYWqDwL/Fj 5shg== X-Gm-Message-State: ANoB5pnlb75GcpOCnWkTf2th09diGkr57j4FuMQzOnlEzWpZXu2hETFg W1DajmTSpLGEgK4wRL4sGg/yfzhZ+q0= X-Google-Smtp-Source: AA0mqf7CuvKQSlMRs9vW9JTZHklNJJedLORqnc2l5Y5/+b3WwwLyZj7XpyFpDJ6dtYGqt7kRHUW5xQ== X-Received: by 2002:adf:dec8:0:b0:241:c7cd:9625 with SMTP id i8-20020adfdec8000000b00241c7cd9625mr6488367wrn.377.1669033623950; Mon, 21 Nov 2022 04:27:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l8-20020adfa388000000b002417f35767asm11385300wrb.40.2022.11.21.04.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 04:27:03 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 21 Nov 2022 12:27:00 +0000 Subject: [PATCH v3 2/2] 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index 091d1add0ec..43ca8bb1ee7 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -26,6 +26,11 @@ open_editor() { eval "$editor -q \$1" } +open_emacs() { + editor=`git var GIT_EDITOR` + eval "$editor --eval \"(prog1 (switch-to-buffer-other-frame (compilation-start \\\"git jump --stdout $@\\\" 'grep-mode)) (delete-other-windows) (select-frame-set-input-focus (selected-frame)))\"" +} + mode_diff() { git diff --no-prefix --relative "$@" | perl -ne ' @@ -79,6 +84,13 @@ if test "$mode" = "--stdout"; then exit 0 fi +# For emacs/emacsclient, call "git jump --stdout" from inside of them. +if git var GIT_EDITOR | grep emacs >/dev/null; then + type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; } + open_emacs "$mode" "$@" + exit 0 +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; }