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?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityTo 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.
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.
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) ))
Link to related source with an example to recursively search using zgrep
: https://unix.stackexchange.com/a/187753/92940
http://emacs.stackexchange.com/search?q=search+info