Emacs 22's client doesn't like the `-nw' option, unsurprisingly. So
interrogate it first to find out what's going on.
I suppose this also means that there's not a great deal of point in
using the `-a' option, but it doesn't do a great deal of harm.
set -e
editor=${MDW_EDITOR-ed}
-emacsclient=t
+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;;
esac
case "$emacsclient" in
t) exec emacsclient -nw -a "$editor" "$@";;
- nil) exec $editor "$@";;
+ *) exec $editor "$@";;
esac