| 1 | #! /bin/sh |
| 2 | |
| 3 | set -e |
| 4 | editor=${MDW_EDITOR-ed} |
| 5 | case ${TMP+t},${TMPDIR+t} in |
| 6 | t,) TMPDIR=$TMP; export TMPDIR ;; |
| 7 | esac |
| 8 | emacsclient=$( |
| 9 | emacsclient --eval '(>= emacs-major-version 23)' 2>/dev/null || :) |
| 10 | [ -t 0 -a -t 1 ] || TERM=dumb |
| 11 | case "$EDITOR,$VISUAL,$TERM" in |
| 12 | mdw-editor,mdw-editor,dumb | \ |
| 13 | mdw-editor,mdw-editor,emacs | \ |
| 14 | mdw-editor,mdw-editor,eterm*) |
| 15 | editor=emacsclient emacsclient=nil;; |
| 16 | mdw-editor,mdw-editor,*);; |
| 17 | mdw-editor,*,*) editor=$VISUAL;; |
| 18 | *,*,*) editor=$EDITOR;; |
| 19 | esac |
| 20 | case "$emacsclient" in |
| 21 | t) exec emacsclient -nw -a "$editor" "$@";; |
| 22 | *) exec $editor "$@";; |
| 23 | esac |