使用Emacs $ PAGER? [英] Using Emacs for $PAGER?

查看:110
本文介绍了使用Emacs $ PAGER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UNIX中有很多地方在程序中调用$ PAGER(通常 less 或类似的命令)来显示一些输出。很多最常见的使用方式是Emacs替代品(例如 man ),但我仍然希望使用Emacs的一般方法作为我的系统范围的寻呼机。理想情况下,这意味着对PAGER的调用最终会出现在类似于* Help *的Emacs临时缓冲区中,这是一个只读缓冲区,您可以通过按q导航并关闭。



我通常通过Mx shell运行一个shell,所以我想象的用例是在* shell *窗口中键入一个像man foo这样的命令,将在另一个窗口中打开手册页,或多或少与内置*帮助*系统工程。

解决方案

对于一般使用 $ PAGER ,您可能对电子汇款感兴趣。



对于手册页的具体情况,最好在您注意时使用Emacs的内置人员模式。我有这个在我的 .bashrc

  man()
{
if [$ TERM==eterm-color];然后
emacsclient -e(man \$ 1\);
else
命令man$ @;
fi
}

由于您使用模式而不是 ansi-term-mode 像我一样,您将不得不一直使用emacsclient,或者执行类似<$您的 .emacs 文件中的c $ c>(setenvWITHIN_EMACS1),以便您可以开启 $ WITHIN_EMACS


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.

解决方案

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.

这篇关于使用Emacs $ PAGER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆