From patchwork Tue Nov 22 14:18: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: 13052430 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 2CF9DC4332F for ; Tue, 22 Nov 2022 14:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233757AbiKVOSc (ORCPT ); Tue, 22 Nov 2022 09:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233743AbiKVOS3 (ORCPT ); Tue, 22 Nov 2022 09:18:29 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E69E58BDB for ; Tue, 22 Nov 2022 06:18:28 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id z4so10339378wrr.3 for ; Tue, 22 Nov 2022 06:18:28 -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=fUmdCwowRYqmyln/CIWg2BNxhRCi7MB3JjTSCFTtzYzM5qb7B3NjjoO+kRcI/m2Lu2 InUKKdQJ6A+4zzpFMdD4Dhb4iZMybKEP5ZOw1G0uJMwnI+Te7i/skEklG3VUGsCUV9pP f/axRg12Y6406umM7xR+WtjXxpSWZ8CbXGeer/J3B9xxBtGdz8Z6JYNua5Ozs0XxDAba 19jESiXoAYXAePEb6pb5htQaoxSLOroFFcE0LzQqDtz4Tttd26/RN9F+v39YDcUNN6rB 3d3uTSZkDA4hAB4G56UyhEyqBiylOP8BN3sirzjuH2q3ufNXBJLyN0oJGoVg9KrWbVrj ih1w== 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=Q0hFi/vsra7GZUZ0jzf/OW1TgCCJ1PmpasX70ee+W2fmOhpAfVzy4fzPH43CL1I/Vs lbojgsyvnQ8qce+JADtIX6LACCFa+QgzAXlPJ7oLSLFKpvYPR6oqUBh0oulug8Jn6Wgn Af/NOen+7HVrBdF7vLjwzmFn/A2hEB9GHfR0qXMerc73RHpAIQ2eJReqm2lrD8u7vqWX vXwyECdGZzM5/B4Yc7kGlmLJ1wk/EbfEmo5fVA/Hyi4yBYFheSQl+tK0xuX+49tET+IF KLDxf6V62sBWWcnlJ6Gejgdk75BFuy17ya5veNPYAl96PaWIKixNh5L/K8LYbo/qPQrv foWA== X-Gm-Message-State: ANoB5pmFXnrPBJ3eE6UkD/WXoiuKtvuduNf8eVean9SLRYmbrSuU4Mxp onIgr/yzIordAzGI87StiPWVJnjuTdQ= X-Google-Smtp-Source: AA0mqf5ei9pPsFyY31u5yPl2mh1YJFYk3ORxgyXQrofiHHfjOjJF2x5Zimbf0wF58A+ZAl0R+GFovg== X-Received: by 2002:a5d:558b:0:b0:241:d71b:fd4c with SMTP id i11-20020a5d558b000000b00241d71bfd4cmr6163308wrv.435.1669126706525; Tue, 22 Nov 2022 06:18:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x11-20020a5d490b000000b0023691d62cffsm12385406wrq.70.2022.11.22.06.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 06:18:25 -0800 (PST) Message-Id: <446777d300d73498bd7da709fad75731a13d0d59.1669126703.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Nov 2022 14:18:22 +0000 Subject: [PATCH v4 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 Signed-off-by: Jeff King --- 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 Tue Nov 22 14:18:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoichi Nakayama X-Patchwork-Id: 13052431 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 A77FAC4332F for ; Tue, 22 Nov 2022 14:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233772AbiKVOSo (ORCPT ); Tue, 22 Nov 2022 09:18:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233754AbiKVOSb (ORCPT ); Tue, 22 Nov 2022 09:18:31 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC7767F50 for ; Tue, 22 Nov 2022 06:18:30 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id z4so10339549wrr.3 for ; Tue, 22 Nov 2022 06:18:30 -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=0BEb1b/8rgtSq2UdWqp5nXJuCIUFAQ0vxrjPJdpdIG0=; b=e0o/1v2ZPc08gWyaY6SGPgpZ1wqBJRdTwLYypbblvlBiLKD1lNpxvTvF2lUwG5Lrnr HQ3QQ0/synZ6lMoTc96mBAAG+WbvQC5GtsHK8IHH1u7byYLlYxsKuVXT0nKYyMs+d8z9 2z74b3Qocx+O0QPQOR0ADn5K6KKVDBlmkO7JU8gals6fDV0yeYKsEgnRyL9zGkUlwSDu an8Oa532W/QnO7bYc2PuFuSYbzaZwVRqD49dPgeMW0tKkB0LJDNhX6QdvN+FYfvJhbaZ MoC2zT4yBKYbS/EqWAk9/Siw26v7nJzSKlLoJS5nK+EhAyAzR/zvOjmY8ctH7Iv0/M7C I6Cw== 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=0BEb1b/8rgtSq2UdWqp5nXJuCIUFAQ0vxrjPJdpdIG0=; b=1n5nD9VCvVq+vhRCPi3gffvk6CmJGRrnV0x13YAYnLk9WmQg3ljOGn+GfK1HVJ/kyH UNDAr2NM+ET7Q1a5wqHxVJCEv4gW3zwaPTrZmv1VkH/EnduNkiGoNyM5wwEf0DuHT0z7 nQvOQkla7VLsAfb2F8XiyuWxDaLbHvV4dTGmAsTDbf9VHHozq1sDBTZZvWMgenO4QQpH lOGHxePDqyRhTGgxrH4J7m8/sRvMlxhqZjKnMPoYocKjWRaegHOeK1lgGI5YaejHtCw4 M+bdXxJAyw0p8+OMPVO5Vz896t4dZjpMX+m/gTRaMlFovpGq4HQ/9dhGnCr6yyHKz9Dv 32ig== X-Gm-Message-State: ANoB5pmmBSTbyj1WpWdexGWKcw83qpThZ7R9UcIUWlRxV3ohqEspAdxh HPFz93ByY3ZcXXYBWi1p38NVykY7Z7Y= X-Google-Smtp-Source: AA0mqf5VUUevOKLHwIH6spqiCAj/lSe+AsmE2bfAOIzbgHecB8hYmAWrZ5cYZ64UEtnB/mR3qsF75g== X-Received: by 2002:a5d:4d04:0:b0:236:6db4:a5fc with SMTP id z4-20020a5d4d04000000b002366db4a5fcmr14923427wrt.73.1669126708517; Tue, 22 Nov 2022 06:18:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c311100b003a2f2bb72d5sm27508170wmo.45.2022.11.22.06.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 06:18:27 -0800 (PST) Message-Id: <2f0bffb484beccf58f2440ed5e2c04a1ba26e6c3.1669126703.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Nov 2022 14:18:23 +0000 Subject: [PATCH v4 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index babb3b5c68d..bfd759aa4b2 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -26,6 +26,17 @@ open_editor() { eval "$editor -q \$1" } +open_emacs() { + # Supported editor values are: + # - emacs + # - emacsclient + # - emacsclient -t + editor=`git var GIT_EDITOR` + # Wait for completion of the asynchronously executed process + # to avoid race conditions in case of "emacsclient". + eval "$editor --eval \"(prog1 (switch-to-buffer-other-frame (compilation-start \\\"cat $@\\\" 'grep-mode)) (delete-other-windows) (while (get-buffer-process (current-buffer)) (sleep-for 0.1)) (select-frame-set-input-focus (selected-frame)))\"" +} + mode_diff() { git diff --no-prefix --relative "$@" | perl -ne ' @@ -98,4 +109,8 @@ 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 +if git var GIT_EDITOR | grep emacs >/dev/null; then + open_emacs "$tmp" + exit 0 +fi open_editor "$tmp"