6

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.

leftaroundabout
  • 117,950
  • 5
  • 174
  • 319

3 Answers3

6

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

Community
  • 1
  • 1
phils
  • 71,335
  • 11
  • 153
  • 198
  • Well that's definitely better already. I suppose with a combination of these I'll most of the time get what I need. ...Shouldn't it actually be quite easy to "bundle" them, e.g. search first simply `apropos-command`, if that doesn't yield anything useful automatically proceed with more slower resources? – leftaroundabout Mar 13 '14 at 13:40
  • I suppose it depends on how you define (and detect) "yield anything useful", but I do agree there's definite scope for something along those lines to be written. – phils Mar 13 '14 at 13:52
1

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.

6EQUJ5
  • 3,142
  • 1
  • 21
  • 29
  • I see there's a Helm interface for this as well: https://github.com/emacs-helm/helm-recoll – phils Mar 13 '14 at 13:48
0

I'll mention how Icicles can help you search Info manuals. The short answer is that Icicles completion, whether for index entries, node names, or menu items, lets you use regexps, and it lets you progressively narrow the hunt by adding more search patterns. And for g you can match node names or node contents or both at the same time.

A more complete answer is here: How to efficiently search Info documentation.

The Icicles doc page for Info enhancements is here. It mentions also a way of flattening a manual or a portion of a manual and then regexp-searching only contexts that you define with a preliminary regexp. Search contexts can be as simple as individual lines (a la grep), from regexp .*, or they can be as complex as you like.

Community
  • 1
  • 1
Drew
  • 29,895
  • 7
  • 74
  • 104