bin/mdw-editor: Use `emacsclient' to edit files.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 9 Nov 2009 15:04:04 +0000 (15:04 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 9 Nov 2009 15:10:53 +0000 (15:10 +0000)
Emacs 23 can open new frames in terminals quite happily.  So we may as
well use it rather than starting up new Emacsen.

bin/mdw-editor

index 8b6e819..312995f 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