initial
[zsh.git] / .zsh / 65_Editor.zsh
1 # -*- mode: sh;-*-
2 # Setup EDITOR
3 mkdir -p $ZDOTDIR/run/
4
5 __ () {
6 local -a editors
7 local editor
8 editors=(
9 "emacs-snapshot -Q -D -nw" # Fast emacs
10 "emacs24 -Q -D -nw" # Fast emacs
11 "emacs23 -Q -D -nw" # Fast emacs
12 "emacs22 -Q -D -nw" # Fast emacs
13 "mcedit" #
14 "vim" "vi" # vi
15 "editor") # fallback
16 for editor in $editors; do
17 (( $+commands[$editor[(w)1]] )) && {
18 # Some programs may not like to have arguments
19 if [[ $editor == *\ * ]]; then
20 export EDITOR=$ZDOTDIR/run/editor-$HOST-$UID
21 cat <<EOF >| $EDITOR
22 #!/bin/sh
23 exec $editor "\$@"
24 EOF
25 chmod +x $EDITOR
26 else
27 export EDITOR=$editor
28 fi
29 break
30 }
31 done
32 } && __
33
34 [[ -z $EDITOR ]] || {
35 alias e=$EDITOR
36 # Maybe use emacsclient?
37 (( $+commands[emacsclient] )) && {
38 export ALTERNATE_EDITOR=$EDITOR
39 export EDITOR="emacsclient"
40 # Maybe with -n
41 alias e="emacsclient"
42 }
43 }
44
45 unset VISUAL