diff --git a/dotfiles/lib/editor.sh b/dotfiles/lib/editor.sh index 96bbce50..7c932eec 100755 --- a/dotfiles/lib/editor.sh +++ b/dotfiles/lib/editor.sh @@ -1,22 +1,3 @@ #!/usr/bin/env zsh - -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 - +emacs_editor "$@" return 0 diff --git a/dotfiles/lib/shellenv/emacs.sh b/dotfiles/lib/shellenv/emacs.sh index 6be1c1ce..cd8890fc 100644 --- a/dotfiles/lib/shellenv/emacs.sh +++ b/dotfiles/lib/shellenv/emacs.sh @@ -111,6 +111,22 @@ function time_emacs { 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. export EDITOR="$HOME/.lib/editor.sh" 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 function inside_emacs_hook { - export PAGER="$EDITOR" - export GITPAGER="$EDITOR" - export MANPAGER="$EDITOR" + export PAGER="$HOME/.lib/pager.sh" + export GITPAGER="$PAGER" + export MANPAGER="$PAGER" }