如何通过所有可用的文档文本进行grep搜索? [英] How can I simply grep-search through all avaliable documentation text?

查看:106
本文介绍了如何通过所有可用的文档文本进行grep搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信Emacs的自我文档是伟大的和一切,但我似乎不能理解它应该如何使用,因为我需要的谷歌搜索通常只有几秒钟我通常度假比那个 - 不完全令人满意! (在离线的时候根本不可能,我宁愿在旅行等等)。



这让我很奇怪:为什么我不能只是google本地安装的文档,给我其中任何看起来像我正在搜索的字符串?我想这甚至可以通过简单的 grep ping命令行中的所有文件,但这不可能做到这一点。



apropos 听起来应该做这样的事情,但它不...我从来没有找到任何与该命令我还没有知道。

解决方案

以下是我以前写过的几个可能会让你指出的答案在正确的方向没有一个(默认)命令搜索所有的文档来源,但大部分时间都是可以的。



(我从来没有调查过在这方面的第三方图书馆,心灵;可能会有一些事情,采取更全面的方法来搜索文档。)





Mx elisp-index -search Mx emacs-index-search 是excel借用第一个呼叫端口。



Mx info-apropos 不太知名但非常有用,因为它搜索系统上所有已知信息文件的索引。当然,它比其他功能相对较慢。



首先,确保你知道如何使用信息阅读器! (请参阅这些链接了解一些更重要的细节)。



我使用以下绑定获取 apropos 命令快速(并确保读取 Ch v apropos-do-all ,其行为可以通过为其提及的命令提供前缀参数来触发) / p>

  ;;自定义'apropos'键绑定
(global-set-key(kbdCh Ca)'my-apropos-prefix)
(define-prefix-command'my-apropos-prefix nilApropos a,d,f,i,l,o,v,Cv))
(define-key my-apropos-prefix(kbda)'apropos)
(define-key my- apropos-prefix(kbdCa)'apropos)
(define-key my-apropos-prefix(kbdd)'apropos-documentation)
(define-key my-apropos-prefix kappc)'apropos-command)
(define-key my-apropos-prefix(kbdf)'apropos-command)
(define-key my-apropos-prefix(kbd我的''''''''''''''''''''''' )'apropos-user-option)
(define-key my-apropos-prefix(kbdv)'apropos-variable)
(define-key my-apropos-prefix(kbdCv )'apropos-value)

我也从中得到很多用处: p>

 (global-set-key(kbd 查询库)
(全局设置密钥(kbdCh Cf)'find-function)
(全局设置密钥(kbdCh Ck)' find-function-on-key)
(global-set-key(kbdCh Cv)'find-variable)

这些函数用于查看源代码,尽管在大多数文档中, describe - * 命令更有用,对于信息手册尚未涵盖的图书馆,在其源代码开头有好的评论也是不常见的。上述功能因此,绑定是访问源代码以检查这些文档的非常方便的快捷方式。



当然还有一堆默认绑定在 帮助前缀(或< f1> 如果您愿意),包括上述<$ c $的一些(但不是全部!) c> describe - * 命令。键入 C-h C-h do 阅读其列出的所有选项。有些你可能不在乎,有些你可能突然决定比你最后一次看起来更有趣。



检查 Mx apropos命令RET ^ describe-RET



最后,查看帮助菜单!特别是搜索文档子菜单,但如上所述,请注意其他项目。



最后,我确实发现原因实际上,/ em>然后grep的Emacs来源。如果您没有压缩任何内容,那么 M-x rgrep 是照常的朋友。然而,如果(未编译)的elisp全部被gzip压缩,那么您需要 Mx zrgrep (其中存在有时是人们的消息)。


I'm sure Emacs' self-documentation is great and everything, but I just can't seem to understand how it should be used, and since googling for what I need is most often only a matter of seconds I typically resort to that than – not exactly satisfying! (And simply impossible while offline, which I rather like to be while travelling etc..)

Which makes me wonder: why can I not just "google" through all of the locally installed documentation, give me anything therein that looks like the string I'm searching for? I suppose that would even be possible by simply grepping through all the files from the command line, but this can't be the way to do it.

apropos sounds like it should do something like that, but it doesn't... I've never found anything with that command I didn't already know about anyway.

解决方案

Here are a couple of previous answers I've written which may get you pointed in the right direction. There isn't a single (default) command which searches all of the documentation sources, but that's going to be okay most of the time.

(I've never investigated third-party libraries in this area, mind; there might well be things out there which take a more all-encompassing approach to searching the documentation.)

M-x elisp-index-search and M-x emacs-index-search are excellent first ports of call.

M-x info-apropos is less well-known but very useful, as it searches the indices of all known Info files on your system. It's correspondingly slower than the other functions, of course.

Above all, make sure you know how to use the Info reader! (see those links for some of the more important details).

I use the following bindings to get at the apropos commands quickly (and be sure to read C-h v apropos-do-all, the behaviour of which can be triggered by supplying a prefix argument to the commands it mentions).

;; Custom 'apropos' key bindings
(global-set-key (kbd "C-h C-a") 'my-apropos-prefix)
(define-prefix-command 'my-apropos-prefix nil "Apropos (a,d,f,i,l,o,v,C-v)")
(define-key my-apropos-prefix (kbd "a")   'apropos)
(define-key my-apropos-prefix (kbd "C-a") 'apropos)
(define-key my-apropos-prefix (kbd "d")   'apropos-documentation)
(define-key my-apropos-prefix (kbd "c")   'apropos-command)
(define-key my-apropos-prefix (kbd "f")   'apropos-command)
(define-key my-apropos-prefix (kbd "i")   'info-apropos)
(define-key my-apropos-prefix (kbd "l")   'apropos-library)
(define-key my-apropos-prefix (kbd "o")   'apropos-user-option)
(define-key my-apropos-prefix (kbd "v")   'apropos-variable)
(define-key my-apropos-prefix (kbd "C-v") 'apropos-value)

And I get a lot of use out of these as well:

(global-set-key (kbd "C-h C-l") 'find-library)
(global-set-key (kbd "C-h C-f") 'find-function)
(global-set-key (kbd "C-h C-k") 'find-function-on-key)
(global-set-key (kbd "C-h C-v") 'find-variable)

These functions are for looking at the source code, and although the describe-* commands are more useful when it comes to most documentation, it's also not uncommon for libraries which are not yet covered by the Info manuals to have good commentaries at the beginning of their source code. The above functions & bindings therefore make very convenient shortcuts for visiting the source code to check for such documentation.

There are, of course, a heap of default bindings on the C-h help prefix (or <f1> if you prefer), including some (but not all!) of the aforementioned describe-* commands. Type C-h C-h and do read through all of the options it lists. Some you might not care about, and some you might suddenly decide are rather more interesting to you than they were the last time you looked.

Check M-x apropos-command RET ^describe- RET as well.

Lastly, look at the "Help" menu! The "Search documentation" sub-menu in particular, but as above, take note of the other items as well.

Extra-lastly, I do find cause to actually grep the Emacs sources every now and then. If you have everything uncompressed, then M-x rgrep is your friend as usual. If, however, the (uncompiled) elisp is all gzipped, then you want M-x zrgrep (the existence of which is sometimes news to people).

这篇关于如何通过所有可用的文档文本进行grep搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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