add pager.sh refactor editor.sh

This commit is contained in:
Ivan Malison 2015-08-15 22:13:27 -07:00
parent 13bb4059ed
commit 2950fb6a94
2 changed files with 20 additions and 23 deletions

View File

@ -1,22 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
emacs_editor "$@"
function editor {
if is_osx; then
reattach-to-user-namespace emacsclient "$@"
else
emacsclient "$@"
fi
}
if [ -t 1 ]; then
TMP="$(mktemp -t emacs)"
echo $TMP
cat > "$TMP"
editor "$TMP" "$@"
rm "$TMP"
else
editor "$@"
fi
return 0 return 0

View File

@ -111,6 +111,22 @@ function time_emacs {
time \emacs --daemon="timing" && emacsclient -e "(kill-emacs)" --server-file="timing" time \emacs --daemon="timing" && emacsclient -e "(kill-emacs)" --server-file="timing"
} }
function emacs_editor {
if is_osx; then
reattach-to-user-namespace emacsclient "$@"
else
emacsclient "$@"
fi
}
function emacs_pager {
TMP="$(mktemp -t emacs_pager.XXXXX --suffix=.ansi_color)"
echo $TMP
cat > "$TMP"
emacs_editor "$TMP" "$@"
rm "$TMP"
}
# Make emacs the default editor. # Make emacs the default editor.
export EDITOR="$HOME/.lib/editor.sh" export EDITOR="$HOME/.lib/editor.sh"
export ALTERNATE_EDITOR="" export ALTERNATE_EDITOR=""
@ -119,7 +135,7 @@ export GIT_EDITOR="$EDITOR"
# This actually gets executed in dotfiles/lib/shellrc.sh to make sure that it takes precedence over other settings # This actually gets executed in dotfiles/lib/shellrc.sh to make sure that it takes precedence over other settings
function inside_emacs_hook { function inside_emacs_hook {
export PAGER="$EDITOR" export PAGER="$HOME/.lib/pager.sh"
export GITPAGER="$EDITOR" export GITPAGER="$PAGER"
export MANPAGER="$EDITOR" export MANPAGER="$PAGER"
} }