From 2950fb6a94ddcd61bfb9808af2027e6d4b60b6d9 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 15 Aug 2015 22:13:27 -0700 Subject: [PATCH] add pager.sh refactor editor.sh --- dotfiles/lib/editor.sh | 21 +-------------------- dotfiles/lib/shellenv/emacs.sh | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 23 deletions(-) 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" }