]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-jump: invoke emacs/emacsclient
authorYoichi Nakayama <yoichi.nakayama@gmail.com>
Sun, 27 Nov 2022 01:18:53 +0000 (01:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Nov 2022 01:49:51 +0000 (10:49 +0900)
It works with GIT_EDITOR="emacs", "emacsclient" or "emacsclient -t"

Signed-off-by: Yoichi Nakayama <yoichi.nakayama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/git-jump/git-jump

index a5a8a77e20e2470a2adb729e59fdb19a6ebcd70c..40c4b0d111071676c278651f49669036e90f079a 100755 (executable)
@@ -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 (grep \\\"cat \$1\\\"))) (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() {