【问题标题】:How to view man pages using emacs when invoking man command in command line?在命令行中调用 man 命令时如何使用 emacs 查看手册页?
【发布时间】:2012-05-25 12:40:39
【问题描述】:

我想在调用 man 命令时使用 emacs 查看手册页。 我将/etc/man.confPAGER中的pager参数修改为emacs

但是,它不起作用。有什么需要修改的吗?

【问题讨论】:

标签: emacs pager manpage


【解决方案1】:

确实,emacs无法将STDIN读入缓冲区,意思是

cat foobar | emacs

在任何情况下都不起作用。因此,将 PAGER 变量设置为“emacs”或“emacs -nw”并不能完成这项工作。 我看到的唯一方法是将man 输出写入 tmp 文件,然后将该文件加载到 emacs 中:

man find > tmp-file; emacs tmp-file

你可以给它取别名。 例如,假设一个 tc-shell 和一个名为 'tmp' 的目录在您的主路径中,您可以将以下行放入您的 ~/.tcshrc 文件中:

alias man '/usr/bin/man \!* > ~/tmp/tmp-file; emacs ~/tmp/tmp-file; rm ~/tmp/tmp-file'

所以下次你打电话给man find 时,emacs 就会启动。

【讨论】:

    【解决方案2】:

    您可以从 emacs 的函数man 中获益。只需在 bash 中定义一个函数,该函数将运行将调用它的 emacs:

    function man () {
        emacs -e '(man "'"$1"'")'
    }
    

    您可能想致电 emacs -nw 甚至是 emacsclient

    【讨论】:

    • 也值得考虑:emacs -eval "(woman \"$1\")",它使用 emacs 的基于 elisp 的 man 而不是外部 man 程序。
    • @ataylor 这会将 man 缓冲区作为弹出窗口打开,我怎样才能最大化它(当然是在脚本中)?
    • @YoujunHu:你说的“不行”是什么意思?你得到什么错误?它对我有用。
    • @choroba : 我得到的错误:symbol's function defintion is void: (man\"find")
    • 适合我的版本:emacs -nw --eval '(progn (man "'$1'") (delete-window))';
    【解决方案3】:

    Emacs 有一个“Man 模式”,可以通过 M-x man RET 调用,然后输入您的命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-24
      • 1970-01-01
      • 2014-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      相关资源
      最近更新 更多