[PATCH v3 0/2] git-jump: support Emacs
- From
Yoichi NAKAYAMA via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 21, 2022, 12:26 UTC
- Message-ID
- <pull.1423.v3.git.1669033620.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1423.v2.git.1668907644.gitgitgadget@gmail.com>
Add an optional argument 'stdout' to print the quickfix lines to standard output. It can be used with M-x grep on Emacs.
Detect emacsclient by GIT_EDITOR and invoke the function. Tested with EDITOR="emacsclient" and EDITOR="emacsclient -t".
Yoichi Nakayama (2): git-jump: add an optional argument '--stdout' git-jump: invoke emacs/emacsclient
contrib/git-jump/README | 10 +++++++++- contrib/git-jump/git-jump | 23 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-)
base-commit: eea7033409a0ed713c78437fc76486983d211e25 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1423%2Fyoichi%2Fgit-jump-emacs-support-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1423/yoichi/git-jump-emacs-support-v3 Pull-Request: https://github.com/gitgitgadget/git/pull/1423
Range-diff vs v2:
1: e56858a3eb2 ! 1: ccfea26de33 git-jump: add an optional argument 'stdout'
@@ Metadata
Author: Yoichi Nakayama <yoichi.nakayama@gmail.com>
## Commit message ##
- git-jump: add an optional argument 'stdout'
+ git-jump: add an optional argument '--stdout'
It can be used with M-x grep on Emacs.
@@ contrib/git-jump/README: 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. You can use it with M-x grep on Emacs.
++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 <mode>"
-+Run grep (like this): git jump stdout diff
++# In Emacs, M-x grep and invoke "git jump --stdout <mode>"
++Run grep (like this): git jump --stdout diff
+--------------------------------------------------
Related Programs
@@ contrib/git-jump/git-jump
usage() {
cat <<\EOF
-usage: git jump <mode> [<args>]
-+usage: git jump [stdout] <mode> [<args>]
++usage: git jump [--stdout] <mode> [<args>]
Jump to interesting elements in an editor.
The <mode> parameter is one of:
@@ contrib/git-jump/git-jump: grep: elements are grep hits. Arguments are given to
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.
++If the optional argument `--stdout` is given, print the quickfix
++lines to standard output instead of feeding it to the editor.
EOF
}
@@ contrib/git-jump/git-jump: if test $# -lt 1; then
exit 1
fi
mode=$1; shift
-+if test "$mode" = "stdout"; then
++if test "$mode" = "--stdout"; then
+ mode=$1; shift
+ type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
+ "mode_$mode" "$@" 2>/dev/null
2: 72c4fd5532b ! 2: b4ad4c083c9 git-jump: invoke emacsclient
@@ Metadata
Author: Yoichi Nakayama <yoichi.nakayama@gmail.com>
## Commit message ##
- git-jump: invoke emacsclient
+ git-jump: invoke emacs/emacsclient
- It works with GIT_EDITOR="emacsclient" or GIT_EDITOR="emacsclient -t"
+ It works with GIT_EDITOR="emacs", "emacsclient" or "emacsclient -t"
Signed-off-by: Yoichi Nakayama <yoichi.nakayama@gmail.com>
@@ contrib/git-jump/git-jump: open_editor() {
eval "$editor -q \$1"
}
-+open_emacsclient() {
++open_emacs() {
+ editor=`git var GIT_EDITOR`
-+ eval "$editor -e \"(prog1 (switch-to-buffer-other-frame (grep \\\"git jump stdout $@\\\")) (delete-other-windows) (select-frame-set-input-focus (selected-frame)))\""
++ 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 '
-@@ contrib/git-jump/git-jump: if test "$mode" = "stdout"; then
+@@ contrib/git-jump/git-jump: if test "$mode" = "--stdout"; then
exit 0
fi
-+if git var GIT_EDITOR | grep emacsclient >/dev/null; then
++# 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_emacsclient "$mode" "$@"
++ open_emacs "$mode" "$@"
+ exit 0
+fi
+-- gitgitgadget