[PATCH v4 0/2] git-jump: support Emacs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 | 40 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)


base-commit: eea7033409a0ed713c78437fc76486983d211e25
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1423%2Fyoichi%2Fgit-jump-emacs-support-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1423/yoichi/git-jump-emacs-support-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1423

Range-diff vs v3:

 1:  ccfea26de33 ! 1:  446777d300d git-jump: add an optional argument '--stdout'
     @@ contrib/git-jump/README: git jump grep -i foo_bar
      +
      +--------------------------------------------------
      +# In Emacs, M-x grep and invoke "git jump --stdout <mode>"
     -+Run grep (like this): git jump --stdout diff
     ++M-x grep<RET>git jump --stdout diff<RET>
      +--------------------------------------------------
       
       Related Programs
     @@ contrib/git-jump/git-jump: grep: elements are grep hits. Arguments are given to
       EOF
       }
       
     -@@ contrib/git-jump/git-jump: if test $# -lt 1; then
     +@@ contrib/git-jump/git-jump: 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 "$mode" = "--stdout"; then
     -+	mode=$1; shift
     -+	type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
     -+	"mode_$mode" "$@" 2>/dev/null
     ++if test "$use_stdout" = "t"; then
     ++	"mode_$mode" "$@"
      +	exit 0
      +fi
       
 2:  b4ad4c083c9 ! 2:  2f0bffb484b git-jump: invoke emacs/emacsclient
     @@ contrib/git-jump/git-jump: open_editor() {
       }
       
      +open_emacs() {
     ++	# Supported editor values are:
     ++	# - emacs
     ++	# - emacsclient
     ++	# - emacsclient -t
      +	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)))\""
     ++	# 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 '
     -@@ contrib/git-jump/git-jump: if test "$mode" = "--stdout"; then
     - 	exit 0
     - fi
     - 
     -+# For emacs/emacsclient, call "git jump --stdout" from inside of them.
     +@@ contrib/git-jump/git-jump: 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
     -+	type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
     -+	open_emacs "$mode" "$@"
     ++	open_emacs "$tmp"
      +	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; }
     + open_editor "$tmp"

-- 
gitgitgadget



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux