Using Emacs for $PAGER?
Asked Answered
A

1

16

There are lots of places in UNIX where programs call out to the program in $PAGER (usually less or some similar command) to display some output. It's certainly true that many of the most common uses have an Emacs replacement (in the case of man, for example), but I'd still like a general way to use Emacs as my system-wide pager. Ideally this would mean that calls to PAGER end up in an Emacs temporary buffer similar to *Help*, a read-only buffer you can navigate around and dismiss by pressing "q".

I usually run a shell through M-x shell, so my envisioned use case is that typing a command like "man foo" in the *shell* window will bring up the man page in another window, more or less exactly like how the built-in *Help* system works.

Acantho answered 6/12, 2011 at 20:56 Comment(1)
less is more, but there is also most another pager which has emacs-like bindings and some nice color.Garrotte
F
6

For general use of $PAGER, you might be interested in e-sink.

For the specific case of man pages, it's better to use Emacs's built-in man mode as you note. I have this in my .bashrc:

man () 
{ 
    if [ "$TERM" == "eterm-color" ]; then
        emacsclient -e "(man \"$1\")";
    else
        command man "$@";
    fi
}

Since you use shell-mode rather than ansi-term-mode like I do you will either have to make this use emacsclient all the time, or do something like (setenv "WITHIN_EMACS" "1") in your .emacs file so you can switch on $WITHIN_EMACS instead.

Firehouse answered 6/12, 2011 at 21:5 Comment(1)
You don't need to set your own variable, emacs sets INSIDE_EMACS for you in M-x shell. See the manualExiguous

© 2022 - 2024 — McMap. All rights reserved.