2

This question already has an answer here:

Emacs claims to be self explanatory, but I couldn't find a way, to search through the documentation. This leads to me searching always in google.

So how can is search through documentation in emacs?

marked as duplicate by Kaushal Modi, Drew, Dan Aug 24 '16 at 15:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • There are many more related questions asked here: http://emacs.stackexchange.com/search?q=search+info – Kaushal Modi Aug 24 '16 at 13:50
3

To search through documentation, you can use the command apropos-documentation, which is bound to C-h d by default.

The other apropos commands may be useful to you. You can use apropos to search for apropos functions by using apropos-command (bound to C-h a) and typing apropos RET.

There is also a Helm command called helm-apropos that will allow you to search through several different apropos sources at once.

1

I guess you mean the manuals? C-h r takes you to the Emacs manual. C-h i takes you (initially) to all of the installed manuals, and from there you can choose a manual to visit. The main manuals for Emacs are the Emacs (user) manual and the Elisp manual.

Once in a manual, you can use i to search for index entries, with completion.

Once in a manual, you can also use incremental search, C-s or C-M-s, to search throughout the manual for literal text or a regexp match, respectively. Repeat by repeating the key.

In general, prefer i to searching full-text (e.g. C-s) through a manual - i is your friend.

This is because there are often plenty of occurrences of some search pattern that are not particularly relevant to what you are looking for. Index entries, on the other hand (which is what i searches), have been carefully chosen by Emacs developers and other users to represent what are typically the best entry points for the term you look up.

When you visit a manual using C-h r or C-h i you are in Info, a hypertext document reader. You can quit it using q. When you enter again using C-h i you re-enter where you left off, in the last manual visited.

In Info you can also search for a pattern across all installed manuals, using a (command info-apropos).


Outside the manuals, the apropos commands are your friends. Type C-h f apropos TAB to see what they are, then C-h f for any of them to see more about them. In particular, there is command apropos-documentation.

If you use Icicles then you have more flexible apropos commands. See, for example, (multi-)command icicle-doc, which gives you all the documentation that matches either symbol-names or doc-string input patterns, or both.

With Icicles you also have an incremental way of getting apropos information about Emacs, available as part of the normal interaction with help commands (e.g. C-h f) or with M-x etc.

1

RECURSIVELY GREP THE BUILT-IN .INFO MANUALS USING A REGEX SEARCH

The following solution relies upon three (3) command-line utilities: find; xargs; and zgrep. In putting together the following function, I discovered that grep cannot see inside gizipped files, and not all versions of zgrep are able to search recursively. Inasmuch as zgrep can handle both gzipped and unzipped .info files, the function includes a search for both.

On OSX find/xargs/zgrep come pre-installed and they are located in the /usr/bin directory; and, the car of Info-default-directory-list contains the built-in Emacs manual consisting of several .info files:

With some command-line utilities, Emacs may complain about exiting abnormally with code 1. The zgrep results in this case are nevertheless complete, and running the same commands in the terminal works perfectly without any error messages.

Just type: M-x ask-emacs

(defun ask-emacs ()
"Grep the .info files that are in the CAR of `Info-default-directory-list'."
(interactive)
  (let* (
      (search-term (read-string "Ask Emacs (regex):  "))
      (search-path (directory-file-name (car Info-default-directory-list)))
      (default-directory (file-name-as-directory search-path))
      (initial-grep-command "-inIE --color=always -C2")
      (grep-command (concat
        "find"
        " "
        search-path
        " "
        "\\( -name \\*.gz -o -name \\*.info \\)"
        " "
        "-print0"
        " "
        "|"
        " "
        "xargs"
        " "
        "-0"
        " "
        "zgrep"
        " "
        initial-grep-command
        " "
        search-term
        " "
        search-path)) )
   (compilation-start grep-command 'grep-mode (lambda (mode) "*grep*") nil) ))

Example


Link to related source with an example to recursively search using zgrep: https://unix.stackexchange.com/a/187753/92940

  • I think that it would be a better approach to paste a link to that other emacs.SE answer of yours: emacs.stackexchange.com/a/26057/115, instead of copy/pasting it. It creates unnecessary duplication within emacs.SE. Also it's good if you have just one place to update the solution if needed in future (else, you will have multiple versions of the same thing, some versions would be better than the other). – Kaushal Modi Aug 24 '16 at 16:38
  • @Kaushal Modi -- Could it still be an answer if it just has a link to another answer, or does that render it just a comment which many people will probably not see? – lawlist Aug 24 '16 at 16:50
  • Yes, you can internally link emacs.SE answers. Normally in such cases, you are referring to another answer and doing some improvement on top of that. If the exact same answer applies in the new question, then most likely that new question is a duplicate and should be closed by the mod, like this one :) – Kaushal Modi Aug 24 '16 at 16:52
  • @KaushalModi No, definitely not. Please keep your answers self-contained. But, lawlist, you should adapt your answer to the question at hand. If you feel like posting the same answer on two questions, that's a strong sign that they're duplicates and you should vote to close instead. – Gilles Aug 24 '16 at 20:07
  • 1
    @KaushalModi The solution to this is to close questions as duplicates. – Gilles Aug 24 '16 at 20:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.