X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/9906310798d936a6cacd0ec5a2d3b607e911c423..fbc10dba9a1ff359cf6f3774a240189e4cd25512:/bin/mdw-editor diff --git a/bin/mdw-editor b/bin/mdw-editor index 8b6e819..c162da3 100755 --- a/bin/mdw-editor +++ b/bin/mdw-editor @@ -2,11 +2,22 @@ set -e editor=${MDW_EDITOR-ed} +case ${TMP+t},${TMPDIR+t} in + t,) TMPDIR=$TMP; export TMPDIR ;; +esac +emacsclient=$( + emacsclient --eval '(>= emacs-major-version 23)' 2>/dev/null || :) [ -t 0 -a -t 1 ] || TERM=dumb case "$EDITOR,$VISUAL,$TERM" in - mdw-editor,mdw-editor,dumb) editor=gnuclient;; + mdw-editor,mdw-editor,dumb | \ + mdw-editor,mdw-editor,emacs | \ + mdw-editor,mdw-editor,eterm*) + editor=emacsclient emacsclient=nil;; mdw-editor,mdw-editor,*);; mdw-editor,*,*) editor=$VISUAL;; *,*,*) editor=$EDITOR;; esac -exec $editor "$@" +case "$emacsclient" in + t) exec emacsclient -nw -a "$editor" "$@";; + *) exec $editor "$@";; +esac