X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/aec3b793a4877cbf5aee98eaac0f9efbc70eae33..5c1771876cc5301c2d0c7e9e28c69a01682d2429:/bin/mdw-editor diff --git a/bin/mdw-editor b/bin/mdw-editor index 312995f..c162da3 100755 --- a/bin/mdw-editor +++ b/bin/mdw-editor @@ -2,15 +2,22 @@ set -e editor=${MDW_EDITOR-ed} -emacsclient=t +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=emacsclient emacsclient=nil;; + 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 case "$emacsclient" in t) exec emacsclient -nw -a "$editor" "$@";; - nil) exec $editor "$@";; + *) exec $editor "$@";; esac