chiark / gitweb /
el/dot-emacs.el (mdw-fontify-rust): Fix integer literal syntax.
[profile] / bin / mdw-editor
index 8b6e819f343b93b4d90b89eb8d96291d98d5ae0c..c162da30bf4a037aeeda8355e25050ffdfbc5f80 100755 (executable)
@@ -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