chiark / gitweb /
bin/mdw-editor: Use `emacsclient' to edit files.
[profile] / bin / mdw-editor
index 8b6e819f343b93b4d90b89eb8d96291d98d5ae0c..312995fb62be3a4ac82ef72582c43a3f83798502 100755 (executable)
@@ -2,11 +2,15 @@
 
 set -e
 editor=${MDW_EDITOR-ed}
+emacsclient=t
 [ -t 0 -a -t 1 ] || TERM=dumb
 case "$EDITOR,$VISUAL,$TERM" in
-  mdw-editor,mdw-editor,dumb) editor=gnuclient;;
+  mdw-editor,mdw-editor,dumb) 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" "$@";;
+  nil) exec $editor "$@";;
+esac