use setvar and respect settings as given in zshenv.local
[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 zstyle -a ':ganneff:config' editors editors \
9 || editors=(
10 "emacs-snapshot -Q -D -nw" # Fast emacs
11 "emacs24 -Q -D -nw" # Fast emacs
12 "emacs23 -Q -D -nw" # Fast emacs
13 "emacs22 -Q -D -nw" # Fast emacs
14 "mcedit" #
15 "vim" "vi" # vi
16 "editor") # fallback
17 for editor in $editors; do
18 (( $+commands[$editor[(w)1]] )) && {
19 # Some programs may not like to have arguments
20 if [[ $editor == *\ * ]]; then
21 export EDITOR=$ZDOTDIR/run/editor-$HOST-$UID
22 cat <<EOF >| $EDITOR
23 #!/bin/sh
24 exec $editor "\$@"
25 EOF
26 chmod +x $EDITOR
27 else
28 export EDITOR=$editor
29 fi
30 break
31 }
32 done
33 } && __
34
35 [[ -z $EDITOR ]] || {
36 # Maybe use emacsclient?
37 if zstyle -T ':ganneff:config' emacsclient; then
38 (( $+commands[emacsclient] )) && {
39 export ALTERNATE_EDITOR=$EDITOR
40 export EDITOR=$ZDOTDIR/run/eeditor-$HOST-$UID
41 cat <<EOF >| $EDITOR
42 #!/bin/sh
43 exec emacsclient -t "\$@"
44 EOF
45 chmod +x $EDITOR
46 alias e=$EDITOR
47 }
48 fi
49 }
50
51 unset VISUAL