anything-config.el (anything-c-etags-init): avoid error
[anything-config.git] / doc / anything.tex
blob9904bc94c53f317aa63e5af7fa453df07006ee18
1 \documentclass[a4paper,11pt]{article}
2 \usepackage[french]{babel}
3 \usepackage[utf8]{inputenc}
4 \usepackage{textcomp}
6 \usepackage[pdftex=true,
7 hyperindex=true,
8 colorlinks=true]{hyperref}
9 \usepackage{url}
10 \usepackage{natbib}
11 \usepackage{setspace}
14 \begin{document}
15 \begin{titlepage}
16 \title{Anything User Manual}
17 \date{\today}
18 \author{ThierryVolpiatto}
19 \maketitle
20 \tableofcontents
21 \end{titlepage}
23 \section{Install}
24 \label{sec:install}
26 First get the files from git repo:
28 Anything git repo is at:\\
29 \url{http://repo.or.cz/w/anything-config.git}
31 To get it with git:
33 \begin{verbatim}
34 git clone git://repo.or.cz/anything-config.git
35 \end{verbatim}
37 NOTE: Files are published on Emacswiki, but be aware that it is \underline{unsafe} to get files from Emacswiki.
39 You need 2 files:
40 \begin{itemize}
41 \item anything.el
42 \end{itemize}
43 Contain the anything engine.
45 \begin{itemize}
46 \item anything-config.el
47 \end{itemize}
48 Contain all the sources and preconfigured functions ready to use.
50 and optionally:
51 \begin{itemize}
52 \item anything-match-plugin.el
53 \end{itemize}
54 Allow matching multi pattern search when entering a space in prompt.
56 Once downloaded these files, put them in your `load-path'.
57 If you don't know what is your load-path do C-h v load-path.
59 \section{Config}
60 \label{sec:config}
61 Edit your ~/.emacs.el file and add:
63 \begin{verbatim}
64 (require 'anything-config)
65 \end{verbatim}
67 Optionally, you can add:
69 \begin{verbatim}
70 (require 'anything-match-plugin)
71 \end{verbatim}
73 Note that if you don't require anything-match-plugin, you can enable/disable it afterward with:
75 M-x anything-c-toggle-match-plugin
77 NOTE:
78 It is not recommended to use the variable `anything-sources', please use instead the preconfigured anything command
79 you will find in anything-config.el or build your own.
81 Be aware also that making your own anything commands with a lot of sources involved can be very costly and slowdown
82 anything a lot.
84 \section{General anything commands}
85 \label{sec:gener-anyth-comm}
86 Anything allow you to have few binding to remember unlike all others Emacs applications.
88 Anything show you by default in mode-line the most useful bindings, you will see in headers of anything buffer some more specific
89 commands.
91 So when anything start what you have to remember:
93 \begin{itemize}
94 \item Access to action menu with
95 \begin{verbatim}
96 TAB
97 \end{verbatim}
98 \end{itemize}
99 \begin{itemize}
100 \item Use persistent actions with
101 \begin{verbatim}
103 \end{verbatim}
104 \end{itemize}
105 \begin{itemize}
106 \item Mark candidate with
107 \begin{verbatim}
108 M-<SPACE>
109 \end{verbatim}
110 \end{itemize}
112 So three bindings to remember and they are anyway documented in mode-line.
113 For more, hitting
114 \begin{verbatim}
115 C-h m
116 \end{verbatim}
117 while in anything session will show you all other bindings.
119 \section{Overview of preconfigured anything commands}
120 \label{sec:overv-comm-avail}
121 For starting with anything, a set of commands have been set for you in anything menu.
122 The bindings of all these commands are prefixed with `f5-a'.
124 To discover more anything commands run from menu anything all commands (anything-execute-anything-command).
125 Or run anything-M-x (f5-a M-x) and type anything.
127 When you like a command, e.g f5 a M-x you should bind it to something more convenient like M-x to replace the Emacs
128 original keybinding.
130 \section{Anything Find Files}
131 \label{sec:anything-find-files}
132 `anything-find-files' provide you a way to navigate in your system file easily.
133 All the actions you can do on files from here are described in this section.
135 It is binded in menu, and in `anything-command-map' to f5-a C-x C-f. \\
136 We will assume you have binded `anything-find-files' to C-x C-f.
137 To do that put in your .emacs.el:
138 \begin{verbatim}
139 (global-set-key (kbd "C-x C-f") 'anything-find-files)
140 \end{verbatim}
141 It is well integrated with tramp, you can enter any tramp filename and it will complete.
142 (e.g /su::, /sudo::, /ssh:host:, ... etc)
144 Called with a prefix arg, (C-u) anything-find-files will show you also history of last visited directories.
146 \subsection{Navigation}
147 \label{sec:navigation}
148 Anything-find-files is not by default on ~/ but on default-directory or
149 thing-at-point as it use ffap.If you are on a url, a mail adress
150 etc.. it will do the right thing.
152 So anything-find-files work like find-file (C-x C-f), but if you use it
153 with anything-match-plugin.el, you have to add a space and then the next
154 part of pattern you want to match:
156 Example:
158 \begin{verbatim}
159 Find Files or url: ~/
160 That show all ~/ directory.
162 Find Files or url: ~/des
163 will show all what begin with "des"
165 Find Files or url: ~/ esk
166 (Notice the space after ~/) will show all what contain esk.
168 Find Files or url: ~/ el$
169 Will show all what finish with el
171 \end{verbatim}
172 You can move in the anything buffer with C-n C-p or arrow keys, when you
173 are on a file, you can hit C-z to show only this file-name in the
174 anything buffer.
175 On a directory, C-z will switch to this directory to continue searching
176 in it.
177 On a symlink C-z will expand to the true name of symlink.(moving your
178 mouse cursor over a symlink will show the true name of it).
180 So it is quite easy to navigate in your files with anything-find-files.
182 Forget to mention C-. that go to root of current dir or to precedent
183 level of dir.
184 So for example you can hit C-z and then come back immediatly where you
185 were with C-. instead of erasing minibuffer input with DEL.
186 On non graphic display, it is bound to C-l.
188 If you like it you can safely bind it to C-x C-f to replace the standard
189 find-file:
191 \begin{verbatim}
192 (global-set-key (kbd "C-x C-f") 'anything-find-files)
193 \end{verbatim}
195 NOTE:
196 Starting anything-find-files with C-u will show you a little history of the last visited directories.
199 \subsection{Jump with nth commands}
200 \label{sec:jump-with-nth}
201 Take advantage of the second, third and 4th actions in anything.
202 Instead of opening action menu with TAB, just hit:
204 C-e for 2th action\\
205 C-j for 3th action\\
207 You can bind 4th action to some key like this:
208 \begin{verbatim}
209 (define-key anything-map (kbd "<C-tab>") 'anything-select-4th-action)
210 \end{verbatim}
212 \subsection{Turn in image viewer}
213 \label{sec:turn-image-viewer}
214 You can turn anything-find-files in a nice image-viewer.
216 Navigate to your image directory, then type C-u C-z on first image.
217 Now turn on `follow-mode' with C-c C-f.
218 You can now navigate in your image directory with arrow up and down or C-n C-p.
219 Don't forget also to use C-t to split you windows vertically if needed.
221 You will find also two actions to rotate image in action menu.
222 To use these actions whitout quitting, use M-l (rotate left) and M-r (rotate right).
223 Of course M-l and M-r have no effect if candidate is not an image file.\\
225 NOTE:
226 It use image-dired in background, so if image-dired don't work for some reason, this will
227 not work too.
228 Be sure to have Imagemagick package installed.
230 \subsection{Grep}
231 \label{sec:grep}
232 We describe here anything-do-grep, an incremental grep.
233 It is really convenient as you can start a search just after finding the place or file(s) you want to search in.
234 By the nature of incremental stuff, it is faster than original Emacs grep for searching.
236 As you type the display change (like in all other anything commands).
237 This grep is also recursive unlike the emacs implementation that use find/xargs.
239 It support wildcard and (re)use the variables `grep-find-ignored-files'
240 and `grep-find-ignored-directories'.
242 It have full tramp integration.
243 (you can grep file on a remote host or in su/sudo methods).
246 \begin{itemize}
247 \item NOTE:
248 You will find a file named anything-grep.el in extensions.
249 It is NOT needed to use with what is described here.
250 It is another implementation of grep but not incremental.
251 \end{itemize}
254 \begin{itemize}
255 \item NOTE:
256 When using it recursively, `grep-find-ignored-files' is not used unless you don't specify
257 the only extensions of files where you want to search (you will have a prompt).
258 You can now specify more than one extension to search.\\
259 e.g *.el *.py *.tex \\
260 will search only in files with these extensions.
261 \end{itemize}
263 \begin{itemize}
264 \item NOTE: Windows users need grep version
265 \begin{math}
266 \geq2.5.4
267 \end{math}
268 of Gnuwin32 on windoze.
269 This version should accept the --exclude-dir option.
270 \end{itemize}
272 \subsection{Anything do grep}
273 \label{sec:anything-do-grep}
274 Start with M-x anything-do-grep bound to f5 a M-g s
275 A prefix arg will launch recursive grep.
277 \subsection{Grep from anything-find-files}
278 \label{sec:grep-from-anything}
279 From anything-find-files (f5 a C-x C-f) Open the action menu with tab and choose grep.
280 A prefix arg will launch recursive grep.
282 \subsection{Grep One file}
283 \label{sec:grep-one-file}
284 Just launch grep, it will search in file at point.
285 if file is a directory, it will search in ALL files of this directory like:
287 \begin{verbatim}
288 grep -nH -e pattern *
289 \end{verbatim}
292 \subsection{Grep Marked files}
293 \label{sec:grep-marked-files}
294 Just mark some files with
295 \begin{verbatim}
296 C-<SPACE>
297 \end{verbatim}
298 and launch grep.
299 \subsubsection{Grep marked files from differents directories}
300 \label{sec:grep-marked-files-1}
301 This is a very nice feature of anything grep implementation that allow to search in specific files located not
302 only in current directory but anywhere in your file system.
304 To use navigate in your file system and mark files with
305 \begin{verbatim}
306 C-<SPACE>
307 \end{verbatim}
308 .When you have marked all files, just launch grep in action menu.
310 NOTE: using recursive search will have no effect of course!
312 \subsection{Grep Directory recursively}
313 \label{sec:grep-direct-recurs}
314 From anything-find-files, reach the root of the directory where you want to search in,
315 then hit TAB to open the action menu and choose grep with a prefix arg (i.e C-u RET).
317 if you want to use grep directly from anything-do-grep, do:
319 \begin{verbatim}
320 C-u f5 a M-g s
321 \end{verbatim}
323 You will be prompted for selecting in which category of files to search:
324 Use the wilcard syntax like *.el for example (search in only .el files).
327 \subsection{Grep Using Wildcard}
328 \label{sec:grep-using-wildcard}
329 You can use wildcard:
330 From the root of your directory, if you want for example to search files with .el extension:
331 add *.el to prompt
333 \subsection{Grep thing at point}
334 \label{sec:grep-thing-at}
335 Before lauching anything, put your cursor on the start of symbol or sexp you will want to grep.
336 Then launch anything-do-grep or anything-find-files, and when in the grep prompt hit C-w as many time as needed.
339 \subsection{Open Files Externally}
340 \label{sec:open-files-extern}
341 You will find in action menu from anything-find-files an action to open file with external program.
342 If you have no entry in .mailcap or /etc/mailcap, you will enter an anything session to choose a program
343 to use with this kind of file.
344 It will offer to you to save setting to always open this kind of files with this program.
345 Once configured, you can however open the files of same extension with some other program by forcing anything
346 to choose program with C-u.
348 \subsection{Eshell command on files}
349 \label{sec:eshell-command-files}
350 You can run eshell-command on files or marked files, the command you use have to accept
351 one file as argument.
352 The completion is make on your eshell aliases.
354 \subsection{Why Eshell}
355 \label{sec:why-eshell}
356 Because eshell allow you to create aliases.
357 You can like that create personal commands for anything-find-files.
358 All these command should end with \$1.
359 You will have completion against all these aliases once eshell is loaded.
360 (start it once before using anything-find-files).
362 NOTE: Eshell accept shell commands but also elisp functions :-).
364 \subsection{Setup Aliases}
365 \label{sec:setup-aliases}
366 Go in eshell, an enter at prompt:
367 \begin{verbatim}
368 alias my_alias command \$1
369 \end{verbatim}
370 NOTE: don't forget to escape the \$.
372 See the documentation of Eshell for more info.
374 \subsection{Problem starting Eshell}
375 \label{sec:probl-start-eshell}
376 Eshell code is available (autoloaded) only when you have started once eshell.
377 That's annoying like many autoloaded stuff in Emacs.
379 \subsection{Dired Commands}
380 \label{sec:dired-commands}
381 To enable some of the usual commands of dired, put in .emacs.el
382 \begin{verbatim}
383 (anything-dired-bindings 1)
384 \end{verbatim}
385 Or run interactively:
386 \begin{verbatim}
387 M-x anything-dired-bindings
388 \end{verbatim}
389 This will replace in dired C, R, S, and H commands.
390 That is copy, rename, symlink, hardlink.
391 When creating a symlink, you will find relsymlink in actions menu.(TAB).
393 \subsection{Copy Files}
394 \label{sec:copy-files}
395 It is a powerfull feature of anything-find-files as you can mark files in very different places in your
396 file system and copy them in one place.
398 Dired is not able to do that, you can mark files only in current dired display and copy them somewhere.
400 So, easy to use, just mark some files, and hit copy files in the action menu.
401 That will open a new anything-find-files where you can choose destination.
402 \subsection{Rename Files}
403 \label{sec:rename-files}
404 Just mark some files, and hit rename files in the action menu.
405 That will open a new anything-find-files where you can choose destination.
406 \subsection{Symlink Files}
407 \label{sec:symlink-files}
408 Just mark some files, and hit symlink or relsymlink files in the action menu.
409 That will open a new anything-find-files where you can choose destination.
410 \subsection{Hardlink}
411 \label{sec:hardlink}
412 Just mark some files, and hit hardlink files in the action menu.
413 That will open a new anything-find-files where you can choose destination.
415 \subsection{Follow file after action}
416 \label{sec:follow-file-after}
417 A prefix arg on any of the action above, copy, rename, symlink, hardlink, will
418 allow you to follow the file.
419 For example, when you want to copy an elisp file somewhere and you want to compile it in this place,
420 hitting C-u RET will bring you in this place with the file already marked, you have just to go in action menu to
421 compile it.
423 \subsection{In Buffer File Completion}
424 \label{sec:buff-file-compl}
425 In any buffer and even in minibuffer if you have enable recursive-minibuffer
426 \begin{verbatim}
427 (setq enable-recursive-minibuffers t)
428 \end{verbatim}
429 You can have completion with C-x C-f and then hit tab to choose action Complete at point \\
430 once you have found the filename you want.
431 \subsection{Create File}
432 \label{sec:create-file}
433 Navigate to the directory where you want to create your new file, then \\
434 continue typing the name of your file and type enter. \\
435 NOTE: If your filename ends with a / you will be prompt to create a new directory.
437 \subsection{Create Directory}
438 \label{sec:create-directory}
439 Navigate to the directory where you want to create your new directory, \\
440 then continue typing the name of new directory - Parents accepted - \\
441 and end it with / type enter, you will be prompt to create your new directory (possibly with parents).
443 \subsection{Ediff files}
444 \label{sec:ediff-files}
445 Well, that is easy to use,
446 move cursor to a file, hit ediff in action menu, you will jump in
447 another anything-find-files to choose second file.
448 \subsection{Ediff merge files}
449 \label{sec:ediff-merge-files}
450 move cursor to a file, hit ediff merge in action menu, you will jump in
451 another anything-find-files to choose second file.
453 \subsection{Browse archive with avfs}
454 \label{sec:browse-archive-with}
456 If you have installed avfs (See: http://sourceforge.net/projects/avf) you can browse archives
457 in your directory .avfs once it is mounted with ``mountavfs''.
459 Just move on the archive filename and press C-z (persistent action) and you will see
460 in anything buffer the subdirectories of archive, just navigate inside as usual.
462 \subsection{Display with icons}
463 \label{sec:display-with-icons}
465 You can have a more fancy display showing icons for files and directories.
466 Just add in .emacs:
467 \begin{verbatim}
468 (setq anything-c-find-files-show-icons t)
469 \end{verbatim}
470 NOTE: This will slowdown anything-find-files unless you have a fast computer.
472 \section{Anything write buffer}
473 \label{sec:anyth-write-buff}
474 That is a replacement of standard write-buffer Emacs command with anything completion.
475 \section{Anything insert file}
476 \label{sec:anything-insert-file}
477 That is a replacement of standard insert-file Emacs command with anything completion.
479 \section{Anything M-x}
480 \label{sec:anything-m-x}
481 It is binded to f5 a M-x, you should bind it to M-x.
483 Features:\\
484 \begin{itemize}
485 \item You can use prefix arguments before or during M-x session
486 \end{itemize}
487 \begin{itemize}
488 \item C-z is a toggle documentation for this command
489 \end{itemize}
490 \begin{itemize}
491 \item The key binding of command are shown.
492 \end{itemize}
494 \section{Anything regexp}
495 \label{sec:anything-regexp}
496 This is a replacement of regexp-builder.
497 The groups are shown in a convenient way.
499 \subsection{Query replace regexp}
500 \label{sec:query-replace-regexp}
501 Write your regexp in anything-regexp, when it match what you want,
502 you can run query-replace from action menu.
503 NOTE:
504 Before running anything-regexp, you can select a region to work in, that will narrow this region
505 automatically.
506 \subsection{Save regexp as sexp}
507 \label{sec:save-regexp-as}
508 When you use this, it will save your regexp for further use in lisp code,
509 with backslash duplicated.
511 \subsection{Save regexp as string}
512 \label{sec:save-regexp-as-1}
513 Save the regexp as you wrote it.
515 \section{Anything locate}
516 \label{sec:anything-locate}
517 First be sure you have a locate program installed on your system.
518 Most GNU/Linux distro come with locate included, you update or create the data base with
519 ``updatedb'' command.
521 \subsection{Search files}
522 \label{sec:search-files}
524 To use, just launch
525 \begin{verbatim}
526 M-x anything-locate (f5 a l)
527 \end{verbatim}
529 Then enter filename at prompt.
530 It will search this pattern entered also in directory and subdirectory names, to limit your search to basename,
531 add ``-b'' after pattern.
532 The search is performed on all files known in database, they maybe not exists anymore, so to limit to
533 really existing files add after pattern ``-e''.
534 To limit you search to specific number of results, use ``-n'' after your pattern with the number of results
535 you want.
537 Example:
538 \begin{verbatim}
539 Pattern: emacs -b -e -n 12
540 \end{verbatim}
542 \subsection{Launch grep}
543 \label{sec:launch-grep}
545 When search is done, you can search in a specific file or directory with grep that you will find in action menu (TAB).
547 \subsection{Windows specificity}
548 \label{sec:windows-specificity}
550 On Windows you should use Everything program that mimic locate, is very fast and don't need to
551 update database manually.
552 To use with anything-locate, you will need his command line named ``es''.
553 Be sure to modify the PATH environment variable, to include path to the directory that contain ``es''.
554 The arguments are the same than the ones in ``locate''.
556 \section{Anything Etags}
557 \label{sec:anything-etags}
559 \subsection{Create the tag file}
560 \label{sec:create-tag-file}
563 To use etags in Emacs you have first to create a TAGS file for your project with the etags shell command.
564 If your directory contains subdirectories use someting like:(e.g .el files)
565 \begin{verbatim}
566 etag find . -iregex .*\.el$ | xargs etags
567 \end{verbatim}
568 Otherwise
569 \begin{verbatim}
570 etags *.el
571 \end{verbatim}
572 is enought
574 For more infos see the man page of etags.
576 \subsection{Start anything etags}
577 \label{sec:start-anything-etags}
580 Now just using f5 a e will show you all entries.
581 If the project is big it take some time to load tag file but when it is done, next search will be very fast.
582 If you modify the TAGS file, use
583 \begin{verbatim}
584 C-u C-u f5 a e
585 \end{verbatim}
586 to refresh the tag cache.
588 To search the definition at point use just
589 \begin{verbatim}
590 C-u f5 a e
591 \end{verbatim}
593 \section{Other tools}
594 \label{sec:other-tools}
596 In addition of what is described above, you will find a bunch of powerfull tools that come with anything-config.el.
597 Just browse the anything commands availables with anything-M-x.
599 Not complete.
600 \section{Usefuls extensions}
601 \label{sec:usefuls-extensions}
602 Not complete.
604 \section{Usefuls links}
605 \label{sec:usefuls-links}
607 You can have info about anything on Emacswiki (Sometime deprecated).\\
608 \url{http://www.emacswiki.org/emacs/Anything}\\
610 You can ask on the anything mailing-list by subscribing at:\\
611 \url{https://groups.google.com/group/emacs-anything?hl=en}
613 \end{document}
615 %%% Local Variables:
616 %%% mode: latex
617 %%% TeX-master: t
618 %%% End: