Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simply grep-search through all avaliable documentation text?

Tags:

emacs

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.

like image 704
leftaroundabout Avatar asked Mar 13 '14 12:03

leftaroundabout


People also ask

How do I use grep to find all files?

To search multiple files with the grep command, insert the filenames you want to search, separated with a space character. The terminal prints the name of every file that contains the matching lines, and the actual lines that include the required string of characters. You can append as many filenames as needed.

How do I grep for multiple searches?

The basic grep syntax when searching multiple patterns in a file includes using the grep command followed by strings and the name of the file or its path. The patterns need to be enclosed using single quotes and separated by the pipe symbol. Use the backslash before pipe | for regular expressions.


2 Answers

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.)

  • how do I get started using Emacs' documentation?
  • Emacs: Open a specific Info section
  • How to efficiently search Info 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).

like image 132
phils Avatar answered Sep 18 '22 03:09

phils


Install something like recoll then you can full text search your entire hard disk if you want.

Recoll is a desktop search tool that provides efficient full text search (from single-word to arbitrarily complex boolean searches) in a friendly GUI, with minimum technical sophistication and few mandatory external dependencies. It runs under many Unix-like operating systems, and is mostly independent of the desktop environment.

like image 35
6EQUJ5 Avatar answered Sep 19 '22 03:09

6EQUJ5