1 ;;; anything-config.el --- Applications libary for `anything.el'
3 ;; Filename: anything-config.el
5 ;; Description: Applications libary for `anything.el'
7 ;; Author: Tassilo Horn <tassilo@member.fsf.org>
9 ;; Maintainer: Tassilo Horn <tassilo@member.fsf.org>
10 ;; rubikitch <rubikitch@ruby-lang.org>
11 ;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
12 ;; Copyright (C) 2007 ~ 2011, Tassilo Horn, all rights reserved.
13 ;; Copyright (C) 2009, Andy Stewart, all rights reserved.
14 ;; Copyright (C) 2009 ~ 2011, rubikitch, all rights reserved.
15 ;; Copyright (C) 2009 ~ 2011, Thierry Volpiatto, all rights reserved.
17 ;; Created: 2009-02-16 21:38:23
19 ;; X-URL: http://repo.or.cz/w/anything-config.git
21 ;; MailingList: https://groups.google.com/group/emacs-anything?hl=en
23 ;; Keywords: anything, anything-config
25 ;; Compatibility: GNU Emacs 22 ~ 24
27 ;; Dependencies: `anything.el'
29 ;;; This file is NOT part of GNU Emacs
33 ;; This program is free software; you can redistribute it and/or modify
34 ;; it under the terms of the GNU General Public License as published by
35 ;; the Free Software Foundation; either version 3, or (at your option)
38 ;; This program is distributed in the hope that it will be useful,
39 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
40 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 ;; GNU General Public License for more details.
43 ;; You should have received a copy of the GNU General Public License
44 ;; along with this program; see the file COPYING. If not, write to
45 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
46 ;; Floor, Boston, MA 02110-1301, USA.
50 ;; If this file does not work, upgrade anything.el!
51 ;; http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
55 ;; Predefined configurations for `anything.el'
57 ;; For quick start, try `anything-for-files' to open files.
59 ;; To configure anything you should define anything command
60 ;; with your favorite sources, like below:
62 ;; (defun my-anything ()
64 ;; (anything-other-buffer
65 ;; '(anything-c-source-buffers
66 ;; anything-c-source-file-name-history
67 ;; anything-c-source-info-pages
68 ;; anything-c-source-info-elisp
69 ;; anything-c-source-man-pages
70 ;; anything-c-source-locate
71 ;; anything-c-source-emacs-commands)
74 ;; Then type M-x my-anything to use sources.
76 ;; Defining own command is better than setup `anything-sources'
77 ;; directly, because you can define multiple anything commands with
78 ;; different sources. Each anything command should have own anything
79 ;; buffer, because M-x anything-resume revives anything command.
82 ;;; Autodoc documentation:
83 ;; ---------------------
85 ;; * Commands defined here are:
86 ;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "anything-" :docstring t)
87 ;; `anything-configuration'
88 ;; Customize `anything'.
89 ;; `anything-c-buffer-help'
90 ;; Help command for anything buffers.
92 ;; Help command for `anything-find-files'.
93 ;; `anything-read-file-name-help'
95 ;; `anything-generic-file-help'
97 ;; `anything-grep-help'
99 ;; `anything-pdfgrep-help'
101 ;; `anything-etags-help'
102 ;; The help function for etags.
103 ;; `anything-c-ucs-help'
104 ;; Help command for `anything-ucs'.
105 ;; `anything-show-this-source-only'
106 ;; Show all candidates of this source.
107 ;; `anything-test-sources'
108 ;; List all anything sources for test.
109 ;; `anything-select-source'
110 ;; [OBSOLETE] Select source.
111 ;; `anything-quit-and-find-file'
112 ;; Drop into `anything-find-files' from `anything'.
113 ;; `anything-mark-all'
114 ;; Mark all visible unmarked candidates in current source.
115 ;; `anything-unmark-all'
116 ;; Unmark all candidates in all sources of current anything session.
117 ;; `anything-toggle-all-marks'
119 ;; `anything-buffer-diff-persistent'
120 ;; Toggle diff buffer without quitting anything.
121 ;; `anything-buffer-revert-persistent'
122 ;; Revert buffer without quitting anything.
123 ;; `anything-buffer-save-persistent'
124 ;; Save buffer without quitting anything.
125 ;; `anything-buffer-run-kill-buffers'
126 ;; Run kill buffer action from `anything-c-source-buffers-list'.
127 ;; `anything-buffer-run-grep'
128 ;; Run Grep action from `anything-c-source-buffers-list'.
129 ;; `anything-buffer-run-zgrep'
130 ;; Run Grep action from `anything-c-source-buffers-list'.
131 ;; `anything-buffer-run-query-replace-regexp'
132 ;; Run Query replace regexp action from `anything-c-source-buffers-list'.
133 ;; `anything-buffer-run-query-replace'
134 ;; Run Query replace action from `anything-c-source-buffers-list'.
135 ;; `anything-buffer-switch-other-window'
136 ;; Run switch to other window action from `anything-c-source-buffers-list'.
137 ;; `anything-buffer-switch-other-frame'
138 ;; Run switch to other frame action from `anything-c-source-buffers-list'.
139 ;; `anything-buffer-switch-to-elscreen'
140 ;; Run switch to elscreen action from `anything-c-source-buffers-list'.
141 ;; `anything-buffer-run-ediff'
142 ;; Run ediff action from `anything-c-source-buffers-list'.
143 ;; `anything-buffer-run-ediff-merge'
144 ;; Run ediff action from `anything-c-source-buffers-list'.
145 ;; `anything-ff-run-toggle-auto-update'
147 ;; `anything-ff-run-switch-to-history'
148 ;; Run Switch to history action from `anything-c-source-find-files'.
149 ;; `anything-ff-run-grep'
150 ;; Run Grep action from `anything-c-source-find-files'.
151 ;; `anything-ff-run-pdfgrep'
152 ;; Run Pdfgrep action from `anything-c-source-find-files'.
153 ;; `anything-ff-run-zgrep'
154 ;; Run Grep action from `anything-c-source-find-files'.
155 ;; `anything-ff-run-copy-file'
156 ;; Run Copy file action from `anything-c-source-find-files'.
157 ;; `anything-ff-run-rename-file'
158 ;; Run Rename file action from `anything-c-source-find-files'.
159 ;; `anything-ff-run-byte-compile-file'
160 ;; Run Byte compile file action from `anything-c-source-find-files'.
161 ;; `anything-ff-run-load-file'
162 ;; Run Load file action from `anything-c-source-find-files'.
163 ;; `anything-ff-run-eshell-command-on-file'
164 ;; Run eshell command on file action from `anything-c-source-find-files'.
165 ;; `anything-ff-run-ediff-file'
166 ;; Run Ediff file action from `anything-c-source-find-files'.
167 ;; `anything-ff-run-ediff-merge-file'
168 ;; Run Ediff merge file action from `anything-c-source-find-files'.
169 ;; `anything-ff-run-symlink-file'
170 ;; Run Symlink file action from `anything-c-source-find-files'.
171 ;; `anything-ff-run-delete-file'
172 ;; Run Delete file action from `anything-c-source-find-files'.
173 ;; `anything-ff-run-complete-fn-at-point'
174 ;; Run complete file name action from `anything-c-source-find-files'.
175 ;; `anything-ff-run-switch-to-eshell'
176 ;; Run switch to eshell action from `anything-c-source-find-files'.
177 ;; `anything-ff-run-switch-other-window'
178 ;; Run switch to other window action from `anything-c-source-find-files'.
179 ;; `anything-ff-run-switch-other-frame'
180 ;; Run switch to other frame action from `anything-c-source-find-files'.
181 ;; `anything-ff-run-open-file-externally'
182 ;; Run open file externally command action from `anything-c-source-find-files'.
183 ;; `anything-ff-run-locate'
184 ;; Run locate action from `anything-c-source-find-files'.
185 ;; `anything-ff-run-gnus-attach-files'
186 ;; Run gnus attach files command action from `anything-c-source-find-files'.
187 ;; `anything-ff-run-etags'
188 ;; Run Etags command action from `anything-c-source-find-files'.
189 ;; `anything-ff-run-print-file'
190 ;; Run Print file action from `anything-c-source-find-files'.
191 ;; `anything-ff-run-toggle-basename'
193 ;; `anything-find-files-down-one-level'
194 ;; Go down one level like unix command `cd ..'.
195 ;; `anything-ff-properties-persistent'
196 ;; Show properties without quitting anything.
197 ;; `anything-ff-run-kill-buffer-persistent'
198 ;; Execute `anything-ff-kill-buffer-fname' whitout quitting.
199 ;; `anything-ff-rotate-left-persistent'
200 ;; Rotate image left without quitting anything.
201 ;; `anything-ff-rotate-right-persistent'
202 ;; Rotate image right without quitting anything.
203 ;; `anything-c-goto-precedent-file'
204 ;; Go to precedent file in anything grep/etags buffers.
205 ;; `anything-c-goto-next-file'
206 ;; Go to precedent file in anything grep/etags buffers.
207 ;; `anything-c-grep-run-persistent-action'
208 ;; Run grep persistent action from `anything-do-grep-1'.
209 ;; `anything-c-grep-run-default-action'
210 ;; Run grep default action from `anything-do-grep-1'.
211 ;; `anything-c-grep-run-other-window-action'
212 ;; Run grep goto other window action from `anything-do-grep-1'.
213 ;; `anything-c-grep-run-save-buffer'
214 ;; Run grep save results action from `anything-do-grep-1'.
215 ;; `anything-do-pdfgrep'
217 ;; `anything-yank-text-at-point'
218 ;; Yank text at point in minibuffer.
219 ;; `anything-c-describe-attributes'
220 ;; Display the full documentation of ANYTHING-ATTRIBUTE (a symbol).
221 ;; `anything-yaoddmuse-cache-pages'
222 ;; Fetch the list of files on emacswiki and create cache file.
223 ;; `anything-eval-new-line-and-indent'
225 ;; `anything-call-source-from-anything'
226 ;; Call anything source within `anything' session.
227 ;; `anything-create-from-anything'
228 ;; Run `anything-create' from `anything' as a fallback.
229 ;; `anything-c-ucs-persistent-insert'
231 ;; `anything-c-ucs-persistent-forward'
233 ;; `anything-c-ucs-persistent-backward'
235 ;; `anything-c-ucs-persistent-delete'
237 ;; `anything-lisp-completion-at-point'
238 ;; Anything lisp symbol completion at point.
239 ;; `anything-c-complete-file-name-at-point'
240 ;; Complete file name at point.
241 ;; `anything-lisp-completion-at-point-or-indent'
242 ;; First call indent and second call complete lisp symbol.
243 ;; `anything-lisp-completion-or-file-name-at-point'
244 ;; Complete lisp symbol or filename at point.
245 ;; `anything-c-set-variable'
246 ;; Set value to VAR interactively.
247 ;; `anything-c-adaptive-save-history'
248 ;; Save history information to file given by `anything-c-adaptive-history-file'.
249 ;; `anything-c-reset-adaptative-history'
250 ;; Delete all `anything-c-adaptive-history' and his file.
251 ;; `anything-c-toggle-match-plugin'
252 ;; Toggle anything-match-plugin.
254 ;; Preconfigured `anything' lightweight version (buffer -> recentf).
255 ;; `anything-for-files'
256 ;; Preconfigured `anything' for opening files.
257 ;; `anything-recentf'
258 ;; Preconfigured `anything' for `recentf'.
259 ;; `anything-info-at-point'
260 ;; Preconfigured `anything' for searching info at point.
261 ;; `anything-info-emacs'
262 ;; Preconfigured anything for Emacs manual index.
263 ;; `anything-show-kill-ring'
264 ;; Preconfigured `anything' for `kill-ring'.
265 ;; `anything-minibuffer-history'
266 ;; Preconfigured `anything' for `minibuffer-history'.
268 ;; Preconfigured `anything' for gentoo linux.
270 ;; Preconfigured `anything' for `imenu'.
271 ;; `anything-google-suggest'
272 ;; Preconfigured `anything' for google search with google suggest.
273 ;; `anything-yahoo-suggest'
274 ;; Preconfigured `anything' for Yahoo searching with Yahoo suggest.
275 ;; `anything-for-buffers'
276 ;; Preconfigured `anything' for buffer.
277 ;; `anything-buffers-list'
278 ;; Enhanced preconfigured `anything' for buffer.
280 ;; Preconfigured `anything' for BBDB.
282 ;; Preconfigured `anything' for Locate.
283 ;; `anything-w3m-bookmarks'
284 ;; Preconfigured `anything' for w3m bookmark.
285 ;; `anything-firefox-bookmarks'
286 ;; Preconfigured `anything' for firefox bookmark.
288 ;; Preconfigured `anything' for color.
289 ;; `anything-bookmarks'
290 ;; Preconfigured `anything' for bookmarks.
291 ;; `anything-c-pp-bookmarks'
292 ;; Preconfigured `anything' for bookmarks (pretty-printed).
293 ;; `anything-c-insert-latex-math'
294 ;; Preconfigured anything for latex math symbols completion.
295 ;; `anything-register'
296 ;; Preconfigured `anything' for Emacs registers.
297 ;; `anything-man-woman'
298 ;; Preconfigured `anything' for Man and Woman pages.
299 ;; `anything-org-keywords'
300 ;; Preconfigured `anything' for org keywords.
302 ;; Preconfigured `anything' for emms sources.
303 ;; `anything-eev-anchors'
304 ;; Preconfigured `anything' for eev anchors.
305 ;; `anything-bm-list'
306 ;; Preconfigured `anything' for visible bookmarks.
308 ;; Preconfigured `anything' for timers.
309 ;; `anything-list-emacs-process'
310 ;; Preconfigured `anything' for emacs process.
312 ;; Preconfigured Anything for Occur source.
313 ;; `anything-browse-code'
314 ;; Preconfigured anything to browse code.
315 ;; `anything-org-headlines'
316 ;; Preconfigured anything to show org headlines.
317 ;; `anything-info-gnus'
318 ;; Preconfigured anything to browse Gnus Manual.
320 ;; Preconfigured anything to build regexps.
321 ;; `anything-c-copy-files-async'
322 ;; Preconfigured anything to copy file list FLIST to DEST asynchronously.
323 ;; `anything-find-files'
324 ;; Preconfigured `anything' for anything implementation of `find-file'.
325 ;; `anything-write-file'
326 ;; Preconfigured `anything' providing completion for `write-file'.
327 ;; `anything-insert-file'
328 ;; Preconfigured `anything' providing completion for `insert-file'.
329 ;; `anything-dired-rename-file'
330 ;; Preconfigured `anything' to rename files from dired.
331 ;; `anything-dired-copy-file'
332 ;; Preconfigured `anything' to copy files from dired.
333 ;; `anything-dired-symlink-file'
334 ;; Preconfigured `anything' to symlink files from dired.
335 ;; `anything-dired-hardlink-file'
336 ;; Preconfigured `anything' to hardlink files from dired.
337 ;; `anything-do-grep'
338 ;; Preconfigured anything for grep.
339 ;; `anything-c-etags-select'
340 ;; Preconfigured anything for etags.
341 ;; `anything-filelist'
342 ;; Preconfigured `anything' to open files instantly.
343 ;; `anything-filelist+'
344 ;; Preconfigured `anything' to open files/buffers/bookmarks instantly.
346 ;; Preconfigured `anything' for Emacs commands.
347 ;; `anything-manage-advice'
348 ;; Preconfigured `anything' to disable/enable function advices.
349 ;; `anything-bookmark-ext'
350 ;; Preconfigured `anything' for bookmark-extensions sources.
351 ;; `anything-simple-call-tree'
352 ;; Preconfigured `anything' for simple-call-tree. List function relationships.
353 ;; `anything-mark-ring'
354 ;; Preconfigured `anything' for `anything-c-source-mark-ring'.
355 ;; `anything-global-mark-ring'
356 ;; Preconfigured `anything' for `anything-c-source-global-mark-ring'.
357 ;; `anything-all-mark-rings'
358 ;; Preconfigured `anything' for `anything-c-source-global-mark-ring' and `anything-c-source-mark-ring'.
359 ;; `anything-yaoddmuse-emacswiki-edit-or-view'
360 ;; Preconfigured `anything' to edit or view EmacsWiki page.
361 ;; `anything-yaoddmuse-emacswiki-post-library'
362 ;; Preconfigured `anything' to post library to EmacsWiki.
363 ;; `anything-eval-expression'
364 ;; Preconfigured anything for `anything-c-source-evaluation-result'.
365 ;; `anything-eval-expression-with-eldoc'
366 ;; Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support.
367 ;; `anything-calcul-expression'
368 ;; Preconfigured anything for `anything-c-source-calculation-result'.
369 ;; `anything-surfraw'
370 ;; Preconfigured `anything' to search PATTERN with search ENGINE.
371 ;; `anything-call-source'
372 ;; Preconfigured `anything' to call anything source.
373 ;; `anything-execute-anything-command'
374 ;; Preconfigured `anything' to execute preconfigured `anything'.
376 ;; Preconfigured `anything' to do many create actions from STRING.
378 ;; Preconfigured `anything' for top command.
379 ;; `anything-select-xfont'
380 ;; Preconfigured `anything' to select Xfont.
381 ;; `anything-world-time'
382 ;; Preconfigured `anything' to show world time.
384 ;; Preconfigured `anything' : frontend of APT package manager.
385 ;; `anything-esh-pcomplete'
386 ;; Preconfigured anything to provide anything completion in eshell.
387 ;; `anything-eshell-history'
388 ;; Preconfigured anything for eshell history.
389 ;; `anything-c-run-external-command'
390 ;; Preconfigured `anything' to run External PROGRAM asyncronously from Emacs.
391 ;; `anything-ratpoison-commands'
392 ;; Preconfigured `anything' to execute ratpoison commands.
394 ;; Preconfigured anything for `ucs-names' math symbols.
395 ;; `anything-c-apropos'
396 ;; Preconfigured anything to describe commands, functions, variables and faces.
398 ;; * User variables defined here:
399 ;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "anything-" :var-value t)
400 ;; `anything-c-adaptive-history-file'
401 ;; Default Value: "~/.emacs.d/anything-c-adaptive-history"
402 ;; `anything-c-adaptive-history-length'
404 ;; `anything-c-google-suggest-url'
405 ;; Default Value: "http://google.com/complete/search?output=toolbar&q="
406 ;; `anything-c-google-suggest-search-url'
407 ;; Default Value: "http://www.google.com/search?ie=utf-8&oe=utf-8&q="
408 ;; `anything-google-suggest-use-curl-p'
409 ;; Default Value: nil
410 ;; `anything-c-yahoo-suggest-url'
411 ;; Default Value: "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=G [...]
412 ;; `anything-c-yahoo-suggest-search-url'
413 ;; Default Value: "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p="
414 ;; `anything-c-boring-buffer-regexp'
415 ;; Default Value: "\\ (\\` \\)\\|\\*anything\\|\\*ac-mode\\| \\*Echo Area\\| \\*Minibuf"
416 ;; `anything-c-boring-file-regexp'
417 ;; Default Value: "/\\ (?:\\(?:\\.\\(?:git\\|hg\\|svn\\)\\|CVS\\|_darcs\\)\\)\\(?:/\\|$\\)\\| [...]
418 ;; `anything-kill-ring-threshold'
420 ;; `anything-c-kill-ring-max-lines-number'
421 ;; Default Value: nil
422 ;; `anything-su-or-sudo'
423 ;; Default Value: "su"
424 ;; `anything-for-files-prefered-list'
425 ;; Default Value: (anything-c-source-ffap-line anything-c-source-ffap-guesser anything-c-sou [...]
426 ;; `anything-create--actions-private'
427 ;; Default Value: nil
428 ;; `anything-allow-skipping-current-buffer'
430 ;; `anything-c-enable-eval-defun-hack'
432 ;; `anything-tramp-verbose'
434 ;; `anything-raise-command'
435 ;; Default Value: nil
436 ;; `anything-command-map-prefix-key'
437 ;; Default Value: "<f5> a"
438 ;; `anything-c-browse-code-regexp-lisp'
439 ;; Default Value: "^ * (def\\(un\\|subst\\|macro\\|face\\|alias\\|advice\\|struct\\|type\\|th [...]
440 ;; `anything-c-browse-code-regexp-python'
441 ;; Default Value: "\\<def\\>\\|\\<class\\>"
442 ;; `anything-c-browse-code-regexp-alist'
443 ;; Default Value: ((lisp-interaction-mode . "^ *(def\\(un\\|subst\\|macro\\|face\\|alias\\|a [...]
444 ;; `anything-c-external-programs-associations'
445 ;; Default Value: nil
446 ;; `anything-ff-auto-update-initial-value'
448 ;; `anything-c-copy-async-prefered-emacs'
449 ;; Default Value: "emacs"
450 ;; `anything-ff-lynx-style-map'
452 ;; `anything-ff-history-max-length'
453 ;; Default Value: 100
454 ;; `anything-ff-smart-completion'
456 ;; `anything-ff-default-kbsize'
457 ;; Default Value: 1024.0
458 ;; `anything-ff-tramp-not-fancy'
460 ;; `anything-ff-exif-data-program'
461 ;; Default Value: "exiftran"
462 ;; `anything-ff-exif-data-program-args'
463 ;; Default Value: "-d"
464 ;; `anything-c-grep-use-ioccur-style-keys'
466 ;; `anything-c-pdfgrep-default-read-command'
467 ;; Default Value: "xpdf '%f' %p"
468 ;; `anything-c-etags-tag-file-name'
469 ;; Default Value: "TAGS"
470 ;; `anything-c-etags-tag-file-search-limit'
472 ;; `anything-c-etags-use-regexp-search'
473 ;; Default Value: nil
474 ;; `anything-c-etags-search-regexp'
475 ;; Default Value: "^.+: .+ \\<%s"
476 ;; `anything-c-filelist-file-name'
477 ;; Default Value: nil
478 ;; `anything-c-eldoc-in-minibuffer-show-fn'
479 ;; Default Value: anything-c-show-info-in-mode-line
480 ;; `anything-c-turn-on-show-completion'
482 ;; `anything-lisp-completion-or-indent-delay'
483 ;; Default Value: 0.6
484 ;; `anything-c-default-external-file-browser'
485 ;; Default Value: "nautilus"
486 ;; `anything-c-use-adaptative-sorting'
487 ;; Default Value: nil
488 ;; `anything-ff-newfile-prompt-p'
490 ;; `anything-ff-avfs-directory'
491 ;; Default Value: nil
492 ;; `anything-ff-file-compressed-list'
493 ;; Default Value: ("gz" "bz2" "zip" "7z")
494 ;; `anything-locate-db-file-regexp'
495 ;; Default Value: "m?locate.db$"
496 ;; `anything-c-show-info-in-mode-line-delay'
498 ;; `anything-c-copy-files-async-log-file'
499 ;; Default Value: "/tmp/dired.log"
500 ;; `anything-ff-printer-list'
501 ;; Default Value: nil
502 ;; `anything-ff-transformer-show-only-basename'
503 ;; Default Value: nil
504 ;; `anything-completing-read-handlers-alist'
505 ;; Default Value: ((describe-function . anything-completing-read-symbols) (describe-variabl [...]
507 ;; * Anything sources defined here:
508 ;; [EVAL] (autodoc-document-lisp-buffer :type 'anything-source :prefix "anything-" :any-sname t)
509 ;; `anything-c-source-regexp' (Regexp Builder)
510 ;; `anything-c-source-buffers' (Buffers)
511 ;; `anything-c-source-buffer-not-found' (Create buffer)
512 ;; `anything-c-source-buffers-list' (Buffers)
513 ;; `anything-c-source-file-name-history' (File Name History)
514 ;; `anything-c-source-files-in-current-dir' (Files from Current Directory)
515 ;; `anything-c-source-files-in-current-dir+' (Files from Current Directory)
516 ;; `anything-c-source-find-files' (Find Files)
517 ;; `anything-c-source-write-file' (Write File)
518 ;; `anything-c-source-insert-file' (Insert File)
519 ;; `anything-c-source-copy-files' (Copy Files)
520 ;; `anything-c-source-symlink-files' (Symlink Files)
521 ;; `anything-c-source-hardlink-files' (Hardlink Files)
522 ;; `anything-c-source-file-cache' (File Cache)
523 ;; `anything-c-source-locate' (Locate)
524 ;; `anything-c-source-recentf' (Recentf)
525 ;; `anything-c-source-ffap-guesser' (File at point)
526 ;; `anything-c-source-ffap-line' (File/Lineno at point)
527 ;; `anything-c-source-files-in-all-dired' (Files in all dired buffer.)
528 ;; `anything-c-source-filelist' (FileList)
529 ;; `anything-c-source-info-pages' (Info Pages)
530 ;; `anything-c-source-info-elisp' (Info index: elisp)
531 ;; `anything-c-source-info-cl' (Info index: cl)
532 ;; `anything-c-source-info-org' (Info index: org)
533 ;; `anything-c-source-info-gnus' (Info index: Gnus)
534 ;; `anything-c-source-info-ratpoison' (Info index: ratpoison)
535 ;; `anything-c-source-info-zsh' (Info index: zsh)
536 ;; `anything-c-source-info-bash' (Info index: bash)
537 ;; `anything-c-source-info-coreutils' (Info index: coreutils)
538 ;; `anything-c-source-info-fileutils' (Info index: fileutils)
539 ;; `anything-c-source-info-find' (Info index: find)
540 ;; `anything-c-source-info-sh-utils' (Info index: sh-utils)
541 ;; `anything-c-source-info-textutils' (Info index: textutils)
542 ;; `anything-c-source-info-libc' (Info index: libc)
543 ;; `anything-c-source-info-make' (Info index: make)
544 ;; `anything-c-source-info-automake' (Info index: automake)
545 ;; `anything-c-source-info-autoconf' (Info index: autoconf)
546 ;; `anything-c-source-info-emacs-lisp-intro' (Info index: emacs-lisp-intro)
547 ;; `anything-c-source-info-emacs' (Info index: emacs)
548 ;; `anything-c-source-info-elib' (Info index: elib)
549 ;; `anything-c-source-info-eieio' (Info index: eieio)
550 ;; `anything-c-source-info-gauche-refe' (Info index: gauche)
551 ;; `anything-c-source-info-guile' (Info index: guile)
552 ;; `anything-c-source-info-guile-tut' (Info index: guile-tut)
553 ;; `anything-c-source-info-goops' (Info index: goops)
554 ;; `anything-c-source-info-screen' (Info index: screen)
555 ;; `anything-c-source-info-latex' (Info index: latex)
556 ;; `anything-c-source-info-gawk' (Info index: gawk)
557 ;; `anything-c-source-info-sed' (Info index: sed)
558 ;; `anything-c-source-info-m4' (Info index: m4)
559 ;; `anything-c-source-info-wget' (Info index: wget)
560 ;; `anything-c-source-info-binutils' (Info index: binutils)
561 ;; `anything-c-source-info-as' (Info index: as)
562 ;; `anything-c-source-info-bfd' (Info index: bfd)
563 ;; `anything-c-source-info-gprof' (Info index: gprof)
564 ;; `anything-c-source-info-ld' (Info index: ld)
565 ;; `anything-c-source-info-diff' (Info index: diff)
566 ;; `anything-c-source-info-flex' (Info index: flex)
567 ;; `anything-c-source-info-grep' (Info index: grep)
568 ;; `anything-c-source-info-gzip' (Info index: gzip)
569 ;; `anything-c-source-info-libtool' (Info index: libtool)
570 ;; `anything-c-source-info-texinfo' (Info index: texinfo)
571 ;; `anything-c-source-info-info' (Info index: info)
572 ;; `anything-c-source-info-gdb' (Info index: gdb)
573 ;; `anything-c-source-info-stabs' (Info index: stabs)
574 ;; `anything-c-source-info-cvsbook' (Info index: cvsbook)
575 ;; `anything-c-source-info-cvs' (Info index: cvs)
576 ;; `anything-c-source-info-bison' (Info index: bison)
577 ;; `anything-c-source-info-id-utils' (Info index: id-utils)
578 ;; `anything-c-source-info-global' (Info index: global)
579 ;; `anything-c-source-man-pages' (Manual Pages)
580 ;; `anything-c-source-complex-command-history' (Complex Command History)
581 ;; `anything-c-source-extended-command-history' (Emacs Commands History)
582 ;; `anything-c-source-emacs-commands' (Emacs Commands)
583 ;; `anything-c-source-emacs-functions' (Emacs Functions)
584 ;; `anything-c-source-emacs-functions-with-abbrevs' (Emacs Functions)
585 ;; `anything-c-source-advice' (Function Advice)
586 ;; `anything-c-source-emacs-variables' (Emacs Variables)
587 ;; `anything-c-source-lacarte' (Lacarte)
588 ;; `anything-c-source-bookmarks' (Bookmarks)
589 ;; `anything-c-source-bookmark-set' (Set Bookmark)
590 ;; `anything-c-source-bm' (Visible Bookmarks)
591 ;; `anything-c-source-bookmarks-ssh' (Bookmarks-ssh)
592 ;; `anything-c-source-bookmarks-su' (Bookmarks-root)
593 ;; `anything-c-source-bookmarks-local' (Bookmarks-Local)
594 ;; `anything-c-source-bmkext-addressbook' (Bookmark Addressbook)
595 ;; `anything-c-source-bookmark-w3m' (Bookmark W3m)
596 ;; `anything-c-source-bookmark-images' (Bookmark Images)
597 ;; `anything-c-source-bookmark-man' (Bookmark Woman&Man)
598 ;; `anything-c-source-bookmark-gnus' (Bookmark Gnus)
599 ;; `anything-c-source-bookmark-info' (Bookmark Info)
600 ;; `anything-c-source-bookmark-files&dirs' (Bookmark Files&Directories)
601 ;; `anything-c-source-bookmark-su-files&dirs' (Bookmark Root-Files&Directories)
602 ;; `anything-c-source-bookmark-ssh-files&dirs' (Bookmark Ssh-Files&Directories)
603 ;; `anything-c-source-firefox-bookmarks' (Firefox Bookmarks)
604 ;; `anything-c-source-w3m-bookmarks' (W3m Bookmarks)
605 ;; `anything-c-source-elisp-library-scan' (Elisp libraries (Scan))
606 ;; `anything-c-source-imenu' (Imenu)
607 ;; `anything-c-source-ctags' (Exuberant ctags)
608 ;; `anything-c-source-etags-select' (Etags)
609 ;; `anything-c-source-semantic' (Semantic Tags)
610 ;; `anything-c-source-simple-call-tree-functions-callers' (Function is called by)
611 ;; `anything-c-source-simple-call-tree-callers-functions' (Function calls)
612 ;; `anything-c-source-commands-and-options-in-file' (Commands/Options in file)
613 ;; `anything-c-source-customize-face' (Customize Face)
614 ;; `anything-c-source-colors' (Colors)
615 ;; `anything-c-source-tracker-search' (Tracker Search)
616 ;; `anything-c-source-mac-spotlight' (mdfind)
617 ;; `anything-c-source-picklist' (Picklist)
618 ;; `anything-c-source-kill-ring' (Kill Ring)
619 ;; `anything-c-source-mark-ring' (mark-ring)
620 ;; `anything-c-source-global-mark-ring' (global-mark-ring)
621 ;; `anything-c-source-register' (Registers)
622 ;; `anything-c-source-latex-math' (Latex Math Menu)
623 ;; `anything-c-source-fixme' (TODO/FIXME/DRY comments)
624 ;; `anything-c-source-rd-headline' (RD HeadLine)
625 ;; `anything-c-source-oddmuse-headline' (Oddmuse HeadLine)
626 ;; `anything-c-source-emacs-source-defun' (Emacs Source DEFUN)
627 ;; `anything-c-source-emacs-lisp-expectations' (Emacs Lisp Expectations)
628 ;; `anything-c-source-emacs-lisp-toplevels' (Emacs Lisp Toplevel / Level 4 Comment / Linkd Star)
629 ;; `anything-c-source-yaoddmuse-emacswiki-edit-or-view' (Yaoddmuse Edit or View (EmacsWiki))
630 ;; `anything-c-source-yaoddmuse-emacswiki-post-library' (Yaoddmuse Post library (EmacsWiki))
631 ;; `anything-c-source-eev-anchor' (Anchors)
632 ;; `anything-c-source-org-headline' (Org HeadLine)
633 ;; `anything-c-source-org-keywords' (Org Keywords)
634 ;; `anything-c-source-bbdb' (BBDB)
635 ;; `anything-c-source-evaluation-result' (Evaluation Result)
636 ;; `anything-c-source-calculation-result' (Calculation Result)
637 ;; `anything-c-source-google-suggest' (Google Suggest)
638 ;; `anything-c-source-yahoo-suggest' (Yahoo Suggest)
639 ;; `anything-c-source-emms-streams' (Emms Streams)
640 ;; `anything-c-source-emms-dired' (Music Directory)
641 ;; `anything-c-source-emms-files' (Emms files)
642 ;; `anything-c-source-jabber-contacts' (Jabber Contacts)
643 ;; `anything-c-source-call-source' (Call anything source)
644 ;; `anything-c-source-anything-commands' (Preconfigured Anything)
645 ;; `anything-c-source-occur' (Occur)
646 ;; `anything-c-source-browse-code' (Browse code)
647 ;; `anything-c-source-create' (Create)
648 ;; `anything-c-source-minibuffer-history' (Minibuffer History)
649 ;; `anything-c-source-elscreen' (Elscreen)
650 ;; `anything-c-source-top' (Top (Press C-c C-u to refresh))
651 ;; `anything-c-source-absolute-time-timers' (Absolute Time Timers)
652 ;; `anything-c-source-idle-time-timers' (Idle Time Timers)
653 ;; `anything-c-source-xrandr-change-resolution' (Change Resolution)
654 ;; `anything-c-source-xfonts' (X Fonts)
655 ;; `anything-c-source-ucs' (Ucs names)
656 ;; `anything-c-source-emacs-process' (Emacs Process)
657 ;; `anything-c-source-time-world' (Time World List)
658 ;; `anything-c-source-apt' (APT)
659 ;; `anything-c-source-gentoo' (Portage sources)
660 ;; `anything-c-source-use-flags' (Use Flags)
661 ;; `anything-c-source-ratpoison-commands' (Ratpoison Commands)
662 ;; `anything-c-source-esh' (Eshell completions)
663 ;; `anything-c-source-eshell-history' (Eshell history)
665 ;; *** END auto-documentation
669 ;; Install developer-tools/autodoc.el and
670 ;; Evaluate (autodoc-update-all) before commit or run it interactively.
671 ;; This function generates anything-c-source-* / functions / options list.
673 ;; [EVAL IT] (autodoc-update-all)
675 ;; Please write details documentation about function, then others will
676 ;; read code more easier. -- Andy Stewart
682 ;; Change log of this file is found at
683 ;; http://repo.or.cz/w/anything-config.git/history/master:/anything-config.el
685 ;; Change log of this project is found at
686 ;; http://repo.or.cz/w/anything-config.git?a=shortlog
691 ;; Tassilo Horn <tassilo@member.fsf.org>
692 ;; Vagn Johansen <gonz808@hotmail.com>
693 ;; Mathias Dahl <mathias.dahl@gmail.com>
694 ;; Bill Clementson <billclem@gmail.com>
695 ;; Stefan Kamphausen (see http://www.skamphausen.de for more informations)
696 ;; Drew Adams <drew.adams@oracle.com>
697 ;; Jason McBrayer <jmcbray@carcosa.net>
698 ;; Andy Stewart <lazycat.manatee@gmail.com>
699 ;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
700 ;; rubikitch <rubikitch@ruby-lang.org>
701 ;; Scott Vokes <vokes.s@gmail.com>
702 ;; Kenichirou Oyama <k1lowxb@gmail.com>
707 ;; - Fix documentation, now many functions haven't documentations.
726 (eval-when-compile (require 'org
)) ; Shut up byte compiler about org-directory.
727 (eval-when-compile (require 'semantic nil t
))
728 (require 'anything-match-plugin
)
732 ;;; Declare external functions
735 (declare-function gnus-dired-attach
"ext:gnus-dired.el" (files-to-attach))
736 (declare-function image-dired-display-image
"image-dired.el" (file &optional original-size
))
737 (declare-function image-dired-update-property
"image-dired.el" (prop value
))
738 (declare-function woman-file-name-all-completions
"woman.el" (topic))
739 (declare-function Man-getpage-in-background
"man.el" (topic))
740 (declare-function simple-call-tree-analyze
"ext:simple-call-tree.el" (&optional test
))
741 (declare-function yaoddmuse-update-pagename
"ext:yaoddmuse.el" (&optional unforced
))
742 (declare-function yaoddmuse-get-library-list
"ext:yaoddmuse.el" (&optional dirs string
))
743 (declare-function org-get-current-options
"ext:org-exp.el")
744 (declare-function emms-streams
"ext:emms-streams")
745 (declare-function emms-stream-delete-bookmark
"ext:emms-streams")
746 (declare-function emms-stream-add-bookmark
"ext:emms-streams" (name url fd type
))
747 (declare-function emms-stream-save-bookmarks-file
"ext:emms-streams")
748 (declare-function emms-stream-quit
"ext:emms-streams")
749 (declare-function with-current-emms-playlist
"ext:emms" (&rest body
))
750 (declare-function emms-playlist-tracks-in-region
"ext:emms" (beg end
))
751 (declare-function emms-playlist-first
"ext:emms")
752 (declare-function emms-playlist-mode-play-smart
"ext:emms-playlist-mode")
753 (declare-function term-line-mode
"term")
754 (declare-function term-char-mode
"term")
755 (declare-function term-send-input
"term")
756 (declare-function term-send-eof
"term")
757 (declare-function Info-index-nodes
"info" (&optional file
))
758 (declare-function Info-goto-node
"info" (&optional fork
))
759 (declare-function Info-find-node
"info.el" (filename nodename
&optional no-going-back
))
760 (declare-function elscreen-find-screen-by-buffer
"ext:elscreen.el" (buffer &optional create
))
761 (declare-function elscreen-find-file
"ext:elscreen.el" (filename))
762 (declare-function elscreen-goto
"ext:elscreen.el" (screen))
763 (declare-function semantic-format-tag-summarize
"ext:format.el" (tag &optional parent color
) t
)
764 (declare-function semantic-tag-components
"ext:tag.el" (tag) t
)
765 (declare-function semantic-go-to-tag
"ext:tag-file.el" (tag) t
)
766 (declare-function semantic-tag-type
"ext:tag-file.el" (tag) t
)
767 (declare-function semantic-tag-class
"ext:tag-file.el" (tag) t
)
768 (declare-function bbdb
"ext:bbdb-com")
769 (declare-function bbdb-current-record
"ext:bbdb-com")
770 (declare-function bbdb-redisplay-one-record
"ext:bbdb-com")
771 (declare-function bbdb-record-net
"ext:bbdb-com" (string) t
)
772 (declare-function bbdb-current-record
"ext:bbdb-com")
773 (declare-function bbdb-dwim-net-address
"ext:bbdb-com")
774 (declare-function bbdb-records
"ext:bbdb-com"
775 (&optional dont-check-disk already-in-db-buffer
))
776 (declare-function eshell-read-aliases-list
"em-alias")
777 (declare-function eshell-send-input
"esh-mode" (&optional use-region queue-p no-newline
))
778 (declare-function eshell-bol
"esh-mode")
779 (declare-function eldoc-current-symbol
"eldoc")
780 (declare-function eldoc-get-fnsym-args-string
"eldoc" (sym &optional index
))
781 (declare-function eldoc-get-var-docstring
"eldoc" (sym))
782 (declare-function eldoc-fnsym-in-current-sexp
"eldoc")
783 (declare-function find-library-name
"find-func.el" (library))
784 (declare-function adoc-construct
"ext:auto-document.el" (buf))
785 (declare-function adoc-first-line
"ext:auto-document.el" (str))
786 (declare-function adoc-prin1-to-string
"ext:auto-document.el" (object))
787 (declare-function secure-hash
"ext:fns.c" (algorithm object
&optional start end binary
))
794 (unless (fboundp 'window-system
)
795 (defun window-system (&optional arg
)
803 (defgroup anything-config nil
804 "Predefined configurations for `anything.el'."
807 (defcustom anything-c-adaptive-history-file
808 "~/.emacs.d/anything-c-adaptive-history"
809 "Path of file where history information is stored."
811 :group
'anything-config
)
813 (defcustom anything-c-adaptive-history-length
50
814 "Maximum number of candidates stored for a source."
816 :group
'anything-config
)
818 (defcustom anything-c-google-suggest-url
819 "http://google.com/complete/search?output=toolbar&q="
820 "URL used for looking up Google suggestions."
822 :group
'anything-config
)
824 (defcustom anything-c-google-suggest-search-url
825 "http://www.google.com/search?ie=utf-8&oe=utf-8&q="
826 "URL used for Google searching."
828 :group
'anything-config
)
830 (defcustom anything-google-suggest-use-curl-p nil
831 "*When non--nil use CURL to get info from `anything-c-google-suggest-url'.
832 Otherwise `url-retrieve-synchronously' is used."
834 :group
'anything-config
)
836 (defcustom anything-c-yahoo-suggest-url
837 "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=Generic&query="
838 "Url used for looking up Yahoo suggestions."
840 :group
'anything-config
)
842 (defcustom anything-c-yahoo-suggest-search-url
843 "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p="
844 "Url used for Yahoo searching."
846 :group
'anything-config
)
848 (defcustom anything-c-boring-buffer-regexp
852 "*anything" "*ac-mode"
854 " *Echo Area" " *Minibuf"))
855 "The regexp that match boring buffers.
856 Buffer candidates matching this regular expression will be
857 filtered from the list of candidates if the
858 `anything-c-skip-boring-buffers' candidate transformer is used, or
859 they will be displayed with face `file-name-shadow' if
860 `anything-c-shadow-boring-buffers' is used."
862 :group
'anything-config
)
863 ;; (string-match anything-c-boring-buffer-regexp "buf")
864 ;; (string-match anything-c-boring-buffer-regexp " hidden")
865 ;; (string-match anything-c-boring-buffer-regexp " *Minibuf-1*")
867 (defcustom anything-c-boring-file-regexp
869 ;; Boring directories
870 (and "/" (or ".svn" "CVS" "_darcs" ".git" ".hg") (or "/" eol
))
872 (and line-start
".#")
873 (and (or ".class" ".la" ".o" "~") eol
)))
874 "The regexp that match boring files.
875 File candidates matching this regular expression will be
876 filtered from the list of candidates if the
877 `anything-c-skip-boring-files' candidate transformer is used, or
878 they will be displayed with face `file-name-shadow' if
879 `anything-c-shadow-boring-files' is used."
881 :group
'anything-config
)
883 (defcustom anything-kill-ring-threshold
10
884 "*Minimum length to be listed by `anything-c-source-kill-ring'."
886 :group
'anything-config
)
888 (defcustom anything-c-kill-ring-max-lines-number nil
889 "Max number of lines displayed per candidate in kill-ring browser.
890 If nil or zero, don't truncate candidate, show all."
892 :group
'anything-config
)
894 (defcustom anything-su-or-sudo
"su"
895 "What command to use for root access."
897 :group
'anything-config
)
899 (defcustom anything-for-files-prefered-list
900 '(anything-c-source-ffap-line
901 anything-c-source-ffap-guesser
902 anything-c-source-buffers-list
903 anything-c-source-recentf
904 anything-c-source-bookmarks
905 anything-c-source-file-cache
906 anything-c-source-files-in-current-dir
+
907 anything-c-source-locate
)
908 "Your prefered sources to find files."
910 :group
'anything-config
)
912 (defcustom anything-create--actions-private nil
913 "User defined actions for `anything-create' / `anything-c-source-create'.
914 It is a list of (DISPLAY . FUNCTION) pairs like `action'
915 attribute of `anything-sources'.
917 It is prepended to predefined pairs."
919 :group
'anything-config
)
921 (defcustom anything-allow-skipping-current-buffer t
922 "Show current buffer or not in anything buffer"
924 :group
'anything-config
)
926 (defcustom anything-c-enable-eval-defun-hack t
927 "*If non-nil, execute `anything' using the source at point when C-M-x is pressed.
928 This hack is invoked when pressing C-M-x in the form \
929 (defvar anything-c-source-XXX ...) or (setq anything-c-source-XXX ...)."
931 :group
'anything-config
)
933 (defcustom anything-tramp-verbose
0
934 "*Just like `tramp-verbose' but specific to anything.
935 When set to 0 don't show tramp messages in anything.
936 If you want to have the default tramp messages set it to 3."
938 :group
'anything-config
)
940 (defcustom anything-raise-command nil
941 "*A shell command to jump to a window running specific program.
942 Need external program wmctrl.
943 This will be use with `format', so use something like \"wmctrl -xa %s\"."
945 :group
'anything-config
)
947 (defun anything-set-anything-command-map-prefix-key (var key
)
948 (declare (special anything-command-map-prefix-key
))
949 (when (boundp 'anything-command-map-prefix-key
)
950 (global-unset-key (read-kbd-macro anything-command-map-prefix-key
)))
951 (setq anything-command-map-prefix-key key
)
952 (global-set-key (read-kbd-macro anything-command-map-prefix-key
)
953 'anything-command-map
))
955 (defcustom anything-command-map-prefix-key
"<f5> a"
956 "*The prefix key for all `anything-command-map' commands.
959 This default value is very likely to be changed,
960 because it is under discussion."
962 :set
'anything-set-anything-command-map-prefix-key
963 :group
'anything-config
)
965 (defcustom anything-c-browse-code-regexp-lisp
966 "^ *\(def\\(un\\|subst\\|macro\\|face\\|alias\\|advice\\|struct\\|\
967 type\\|theme\\|var\\|group\\|custom\\|const\\|method\\|class\\)"
968 "*Regexp used to parse lisp buffer when browsing code."
970 :group
'anything-config
)
972 (defcustom anything-c-browse-code-regexp-python
973 "\\<def\\>\\|\\<class\\>"
974 "*Regexp used to parse python buffer when browsing code."
976 :group
'anything-config
)
978 (defcustom anything-c-browse-code-regexp-alist
979 `((lisp-interaction-mode .
,anything-c-browse-code-regexp-lisp
)
980 (emacs-lisp-mode .
,anything-c-browse-code-regexp-lisp
)
981 (lisp-mode .
,anything-c-browse-code-regexp-lisp
)
982 (python-mode .
,anything-c-browse-code-regexp-python
))
983 "*Alist to store regexps for browsing code corresponding \
984 to a specific `major-mode'."
986 :group
'anything-config
)
988 (defcustom anything-c-external-programs-associations nil
989 "*Alist to store externals programs associated with file extension.
990 This variable overhide setting in .mailcap file.
991 e.g : '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) "
993 :group
'anything-config
)
995 (defcustom anything-ff-auto-update-initial-value t
996 "Auto update when only one candidate directory is matched.
997 This is the default value when starting `anything-find-files'."
998 :group
'anything-config
1001 (defcustom anything-c-copy-async-prefered-emacs
"emacs"
1002 "Path to the emacs you want to use for copying async.
1003 Emacs versions < 24 fail to copy directory due to a bug not fixed
1004 in `copy-directory'."
1005 :group
'anything-config
1008 (defcustom anything-ff-lynx-style-map t
1009 "Use arrow keys to navigate with `anything-find-files'.
1010 You will have to restart Emacs or reeval `anything-find-files-map'
1011 and `anything-c-read-file-map' for this take effect."
1012 :group
'anything-config
1015 (defcustom anything-ff-history-max-length
100
1016 "*Number of elements shown in `anything-find-files' history."
1017 :group
'anything-config
1020 (defcustom anything-ff-smart-completion t
1021 "Try to complete filenames smarter when non--nil.
1022 See `anything-ff-transform-fname-for-completion' for more info."
1023 :group
'anything-config
1026 (defcustom anything-ff-default-kbsize
1024.0
1027 "Default Kbsize to use for showing files size.
1028 It is a float, usually 1024.0 but could be 1000.0 on some systems."
1029 :group
'anything-config
1032 (defcustom anything-ff-tramp-not-fancy t
1033 "No colors when listing remote files when set to non--nil.
1034 This make listing much faster, specially on slow machines."
1035 :group
'anything-config
1038 (defcustom anything-ff-exif-data-program
"exiftran"
1039 "*Program used to extract exif data of an image file."
1040 :group
'anything-config
1043 (defcustom anything-ff-exif-data-program-args
"-d"
1044 "*Arguments used for `anything-ff-exif-data-program'."
1045 :group
'anything-config
1048 (defcustom anything-c-grep-use-ioccur-style-keys t
1049 "Use Arrow keys to jump to occurences."
1050 :group
'anything-config
1053 (defcustom anything-c-pdfgrep-default-read-command
"xpdf '%f' %p"
1054 "Default command to read pdf files from pdfgrep.
1055 Where '%f' format spec is filename and '%p' is page number"
1056 :group
'anything-config
1059 (defcustom anything-c-etags-tag-file-name
"TAGS"
1060 "Etags tag file name."
1062 :group
'anything-config
)
1064 (defcustom anything-c-etags-tag-file-search-limit
10
1065 "The limit level of directory to search tag file.
1066 Don't search tag file deeply if outside this value."
1068 :group
'anything-config
)
1070 (defcustom anything-c-etags-use-regexp-search nil
1071 "When non--nil search etags candidates by regexp.
1072 This disable anything-match-plugin when enabled.
1073 When nil search is performed directly on patter and *match-plugin is used
1074 if available. You can customize `anything-c-etags-search-regexp'."
1075 :group
'anything-config
1078 (defcustom anything-c-etags-search-regexp
"^.+: .+ \\<%s"
1079 "Regexp that match tags in an anything etags buffer.
1080 The format spec is replaced by pattern.
1081 This regexp have no effect when `anything-c-etags-use-regexp-search'
1083 :group
'anything-config
1086 (defcustom anything-c-filelist-file-name nil
1087 "Filename of file list.
1088 Accept a list of string for multiple files.
1090 This file tend to be very large \(> 100MB\) and recommend to be in ramdisk for speed.
1091 File list is created by make-filelist.rb script.
1094 ruby make-filelist.rb > /tmp/all.filelist
1097 ;; Assume that /tmp is ramdisk or tmpfs
1098 \(setq anything-grep-candidates-fast-directory-regexp \"^/tmp/\"\)
1099 \(setq anything-c-filelist-file-name \"/tmp/all.filelist\"\)
1102 :group
'anything-config
)
1104 (defcustom anything-c-eldoc-in-minibuffer-show-fn
1105 'anything-c-show-info-in-mode-line
1106 "A function to display eldoc info.
1107 Should take one arg: the string to display."
1108 :group
'anything-config
1111 (defcustom anything-c-turn-on-show-completion t
1112 "Display candidate in buffer while moving selection when non--nil."
1113 :group
'anything-config
1116 (defcustom anything-lisp-completion-or-indent-delay
0.6
1117 "After this delay `anything-lisp-completion-counter' is reset to 0.
1118 This allow to indent again without completing lisp symbol after this delay.
1119 Default is 0.6 seconds."
1120 :group
'anything-config
1123 (defcustom anything-c-default-external-file-browser
"nautilus"
1124 "Default external file browser for your system.
1125 Directories will be opened externally with it.
1126 Set to nil if you do not have external file browser
1127 or do not want to use it."
1128 :group
'anything-config
1131 (defcustom anything-c-use-adaptative-sorting nil
1132 "*Wheter to use or not adaptative sorting.
1133 Even if a source use it, it will have no effect when set to nil."
1135 :group
'anything-config
)
1137 (defcustom anything-ff-newfile-prompt-p t
1138 "Whether Prompt or not when creating new file.
1139 This set `ffap-newfile-prompt'."
1141 :group
'anything-config
)
1144 (defcustom anything-ff-avfs-directory nil
1145 "*The default avfs directory, usually '.avfs'.
1146 When this is set you will be able to expand archive filenames with `C-z'
1147 inside an avfs directory mounted with mountavfs.
1148 See <http://sourceforge.net/projects/avf/>."
1150 :group
'anything-config
)
1152 (defcustom anything-ff-file-compressed-list
'("gz" "bz2" "zip" "7z")
1153 "*Minimal list of compressed files extension."
1155 :group
'anything-config
)
1157 (defcustom anything-locate-db-file-regexp
"m?locate\.db$"
1158 "Default regexp to match locate database.
1159 If nil Search in all files."
1161 :group
'anything-config
)
1163 (defcustom anything-c-show-info-in-mode-line-delay
12
1164 "Eldoc will show info in mode-line during this delay if user is idle."
1166 :group
'anything-config
)
1168 (defcustom anything-c-copy-files-async-log-file
"/tmp/dired.log"
1169 "The file used to communicate with two emacs when copying files async."
1171 :group
'anything-config
)
1173 (defcustom anything-ff-printer-list nil
1174 "A list of available printers on your system.
1175 When non--nil let you choose a printer to print file.
1176 Otherwise when nil the variable `printer-name' will be used.
1177 On Unix based systems you can use `anything-ff-find-printers' to
1178 find a list of available printers."
1180 :group
'anything-config
)
1182 (defcustom anything-ff-transformer-show-only-basename nil
1183 "Show only basename of candidates in `anything-find-files'.
1184 This can be toggled at anytime from `anything-find-files' with \
1185 \\<anything-find-files-map>0\\[anything-ff-run-toggle-basename]."
1187 :group
'anything-config
)
1189 (defcustom anything-ff-quick-delete-dont-prompt-for-deletion nil
1190 "Don't ask in persistent deletion of files when non--nil."
1191 :group
'anything-config
1194 (defcustom anything-completing-read-handlers-alist
1195 '((describe-function . anything-completing-read-symbols
)
1196 (describe-variable . anything-completing-read-symbols
)
1197 (debug-on-entry . anything-completing-read-symbols
)
1198 (find-function . anything-completing-read-symbols
)
1199 (trace-function . anything-completing-read-symbols
)
1200 (trace-function-background . anything-completing-read-symbols
)
1201 (find-tag . anything-completing-read-with-cands-in-buffer
)
1202 (ffap-alternate-file . nil
))
1203 "Alist of handlers to replace `completing-read', `read-file-name' in `ac-mode'.
1204 Each entry is a cons cell like \(emacs_command . completing-read_handler\)
1205 where key and value are symbols.
1207 Each key is an Emacs command that use originaly `completing-read'.
1209 Each value maybe an anything function that take same arguments as
1210 `completing-read' plus NAME and BUFFER, where NAME is the name of the new
1211 anything source and BUFFER the name of the buffer we will use.
1212 This function prefix name must start by \"anything\".
1214 See `anything-completing-read-symbols' for example.
1216 If the value of an entry is nil completion will fall back to
1217 emacs vanilla behavior.
1218 e.g If you want to disable anything completion for `describe-function':
1219 \(describe-function . nil\).
1221 Ido is also supported, you can use `ido-completing-read' and
1222 `ido-read-file-name' as value of an entry or just 'ido.
1223 e.g ido completion for `find-file':
1226 \(find-file . ido-read-file-name\)
1227 Note that you don't need to enable `ido-mode' for this to work."
1228 :group
'anything-config
1229 :type
'(alist :key-type symbol
:value-type symbol
))
1233 ;;; General internal variables
1235 ;; Some internals variable that need to be loaded
1236 ;; here to avoid compiler warnings.
1237 (defvar anything-c-external-commands-list nil
1238 "A list of all external commands the user can execute. If this
1239 variable is not set by the user, it will be calculated
1242 (defvar anything-c-show-completion-overlay nil
)
1244 (defvar anything-c-locate-command
1246 ('gnu
/linux
"locate -i -r %s")
1247 ('berkeley-unix
"locate -i %s")
1248 ('windows-nt
"es -i -r %s")
1250 "A list of arguments for locate program.
1251 The \"-r\" option must be the last option.")
1257 (defface anything-buffer-saved-out
1258 '((t (:foreground
"red")))
1259 "*Face used for buffer files modified outside of emacs."
1260 :group
'anything-config
)
1262 (defface anything-buffer-not-saved
1263 '((t (:foreground
"Indianred2")))
1264 "*Face used for buffer files not already saved on disk."
1265 :group
'anything-config
)
1267 (defface anything-ff-prefix
1268 '((t (:background
"yellow" :foreground
"black")))
1269 "*Face used to prefix new file or url paths in `anything-find-files'."
1270 :group
'anything-config
)
1272 (defface anything-ff-executable
1273 '((t (:foreground
"green")))
1274 "*Face used for executable files in `anything-find-files'."
1275 :group
'anything-config
)
1277 (defface anything-ff-directory
1278 '((t (:foreground
"DarkRed" :background
"LightGray")))
1279 "*Face used for directories in `anything-find-files'."
1280 :group
'anything-config
)
1282 (defface anything-ff-symlink
1283 '((t (:foreground
"DarkOrange")))
1284 "*Face used for symlinks in `anything-find-files'."
1285 :group
'anything-config
)
1287 (defface anything-ff-invalid-symlink
1288 '((t (:foreground
"black" :background
"red")))
1289 "*Face used for invalid symlinks in `anything-find-files'."
1290 :group
'anything-config
)
1292 (defface anything-ff-file
1293 '((t (:foreground
"CadetBlue" :underline t
)))
1294 "*Face used for file names in `anything-find-files'."
1295 :group
'anything-config
)
1297 (defface anything-grep-match
1298 '((t (:inherit match
)))
1299 "Face used to highlight grep matches."
1300 :group
'anything-config
)
1302 (defface anything-grep-file
1303 '((t (:foreground
"BlueViolet" :underline t
)))
1304 "Face used to highlight grep results filenames."
1305 :group
'anything-config
)
1307 (defface anything-grep-lineno
1308 '((t (:foreground
"Darkorange1")))
1309 "Face used to highlight grep number lines."
1310 :group
'anything-config
)
1312 (defface anything-grep-running
1313 '((t (:foreground
"Red")))
1314 "Face used in mode line when grep is running."
1315 :group
'anything-config
)
1317 (defface anything-grep-finish
1318 '((t (:foreground
"Green")))
1319 "Face used in mode line when grep is finish."
1320 :group
'anything-config
)
1322 (defface anything-M-x-key-face
'((t (:foreground
"orange" :underline t
)))
1323 "*Face used in anything-M-x to show keybinding."
1326 (defface anything-bmkext-info
1327 '((t (:foreground
"green")))
1328 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
1331 (defface anything-bmkext-w3m
1332 '((t (:foreground
"yellow")))
1333 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
1336 (defface anything-bmkext-gnus
1337 '((t (:foreground
"magenta")))
1338 "*Face used for Gnus bookmarks."
1341 (defface anything-bmkext-man
1342 '((t (:foreground
"Orange4")))
1343 "*Face used for Woman/man bookmarks."
1346 (defface anything-bmkext-no--file
1347 '((t (:foreground
"grey")))
1348 "*Face used for non--file bookmarks."
1351 (defface anything-bmkext-file
1352 '((t (:foreground
"Deepskyblue2")))
1353 "*Face used for non--file bookmarks."
1356 (defface anything-bookmarks-su-face
'((t (:foreground
"red")))
1357 "Face for su/sudo bookmarks."
1360 (defface anything-w3m-bookmarks-face
'((t (:foreground
"cyan1" :underline t
)))
1361 "Face for w3m bookmarks" :group
'anything
)
1363 (defface anything-emms-playlist
1364 '((t (:foreground
"Springgreen4" :underline t
)))
1365 "*Face used for tracks in current emms playlist."
1368 (defface anything-apt-installed
1369 '((t (:foreground
"green")))
1370 "*Face used for apt installed candidates."
1373 (defface anything-gentoo-match-face
'((t (:foreground
"red")))
1374 "Face for anything-gentoo installed packages."
1375 :group
'traverse-faces
)
1377 (defface anything-lisp-show-completion
1378 '((t (:background
"DarkSlateGray")))
1379 "*Face used for showing candidates in `anything-lisp-completion'."
1380 :group
'anything-config
)
1382 (defface anything-lisp-completion-info
1383 '((t (:foreground
"red")))
1384 "*Face used for showing info in `anything-lisp-completion'."
1385 :group
'anything-config
)
1387 (defface anything-overlay-line-face
'((t (:background
"IndianRed4" :underline t
)))
1388 "Face for source header in the anything buffer." :group
'anything
)
1391 (defun anything-configuration ()
1392 "Customize `anything'."
1394 (customize-group "anything-config"))
1398 ;;; Anything-command-map
1402 (defvar anything-command-map
)
1403 (define-prefix-command 'anything-command-map
)
1406 (define-key anything-command-map
(kbd "<SPC>") 'anything-execute-anything-command
)
1407 (define-key anything-command-map
(kbd "a") 'anything-c-apropos
)
1408 (define-key anything-command-map
(kbd "e") 'anything-c-etags-select
)
1409 (define-key anything-command-map
(kbd "l") 'anything-locate
)
1410 (define-key anything-command-map
(kbd "s") 'anything-surfraw
)
1411 (define-key anything-command-map
(kbd "r") 'anything-regexp
)
1412 (define-key anything-command-map
(kbd "w") 'anything-w3m-bookmarks
)
1413 (define-key anything-command-map
(kbd "x") 'anything-firefox-bookmarks
)
1414 (define-key anything-command-map
(kbd "#") 'anything-emms
)
1415 (define-key anything-command-map
(kbd "m") 'anything-man-woman
)
1416 (define-key anything-command-map
(kbd "t") 'anything-top
)
1417 (define-key anything-command-map
(kbd "i") 'anything-imenu
)
1418 (define-key anything-command-map
(kbd "<tab>") 'anything-lisp-completion-at-point
)
1419 (define-key anything-command-map
(kbd "p") 'anything-list-emacs-process
)
1420 (define-key anything-command-map
(kbd "C-x r b") 'anything-c-pp-bookmarks
)
1421 (define-key anything-command-map
(kbd "M-y") 'anything-show-kill-ring
)
1422 (define-key anything-command-map
(kbd "C-c <SPC>") 'anything-all-mark-rings
)
1423 (define-key anything-command-map
(kbd "C-x C-f") 'anything-find-files
)
1424 (define-key anything-command-map
(kbd "f") 'anything-for-files
)
1425 (define-key anything-command-map
(kbd "C-:") 'anything-eval-expression-with-eldoc
)
1426 (define-key anything-command-map
(kbd "C-,") 'anything-calcul-expression
)
1427 (define-key anything-command-map
(kbd "M-x") 'anything-M-x
)
1428 (define-key anything-command-map
(kbd "C-x C-w") 'anything-write-file
)
1429 (define-key anything-command-map
(kbd "C-x i") 'anything-insert-file
)
1430 (define-key anything-command-map
(kbd "M-s o") 'anything-occur
)
1431 (define-key anything-command-map
(kbd "M-g s") 'anything-do-grep
)
1432 (define-key anything-command-map
(kbd "c") 'anything-colors
)
1433 (define-key anything-command-map
(kbd "F") 'anything-select-xfont
)
1434 (define-key anything-command-map
(kbd "C-c f") 'anything-recentf
)
1435 (define-key anything-command-map
(kbd "C-c g") 'anything-google-suggest
)
1436 (define-key anything-command-map
(kbd "h i") 'anything-info-at-point
)
1437 (define-key anything-command-map
(kbd "h r") 'anything-info-emacs
)
1438 (define-key anything-command-map
(kbd "h g") 'anything-info-gnus
)
1439 (define-key anything-command-map
(kbd "C-x C-b") 'anything-buffers-list
)
1440 (define-key anything-command-map
(kbd "C-c C-b") 'anything-browse-code
)
1441 (define-key anything-command-map
(kbd "C-x r i") 'anything-register
)
1442 (define-key anything-command-map
(kbd "C-c C-x") 'anything-c-run-external-command
)
1444 ;; In Emacs 23.1.50, minibuffer-local-must-match-filename-map was renamed to
1445 ;; minibuffer-local-filename-must-match-map.
1446 (defvar minibuffer-local-filename-must-match-map
(make-sparse-keymap)) ;; Emacs 23.1.+
1447 (defvar minibuffer-local-must-match-filename-map
(make-sparse-keymap)) ;; Older Emacsen
1448 (dolist (map (list minibuffer-local-filename-completion-map
1449 minibuffer-local-completion-map
1450 minibuffer-local-must-match-filename-map
1451 minibuffer-local-filename-must-match-map
1452 minibuffer-local-map
1453 minibuffer-local-isearch-map
1454 minibuffer-local-must-match-map
1455 minibuffer-local-ns-map
))
1456 (define-key map
"\C-r" 'anything-minibuffer-history
))
1463 (easy-menu-define nil global-map
1466 ["All anything commands" anything-execute-anything-command t
]
1467 ["Find any Files/Buffers" anything-for-files t
]
1468 ["Anything Everywhere (Toggle)" ac-mode t
]
1471 ["Find files" anything-find-files t
]
1472 ["Recent Files" anything-recentf t
]
1473 ["Locate" anything-locate t
]
1474 ["Bookmarks" anything-c-pp-bookmarks t
])
1476 ["Find buffers" anything-buffers-list t
])
1478 ["Emacs Commands" anything-M-x t
]
1479 ["Externals Commands" anything-c-run-external-command t
])
1481 ["Anything Apropos" anything-c-apropos t
])
1483 ["Info at point" anything-info-at-point t
]
1484 ["Emacs Manual index" anything-info-emacs t
]
1485 ["Gnus Manual index" anything-info-gnus t
])
1487 ["Org keywords" anything-org-keywords t
]
1488 ["Org headlines" anything-org-headlines t
])
1490 ["Occur" anything-occur t
]
1491 ["Grep" anything-do-grep t
]
1492 ["Etags" anything-c-etags-select t
]
1493 ["Lisp complete at point" anything-lisp-completion-at-point t
]
1494 ["Browse Kill ring" anything-show-kill-ring t
]
1495 ["Browse register" anything-register t
]
1496 ["Browse code" anything-browse-code t
]
1497 ["Mark Ring" anything-all-mark-rings t
]
1498 ["Regexp handler" anything-regexp t
]
1499 ["Colors & Faces" anything-colors t
]
1500 ["Show xfonts" anything-select-xfont t
]
1501 ["Ucs Symbols" anything-ucs t
]
1502 ["Imenu" anything-imenu t
]
1503 ["Google Suggest" anything-google-suggest t
]
1504 ["Eval expression" anything-eval-expression-with-eldoc t
]
1505 ["Calcul expression" anything-calcul-expression t
]
1506 ["Man pages" anything-man-woman t
]
1507 ["Top externals process" anything-top t
]
1508 ["Emacs internals process" anything-list-emacs-process t
])
1510 ["Prefered Options" anything-configuration t
]))
1512 ;;; Anything map add ons
1515 (define-key anything-map
(kbd "C-x C-f") 'anything-quit-and-find-file
)
1516 (define-key anything-map
(kbd "M-m") 'anything-toggle-all-marks
)
1517 (define-key anything-map
(kbd "C-w") 'anything-yank-text-at-point
)
1520 ;;; Specialized keymaps
1523 (defvar anything-c-buffer-map
1524 (let ((map (copy-keymap anything-map
)))
1525 (define-key map
(kbd "C-c ?") 'anything-c-buffer-help
)
1526 ;; No need to have separate command for grep and zgrep
1527 ;; as we don't use recursivity for buffers.
1528 ;; So use zgrep for both as it is capable to handle non--compressed files.
1529 (define-key map
(kbd "M-g s") 'anything-buffer-run-zgrep
)
1530 (define-key map
(kbd "C-o") 'anything-buffer-switch-other-window
)
1531 (define-key map
(kbd "C-c C-o") 'anything-buffer-switch-other-frame
)
1532 (define-key map
(kbd "C-c =") 'anything-buffer-run-ediff
)
1533 (define-key map
(kbd "M-=") 'anything-buffer-run-ediff-merge
)
1534 (define-key map
(kbd "C-=") 'anything-buffer-diff-persistent
)
1535 (define-key map
(kbd "M-U") 'anything-buffer-revert-persistent
)
1536 (define-key map
(kbd "M-D") 'anything-buffer-run-kill-buffers
)
1537 (define-key map
(kbd "C-x C-s") 'anything-buffer-save-persistent
)
1538 (define-key map
(kbd "C-M-%") 'anything-buffer-run-query-replace-regexp
)
1539 (define-key map
(kbd "M-%") 'anything-buffer-run-query-replace
)
1540 (define-key map
(kbd "M-m") 'anything-toggle-all-marks
)
1541 (define-key map
(kbd "M-a") 'anything-mark-all
)
1542 (when (locate-library "elscreen")
1543 (define-key map
(kbd "<C-tab>") 'anything-buffer-switch-to-elscreen
))
1545 "Keymap for buffer sources in anything.")
1547 (defvar anything-find-files-map
1548 (let ((map (copy-keymap anything-map
)))
1549 (define-key map
(kbd "C-]") 'anything-ff-run-toggle-basename
)
1550 (define-key map
(kbd "C-x C-f") 'anything-ff-run-locate
)
1551 (define-key map
(kbd "M-g s") 'anything-ff-run-grep
)
1552 (define-key map
(kbd "M-g p") 'anything-ff-run-pdfgrep
)
1553 (define-key map
(kbd "M-g z") 'anything-ff-run-zgrep
)
1554 (define-key map
(kbd "M-.") 'anything-ff-run-etags
)
1555 (define-key map
(kbd "M-R") 'anything-ff-run-rename-file
)
1556 (define-key map
(kbd "M-C") 'anything-ff-run-copy-file
)
1557 (define-key map
(kbd "M-B") 'anything-ff-run-byte-compile-file
)
1558 (define-key map
(kbd "M-L") 'anything-ff-run-load-file
)
1559 (define-key map
(kbd "M-S") 'anything-ff-run-symlink-file
)
1560 (define-key map
(kbd "M-D") 'anything-ff-run-delete-file
)
1561 (define-key map
(kbd "M-K") 'anything-ff-run-kill-buffer-persistent
)
1562 (define-key map
(kbd "<deletechar>") 'anything-ff-persistent-delete
)
1563 (define-key map
(kbd "M-e") 'anything-ff-run-switch-to-eshell
)
1564 (define-key map
(kbd "<M-tab>") 'anything-ff-run-complete-fn-at-point
)
1565 (define-key map
(kbd "C-o") 'anything-ff-run-switch-other-window
)
1566 (define-key map
(kbd "C-c C-o") 'anything-ff-run-switch-other-frame
)
1567 (define-key map
(kbd "C-c C-x") 'anything-ff-run-open-file-externally
)
1568 (define-key map
(kbd "M-!") 'anything-ff-run-eshell-command-on-file
)
1569 (define-key map
(kbd "C-=") 'anything-ff-run-ediff-file
)
1570 (define-key map
(kbd "C-c =") 'anything-ff-run-ediff-merge-file
)
1571 (define-key map
(kbd "M-p") 'anything-ff-run-switch-to-history
)
1572 (define-key map
(kbd "M-i") 'anything-ff-properties-persistent
)
1573 (define-key map
(kbd "C-c ?") 'anything-ff-help
)
1574 (define-key map
(kbd "C-}") 'anything-narrow-window
)
1575 (define-key map
(kbd "C-{") 'anything-enlarge-window
)
1576 (define-key map
(kbd "C-<backspace>") 'anything-ff-run-toggle-auto-update
)
1577 (define-key map
(kbd "M-a") 'anything-mark-all
)
1578 (define-key map
(kbd "M-m") 'anything-toggle-all-marks
)
1579 (define-key map
(kbd "M-u") 'anything-unmark-all
)
1580 (define-key map
(kbd "C-c C-a") 'anything-ff-run-gnus-attach-files
)
1581 (define-key map
(kbd "C-c p") 'anything-ff-run-print-file
)
1582 ;; Next 2 have no effect if candidate is not an image file.
1583 (define-key map
(kbd "M-l") 'anything-ff-rotate-left-persistent
)
1584 (define-key map
(kbd "M-r") 'anything-ff-rotate-right-persistent
)
1585 (define-key map
(kbd "C-.") 'anything-find-files-down-one-level
)
1586 (define-key map
(kbd "C-l") 'anything-find-files-down-one-level
)
1587 (define-key map
(kbd "C-h C-b") 'anything-send-bug-report-from-anything
)
1588 (define-key map
(kbd "C-h C-d") 'anything-debug-output
)
1589 (when anything-ff-lynx-style-map
1590 (define-key map
(kbd "<left>") 'anything-find-files-down-one-level
)
1591 (define-key map
(kbd "<right>") 'anything-execute-persistent-action
))
1593 "Keymap for `anything-find-files'.")
1595 (defvar anything-c-read-file-map
1596 (let ((map (copy-keymap anything-map
)))
1597 (define-key map
(kbd "C-.") 'anything-find-files-down-one-level
)
1598 (define-key map
(kbd "C-l") 'anything-find-files-down-one-level
)
1599 (define-key map
(kbd "C-<backspace>") 'anything-ff-run-toggle-auto-update
)
1600 (define-key map
(kbd "C-c ?") 'anything-read-file-name-help
)
1601 (when anything-ff-lynx-style-map
1602 (define-key map
(kbd "<left>") 'anything-find-files-down-one-level
)
1603 (define-key map
(kbd "<right>") 'anything-execute-persistent-action
)
1604 (define-key map
(kbd "<M-left>") 'anything-previous-source
)
1605 (define-key map
(kbd "<M-right>") 'anything-next-source
))
1607 "Keymap for `anything-c-read-file-name'.")
1609 (defvar anything-generic-files-map
1610 (let ((map (copy-keymap anything-map
)))
1611 (define-key map
(kbd "M-g s") 'anything-ff-run-grep
)
1612 (define-key map
(kbd "M-g z") 'anything-ff-run-zgrep
)
1613 (define-key map
(kbd "M-g p") 'anything-ff-run-pdfgrep
)
1614 (define-key map
(kbd "M-D") 'anything-ff-run-delete-file
)
1615 (define-key map
(kbd "C-=") 'anything-ff-run-ediff-file
)
1616 (define-key map
(kbd "C-c =") 'anything-ff-run-ediff-merge-file
)
1617 (define-key map
(kbd "C-o") 'anything-ff-run-switch-other-window
)
1618 (define-key map
(kbd "M-i") 'anything-ff-properties-persistent
)
1619 (define-key map
(kbd "C-c C-x") 'anything-ff-run-open-file-externally
)
1620 (define-key map
(kbd "C-w") 'anything-yank-text-at-point
)
1621 (define-key map
(kbd "C-c ?") 'anything-generic-file-help
)
1623 "Generic Keymap for files.")
1625 (defvar anything-c-grep-map
1626 (let ((map (copy-keymap anything-map
)))
1627 (define-key map
(kbd "M-<down>") 'anything-c-goto-next-file
)
1628 (define-key map
(kbd "M-<up>") 'anything-c-goto-precedent-file
)
1629 (define-key map
(kbd "C-o") 'anything-c-grep-run-other-window-action
)
1630 (define-key map
(kbd "C-w") 'anything-yank-text-at-point
)
1631 (define-key map
(kbd "C-x C-s") 'anything-c-grep-run-save-buffer
)
1632 (when anything-c-grep-use-ioccur-style-keys
1633 (define-key map
(kbd "<right>") 'anything-c-grep-run-persistent-action
)
1634 (define-key map
(kbd "<left>") 'anything-c-grep-run-default-action
))
1635 (define-key map
(kbd "C-c ?") 'anything-grep-help
)
1637 "Keymap used in Grep sources.")
1639 (defvar anything-c-pdfgrep-map
1640 (let ((map (copy-keymap anything-map
)))
1641 (define-key map
(kbd "M-<down>") 'anything-c-goto-next-file
)
1642 (define-key map
(kbd "M-<up>") 'anything-c-goto-precedent-file
)
1643 (define-key map
(kbd "C-w") 'anything-yank-text-at-point
)
1644 (define-key map
(kbd "C-c ?") 'anything-pdfgrep-help
)
1646 "Keymap used in pdfgrep.")
1648 (defvar anything-c-etags-map
1649 (let ((map (copy-keymap anything-map
)))
1650 (define-key map
(kbd "M-<down>") 'anything-c-goto-next-file
)
1651 (define-key map
(kbd "M-<up>") 'anything-c-goto-precedent-file
)
1652 (define-key map
(kbd "C-w") 'anything-yank-text-at-point
)
1653 (define-key map
(kbd "C-c ?") 'anything-etags-help
)
1655 "Keymap used in Etags.")
1657 (defvar anything-eval-expression-map
1658 (let ((map (copy-keymap anything-map
)))
1659 (define-key map
(kbd "<C-return>") 'anything-eval-new-line-and-indent
)
1660 (define-key map
(kbd "<tab>") 'lisp-indent-line
)
1661 (define-key map
(kbd "<C-tab>") 'lisp-complete-symbol
)
1662 (define-key map
(kbd "C-p") 'previous-line
)
1663 (define-key map
(kbd "C-n") 'next-line
)
1664 (define-key map
(kbd "<up>") 'previous-line
)
1665 (define-key map
(kbd "<down>") 'next-line
)
1666 (define-key map
(kbd "<right>") 'forward-char
)
1667 (define-key map
(kbd "<left>") 'backward-char
)
1670 (defvar anything-c-ucs-map
1671 (let ((map (copy-keymap anything-map
)))
1672 (define-key map
(kbd "<C-backspace>") 'anything-c-ucs-persistent-delete
)
1673 (define-key map
(kbd "<C-left>") 'anything-c-ucs-persistent-backward
)
1674 (define-key map
(kbd "<C-right>") 'anything-c-ucs-persistent-forward
)
1675 (define-key map
(kbd "<C-return>") 'anything-c-ucs-persistent-insert
)
1676 (define-key map
(kbd "C-c ?") 'anything-c-ucs-help
)
1678 "Keymap for `anything-ucs'.")
1682 ;;; Embeded documentation.
1685 (defun anything-c-list-preconfigured-anything ()
1686 "Collect preconfigured anything functions in this file."
1689 for entry in
(cdr (assoc
1690 (file-truename (locate-library "anything-config"))
1692 if
(and (consp entry
)
1693 (eq (car entry
) 'defun
)
1694 (string-match "^Preconfigured.+$"
1695 (setq doc
(or (documentation (setq sym
(cdr entry
)))
1697 collect
(cons sym
(match-string 0 doc
))))
1699 (defun anything-c-format-preconfigured-anything ()
1700 (mapcar (lambda (x) (format "\\[%s] : %s\n" (car x
) (cdr x
)))
1701 (anything-c-list-preconfigured-anything)))
1703 ;;; Global help message - Used by `anything-help'
1706 (setq anything-help-message
1710 "`anything' is QuickSilver-like candidate-selection framework.
1712 Narrow the list by typing some pattern,
1713 Multiple patterns are allowed by splitting by space.
1714 Select with natural Emacs operations, choose with RET.
1716 If you have any problems, press C-c C-x C-b!!
1717 Feel free to send bug reports. I'll fix them.
1718 The steps are described in the beginning of anything.el file.
1720 == Basic Operations ==
1721 C-p, Up: Previous Line
1722 C-n, Down : Next Line
1723 M-v, PageUp : Previous Page
1724 C-v, PageDown : Next Page
1725 Enter : Execute first (default) action / Select
1728 M-PageUp, C-M-S-v, C-M-y : Previous Page (other-window)
1729 M-PageDown, C-M-v : Next Page (other-window)
1731 Tab, C-i : Show action list
1732 Left : Previous Source
1733 Right, C-o : Next Source
1734 C-k : Delete pattern
1735 C-z : Persistent Action (Execute action with anything session kept)
1736 C-c C-x C-b: Send a bug report
1738 == Shortcuts For 2nd/3rd Action ==
1739 \\[anything-select-2nd-action-or-end-of-line] : Execute 2nd Action (if the minibuffer cursor is at end of line)
1740 \\[anything-select-3rd-action] : Execute 3rd Action
1743 Visible marks store candidate. Some actions uses marked candidates.
1745 \\[anything-toggle-visible-mark] : Toggle Visible Mark
1746 \\[anything-prev-visible-mark] : Previous Mark
1747 \\[anything-next-visible-mark] : Next Mark
1749 == Miscellaneous Commands ==
1750 \\[anything-toggle-resplit-window] : Toggle vertical/horizontal split anything window
1751 \\[anything-quit-and-find-file] : Drop into `find-file'
1752 \\[anything-delete-current-selection] : Delete Selected Item (visually)
1753 \\[anything-kill-selection-and-quit] : Set Item Into the kill-ring And Quit
1754 \\[anything-yank-selection] : Yank Selected Item Into Pattern
1755 \\[anything-follow-mode] : Toggle Automatical Execution Of Persistent Action
1756 \\[anything-force-update] : Recalculate And Redisplay Candidates
1758 == Global Commands ==
1759 \\<global-map>\\[anything-resume] revives last `anything' session.
1760 It is very useful, so you should bind any key.
1762 Single source is executed by \\[anything-call-source].
1764 == Preconfigured `anything' ==
1765 Preconfigured `anything' is commands that uses `anything' interface.
1766 You can use them without configuration.
1769 (apply 'concat
(anything-c-format-preconfigured-anything))
1773 ;;; `anything-buffer-list' help
1777 (defun anything-c-buffer-help ()
1778 "Help command for anything buffers."
1780 (let ((anything-help-message "== Anything Buffer ==
1782 You can enter a partial name of major-mode (e.g lisp, sh) to narrow down buffers.
1783 Enter then a space and a pattern to narrow down to buffers matching this pattern.
1784 \nSpecific commands for `anything-buffers-list':
1785 \\<anything-c-buffer-map>
1786 \\[anything-buffer-run-zgrep]\t\t->Grep Buffer(s) works as zgrep too. (C-u grep all buffers but non--file buffers).
1787 \\[anything-buffer-switch-other-window]\t\t->Switch other window.
1788 \\[anything-buffer-switch-other-frame]\t\t->Switch other frame.
1789 \\[anything-buffer-run-query-replace-regexp]\t\t->Query replace regexp in marked buffers.
1790 \\[anything-buffer-run-query-replace]\t\t->Query replace in marked buffers.
1791 \\[anything-buffer-switch-to-elscreen]\t\t->Find buffer in Elscreen.
1792 \\[anything-buffer-run-ediff]\t\t->Ediff current buffer with candidate. If two marked buffers ediff those buffers.
1793 \\[anything-buffer-run-ediff-merge]\t\t->Ediff merge current buffer with candidate. If two marked buffers ediff merge those buffers.
1794 \\[anything-buffer-diff-persistent]\t\t->Toggle Diff buffer with saved file without quitting.
1795 \\[anything-buffer-revert-persistent]\t\t->Revert buffer without quitting.
1796 \\[anything-buffer-save-persistent]\t\t->Save buffer without quitting.
1797 \\[anything-buffer-run-kill-buffers]\t\t->Delete marked buffers and quit.
1798 \\[anything-toggle-all-marks]\t\t->Toggle all marks.
1799 \\[anything-mark-all]\t\t->Mark all.
1800 \\[anything-c-buffer-help]\t\t->Display this help.
1801 \n== Anything Map ==
1807 ;;; Find files help (`anything-find-files')
1811 (defun anything-ff-help ()
1812 "Help command for `anything-find-files'."
1814 (let ((anything-help-message "== Anything Find Files ==
1816 \n- Enter `~/' at end of pattern to quickly reach home directory.
1817 - Enter `/' at end of pattern to quickly reach root of your file system.
1818 - Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session).
1819 - You can complete with partial basename \(e.g \"fb\" will complete \"foobar\"\).
1820 - Use `C-u C-z' to watch an image.
1821 - To browse images directories turn on `anything-follow-mode' and navigate with arrow keys.
1822 - When entered ediff, hitting `C-g' will ask you to use locate to find the file to ediff with.
1824 \nSpecific commands for `anything-find-files':
1825 \\<anything-find-files-map>
1826 \\[anything-ff-run-locate]\t\t->Run Locate on basename of candidate (C-u to specify locate db).
1827 \\[anything-ff-run-grep]\t\t->Run Grep (C-u Recursive).
1828 \\[anything-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files.
1829 \\[anything-ff-run-zgrep]\t\t->Run zgrep (C-u Recursive).
1830 \\[anything-ff-run-etags]\t\t->Run Etags (C-u use thing-at-point `C-u C-u' reload cache)
1831 \\[anything-ff-run-rename-file]\t\t->Rename File (C-u Follow).
1832 \\[anything-ff-run-copy-file]\t\t->Copy File (C-u Follow).
1833 \\[anything-ff-run-byte-compile-file]\t\t->Byte Compile File (C-u Load).
1834 \\[anything-ff-run-load-file]\t\t->Load File.
1835 \\[anything-ff-run-symlink-file]\t\t->Symlink File.
1836 \\[anything-ff-run-delete-file]\t\t->Delete File.
1837 \\[anything-ff-run-kill-buffer-persistent]\t\t->Kill buffer candidate without quitting.
1838 \\[anything-ff-persistent-delete]\t->Delete file without quitting.
1839 \\[anything-ff-run-switch-to-eshell]\t\t->Switch to Eshell.
1840 \\[anything-ff-run-eshell-command-on-file]\t\t->Eshell command on file (C-u Run on all marked files at once).
1841 \\[anything-ff-run-ediff-file]\t\t->Ediff file.
1842 \\[anything-ff-run-ediff-merge-file]\t\t->Ediff merge file.
1843 \\[anything-ff-run-complete-fn-at-point]\t\t->Complete file name at point.
1844 \\[anything-ff-run-switch-other-window]\t\t->Switch other window.
1845 \\[anything-ff-run-switch-other-frame]\t\t->Switch other frame.
1846 \\[anything-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose).
1847 \\[anything-ff-rotate-left-persistent]\t\t->Rotate Image Left.
1848 \\[anything-ff-rotate-right-persistent]\t\t->Rotate Image Right.
1849 \\[anything-find-files-down-one-level]\t\t->Go down precedent directory.
1850 \\[anything-ff-run-switch-to-history]\t\t->Switch to anything find-files history.
1851 \\[anything-ff-properties-persistent]\t\t->Show file properties in a tooltip.
1852 \\[anything-mark-all]\t\t->Mark all visibles candidates.
1853 \\[anything-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories.
1854 \\[anything-unmark-all]\t\t->Unmark all candidates, visibles and invisibles.
1855 \\[anything-ff-run-gnus-attach-files]\t\t->Gnus attach files to message buffer.
1856 \\[anything-ff-run-print-file]\t\t->Print file with default printer.
1857 \\[anything-enlarge-window]\t\t->Enlarge anything window.
1858 \\[anything-narrow-window]\t\t->Narrow anything window.
1859 \\[anything-ff-run-toggle-basename]\t\t->Toggle basename/fullpath.
1860 \\[anything-send-bug-report-from-anything]\t\t->Send Bug report.
1861 \\[anything-ff-help]\t\t->Display this help info.
1862 \n== Anything Map ==
1867 ;;; Help for `anything-c-read-file-name'
1871 (defun anything-read-file-name-help ()
1873 (let ((anything-help-message "== Anything read file name Map ==\
1874 \nSpecific commands for anything-c-read-file-name:
1875 \\<anything-c-read-file-map>
1876 \\[anything-find-files-down-one-level]\t\t->Go down precedent directory.
1877 \\[anything-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories.
1878 \\[anything-next-source]\t\t->Goto next source.
1879 \\[anything-previous-source]\t->Goto previous source.
1880 \\[anything-read-file-name-help]\t\t->Display this help info.
1881 \n== Anything Map ==
1886 ;;; Generic file help - Used by locate.
1890 (defun anything-generic-file-help ()
1892 (let ((anything-help-message "== Anything Generic files Map ==\
1893 \nSpecific commands for anything locate and others files sources:
1894 \\<anything-generic-files-map>
1895 \\[anything-ff-run-grep]\t\t->Run grep (C-u recurse).
1896 \\[anything-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files.
1897 \\[anything-ff-run-delete-file]\t\t->Delete file.
1898 \\[anything-ff-run-ediff-file]\t\t->Ediff file.
1899 \\[anything-ff-run-ediff-merge-file]\t\t->Ediff merge file.
1900 \\[anything-ff-run-switch-other-window]\t\t->Switch other window.
1901 \\[anything-ff-properties-persistent]\t\t->Show file properties.
1902 \\[anything-yank-text-at-point]\t\t->Yank text at point.
1903 \\[anything-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose).
1905 You can add after writing search pattern any of the locate command line options.
1906 e.g -b, -e, -n <number>...etc.
1907 See Man locate for more infos.
1908 \n== Anything Map ==
1917 (defun anything-grep-help ()
1919 (let ((anything-help-message "== Anything Grep Map ==\
1920 \nSpecific commands for Grep and Etags:
1921 \\<anything-c-grep-map>
1922 \\[anything-c-goto-next-file]\t->Next File.
1923 \\[anything-c-goto-precedent-file]\t\t->Precedent File.
1924 \\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer.
1925 \\[anything-c-grep-run-other-window-action]\t\t->Jump other window.
1926 \\[anything-c-grep-run-persistent-action]\t\t->Run persistent action (Same as `C-z').
1927 \\[anything-c-grep-run-default-action]\t\t->Run default action (Same as RET).
1928 \\[anything-grep-help]\t\t->Show this help.
1929 \n== Anything Map ==
1937 (defun anything-pdfgrep-help ()
1939 (let ((anything-help-message "== Anything PdfGrep Map ==\
1940 \nSpecific commands for Pdf Grep:
1941 \\<anything-c-pdfgrep-map>
1942 \\[anything-c-goto-next-file]\t->Next File.
1943 \\[anything-c-goto-precedent-file]\t\t->Precedent File.
1944 \\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer.
1945 \\[anything-pdfgrep-help]\t\t->Show this help.
1946 \n== Anything Map ==
1954 (defun anything-etags-help ()
1955 "The help function for etags."
1957 (let ((anything-help-message "== Anything Etags Map ==\
1958 \nSpecific commands for Etags:
1959 \\<anything-c-etags-map>
1960 \\[anything-c-goto-next-file]\t->Next File.
1961 \\[anything-c-goto-precedent-file]\t\t->Precedent File.
1962 \\[anything-yank-text-at-point]\t\t->Yank Text at point in minibuffer.
1963 \\[anything-etags-help]\t\t->Show this help.
1964 \n== Anything Map ==
1971 (defun anything-c-ucs-help ()
1972 "Help command for `anything-ucs'."
1974 (let ((anything-help-message "== Anything Ucs ==
1975 \nSpecific commands for `anything-ucs':
1976 \\<anything-c-ucs-map>
1977 \\[anything-c-ucs-persistent-insert]\t->Insert char.
1978 \\[anything-c-ucs-persistent-forward]\t->Forward char.
1979 \\[anything-c-ucs-persistent-backward]\t->Backward char.
1980 \\[anything-c-ucs-persistent-delete]\t->Delete char backward.
1981 \\[anything-c-ucs-help]\t\t->Show this help.
1983 \n== Anything Map ==
1990 ;;; Mode line strings
1993 (defvar anything-buffer-mode-line-string
1995 "\\<anything-c-buffer-map>\
1996 \\[anything-c-buffer-help]:Help, \
1998 \\[anything-select-action]:Acts,\
1999 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2000 \\[anything-select-3rd-action]:NthAct,\
2001 \\[anything-send-bug-report-from-anything]:BugReport."
2002 "String displayed in mode-line in `anything-c-source-buffers-list'"))
2004 (defvar anything-ff-mode-line-string
2005 "\\<anything-find-files-map>\
2006 \\[anything-ff-help]:Help, \
2007 \\[anything-send-bug-report-from-anything]:BugReport, \
2009 \\[anything-select-action]:Acts, \
2010 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2011 \\[anything-select-3rd-action]:NthAct"
2012 "String displayed in mode-line in `anything-c-source-find-files'")
2014 (defvar anything-read-file-name-mode-line-string
2015 "\\<anything-c-read-file-map>\
2016 \\[anything-read-file-name-help]:Help, \
2018 \\[anything-select-action]:Acts,\
2019 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2020 \\[anything-select-3rd-action]:NthAct"
2021 "String displayed in mode-line in `anything-c-source-find-files'")
2023 (defvar anything-generic-file-mode-line-string
2024 "\\<anything-generic-files-map>\
2025 \\[anything-generic-file-help]:Help, \
2027 \\[anything-select-action]:Acts,\
2028 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2029 \\[anything-select-3rd-action]:NthAct,\
2030 \\[anything-send-bug-report-from-anything]:BugReport."
2031 "String displayed in mode-line in Locate.")
2033 (defvar anything-grep-mode-line-string
2034 "\\<anything-c-grep-map>\
2035 \\[anything-grep-help]:Help,\
2037 \\[anything-select-action]:Acts,\
2038 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2039 \\[anything-select-3rd-action]:NthAct,\
2040 \\[anything-send-bug-report-from-anything]:BugReport."
2041 "String displayed in mode-line in `anything-do-grep'.")
2043 (defvar anything-pdfgrep-mode-line-string
2044 "\\<anything-c-pdfgrep-map>\
2045 \\[anything-pdfgrep-help]:Help,\
2047 \\[anything-select-action]:Acts,\
2048 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2049 \\[anything-select-3rd-action]:NthAct,\
2050 \\[anything-send-bug-report-from-anything]:BugReport."
2051 "String displayed in mode-line in `anything-do-pdfgrep'.")
2053 (defvar anything-etags-mode-line-string
2054 "\\<anything-c-etags-map>\
2055 \\[anything-etags-help]:Help,\
2057 \\[anything-select-action]:Acts,\
2058 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2059 \\[anything-select-3rd-action]:NthAct,\
2060 \\[anything-send-bug-report-from-anything]:BugReport."
2061 "String displayed in mode-line in `anything-c-etags-select'.")
2064 (defvar anything-c-ucs-mode-line-string
2065 "\\<anything-c-ucs-map>\
2066 \\[anything-c-ucs-help]:Help, \
2068 \\[anything-select-action]:Acts,\
2069 \\[anything-exit-minibuffer]/\\[anything-select-2nd-action-or-end-of-line]/\
2070 \\[anything-select-3rd-action]:NthAct."
2071 "String displayed in mode-line in `anything-ucs'.")
2075 ;;; Utilities Functions
2078 (defun anything-ff-find-printers ()
2079 "Return a list of available printers on Unix systems."
2080 (let ((printer-list (with-temp-buffer
2081 (call-process "lpstat" nil t nil
"-a")
2082 (split-string (buffer-string) "\n"))))
2083 (loop for p in printer-list
2084 for printer
= (car (split-string p
))
2088 ;; Shut up byte compiler in emacs24*.
2089 (defun anything-c-switch-to-buffer (buffer-or-name)
2090 "Same as `switch-to-buffer' whithout warnings at compile time."
2092 (switch-to-buffer buffer-or-name
)))
2094 (defsubst* anything-c-position
(item seq
&key
(test 'eq
))
2095 "A simple and faster replacement of CL `position'."
2096 (loop for i in seq for index from
0
2097 when
(funcall test i item
) return index
))
2099 (defun anything-c-get-pid-from-process-name (process-name)
2100 "Get pid from running process PROCESS-NAME."
2101 (loop with process-list
= (list-system-processes)
2102 for pid in process-list
2103 for process
= (assoc-default 'comm
(process-attributes pid
))
2104 when
(and process
(string-match process-name process
))
2107 (defun* anything-current-buffer-narrowed-p
(&optional
2108 (buffer anything-current-buffer
))
2109 "Check if BUFFER is narrowed.
2110 Default is `anything-current-buffer'."
2111 (with-current-buffer buffer
2112 (let ((beg (point-min))
2114 (total (buffer-size)))
2115 (or (/= beg
1) (/= end
(1+ total
))))))
2117 (defun anything-region-active-p ()
2118 (and transient-mark-mode mark-active
(/= (mark) (point))))
2120 (defun anything-goto-line (lineno)
2121 "Goto LINENO opening only outline headline if needed."
2122 (goto-char (point-min)) (forward-line (1- lineno
))
2123 (when (or (eq major-mode
'org-mode
)
2124 (and (boundp 'outline-minor-mode
)
2125 outline-minor-mode
))
2126 (require 'org
) ; On some old Emacs versions org may not be loaded.
2128 (anything-match-line-color-current-line) (sit-for 0.3)
2129 (anything-match-line-cleanup))
2131 (defun anything-show-this-source-only ()
2132 "Show all candidates of this source."
2134 (setq anything-candidate-number-limit nil
)
2135 (anything-set-source-filter
2136 (list (assoc-default 'name
(anything-get-current-source)))))
2139 (defun anything-test-sources ()
2140 "List all anything sources for test.
2141 The output is sexps which are evaluated by \\[eval-last-sexp]."
2143 (with-output-to-temp-buffer "*Anything Test Sources*"
2144 (mapc (lambda (s) (princ (format ";; (anything '%s)\n" s
)))
2145 (apropos-internal "^anything-c-source" #'boundp
))
2146 (pop-to-buffer standard-output
)))
2148 (defun anything-nest (&rest same-as-anything
)
2149 "Nested `anything'. If you use `anything' within `anything', use it."
2150 (with-selected-window (anything-window)
2151 (let (anything-current-position
2152 anything-current-buffer
2153 (orig-anything-buffer anything-buffer
)
2157 anything-compiled-sources
2158 anything-buffer-chars-modified-tick
2159 (anything-samewindow t
)
2160 (enable-recursive-minibuffers t
))
2162 (apply #'anything same-as-anything
)
2163 (anything-initialize-overlays orig-anything-buffer
)
2164 (add-hook 'post-command-hook
'anything-check-minibuffer-input
)))))
2166 (defun anything-displaying-source-names ()
2167 "Display sources name."
2168 (with-current-buffer anything-buffer
2169 (goto-char (point-min))
2171 while
(setq pos
(next-single-property-change (point) 'anything-header
))
2173 collect
(buffer-substring-no-properties (point-at-bol)(point-at-eol))
2174 do
(forward-line 1))))
2177 (defun anything-select-source ()
2178 "[OBSOLETE] Select source."
2180 (let ((default (assoc-default 'name
(anything-get-current-source)))
2181 (source-names (anything-displaying-source-names))
2182 (all-source-names (mapcar (lambda (s) (assoc-default 'name s
))
2183 (anything-get-sources))))
2184 (setq anything-candidate-number-limit
9999)
2186 (let (anything-source-filter)
2187 (anything-nest '(((name .
"Anything Source")
2188 (candidates . source-names
)
2189 (action . identity
))
2190 ((name .
"Anything Source (ALL)")
2191 (candidates . all-source-names
)
2192 (action . identity
)))
2194 default
"*anything select source*"))
2195 (anything-set-source-filter (list it
))
2196 (anything-set-source-filter nil
))))
2198 (defun anything-insert-string (str)
2200 (delete-minibuffer-contents)
2203 (defun anything-c-match-on-file-name (candidate)
2204 "Return non-nil if `anything-pattern' match basename of filename CANDIDATE."
2205 (string-match anything-pattern
(file-name-nondirectory candidate
)))
2207 (defun anything-c-match-on-directory-name (candidate)
2208 "Return non-nil if `anything-pattern' match directory part of CANDIDATE."
2209 (anything-aif (file-name-directory candidate
)
2210 (string-match anything-pattern it
)))
2212 (defun anything-c-match-on-basename (candidate)
2213 "Return non-nil if `anything-pattern' match basename of filename CANDIDATE."
2214 (string-match anything-pattern
(anything-c-basename candidate
)))
2216 (defun anything-c-string-match (candidate)
2217 "Return non-nil if `anything-pattern' match CANDIDATE.
2218 The match is done with `string-match'."
2219 (string-match anything-pattern candidate
))
2221 (defun anything-c-skip-entries (list regexp
)
2222 "Remove entries which matches REGEXP from LIST."
2223 (remove-if (lambda (x) (and (stringp x
) (string-match regexp x
)))
2226 (defun anything-c-shadow-entries (list regexp
)
2227 "Display elements of LIST matching REGEXP with the `file-name-shadow' face."
2228 (mapcar (lambda (file)
2229 ;; Add shadow face property to boring files.
2230 (let ((face (if (facep 'file-name-shadow
)
2232 ;; fall back to default on XEmacs
2234 (if (string-match regexp file
)
2235 (setq file
(propertize file
'face face
))))
2239 (defsubst anything-c-stringify
(str-or-sym)
2240 "Get string of STR-OR-SYM."
2241 (if (stringp str-or-sym
)
2243 (symbol-name str-or-sym
)))
2245 (defsubst anything-c-symbolify
(str-or-sym)
2246 "Get symbol of STR-OR-SYM."
2247 (if (symbolp str-or-sym
)
2249 (intern str-or-sym
)))
2251 (defun anything-c-describe-function (func)
2252 "FUNC is symbol or string."
2253 (describe-function (anything-c-symbolify func
)))
2255 (defun anything-c-describe-variable (var)
2256 "VAR is symbol or string."
2257 (describe-variable (anything-c-symbolify var
)))
2259 (defun anything-c-find-function (func)
2260 "FUNC is symbol or string."
2261 (find-function (anything-c-symbolify func
)))
2263 (defun anything-c-find-variable (var)
2264 "VAR is symbol or string."
2265 (find-variable (anything-c-symbolify var
)))
2267 (defun anything-c-kill-new (candidate &optional replace
)
2268 "CANDIDATE is symbol or string.
2269 See `kill-new' for argument REPLACE."
2270 (kill-new (anything-c-stringify candidate
) replace
))
2272 (defun* anything-fast-remove-dups
(seq &key
(test 'eq
))
2273 "Remove duplicates elements in list SEQ.
2274 This is same as `remove-duplicates' but with memoisation.
2275 It is much faster, especially in large lists.
2276 A test function can be provided with TEST argument key.
2278 (let ((cont (make-hash-table :test test
)))
2279 (loop for elm in seq
2280 unless
(gethash elm cont
)
2281 do
(puthash elm elm cont
)
2283 (loop for i being the hash-values in cont collect i
))))
2285 (defadvice eval-defun
(after anything-source-hack activate
)
2286 "Allow immediate execution of anything source when evaling it.
2287 See `anything-c-enable-eval-defun-hack'."
2288 (when anything-c-enable-eval-defun-hack
2289 (let ((varsym (save-excursion
2290 (beginning-of-defun)
2292 (when (memq (read (current-buffer)) '(defvar setq
))
2293 (read (current-buffer))))))
2294 (when (string-match "^anything-c-source-" (symbol-name varsym
))
2295 (anything varsym
)))))
2296 ;; (progn (ad-disable-advice 'eval-defun 'after 'anything-source-hack) (ad-update 'eval-defun))
2299 ;; Move this function from anything.el and redefine here
2300 ;; to avoid an unneeded defadvice.
2301 (defun anything-quit-and-find-file ()
2302 "Drop into `anything-find-files' from `anything'.
2303 If current selection is a buffer or a file, `anything-find-files'
2304 from its directory."
2306 (anything-run-after-quit
2308 (if (file-exists-p f
)
2309 (anything-find-files-1 (file-name-directory f
)
2310 (if anything-ff-transformer-show-only-basename
2311 (anything-c-basename f
) f
))
2312 (anything-find-files-1 f
)))
2313 (anything-aif (get-buffer (anything-get-selection))
2314 (or (buffer-file-name it
)
2315 (car (rassoc it dired-buffers
))
2316 (and (with-current-buffer it
2317 (eq major-mode
'org-agenda-mode
))
2319 (expand-file-name org-directory
))
2321 (let ((sel (anything-get-selection)))
2322 (if (file-exists-p sel
)
2323 (expand-file-name sel
)
2324 default-directory
)))))
2327 (defmacro* anything-c-walk-directory
(directory &key path
(directories t
) match
)
2328 "Walk through DIRECTORY tree.
2329 PATH can be one of basename, relative, or full.
2330 DIRECTORIES when non--nil (default) return also directories names, otherwise
2331 skip directories names.
2332 MATCH match only filenames matching regexp MATCH."
2335 (basename 'file-name-nondirectory
)
2336 (relative 'file-relative-name
)
2338 (t 'file-name-nondirectory
))))
2339 (labels ((ls-R (dir)
2340 (loop with ls
= (directory-files dir t directory-files-no-dot-files-regexp
)
2342 if
(file-directory-p f
)
2343 do
(progn (when ,directories
2344 (push (funcall fn f
) result
))
2345 ;; Don't recurse in directory symlink.
2346 (unless (file-symlink-p f
)
2349 (unless (and ,match
(not (string-match ,match
(file-name-nondirectory f
))))
2350 (push (funcall fn f
) result
)))))
2352 (nreverse result
))))
2354 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Applications ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2356 ;;; Anything regexp.
2359 (defvar anything-build-regexp-history nil
)
2360 (defun anything-c-query-replace-regexp (candidate)
2361 "Query replace regexp from `anything-regexp'.
2362 With a prefix arg replace only matches surrounded by word boundaries,
2363 i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b."
2364 (let ((regexp (funcall (anything-attr 'regexp
))))
2365 (apply 'query-replace-regexp
2366 (anything-c-query-replace-args regexp
))))
2368 (defun anything-c-kill-regexp-as-sexp (candidate)
2369 "Kill regexp in a format usable in lisp code."
2370 (anything-c-regexp-kill-new
2371 (prin1-to-string (funcall (anything-attr 'regexp
)))))
2373 (defun anything-c-kill-regexp (candidate)
2374 "Kill regexp as it is in `anything-pattern'."
2375 (anything-c-regexp-kill-new (funcall (anything-attr 'regexp
))))
2377 (defun anything-c-query-replace-args (regexp)
2378 "create arguments of `query-replace-regexp' action in `anything-regexp'."
2379 (let ((region-only (anything-region-active-p)))
2382 (query-replace-read-to regexp
2383 (format "Query replace %sregexp %s"
2384 (if anything-current-prefix-arg
"word " "")
2385 (if region-only
"in region " ""))
2387 anything-current-prefix-arg
2388 (when region-only
(region-beginning))
2389 (when region-only
(region-end)))))
2391 (defvar anything-c-source-regexp
2392 '((name .
"Regexp Builder")
2394 (anything-candidate-buffer anything-current-buffer
)))
2395 (candidates-in-buffer)
2396 (get-line . anything-c-regexp-get-line
)
2397 (persistent-action . anything-c-regexp-persistent-action
)
2398 (persistent-help .
"Show this line")
2401 (requires-pattern .
2)
2402 (mode-line .
"Press TAB to select action.")
2403 (regexp .
(lambda () anything-input
))
2404 (action .
(("Kill Regexp as sexp" . anything-c-kill-regexp-as-sexp
)
2405 ("Query Replace Regexp (C-u Not inside word.)"
2406 . anything-c-query-replace-regexp
)
2407 ("Kill Regexp" . anything-c-kill-regexp
)))))
2409 (defun anything-c-regexp-get-line (s e
)
2413 (format "%5d: %s" (line-number-at-pos (1- s
)) (buffer-substring s e
))
2415 (loop for i from
0 to
(1- (/ (length (match-data)) 2))
2416 collect
(format "\n %s'%s'"
2417 (if (zerop i
) "Group 0: " (format "Group %d: " i
))
2420 ;; KLUDGE: point of anything-candidate-buffer is +1 than that of anything-current-buffer.
2421 ;; It is implementation problem of candidates-in-buffer.
2425 (defun anything-c-regexp-persistent-action (pt)
2427 (anything-persistent-highlight-point))
2429 (defun anything-c-regexp-kill-new (input)
2431 (message "Killed: %s" input
))
2435 ;;; Toggle all marks.
2439 (defun anything-mark-all ()
2440 "Mark all visible unmarked candidates in current source."
2442 (with-anything-window
2444 (goto-char (anything-get-previous-header-pos))
2445 (anything-next-line)
2446 (let* ((next-head (anything-get-next-header-pos))
2449 (goto-char next-head
)
2452 (maxpoint (or end
(point-max))))
2453 (while (< (point) maxpoint
)
2454 (anything-mark-current-line)
2455 (let ((prefix (get-text-property (point-at-bol) 'display
))
2456 (bn (anything-c-basename (anything-get-selection)))
2457 (src (assoc-default 'name
(anything-get-current-source))))
2458 (when (and (not (anything-this-visible-mark))
2459 (not (or (string= prefix
"[?]")
2460 (string= prefix
"[@]"))))
2461 ;; Don't mark possibles directories ending with . or ..
2462 ;; and also autosave files/links.
2464 (and (or (anything-file-completion-source-p)
2465 (equal src
"Files from Current Directory"))
2466 (string-match "^\\.#.*\\|^#.*#$\\|\\.$" bn
))
2467 (anything-make-visible-mark))))
2468 (forward-line 1) (end-of-line))))
2469 (anything-mark-current-line)
2470 (message "%s candidates marked" (length anything-marked-candidates
))))
2473 (defun anything-unmark-all ()
2474 "Unmark all candidates in all sources of current anything session."
2476 (with-anything-window
2477 (let ((len (length anything-marked-candidates
)))
2479 (anything-clear-visible-mark))
2480 (setq anything-marked-candidates nil
)
2481 (anything-mark-current-line)
2482 (message "%s candidates unmarked" len
))))
2485 (defun anything-toggle-all-marks ()
2487 Mark all visible candidates of current source or unmark all candidates
2488 visible or invisible in all sources of current anything session"
2490 (let ((marked (anything-marked-candidates)))
2491 (if (and (>= (length marked
) 1)
2492 (with-anything-window anything-visible-mark-overlays
))
2493 (anything-unmark-all)
2494 (anything-mark-all))))
2501 (defun anything-c-buffer-list ()
2502 "Return the list of names of buffers with boring buffers filtered out.
2503 Boring buffers is specified by `anything-c-boring-buffer-regexp'.
2504 The first buffer in the list will be the last recently used
2505 buffer that is not the current buffer."
2506 (let ((buffers (mapcar 'buffer-name
(buffer-list))))
2507 (append (cdr buffers
) (list (car buffers
)))))
2509 (defvar anything-c-source-buffers
2510 '((name .
"Buffers")
2511 (candidates . anything-c-buffer-list
)
2513 ;; (anything 'anything-c-source-buffers)
2515 (defvar anything-c-source-buffer-not-found
2516 '((name .
"Create buffer")
2518 (filtered-candidate-transformer (lambda (cands source
)
2519 (list anything-pattern
)))
2520 (action .
(lambda (candidate)
2521 (anything-c-switch-to-buffer (get-buffer-create candidate
))))))
2522 ;; (anything 'anything-c-source-buffer-not-found)
2524 ;;; Buffers-list (was buffers+)
2527 (eval-when-compile (require 'dired
))
2529 (defun anything-c-highlight-buffers (buffers)
2530 (loop for i in buffers
2531 for buf
= (get-buffer i
)
2532 for bfname
= (buffer-file-name buf
)
2534 (cond (;; A dired buffer.
2535 (rassoc buf dired-buffers
)
2536 (propertize i
'face
'anything-ff-directory
2537 'help-echo
(car (rassoc buf dired-buffers
))))
2538 ;; A buffer file modified somewhere outside of emacs.
2539 ((and bfname
(not (file-remote-p bfname
))
2540 (file-exists-p bfname
)
2541 (not (verify-visited-file-modtime buf
)))
2542 (propertize i
'face
'anything-buffer-saved-out
2544 ;; A new buffer file not already saved on disk.
2545 ((and bfname
(not (file-remote-p bfname
))
2546 (not (verify-visited-file-modtime buf
)))
2547 (propertize i
'face
'anything-buffer-not-saved
2549 ;; A Remote buffer file modified and not saved on disk.
2550 ((and bfname
(file-remote-p bfname
) (buffer-modified-p buf
))
2551 (let ((prefix (propertize
2553 (propertize "@ " 'face
'anything-ff-prefix
))))
2554 (cons (concat prefix
(propertize i
'face
'anything-ff-symlink
2555 'help-echo bfname
)) i
)))
2556 ;; A buffer file modified and not saved on disk.
2557 ((and bfname
(buffer-modified-p buf
))
2558 (propertize i
'face
'anything-ff-symlink
2560 ;; A remote buffer file not modified and saved on disk.
2561 ((and bfname
(file-remote-p bfname
))
2562 (let ((prefix (propertize
2564 (propertize "@ " 'face
'anything-ff-prefix
))))
2565 (cons (concat prefix
(propertize i
'face
'font-lock-type-face
2566 'help-echo bfname
)) i
)))
2567 ;; A buffer file not modified and saved on disk.
2569 (propertize i
'face
'font-lock-type-face
2571 ;; Any non--file buffer.
2572 (t (propertize i
'face
'italic
)))))
2575 (defvar anything-c-source-buffers-list
2576 '((name .
"Buffers")
2577 (candidates . anything-c-buffer-list
)
2579 (match anything-c-buffer-match-major-mode
)
2580 (diff-action . anything-buffer-toggle-diff
)
2581 (revert-action . anything-buffer-revert-and-update
)
2582 (save-action . anything-buffer-save-and-update
)
2583 (candidate-transformer
2584 anything-c-skip-current-buffer
2585 anything-c-skip-boring-buffers
2586 anything-c-highlight-buffers
)
2587 (persistent-action . anything-c-buffers-list-persistent-action
)
2589 (mode-line . anything-buffer-mode-line-string
)
2590 (persistent-help .
"Show this buffer / C-u \\[anything-execute-persistent-action]: Kill this buffer")))
2591 ;; (anything 'anything-c-source-buffers-list)
2593 (defun anything-c-buffer-match-major-mode (candidate)
2594 "Match maybe buffer by major-mode.
2595 If you give a major-mode or partial major-mode,
2596 it will list all buffers of this major-mode and/or buffers with name
2597 matching this major-mode.
2598 If you add a space after major-mode and then a space,
2599 it will match all buffers of the major-mode
2600 before space matching pattern after space.
2601 If you give a pattern which doesn't match a major-mode, it will search buffer
2602 with name matching pattern."
2603 (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate
))
2604 (buf (get-buffer cand
)))
2606 (with-current-buffer buf
2607 (let ((mjm (symbol-name major-mode
))
2608 (split (split-string anything-pattern
)))
2609 (cond ((string-match "\\s-$" anything-pattern
)
2610 (string-match (car split
) mjm
))
2611 ((string-match "\\s-" anything-pattern
)
2612 (and (string-match (car split
) mjm
)
2613 (string-match (cadr split
) cand
)))
2614 (t (or (string-match anything-pattern mjm
)
2615 (string-match anything-pattern cand
)))))))))
2617 (defun anything-c-buffer-query-replace-1 (&optional regexp-flag
)
2618 "Query replace in marked buffers.
2619 If REGEXP-FLAG is given use `query-replace-regexp'."
2620 (let ((fn (if regexp-flag
'query-replace-regexp
'query-replace
))
2621 (prompt (if regexp-flag
"Query replace regexp" "Query replace"))
2622 (bufs (anything-marked-candidates)))
2624 with replace
= (query-replace-read-from prompt regexp-flag
)
2625 with tostring
= (unless (consp replace
)
2626 (query-replace-read-to
2627 replace prompt regexp-flag
))
2630 (save-window-excursion
2631 (anything-c-switch-to-buffer buf
)
2633 (let ((case-fold-search t
))
2634 (goto-char (point-min))
2636 (apply fn
(list (car replace
) (cdr replace
)))
2637 (apply fn
(list replace tostring
)))))))))
2639 (defun anything-c-buffer-query-replace-regexp (candidate)
2640 (anything-c-buffer-query-replace-1 'regexp
))
2642 (defun anything-c-buffer-query-replace (candidate)
2643 (anything-c-buffer-query-replace-1))
2645 (defun anything-buffer-toggle-diff (candidate)
2646 "Toggle diff buffer CANDIDATE with it's file."
2647 (if (get-buffer-window "*Diff*")
2648 (kill-buffer "*Diff*")
2649 (diff-buffer-with-file (get-buffer candidate
))))
2652 (defun anything-buffer-diff-persistent ()
2653 "Toggle diff buffer without quitting anything."
2655 (anything-execute-persistent-action 'diff-action
))
2657 (defun anything-buffer-revert-and-update (candidate)
2658 (let ((marked (anything-marked-candidates)))
2659 (loop for buf in marked do
(anything-revert-buffer buf
))
2660 (anything-force-update candidate
)))
2663 (defun anything-buffer-revert-persistent ()
2664 "Revert buffer without quitting anything."
2666 (anything-execute-persistent-action 'revert-action
'onewindow
))
2668 (defun anything-buffer-save-and-update (candidate)
2669 (let ((marked (anything-marked-candidates))
2670 (enable-recursive-minibuffers t
))
2671 (loop for buf in marked do
2672 (with-current-buffer (get-buffer buf
)
2674 (anything-force-update candidate
)))
2677 (defun anything-buffer-save-persistent ()
2678 "Save buffer without quitting anything."
2680 (anything-execute-persistent-action 'save-action
'onewindow
))
2683 (defun anything-buffer-run-kill-buffers ()
2684 "Run kill buffer action from `anything-c-source-buffers-list'."
2686 (anything-c-quit-and-execute-action 'anything-kill-marked-buffers
))
2689 (defun anything-buffer-run-grep ()
2690 "Run Grep action from `anything-c-source-buffers-list'."
2692 (anything-c-quit-and-execute-action 'anything-c-grep-buffers
))
2695 (defun anything-buffer-run-zgrep ()
2696 "Run Grep action from `anything-c-source-buffers-list'."
2698 (anything-c-quit-and-execute-action 'anything-c-zgrep-buffers
))
2701 (defun anything-buffer-run-query-replace-regexp ()
2702 "Run Query replace regexp action from `anything-c-source-buffers-list'."
2704 (anything-c-quit-and-execute-action 'anything-c-buffer-query-replace-regexp
))
2707 (defun anything-buffer-run-query-replace ()
2708 "Run Query replace action from `anything-c-source-buffers-list'."
2710 (anything-c-quit-and-execute-action 'anything-c-buffer-query-replace
))
2713 (defun anything-buffer-switch-other-window ()
2714 "Run switch to other window action from `anything-c-source-buffers-list'."
2716 (anything-c-quit-and-execute-action 'switch-to-buffer-other-window
))
2719 (defun anything-buffer-switch-other-frame ()
2720 "Run switch to other frame action from `anything-c-source-buffers-list'."
2722 (anything-c-quit-and-execute-action 'switch-to-buffer-other-frame
))
2725 (defun anything-buffer-switch-to-elscreen ()
2726 "Run switch to elscreen action from `anything-c-source-buffers-list'."
2728 (anything-c-quit-and-execute-action 'anything-find-buffer-on-elscreen
))
2731 (defun anything-buffer-run-ediff ()
2732 "Run ediff action from `anything-c-source-buffers-list'."
2734 (anything-c-quit-and-execute-action 'anything-ediff-marked-buffers
))
2736 (defun anything-buffer-run-ediff-merge ()
2737 "Run ediff action from `anything-c-source-buffers-list'."
2739 (anything-c-quit-and-execute-action 'anything-ediff-marked-buffers-merge
))
2741 (defun anything-c-buffers-persistent-kill (buffer)
2742 "Persistent action to kill buffer."
2743 (with-current-buffer (get-buffer buffer
)
2744 (if (and (buffer-modified-p)
2745 (buffer-file-name (current-buffer)))
2748 (kill-buffer buffer
))
2749 (kill-buffer buffer
)))
2750 (anything-delete-current-selection))
2752 (defun anything-c-buffers-list-persistent-action (candidate)
2753 (if current-prefix-arg
2754 (anything-c-buffers-persistent-kill candidate
)
2755 (anything-c-switch-to-buffer candidate
)))
2761 ;;; File name history
2762 (defvar anything-c-source-file-name-history
2763 '((name .
"File Name History")
2764 (candidates . file-name-history
)
2765 (match anything-c-match-on-basename
)
2767 ;; (anything 'anything-c-source-file-name-history)
2769 ;;; Files in current dir
2772 (defvar anything-c-source-files-in-current-dir
2773 '((name .
"Files from Current Directory")
2774 (candidates .
(lambda ()
2775 (with-anything-current-buffer
2776 (directory-files (anything-c-current-directory)))))
2777 ;; volatile is not needed, I think.
2779 ;; (anything 'anything-c-source-files-in-current-dir)
2781 (defun anything-c-highlight-files (files)
2782 (loop for i in files
2783 if
(file-directory-p i
)
2784 collect
(propertize (file-name-nondirectory i
)
2785 'face
'anything-ff-directory
2786 'help-echo
(expand-file-name i
))
2788 collect
(propertize (file-name-nondirectory i
)
2789 'face
'anything-ff-file
2790 'help-echo
(expand-file-name i
))))
2792 (defvar anything-c-source-files-in-current-dir
+
2793 '((name .
"Files from Current Directory")
2794 (candidates .
(lambda ()
2795 (with-anything-current-buffer
2796 (directory-files (anything-c-current-directory) t
))))
2797 (candidate-transformer anything-c-highlight-files
)
2798 ;; volatile is not needed, I think.
2800 ;; (anything 'anything-c-source-files-in-current-dir+)
2804 ;;; Anything-find-files - The anything files browser.
2808 (defvar anything-c-find-files-doc-header
" (`C-l': Go to precedent level)"
2809 "*The doc that is inserted in the Name header of a find-files or dired source.")
2810 (defvar anything-ff-auto-update-flag nil
2811 "Internal, flag to turn on/off auto-update in `anything-find-files'.
2812 Don't set it directly, use instead `anything-ff-auto-update-initial-value'.")
2813 (defvar anything-ff-last-expanded nil
2814 "Store last expanded directory or file.")
2815 (defvar anything-ff-default-directory nil
)
2816 (defvar anything-ff-history nil
)
2817 (defvar anything-ff-cand-to-mark nil
)
2820 (defvar anything-c-source-find-files
2821 `((name .
"Find Files")
2822 (header-name .
(lambda (name)
2823 (concat name anything-c-find-files-doc-header
)))
2824 ;; It is needed for filenames with capital letters
2827 (setq anything-ff-auto-update-flag
2828 anything-ff-auto-update-initial-value
)))
2829 (candidates . anything-find-files-get-candidates
)
2830 (filtered-candidate-transformer anything-c-find-files-transformer
)
2831 (persistent-action . anything-find-files-persistent-action
)
2832 (persistent-help .
"Hit1 Expand Candidate, Hit2 or (C-u) Find file")
2833 (mode-line . anything-ff-mode-line-string
)
2835 (candidate-number-limit .
9999)
2836 (action-transformer . anything-find-files-action-transformer
)
2840 `(("Find File" . anything-c-find-file-or-marked
)
2841 ("Find file in Dired" . anything-c-point-file-in-dired
)
2842 ,(and (locate-library "elscreen")
2843 '("Find file in Elscreen" . anything-elscreen-find-file
))
2844 ,(and (locate-library "popwin")
2845 '("Find file in popup window" . popwin
:find-file
))
2846 ("Checksum File" . anything-ff-checksum
)
2847 ("Complete at point `M-tab'"
2848 . anything-c-insert-file-name-completion-at-point
)
2849 ("Open file externally `C-c C-x, C-u to choose'"
2850 . anything-c-open-file-externally
)
2851 ("Grep File(s) `M-g s, C-u Recurse'" . anything-find-files-grep
)
2852 ("Zgrep File(s) `M-g z, C-u Recurse'" . anything-ff-zgrep
)
2853 ("Switch to Eshell `M-e'" . anything-ff-switch-to-eshell
)
2854 ("Etags `M-., C-u tap, C-u C-u reload tag file'" . anything-ff-etags-select
)
2855 ("Eshell command on file(s) `M-!, C-u run on all marked at once.'"
2856 . anything-find-files-eshell-command-on-file
)
2857 ("Find file as root" . anything-find-file-as-root
)
2858 ("Find file in hex dump" . hexl-find-file
)
2859 ("Ediff File `C-='" . anything-find-files-ediff-files
)
2860 ("Ediff Merge File `C-c ='" . anything-find-files-ediff-merge-files
)
2861 ("Delete File(s) `M-D'" . anything-delete-marked-files
)
2862 ("Copy file(s) `M-C, C-u to follow'" . anything-find-files-copy
)
2863 ("Copy file(s) Async" . anything-ff-copy-async
)
2864 ("Rename file(s) `M-R, C-u to follow'" . anything-find-files-rename
)
2865 ("Serial rename files" . anything-ff-serial-rename
)
2866 ("Serial rename by symlinking files" . anything-ff-serial-rename-by-symlink
)
2867 ("Serial rename by copying files" . anything-ff-serial-rename-by-copying
)
2868 ("Symlink files(s) `M-S, C-u to follow'" . anything-find-files-symlink
)
2869 ("Relsymlink file(s) `C-u to follow'" . anything-find-files-relsymlink
)
2870 ("Hardlink file(s) `C-u to follow'" . anything-find-files-hardlink
)
2871 ("Find file other window `C-o'" . find-file-other-window
)
2872 ("Switch to history `M-p'" . anything-find-files-switch-to-hist
)
2873 ("Find file other frame `C-c C-o'" . find-file-other-frame
)
2874 ("Print File `C-c p'" . anything-ff-print
)
2875 ("Locate `C-x C-f, C-u to specify locate db'" . anything-ff-locate
))))))
2876 ;; (anything 'anything-c-source-find-files)
2878 (defun anything-find-files-set-prompt-for-action (action files
)
2879 "Set prompt for action ACTION for FILES."
2880 (let ((len (length files
)))
2881 (format "%s *%s File(s)\n%s to: "
2883 (mapconcat (lambda (f)
2884 (format "- %s\n" f
)) files
""))))
2886 (defun anything-dwim-target-directory ()
2887 "Return value of `default-directory' of buffer in other window.
2888 If there is only one window return the value ot `default-directory'
2889 for current buffer."
2890 (with-anything-current-buffer
2891 (let ((num-windows (length (window-list))))
2892 (if (> num-windows
1)
2893 (save-window-excursion
2896 (car anything-ff-history
)))))
2898 (defun anything-find-files-do-action (action)
2899 "Generic function for creating action from `anything-c-source-find-files'.
2900 ACTION must be an action supported by `anything-dired-action'."
2901 (let* ((ifiles (mapcar 'expand-file-name
; Allow modify '/foo/.' -> '/foo'
2902 (anything-marked-candidates)))
2903 (cand (anything-get-selection)) ; Target
2904 (prompt (anything-find-files-set-prompt-for-action
2905 (capitalize (symbol-name action
)) ifiles
))
2906 (parg anything-current-prefix-arg
)
2907 (dest (anything-c-read-file-name
2909 :preselect
(if anything-ff-transformer-show-only-basename
2910 (anything-c-basename cand
) cand
)
2911 :initial-input
(anything-dwim-target-directory)
2912 :history
(anything-find-files-history :comp-read nil
))))
2913 (anything-dired-action
2914 dest
:files ifiles
:action action
:follow parg
)))
2916 (defun anything-find-files-copy (candidate)
2917 "Copy files from `anything-find-files'."
2918 (anything-find-files-do-action 'copy
))
2920 (defun anything-find-files-rename (candidate)
2921 "Rename files from `anything-find-files'."
2922 (anything-find-files-do-action 'rename
))
2924 (defun anything-find-files-symlink (candidate)
2925 "Symlink files from `anything-find-files'."
2926 (anything-find-files-do-action 'symlink
))
2928 (defun anything-find-files-relsymlink (candidate)
2929 "Relsymlink files from `anything-find-files'."
2930 (anything-find-files-do-action 'relsymlink
))
2932 (defun anything-find-files-hardlink (candidate)
2933 "Hardlink files from `anything-find-files'."
2934 (anything-find-files-do-action 'hardlink
))
2936 (defun anything-find-files-byte-compile (candidate)
2937 "Byte compile elisp files from `anything-find-files'."
2938 (let ((files (anything-marked-candidates))
2939 (parg anything-current-prefix-arg
))
2940 (loop for fname in files
2941 do
(byte-compile-file fname parg
))))
2943 (defun anything-find-files-load-files (candidate)
2944 "Load elisp files from `anything-find-files'."
2945 (let ((files (anything-marked-candidates)))
2946 (loop for fname in files
2949 (defun anything-find-files-ediff-files-1 (candidate &optional merge
)
2950 "Generic function to ediff/merge files in `anything-find-files'."
2951 (let ((bname (anything-c-basename candidate
))
2952 (prompt (if merge
"Ediff Merge `%s' With File: "
2953 "Ediff `%s' With File: "))
2954 (fun (if merge
'ediff-merge-files
'ediff-files
)))
2957 (condition-case quit
2958 (anything-c-read-file-name
2959 (format prompt bname
))
2960 (quit ;; Hit C-g ask user to fallback to locate.
2961 (if (y-or-n-p "Search file for ediff with locate? ")
2962 (anything-c-locate-read-file-name
2963 (format prompt bname
)
2964 ;; Check if -b option is available.
2965 (if (and (eq system-type
'windows-nt
)
2966 (string-match "^es" anything-c-locate-command
))
2968 (concat bname
" -b")))
2969 (error "Error: Ediff Operation aborted")))))))
2971 (defun anything-find-files-ediff-files (candidate)
2972 (anything-find-files-ediff-files-1 candidate
))
2974 (defun anything-find-files-ediff-merge-files (candidate)
2975 (anything-find-files-ediff-files-1 candidate
'merge
))
2977 (defun anything-find-files-grep (candidate)
2978 "Default action to grep files from `anything-find-files'."
2979 (anything-do-grep-1 (anything-marked-candidates)
2980 anything-current-prefix-arg
))
2982 (defun anything-ff-zgrep (candidate)
2983 "Default action to zgrep files from `anything-find-files'."
2984 (let ((prefarg anything-current-prefix-arg
)
2985 (ls (anything-marked-candidates)))
2986 (anything-ff-zgrep-1 ls prefarg
)))
2988 (defun anything-ff-pdfgrep (candidate)
2989 "Default action to pdfgrep files from `anything-find-files'."
2990 (let ((cands (loop for file in
(anything-marked-candidates)
2991 if
(or (string= (file-name-extension file
) "pdf")
2992 (string= (file-name-extension file
) "PDF"))
2994 (anything-c-pdfgrep-default-function 'anything-c-pdfgrep-init
))
2996 (anything-do-pdfgrep-1 cands
))))
2998 (defun anything-ff-etags-select (candidate)
2999 "Default action to jump to etags from `anything-find-files'."
3000 (when (get-buffer anything-action-buffer
)
3001 (kill-buffer anything-action-buffer
))
3002 (let ((default-directory anything-ff-default-directory
))
3003 (anything-c-etags-select anything-current-prefix-arg
)))
3005 (defun anything-find-files-switch-to-hist (candidate)
3006 "Switch to anything-find-files history."
3007 (anything-find-files t
))
3009 ;;; Asynchronous copy of files.
3012 (defun anything-c-copy-files-async-1 (flist dest
)
3013 "Copy a list of Files FLIST to DEST asynchronously.
3014 It use another emacs process to do the job.
3015 Communication with background emacs is done with temp file
3016 `anything-c-copy-files-async-log-file'."
3017 (start-file-process "emacs-batch" nil anything-c-copy-async-prefered-emacs
3018 "-Q" "--batch" "--eval"
3020 (require 'dired) (require 'cl)
3021 (let ((dired-recursive-copies 'always)
3027 (let ((file-exists (file-exists-p
3029 (file-name-nondirectory (directory-file-name f))
3030 (file-name-directory
3031 (file-name-as-directory \"%s\"))))))
3032 (dired-copy-file f \"%s\" t)
3034 (progn (push (cons \"Overwriting\" f) success)
3036 (push (cons \"Copying\" f) success)
3039 (push (dired-make-relative
3041 (file-name-nondirectory (directory-file-name f))
3042 (file-name-directory \"%s\")))
3044 (with-current-buffer (find-file-noselect \"%s\")
3047 (dolist (fail (reverse failures))
3048 (insert (concat \"Failed to copy \" fail \"\n\"))))
3050 (loop for (a . s) in (reverse success) do
3051 (insert (concat a \" \" s \" to %s done\n\"))))
3052 (and (/= cpf-count 0) (insert (concat (int-to-string cpf-count) \" File(s) Copied\n\")))
3053 (and (/= ovw-count 0) (insert (concat (int-to-string ovw-count) \" File(s) Overwrited\n\")))
3054 (and failures (insert (concat (int-to-string (length failures)) \" File(s) Failed to copy\n\")))
3056 flist dest dest dest anything-c-copy-files-async-log-file dest
)))
3058 (defun anything-c-copy-async-with-log (flist dest
)
3059 "Copy file list FLIST to DEST showing log.
3060 Log is send to `anything-c-copy-files-async-log-file'.
3061 Copying is done asynchronously with `anything-c-copy-files-async-1'."
3062 (declare (special auto-revert-interval
))
3063 (pop-to-buffer (find-file-noselect anything-c-copy-files-async-log-file
))
3064 (set (make-local-variable 'auto-revert-interval
) 1)
3066 (insert "Wait copying files...\n")
3067 (sit-for 0.5) (save-buffer)
3068 (goto-char (point-max))
3069 (auto-revert-mode 1)
3070 (anything-c-copy-files-async-1 flist dest
))
3072 (defun anything-ff-copy-async (candidate)
3073 "Anything find files action to copy files async.
3074 Copying is done asynchronously with `anything-c-copy-files-async-1'."
3075 (let* ((flist (anything-marked-candidates))
3076 (dest (anything-c-read-file-name
3077 (anything-find-files-set-prompt-for-action
3079 :preselect candidate
3080 :initial-input
(car anything-ff-history
)
3081 :history
(anything-find-files-history :comp-read nil
))))
3082 (anything-c-copy-async-with-log flist dest
)))
3084 (defvar eshell-command-aliases-list nil
)
3085 (defvar anything-eshell-command-on-file-input-history nil
)
3086 (defun anything-find-files-eshell-command-on-file-1 (candidate &optional map
)
3087 "Run `eshell-command' on CANDIDATE or marked candidates possibly with an eshell alias.
3089 Basename of CANDIDATE can be a wild-card.
3090 If MAP is given run `eshell-command' on all marked files at once,
3091 Otherwise, run `eshell-command' on each marked files.
3093 If `eshell' or `eshell-command' have not been run once, or if you have no eshell aliases
3094 `eshell-command-aliases-list' will not be loaded first time you use this."
3095 (when (or eshell-command-aliases-list
3096 (y-or-n-p "Eshell is not loaded, run eshell-command without alias anyway? "))
3097 (and eshell-command-aliases-list
(eshell-read-aliases-list))
3098 (let* ((cand-list (anything-marked-candidates))
3099 (default-directory (or anything-ff-default-directory
3100 ;; If candidate is an url *-ff-default-directory is nil
3101 ;; so keep value of default-directory.
3103 (command (anything-comp-read
3105 (loop for
(a . c
) in eshell-command-aliases-list
3106 when
(string-match "\\(\\$1\\|\\$\\*\\)$" (car c
))
3107 collect
(propertize a
'help-echo
(car c
)) into ls
3108 finally return
(sort ls
'string
<))
3109 :buffer
"*esh command on file*"
3110 :name
"Eshell command"
3112 'anything-eshell-command-on-file-input-history
))
3113 (com-value (car (assoc-default command eshell-command-aliases-list
))))
3114 (if (and (or map
(and com-value
(string-match "\\$\\*$" com-value
)))
3115 (> (length cand-list
) 1))
3116 ;; Run eshell-command with ALL marked files as arguments.
3117 (let ((mapfiles (mapconcat 'shell-quote-argument cand-list
" ")))
3118 (eshell-command (format "%s %s" command mapfiles
)))
3119 ;; Run eshell-command on EACH marked files.
3122 for bn
= (anything-c-basename i
)
3123 for files
= (if (and bn
(string-match "^\*" bn
))
3124 ;; Assume if fname is a wildcard
3125 ;; cand-list have a length of 1.
3127 'shell-quote-argument
3128 (file-expand-wildcards i t
) " ")
3130 for com
= (if (string-match "'%s'\\|\"%s\"\\|%s" command
)
3131 ;; This allow to enter other args AFTER filename
3132 ;; i.e <command %s some_more_args>
3133 (format command files
)
3134 (format "%s %s" command files
))
3135 do
(eshell-command com
))))))
3137 (defun anything-find-files-eshell-command-on-file (candidate)
3138 "Run `eshell-command' on CANDIDATE or marked candidates.
3139 See `anything-find-files-eshell-command-on-file-1' for more info."
3140 (anything-find-files-eshell-command-on-file-1
3141 candidate anything-current-prefix-arg
))
3143 (defun anything-ff-switch-to-eshell (candidate)
3144 "Switch to eshell and cd to `anything-ff-default-directory'."
3145 (flet ((cd-eshell ()
3146 (goto-char (point-max))
3148 (format "cd '%s'" anything-ff-default-directory
))
3149 (eshell-send-input)))
3150 (if (get-buffer "*eshell*")
3152 (anything-c-switch-to-buffer "*eshell*")
3154 (call-interactively 'eshell
)
3157 (defun anything-ff-serial-rename-action (method)
3158 "Rename all marked files to `anything-ff-default-directory' with METHOD.
3159 See `anything-ff-serial-rename-1'."
3160 (let* ((cands (anything-marked-candidates))
3161 (name (read-string "NewName: "))
3162 (start (read-number "StartAtNumber: "))
3163 (extension (read-string "Extension: " (file-name-extension (car cands
))))
3164 (dir (expand-file-name
3165 (anything-c-read-file-name
3166 "Serial Rename to directory: " :initial-input
3167 (expand-file-name anything-ff-default-directory
)))))
3168 (when (y-or-n-p (format "Serial Rename %s *files to `%s' with prefix `%s'? "
3169 (length cands
) dir name
))
3170 (anything-ff-serial-rename-1 dir cands name start extension
:method method
)
3171 (anything-find-files-1 dir
))))
3173 (defun anything-ff-member-directory-p (file directory
)
3174 (let ((dir-file (expand-file-name (file-name-as-directory (file-name-directory file
))))
3175 (cur-dir (expand-file-name (file-name-as-directory directory
))))
3176 (string= dir-file cur-dir
)))
3178 (defun* anything-ff-serial-rename-1
3179 (directory collection new-name start-at-num extension
&key
(method 'rename
))
3180 "rename files in COLLECTION to DIRECTORY with the prefix name NEW-NAME.
3181 Rename start at number START-AT-NUM - ex: prefixname-01.jpg.
3182 EXTENSION is the file extension to use, in empty prompt,
3183 reuse the original extension of file.
3184 METHOD can be one of rename, copy or symlink.
3185 Files will be renamed if they are files of current directory, otherwise they
3186 will be treated with METHOD.
3187 Default METHOD is rename."
3188 ;; Maybe remove directories selected by error in collection.
3189 (setq collection
(remove-if 'file-directory-p collection
))
3190 (flet ((symlink-file (file dest
)
3191 (let ((flist (list file
)))
3192 (anything-dired-action
3193 dest
:action
'symlink
:files flist
))))
3195 (let* ((tmp-dir (file-name-as-directory
3196 (concat (file-name-as-directory directory
)
3197 (symbol-name (gensym "tmp")))))
3200 (symlink 'symlink-file
)
3201 (rename 'rename-file
)
3202 (t (error "Error: Unknow method %s" method
)))))
3203 (make-directory tmp-dir
)
3204 (loop for i in collection
3205 for count from start-at-num
3206 for fnum
= (if (< count
10) "0%s" "%s")
3207 for nname
= (concat tmp-dir new-name
(format fnum count
)
3208 (if (not (string= extension
""))
3209 (format ".%s" (replace-regexp-in-string
3210 "[.]" "" extension
))
3211 (file-name-extension i
'dot
)))
3212 do
(if (anything-ff-member-directory-p i directory
)
3213 (rename-file i nname
)
3214 (funcall fn i nname
)))
3215 (loop with dirlist
= (directory-files
3216 tmp-dir t directory-files-no-dot-files-regexp
)
3218 (if (file-symlink-p f
)
3219 (symlink-file (file-truename f
)
3220 (concat (file-name-as-directory directory
)
3221 (anything-c-basename f
)))
3222 (rename-file f directory
)))
3223 (delete-directory tmp-dir t
))))
3225 (defun anything-ff-serial-rename (candidate)
3226 "Serial rename all marked files to `anything-ff-default-directory'.
3227 Rename only file of current directory, and symlink files coming from
3229 See `anything-ff-serial-rename-1'."
3230 (anything-ff-serial-rename-action 'rename
))
3232 (defun anything-ff-serial-rename-by-symlink (candidate)
3233 "Serial rename all marked files to `anything-ff-default-directory'.
3234 Rename only file of current directory, and symlink files coming from
3236 See `anything-ff-serial-rename-1'."
3237 (anything-ff-serial-rename-action 'symlink
))
3239 (defun anything-ff-serial-rename-by-copying (candidate)
3240 "Serial rename all marked files to `anything-ff-default-directory'.
3241 Rename only file of current directory, and copy files coming from
3243 See `anything-ff-serial-rename-1'."
3244 (anything-ff-serial-rename-action 'copy
))
3246 (defun anything-c-quit-and-execute-action (action)
3247 "Quit current anything session and execute ACTION."
3248 (setq anything-saved-action action
)
3249 (anything-exit-minibuffer))
3251 (defun anything-ff-toggle-auto-update (candidate)
3252 (setq anything-ff-auto-update-flag
(not anything-ff-auto-update-flag
))
3253 (message "[Auto expansion %s]"
3254 (if anything-ff-auto-update-flag
"enabled" "disabled")))
3257 (defun anything-ff-run-toggle-auto-update ()
3259 (anything-attrset 'toggle-auto-update
'anything-ff-toggle-auto-update
)
3260 (anything-execute-persistent-action 'toggle-auto-update
))
3263 (defun anything-ff-run-switch-to-history ()
3264 "Run Switch to history action from `anything-c-source-find-files'."
3266 (anything-c-quit-and-execute-action 'anything-find-files-switch-to-hist
))
3269 (defun anything-ff-run-grep ()
3270 "Run Grep action from `anything-c-source-find-files'."
3272 (anything-c-quit-and-execute-action 'anything-find-files-grep
))
3275 (defun anything-ff-run-pdfgrep ()
3276 "Run Pdfgrep action from `anything-c-source-find-files'."
3278 (anything-c-quit-and-execute-action 'anything-ff-pdfgrep
))
3281 (defun anything-ff-run-zgrep ()
3282 "Run Grep action from `anything-c-source-find-files'."
3284 (anything-c-quit-and-execute-action 'anything-ff-zgrep
))
3287 (defun anything-ff-run-copy-file ()
3288 "Run Copy file action from `anything-c-source-find-files'."
3290 (anything-c-quit-and-execute-action 'anything-find-files-copy
))
3293 (defun anything-ff-run-rename-file ()
3294 "Run Rename file action from `anything-c-source-find-files'."
3296 (anything-c-quit-and-execute-action 'anything-find-files-rename
))
3299 (defun anything-ff-run-byte-compile-file ()
3300 "Run Byte compile file action from `anything-c-source-find-files'."
3302 (anything-c-quit-and-execute-action 'anything-find-files-byte-compile
))
3305 (defun anything-ff-run-load-file ()
3306 "Run Load file action from `anything-c-source-find-files'."
3308 (anything-c-quit-and-execute-action 'anything-find-files-load-files
))
3311 (defun anything-ff-run-eshell-command-on-file ()
3312 "Run eshell command on file action from `anything-c-source-find-files'."
3314 (anything-c-quit-and-execute-action 'anything-find-files-eshell-command-on-file
))
3317 (defun anything-ff-run-ediff-file ()
3318 "Run Ediff file action from `anything-c-source-find-files'."
3320 (anything-c-quit-and-execute-action 'anything-find-files-ediff-files
))
3323 (defun anything-ff-run-ediff-merge-file ()
3324 "Run Ediff merge file action from `anything-c-source-find-files'."
3326 (anything-c-quit-and-execute-action 'anything-find-files-ediff-merge-files
))
3329 (defun anything-ff-run-symlink-file ()
3330 "Run Symlink file action from `anything-c-source-find-files'."
3332 (anything-c-quit-and-execute-action 'anything-find-files-symlink
))
3335 (defun anything-ff-run-delete-file ()
3336 "Run Delete file action from `anything-c-source-find-files'."
3338 (anything-c-quit-and-execute-action 'anything-delete-marked-files
))
3341 (defun anything-ff-run-complete-fn-at-point ()
3342 "Run complete file name action from `anything-c-source-find-files'."
3344 (anything-c-quit-and-execute-action
3345 'anything-c-insert-file-name-completion-at-point
))
3348 (defun anything-ff-run-switch-to-eshell ()
3349 "Run switch to eshell action from `anything-c-source-find-files'."
3351 (anything-c-quit-and-execute-action 'anything-ff-switch-to-eshell
))
3354 (defun anything-ff-run-switch-other-window ()
3355 "Run switch to other window action from `anything-c-source-find-files'."
3357 (anything-c-quit-and-execute-action 'find-file-other-window
))
3360 (defun anything-ff-run-switch-other-frame ()
3361 "Run switch to other frame action from `anything-c-source-find-files'."
3363 (anything-c-quit-and-execute-action 'find-file-other-frame
))
3366 (defun anything-ff-run-open-file-externally ()
3367 "Run open file externally command action from `anything-c-source-find-files'."
3369 (anything-c-quit-and-execute-action 'anything-c-open-file-externally
))
3371 (defun anything-ff-locate (candidate)
3372 "Locate action function for `anything-find-files'."
3373 (let ((input (concat (anything-c-basename
3376 anything-ff-default-directory
))
3377 ;; The locate '-b' option doesn't exists
3379 (unless (and (eq system-type
'windows-nt
)
3380 (string-match "^es" anything-c-locate-command
))
3382 (anything-mp-highlight-delay 0.7))
3383 (anything-locate-1 anything-current-prefix-arg input
)))
3386 (defun anything-ff-run-locate ()
3387 "Run locate action from `anything-c-source-find-files'."
3389 (anything-c-quit-and-execute-action 'anything-ff-locate
))
3392 (defun anything-ff-run-gnus-attach-files ()
3393 "Run gnus attach files command action from `anything-c-source-find-files'."
3395 (anything-c-quit-and-execute-action 'anything-ff-gnus-attach-files
))
3398 (defun anything-ff-run-etags ()
3399 "Run Etags command action from `anything-c-source-find-files'."
3401 (anything-c-quit-and-execute-action 'anything-ff-etags-select
))
3404 (defun anything-ff-print (candidate)
3405 "Print marked files.
3406 You have to set in order
3407 variables `lpr-command',`lpr-switches' and/or `printer-name'.
3410 \(setq lpr-command \"gtklp\"\)
3411 \(setq lpr-switches '(\"-P\")\)
3412 \(setq printer-name \"Epson-Stylus-Photo-R265\"\)
3414 Same as `dired-do-print' but for anything."
3415 (let* ((file-list (anything-marked-candidates))
3416 (len (length file-list
))
3417 (printer-name (if anything-ff-printer-list
3419 "Printer: " anything-ff-printer-list
)
3421 (command (read-string
3422 (format "Print *%s File(s):\n%s with: "
3425 (lambda (f) (format "- %s\n" f
))
3427 (when (and lpr-command
3430 (mapconcat 'identity
3432 (append (if (stringp lpr-switches
)
3435 (list printer-name
)))
3437 (file-args (mapconcat #'(lambda (x)
3440 (cmd-line (concat command
" " file-args
)))
3442 (start-process-shell-command "anything-print" nil cmd-line
)
3443 (error "Error: Please verify your printer settings in Emacs."))))
3446 (defun anything-ff-run-print-file ()
3447 "Run Print file action from `anything-c-source-find-files'."
3449 (anything-c-quit-and-execute-action 'anything-ff-print
))
3451 (defun anything-ff-checksum (file)
3452 "Calculate the checksum of FILE.
3453 Provide completion on different algorithms to use on Emacs24.
3454 On Emacs23 only 'sha1' is available.
3455 The checksum is copied to kill-ring."
3456 (let ((algo-list (and (fboundp 'secure-hash
)
3457 '(md5 sha1 sha224 sha256 sha384 sha512
))))
3460 (secure-hash (intern
3462 "Algorithm: " algo-list
))
3464 (sha1 (with-temp-buffer
3465 (insert-file-contents file
)
3467 (message "Checksum copied to kill-ring.")))
3469 (defun anything-ff-toggle-basename (candidate)
3470 (setq anything-ff-transformer-show-only-basename
3471 (not anything-ff-transformer-show-only-basename
))
3472 (let ((target (if anything-ff-transformer-show-only-basename
3473 (anything-c-basename candidate
) candidate
)))
3474 (anything-force-update target
)))
3476 (defun anything-ff-run-toggle-basename ()
3478 (anything-attrset 'toggle-basename
'anything-ff-toggle-basename
)
3479 (anything-execute-persistent-action 'toggle-basename
))
3481 (defun* anything-reduce-file-name
(fname level
&key unix-close expand
)
3482 "Reduce FNAME by LEVEL from end or beginning depending LEVEL value.
3483 If LEVEL is positive reduce from end else from beginning.
3484 If UNIX-CLOSE is non--nil close filename with /.
3485 If EXPAND is non--nil expand-file-name."
3486 (let* ((exp-fname (expand-file-name fname
))
3487 (fname-list (split-string (if (or (string= fname
"~/") expand
)
3488 exp-fname fname
) "/" t
))
3489 (len (length fname-list
))
3490 (pop-list (if (< level
0)
3491 (subseq fname-list
(* level -
1))
3492 (subseq fname-list
0 (- len level
))))
3493 (result (mapconcat 'identity pop-list
"/"))
3494 (empty (string= result
"")))
3495 (when unix-close
(setq result
(concat result
"/")))
3496 (if (string-match "^~" result
)
3497 (if (string= result
"~/") "~/" result
)
3499 (if empty
"../" (concat "../" result
))
3500 (cond ((eq system-type
'windows-nt
)
3501 (if empty
"c:/" result
))
3504 (concat "/" result
)))))))
3507 (defvar anything-file-completion-sources
3508 '("Find Files" "Read File Name"
3509 "Read File Name History" "Copy Files"
3510 "Rename Files" "Symlink Files"
3511 "Hardlink Files" "Write File" "Insert File")
3512 "Sources that use the *find-files mechanism can be added here.
3513 You should not modify this yourself and know what you do if you do so.")
3515 (defun anything-file-completion-source-p ()
3516 "Test if current source is a dired or find-files source."
3517 (let ((cur-source (cdr (assoc 'name
(anything-get-current-source)))))
3518 (loop for i in anything-file-completion-sources
3519 thereis
(string= cur-source i
))))
3521 (defun anything-find-files-down-one-level (arg)
3522 "Go down one level like unix command `cd ..'.
3523 If prefix numeric arg is given go ARG level down."
3525 (when (and (anything-file-completion-source-p)
3526 (not (anything-ff-invalid-tramp-name-p)))
3527 (with-anything-window
3528 (setq anything-follow-mode nil
))
3529 ;; When going to precedent level we want to be at the line
3530 ;; corresponding to actual directory, so store this info
3531 ;; in `anything-ff-last-expanded'.
3532 (if (and (not (file-directory-p anything-pattern
))
3533 (file-exists-p anything-pattern
))
3534 (setq anything-ff-last-expanded anything-pattern
)
3535 (setq anything-ff-last-expanded anything-ff-default-directory
))
3536 (let ((new-pattern (anything-reduce-file-name anything-pattern arg
3537 :unix-close t
:expand t
)))
3538 (anything-set-pattern new-pattern
))))
3540 (defun anything-ff-retrieve-last-expanded ()
3541 "Move overlay to last visited directory `anything-ff-last-expanded'.
3542 This happen after using `anything-find-files-down-one-level',
3543 or hitting C-z on \"..\"."
3544 (when (and anything-ff-last-expanded
3545 (anything-file-completion-source-p))
3546 (let ((dirname (if anything-ff-transformer-show-only-basename
3547 (anything-c-basename
3548 (directory-file-name anything-ff-last-expanded
))
3549 (directory-file-name anything-ff-last-expanded
))))
3550 (with-anything-window
3551 (when (or (re-search-forward (concat dirname
"$") nil t
)
3553 (concat anything-ff-last-expanded
"$") nil t
))
3555 (anything-mark-current-line)))
3556 (setq anything-ff-last-expanded nil
))))
3557 (add-hook 'anything-after-update-hook
'anything-ff-retrieve-last-expanded
)
3559 ;; Auto-update - anything-find-files auto expansion of directories.
3561 (defun anything-ff-update-when-only-one-matched ()
3562 "Expand to directory when sole completion.
3563 When only one candidate is remaining and it is a directory,
3564 expand to this directory."
3565 (when (and anything-ff-auto-update-flag
3566 (anything-file-completion-source-p)
3567 (not (anything-ff-invalid-tramp-name-p)))
3568 (let* ((history-p (string= (assoc-default
3569 'name
(anything-get-current-source))
3570 "Read File Name History"))
3571 (pat (if (string-match tramp-file-name-regexp
3573 (anything-create-tramp-name anything-pattern
)
3575 (completed-p (string= (file-name-as-directory pat
)
3576 anything-ff-default-directory
)))
3578 ;; Only one candidate remaining
3579 ;; and at least 2 char in basename.
3580 (and (<= (anything-approximate-candidate-number) 2)
3581 (>= (length (anything-c-basename anything-pattern
)) 2))
3582 ;; Already completed.
3584 (not history-p
)) ; Don't try to auto complete in history.
3585 (with-anything-window
3586 (let ((cur-cand (prog2
3588 ;; Only one non--existing candidate
3589 ;; and one directory candidate, move to it.
3590 (anything-next-line))
3591 (anything-get-selection))))
3592 (when (file-directory-p cur-cand
)
3593 (if (and (not (string-match "^.*[.]\\{1,2\\}$" cur-cand
)) ; [1]
3594 ;; Maybe we are here because completed-p is true
3595 ;; but check this again to be sure. (Windows fix)
3596 (<= (anything-approximate-candidate-number) 2)) ; [2]
3597 ;; If after going to next line the candidate
3598 ;; is not one of "." or ".." [1]
3599 ;; and only one candidate is remaining [2],
3600 ;; assume candidate is a new directory to expand, and do it.
3601 (anything-set-pattern (file-name-as-directory cur-cand
))
3602 ;; The candidate is one of "." or ".."
3603 ;; that mean we have entered the last letter of the directory name
3604 ;; in prompt, so expansion is already done, just add the "/" at end
3605 ;; of name unless anything-pattern ends with "."
3606 ;; (i.e we are writing something starting with ".")
3607 (unless (string-match "^.*[.]\\{1\\}$" anything-pattern
)
3608 (anything-set-pattern
3609 ;; Need to expand-file-name to avoid e.g /ssh:host:./ in prompt.
3610 (expand-file-name (file-name-as-directory anything-pattern
)))))
3611 (anything-check-minibuffer-input-1))))))))
3612 (add-hook 'anything-after-update-hook
'anything-ff-update-when-only-one-matched
)
3614 ;; Allow expanding to home directory or root
3615 ;; when entering respectively "~/" or "//" at end of pattern.
3616 ;; e.g /home/thierry/labo/anything-config-qp/~/
3617 ;; will expand to "~/"
3618 ;; and /home/thierry/labo/anything-config-qp//
3619 ;; will expand to "/"
3620 (defun anything-ff-auto-expand-to-home-or-root ()
3621 "Goto home, root or default directory when pattern ends with ~/, /, or ./.
3622 This happen only in function using sources that are
3623 `anything-file-completion-source-p' compliant."
3624 (when (and (anything-file-completion-source-p)
3625 (string-match ".*\\(/~/\\|/\\{2\\}\\|/[.]\\{1\\}/\\)$"
3627 (let ((match (match-string 1 anything-pattern
)))
3628 (cond ((string= match
"//")
3629 (if (eq system-type
'windows-nt
)
3630 (setq anything-pattern
"c:/")
3631 (setq anything-pattern
"/")))
3632 ((string= match
"/~/")
3633 (if (eq system-type
'windows-nt
)
3634 (setq anything-pattern
(file-name-as-directory (getenv "HOME")))
3635 (setq anything-pattern
"~/")))
3636 ((string= match
"/./")
3637 (setq anything-pattern
3638 (with-anything-current-buffer
3639 (expand-file-name default-directory
))))))
3640 (setq anything-ff-default-directory anything-pattern
)
3641 ;; For some reasons, i must use here with-current-buffer => mini buffer
3642 ;; and not `anything-set-pattern' that use with-selected-window => mini win.
3643 (with-current-buffer (window-buffer (minibuffer-window))
3644 (delete-minibuffer-contents)
3645 (insert anything-pattern
))))
3647 (add-hook 'anything-after-update-hook
'anything-ff-auto-expand-to-home-or-root
)
3649 (defun anything-c-point-file-in-dired (file)
3650 "Put point on filename FILE in dired buffer."
3651 (dired (file-name-directory file
))
3652 (dired-goto-file file
))
3654 (defun anything-create-tramp-name (fname)
3655 "Build filename for `anything-pattern' like /su:: or /sudo::."
3656 (apply #'tramp-make-tramp-file-name
3657 (loop with v
= (tramp-dissect-file-name fname
)
3658 for i across v collect i
)))
3660 (defun* anything-ff-tramp-hostnames
(&optional
(pattern anything-pattern
))
3661 "Get a list of hosts for tramp method found in `anything-pattern'.
3662 Argument PATTERN default to `anything-pattern', it is here only for debugging
3664 (when (string-match tramp-file-name-regexp pattern
)
3665 (let ((method (match-string 1 pattern
))
3666 (tn (match-string 0 pattern
))
3667 (all-methods (mapcar 'car tramp-methods
)))
3669 (loop for
(f . h
) in
(tramp-get-completion-function method
)
3670 append
(loop for e in
(funcall f
(car h
))
3671 for host
= (and (consp e
) (cadr e
))
3672 when
(and host
(not (member host all-methods
)))
3673 collect
(concat tn host
)))
3676 (defun anything-ff-before-action-hook-fn ()
3677 "Exit anything when user try to execute action on an invalid tramp fname."
3678 (let ((cand (anything-get-selection)))
3679 (when (and (anything-file-completion-source-p)
3680 (anything-ff-invalid-tramp-name-p cand
) ; Check candidate.
3681 (anything-ff-invalid-tramp-name-p)) ; check anything-pattern.
3682 (error "Error: Unknow file or directory `%s'" cand
))))
3683 (add-hook 'anything-before-action-hook
'anything-ff-before-action-hook-fn
)
3685 (defun* anything-ff-invalid-tramp-name-p
(&optional
(pattern anything-pattern
))
3686 "Return non--nil when PATTERN is an invalid tramp filename."
3687 (string= (anything-ff-set-pattern pattern
)
3688 "Invalid tramp file name"))
3690 (defun anything-ff-set-pattern (pattern)
3691 "Handle tramp filenames in `anything-pattern'."
3692 (let ((methods (mapcar 'car tramp-methods
))
3693 (reg "\\`/\\([^[/:]+\\|[^/]+]\\):.*:")
3694 cur-method tramp-name
)
3695 (cond ((string= pattern
"") "")
3696 ((string-match ".*\\(~?/?[.]\\{1\\}/\\)$" pattern
)
3697 (with-anything-current-buffer
3698 (expand-file-name default-directory
)))
3699 ((string-match ".*\\(~//\\|//\\)$" pattern
)
3700 (if (eq system-type
'windows-nt
) "c:/" "/"))
3701 ((string-match "^~\\|.*/~/$" pattern
)
3702 (let* ((home (expand-file-name (getenv "HOME"))))
3703 (replace-match home nil t pattern
)))
3704 ;; Match "/method:maybe_hostname:"
3705 ((and (string-match reg pattern
)
3706 (setq cur-method
(match-string 1 pattern
))
3707 (member cur-method methods
))
3708 (setq tramp-name
(anything-create-tramp-name
3709 (match-string 0 pattern
)))
3710 (replace-match tramp-name nil t pattern
))
3711 ;; Match "/hostname:"
3712 ((and (string-match tramp-file-name-regexp pattern
)
3713 (setq cur-method
(match-string 1 pattern
))
3714 (and cur-method
(not (member cur-method methods
))))
3715 (setq tramp-name
(anything-create-tramp-name
3716 (match-string 0 pattern
)))
3717 (replace-match tramp-name nil t pattern
))
3718 ;; Match "/method:" in this case don't try to connect.
3719 ((and (not (string-match reg pattern
))
3720 (string-match tramp-file-name-regexp pattern
)
3721 (member (match-string 1 pattern
) methods
))
3722 "Invalid tramp file name") ; Write in anything-buffer.
3723 ;; PATTERN is a directory, end it with "/".
3724 ;; This will make PATTERN not ending yet with "/"
3725 ;; candidate for `anything-ff-default-directory',
3726 ;; allowing `anything-ff-retrieve-last-expanded' to retrieve it
3727 ;; when descending level.
3728 ((file-directory-p pattern
)
3729 (file-name-as-directory pattern
))
3730 ;; Return PATTERN unchanged.
3733 (defun anything-find-files-get-candidates ()
3734 "Create candidate list for `anything-c-source-find-files'."
3735 (let* ((path (anything-ff-set-pattern anything-pattern
))
3736 (path-name-dir (if (file-directory-p path
)
3737 (file-name-as-directory path
)
3738 (file-name-directory path
)))
3739 (tramp-verbose anything-tramp-verbose
)) ; No tramp message when 0.
3740 (set-text-properties 0 (length path
) nil path
)
3741 ;; Don't set now `anything-pattern' if `path' == "Invalid tramp file name"
3742 ;; like that the actual value (e.g /ssh:) is passed to
3743 ;; `anything-ff-tramp-hostnames'.
3744 (unless (string= path
"Invalid tramp file name")
3745 (setq anything-pattern
(anything-ff-transform-fname-for-completion path
)))
3746 (setq anything-ff-default-directory
3747 (if (string= anything-pattern
"")
3748 (if (eq system-type
'windows-nt
) "c:/" "/")
3749 (unless (string-match ffap-url-regexp path
)
3750 ;; If path is an url *default-directory have to be nil.
3752 (cond ((string= path
"Invalid tramp file name")
3753 (or (anything-ff-tramp-hostnames) ; Hostnames completion.
3755 ;; `anything-pattern' have not been modified yet.
3756 ;; Set it here to the value of `path' that should be now
3757 ;; "Invalid tramp file name" and set the candidates list
3758 ;; to ("Invalid tramp file name") to make `anything-pattern'
3759 ;; match single candidate "Invalid tramp file name".
3760 (setq anything-pattern path
)
3761 ;; "Invalid tramp file name" is now printed
3762 ;; in `anything-buffer'.
3764 ((or (file-regular-p path
)
3765 (and (not (file-exists-p path
)) (string-match "/$" path
))
3766 (and ffap-url-regexp
(string-match ffap-url-regexp path
)))
3768 ((string= path
"") (directory-files "/" t
))
3769 ((and (file-directory-p path
) (not (file-readable-p path
)))
3770 (list (format "Opening directory: access denied, `%s'" path
)))
3771 ((file-directory-p path
) (directory-files path t
))
3773 (append (list path
) (directory-files path-name-dir t
))))))
3775 (defun anything-ff-transform-fname-for-completion (fname)
3776 "Return FNAME with it's basename modified as a regexp.
3777 e.g foo => f.*o.*o .
3778 If basename contain one or more space or FNAME is a valid directory name
3779 return FNAME unchanged."
3780 (let ((bn (anything-c-basename fname
)))
3781 (if (or (not anything-ff-smart-completion
)
3782 (string-match "\\s-" bn
)
3783 (string-match "/$" fname
) ; Allow mkdir.
3784 (file-directory-p fname
))
3785 fname
; Fall back to match-plugin.
3786 (setq bn
(if (> (length bn
) 2) ; Normal completion on first 2 char.
3787 (mapconcat 'identity
(split-string bn
"" t
) ".*") bn
))
3788 (concat (file-name-directory fname
) bn
))))
3790 (defun anything-ff-save-history ()
3791 "Store the last value of `anything-ff-default-directory' \
3792 in `anything-ff-history'."
3793 (when (and anything-ff-default-directory
3794 (anything-file-completion-source-p))
3795 (push anything-ff-default-directory anything-ff-history
)))
3796 (add-hook 'anything-cleanup-hook
'anything-ff-save-history
)
3798 (defun anything-ff-valid-symlink-p (file)
3799 (file-exists-p (file-truename file
)))
3801 (defun anything-ff-properties (candidate)
3802 "Show file properties of CANDIDATE in a tooltip or message."
3803 (let ((type (anything-ff-attributes candidate
:type t
))
3804 (dired-line (anything-ff-attributes candidate
:dired t
:human-size t
)))
3808 (anything-c-basename candidate
) ": \n"
3810 (when (string= type
"symlink")
3811 (format "True name: '%s'\n"
3812 (cond ((string-match "^\.#" (anything-c-basename candidate
))
3814 ((anything-ff-valid-symlink-p candidate
)
3815 (file-truename candidate
))
3816 (t "Invalid Symlink"))))
3818 (message dired-line
) (sit-for 5))))
3821 (defun anything-ff-properties-persistent ()
3822 "Show properties without quitting anything."
3824 (anything-attrset 'properties-action
'anything-ff-properties
)
3825 (anything-execute-persistent-action 'properties-action
))
3828 (defun anything-ff-persistent-delete ()
3829 "Delete current candidate without quitting."
3831 (anything-attrset 'quick-delete
'anything-ff-quick-delete
)
3832 (anything-execute-persistent-action 'quick-delete
))
3834 (defun anything-ff-quick-delete (candidate)
3835 "Delete file CANDIDATE without quitting."
3836 (let ((presel (prog1 (save-excursion
3838 (anything-next-line)
3839 (setq sel
(anything-get-selection))
3840 (if (string= sel candidate
)
3841 (progn (anything-previous-line)
3842 (anything-get-selection))
3844 (anything-mark-current-line))))
3845 (setq presel
(if (and anything-ff-transformer-show-only-basename
3846 (not (string-match-p "[.]\\{1,2\\}$" presel
)))
3847 (anything-c-basename presel
) presel
))
3848 (if anything-ff-quick-delete-dont-prompt-for-deletion
3849 (anything-c-delete-file candidate
)
3850 (save-window-excursion
3851 (when (y-or-n-p (format "Really Delete file `%s'? " candidate
))
3852 (anything-c-delete-file candidate
))))
3853 (anything-force-update presel
)))
3855 (defun anything-ff-kill-buffer-fname (candidate)
3856 (let* ((buf (get-file-buffer candidate
))
3857 (buf-name (buffer-name buf
)))
3860 (kill-buffer buf
) (message "Buffer `%s' killed" buf
))
3861 (message "No buffer to kill"))))
3863 (defun anything-ff-kill-or-find-buffer-fname (candidate)
3864 "Find file CANDIDATE or kill it's buffer if it is visible.
3865 Never kill `anything-current-buffer'.
3866 Never kill buffer modified.
3867 This is called normally on third hit of \
3868 \\<anything-map>\\[anything-execute-persistent-action]
3869 in `anything-find-files-persistent-action'."
3870 (let* ((buf (get-file-buffer candidate
))
3871 (buf-name (buffer-name buf
)))
3872 (if (and buf
(get-buffer-window buf
)
3873 (not (eq buf
(get-buffer anything-current-buffer
)))
3874 (not (buffer-modified-p buf
)))
3876 (kill-buffer buf
) (message "Buffer `%s' killed" buf-name
))
3877 (find-file candidate
))))
3880 (defun anything-ff-run-kill-buffer-persistent ()
3881 "Execute `anything-ff-kill-buffer-fname' whitout quitting."
3883 (anything-attrset 'kill-buffer-fname
'anything-ff-kill-buffer-fname
)
3884 (anything-execute-persistent-action 'kill-buffer-fname
))
3886 (defun anything-ff-human-size (size)
3887 "Return a string showing SIZE of a file in human readable form.
3888 SIZE can be an integer or a float depending it's value.
3889 `file-attributes' will take care of that to avoid overflow error.
3890 KBSIZE if a floating point number, default value is 1024.0."
3891 (let ((M (cons "M" (/ size
(expt anything-ff-default-kbsize
2))))
3892 (G (cons "G" (/ size
(expt anything-ff-default-kbsize
3))))
3893 (K (cons "K" (/ size anything-ff-default-kbsize
)))
3894 (B (cons "B" size
)))
3895 (loop with result
= B
3897 (loop for
(x . y
) in
(list M G K B
)
3898 unless
(< y
1) collect
(cons x y
))
3899 when
(< b
(cdr result
)) do
(setq result
(cons a b
))
3900 finally return
(if (string= (car result
) "B")
3902 (format "%.1f%s" (cdr result
) (car result
))))))
3904 (defun* anything-ff-attributes
3905 (file &key type links uid gid access-time modif-time
3906 status size mode gid-change inode device-num dired human-size
)
3907 "Easy interface for `file-attributes'."
3908 (let ((all (destructuring-bind
3909 (type links uid gid access-time modif-time
3910 status size mode gid-change inode device-num
)
3911 (file-attributes file
'string
)
3916 :access-time access-time
3917 :modif-time modif-time
3921 :gid-change gid-change
3923 :device-num device-num
))))
3925 (let ((result (getf all
:type
)))
3926 (cond ((stringp result
)
3928 (result "directory")
3930 (links (getf all
:links
))
3931 (uid (getf all
:uid
))
3932 (gid (getf all
:gid
))
3934 (format-time-string "%Y-%m-%d %R" (getf all
:access-time
)))
3936 (format-time-string "%Y-%m-%d %R" (getf all
:modif-time
)))
3938 (format-time-string "%Y-%m-%d %R" (getf all
:status
)))
3939 (size (if human-size
(anything-ff-human-size (getf all
:size
))
3941 (mode (getf all
:mode
))
3942 (gid-change (getf all
:gid-change
))
3943 (inode (getf all
:inode
))
3944 (device-num (getf all
:device-num
))
3947 (getf all
:mode
) " "
3948 (number-to-string (getf all
:links
)) " "
3951 (if human-size
(anything-ff-human-size (getf all
:size
))
3952 (int-to-string (getf all
:size
))) " "
3953 (format-time-string "%Y-%m-%d %R" (getf all
:modif-time
))))
3956 (defun anything-ff-prefix-filename (fname &optional file-or-symlinkp new-file
)
3957 "Return filename FNAME maybe prefixed with [?] or [@].
3958 If FILE-OR-SYMLINKP is non--nil this mean we assume FNAME is an
3959 existing filename or valid symlink and there is no need to test it.
3960 NEW-FILE when non--nil mean FNAME is a non existing file and
3961 return FNAME prefixed with [?]."
3962 (let* ((prefix-new (propertize
3964 (propertize "[?]" 'face
'anything-ff-prefix
)))
3965 (prefix-url (propertize
3967 (propertize "[@]" 'face
'anything-ff-prefix
))))
3968 (cond ((or file-or-symlinkp
(file-exists-p fname
)) fname
)
3969 ((string-match ffap-url-regexp fname
)
3970 (concat prefix-url
" " fname
))
3971 ((or new-file
(not (file-exists-p fname
)))
3972 (concat prefix-new
" " fname
)))))
3974 (defun anything-c-find-files-transformer (files sources
)
3975 "Transformer for `anything-c-source-find-files'.
3976 Tramp files are not highlighted unless `anything-ff-tramp-not-fancy'
3978 (if (and (string-match tramp-file-name-regexp anything-pattern
)
3979 anything-ff-tramp-not-fancy
)
3980 (if anything-ff-transformer-show-only-basename
3981 (loop for i in files collect
3982 (if (string-match "[.]\\{1,2\\}$" i
)
3983 i
(cons (anything-c-basename i
) i
)))
3985 (anything-ff-highlight-files files sources
)))
3987 (defun anything-ff-highlight-files (files sources
)
3988 "Candidate transformer for `anything-c-source-find-files' without icons."
3989 (loop for i in files
3990 for disp
= (if (and anything-ff-transformer-show-only-basename
3991 (not (string-match "[.]\\{1,2\\}$" i
))
3992 (not (string-match ffap-url-regexp i
)))
3993 (anything-c-basename i
) i
)
3995 (cond ((and (stringp (car (file-attributes i
)))
3996 (not (anything-ff-valid-symlink-p i
))
3997 (not (string-match "^\.#" (anything-c-basename i
))))
3998 (cons (anything-ff-prefix-filename
3999 (propertize disp
'face
'anything-ff-invalid-symlink
) t
)
4001 ((stringp (car (file-attributes i
)))
4002 (cons (anything-ff-prefix-filename
4003 (propertize disp
'face
'anything-ff-symlink
) t
)
4005 ((eq t
(car (file-attributes i
)))
4006 (cons (anything-ff-prefix-filename
4007 (propertize disp
'face
'anything-ff-directory
) t
)
4009 ((file-executable-p i
)
4010 (cons (anything-ff-prefix-filename
4011 (propertize disp
'face
'anything-ff-executable
) t
)
4014 (cons (anything-ff-prefix-filename
4015 (propertize disp
'face
'anything-ff-file
) t
)
4018 (cons (anything-ff-prefix-filename
4019 (propertize disp
'face
'anything-ff-file
) nil
'new-file
)
4022 (defun anything-find-files-action-transformer (actions candidate
)
4023 "Action transformer for `anything-c-source-find-files'."
4024 (cond ((with-anything-current-buffer
4025 (eq major-mode
'message-mode
))
4026 (append (subseq actions
0 4)
4027 '(("Gnus attach file(s)" . anything-ff-gnus-attach-files
))
4028 (subseq actions
4)))
4029 ((string-match (image-file-name-regexp) candidate
)
4030 (append (subseq actions
0 4)
4031 '(("Rotate image right `M-r'" . anything-ff-rotate-image-right
)
4032 ("Rotate image left `M-l'" . anything-ff-rotate-image-left
))
4033 (subseq actions
4)))
4034 ((string-match "\.el$" (anything-aif (anything-marked-candidates)
4035 (car it
) candidate
))
4036 (append (subseq actions
0 4)
4037 '(("Byte compile lisp file(s) `M-B, C-u to load'"
4038 . anything-find-files-byte-compile
)
4039 ("Load File(s) `M-L'" . anything-find-files-load-files
))
4040 (subseq actions
4)))
4041 ((and (string-match "\.html?$" candidate
)
4042 (file-exists-p candidate
))
4043 (append (subseq actions
0 4)
4044 '(("Browse url file" . browse-url-of-file
))
4045 (subseq actions
5)))
4046 ((or (string= (file-name-extension candidate
) "pdf")
4047 (string= (file-name-extension candidate
) "PDF"))
4048 (append (subseq actions
0 4)
4049 '(("Pdfgrep File(s)" . anything-ff-pdfgrep
))
4050 (subseq actions
5)))
4053 (defun anything-ff-gnus-attach-files (candidate)
4054 "Run `gnus-dired-attach' on `anything-marked-candidates' or CANDIDATE."
4055 (let ((flist (anything-marked-candidates)))
4056 (gnus-dired-attach flist
)))
4058 (defun anything-ff-rotate-current-image-1 (file &optional num-arg
)
4059 "Rotate current image at NUM-ARG degrees.
4060 This is a destructive operation on FILE made by external tool mogrify."
4061 (declare (special image-dired-display-image-buffer
))
4062 (setq file
(file-truename file
)) ; For symlinked images.
4063 ;; When FILE is not an image-file, do nothing.
4064 (when (string-match (image-file-name-regexp) file
)
4065 (if (executable-find "mogrify")
4067 (shell-command (format "mogrify -rotate %s %s"
4069 (shell-quote-argument file
)))
4070 (when (buffer-live-p image-dired-display-image-buffer
)
4071 (kill-buffer image-dired-display-image-buffer
))
4072 (image-dired-display-image file
)
4074 (display-buffer (get-buffer image-dired-display-image-buffer
)))
4075 (error "mogrify not found"))))
4077 (defun anything-ff-rotate-image-left (candidate)
4078 "Rotate image file CANDIDATE left.
4079 This affect directly file CANDIDATE."
4080 (anything-ff-rotate-current-image-1 candidate -
90))
4082 (defun anything-ff-rotate-image-right (candidate)
4083 "Rotate image file CANDIDATE right.
4084 This affect directly file CANDIDATE."
4085 (anything-ff-rotate-current-image-1 candidate
))
4087 (defun anything-ff-rotate-left-persistent ()
4088 "Rotate image left without quitting anything."
4090 (anything-attrset 'image-action1
'anything-ff-rotate-image-left
)
4091 (anything-execute-persistent-action 'image-action1
))
4093 (defun anything-ff-rotate-right-persistent ()
4094 "Rotate image right without quitting anything."
4096 (anything-attrset 'image-action2
'anything-ff-rotate-image-right
)
4097 (anything-execute-persistent-action 'image-action2
))
4099 (defun anything-ff-exif-data (candidate)
4100 "Extract exif data from file CANDIDATE using `anything-ff-exif-data-program'."
4101 (if (and anything-ff-exif-data-program
4102 (executable-find anything-ff-exif-data-program
))
4103 (shell-command-to-string (format "%s %s %s"
4104 anything-ff-exif-data-program
4105 anything-ff-exif-data-program-args
4107 (format "No program %s found to extract exif"
4108 anything-ff-exif-data-program
)))
4110 (defun anything-find-files-persistent-action (candidate)
4111 "Open subtree CANDIDATE without quitting anything.
4112 If CANDIDATE is not a directory expand CANDIDATE filename.
4113 If CANDIDATE is alone, open file CANDIDATE filename.
4115 First hit on C-z expand CANDIDATE second hit open file.
4116 If a prefix arg is given or `anything-follow-mode' is on open file."
4117 (let ((follow (buffer-local-value
4118 'anything-follow-mode
4119 (get-buffer-create anything-buffer
)))
4120 (new-pattern (anything-get-selection))
4121 (num-lines-buf (with-current-buffer anything-buffer
4122 (count-lines (point-min) (point-max)))))
4123 (flet ((insert-in-minibuffer (fname)
4124 (with-selected-window (minibuffer-window)
4126 (delete-minibuffer-contents)
4127 (set-text-properties 0 (length fname
) nil fname
)
4129 (cond ((and (string= (anything-ff-set-pattern anything-pattern
)
4130 "Invalid tramp file name")
4131 (string-match tramp-file-name-regexp candidate
))
4132 ;; First hit insert hostname and
4133 ;; second hit insert ":" and expand.
4134 (if (string= candidate anything-pattern
)
4135 (insert-in-minibuffer (concat candidate
":"))
4136 (insert-in-minibuffer candidate
)))
4137 (;; A symlink directory, expand it's truename.
4138 (and (file-directory-p candidate
) (file-symlink-p candidate
))
4139 (insert-in-minibuffer (file-name-as-directory
4141 (expand-file-name candidate
)))))
4142 ;; A directory, open it.
4143 ((file-directory-p candidate
)
4144 (when (string= (anything-c-basename candidate
) "..")
4145 (setq anything-ff-last-expanded anything-ff-default-directory
))
4146 (insert-in-minibuffer (file-name-as-directory
4147 (expand-file-name candidate
))))
4148 ;; A symlink file, expand to it's true name. (first hit)
4149 ((and (file-symlink-p candidate
) (not current-prefix-arg
) (not follow
))
4150 (insert-in-minibuffer (file-truename candidate
)))
4151 ;; A regular file, expand it, (first hit)
4152 ((and (>= num-lines-buf
3) (not current-prefix-arg
) (not follow
))
4153 (insert-in-minibuffer new-pattern
))
4154 ;; An image file and it is the second hit on C-z,
4155 ;; show the file in `image-dired'.
4156 ((string-match (image-file-name-regexp) candidate
)
4157 (when (buffer-live-p image-dired-display-image-buffer
)
4158 (kill-buffer image-dired-display-image-buffer
))
4159 (image-dired-display-image candidate
)
4161 (anything-c-switch-to-buffer image-dired-display-image-buffer
)
4162 (with-current-buffer image-dired-display-image-buffer
4163 (let ((exif-data (anything-ff-exif-data candidate
)))
4164 (image-dired-update-property 'help-echo exif-data
))))
4165 ;; Allow browsing archive on avfs fs.
4166 ;; Assume volume is already mounted with mountavfs.
4167 ((and anything-ff-avfs-directory
4169 (regexp-quote (expand-file-name anything-ff-avfs-directory
))
4170 (file-name-directory candidate
))
4171 (anything-ff-file-compressed-p candidate
))
4172 (insert-in-minibuffer (concat candidate
"#")))
4173 ;; On second hit we open file.
4174 ;; On Third hit we kill it's buffer maybe.
4176 (anything-ff-kill-or-find-buffer-fname candidate
))))))
4178 (defun anything-ff-file-compressed-p (candidate)
4179 "Whether CANDIDATE is a compressed file or not."
4180 (member (file-name-extension candidate
)
4181 anything-ff-file-compressed-list
))
4183 (defun anything-c-insert-file-name-completion-at-point (candidate)
4184 "Insert file name completion at point."
4185 (with-anything-current-buffer
4186 (if buffer-read-only
4187 (error "Error: Buffer `%s' is read-only" (buffer-name))
4188 (let* ((end (point))
4189 (guess (substring-no-properties (thing-at-point 'filename
)))
4190 (beg (- (point) (length guess
)))
4191 (full-path-p (or (string-match-p (concat "^" (getenv "HOME")) guess
)
4192 (string-match-p "^[^\~]" guess
))))
4193 (set-text-properties 0 (length candidate
) nil candidate
)
4194 (if (and guess
(not (string= guess
""))
4195 (string-match-p "^~\\|/.*" guess
))
4197 (delete-region beg end
)
4198 (insert (if full-path-p
4199 (expand-file-name candidate
)
4200 (abbreviate-file-name candidate
))))
4201 (error "Aborting completion: No valid file name at point"))))))
4203 (defun* anything-find-files-history
(&key
(comp-read t
))
4204 "The `anything-find-files' history.
4205 Show the first `anything-ff-history-max-length' elements of
4206 `anything-ff-history' in an `anything-comp-read'."
4207 (let ((history (when anything-ff-history
4208 (anything-fast-remove-dups anything-ff-history
4211 (setq anything-ff-history
4212 (if (>= (length history
) anything-ff-history-max-length
)
4213 (subseq history
0 anything-ff-history-max-length
)
4217 "Switch to Directory: "
4219 :name
"Anything Find Files History"
4221 anything-ff-history
))))
4223 (defun anything-find-files-1 (fname &optional preselect
)
4224 "Find FNAME with `anything' completion.
4225 Like `find-file' but with `anything' support.
4226 Use it for non--interactive calls of `anything-find-files'."
4227 (when (get-buffer anything-action-buffer
)
4228 (kill-buffer anything-action-buffer
))
4229 (let ((anything-mp-highlight-delay nil
)
4230 ;; Be sure we don't erase the precedent minibuffer if some.
4231 (anything-ff-auto-update-initial-value
4232 (not (minibuffer-window-active-p (minibuffer-window))))
4233 anything-samewindow
)
4234 (anything :sources
'anything-c-source-find-files
4236 :preselect preselect
4237 :keymap anything-find-files-map
4238 :prompt
"Find Files or Url: "
4239 :buffer
"*Anything Find Files*")))
4242 (defun anything-find-files-initial-input (&optional input
)
4243 "Return INPUT if present, otherwise try to guess it."
4244 (or (and input
(expand-file-name input
))
4245 (anything-find-files-input
4247 (thing-at-point 'filename
))))
4249 (defun anything-find-files-input (fap tap
)
4250 "Default input of `anything-find-files'."
4251 (let* ((def-dir (anything-c-current-directory))
4252 (lib (anything-find-library-at-point))
4253 (url (anything-ff-find-url-at-point))
4254 (file-p (and fap
(not (string= fap
""))
4256 tap
(not (string= tap
""))
4258 (file-name-directory (expand-file-name tap def-dir
))))))
4259 (cond (lib) ; e.g we are inside a require sexp.
4260 (url) ; String at point is an hyperlink.
4261 (file-p (expand-file-name tap def-dir
))
4262 (t (and (not (string= fap
"")) fap
)))))
4264 (defun anything-c-current-directory ()
4265 "Return current-directory name at point.
4266 Useful in dired buffers when there is inserted subdirs."
4267 (if (eq major-mode
'dired-mode
)
4268 (dired-current-directory)
4271 (defun anything-ff-find-url-at-point ()
4272 "Try to find link to an url in text-property at point."
4273 (let* ((he (get-text-property (point) 'help-echo
))
4274 (ov (overlays-at (point)))
4275 (ov-he (and ov
(overlay-get
4276 (car (overlays-at (point))) 'help-echo
)))
4277 (w3m-l (get-text-property (point) 'w3m-href-anchor
))
4278 (nt-prop (get-text-property (point) 'nt-link
)))
4280 (when (and (stringp he
) (string-match "^LINK: " he
))
4281 (setq he
(replace-match "" t t he
)))
4282 (loop for i in
(list he ov-he w3m-l nt-prop
)
4283 thereis
(and (stringp i
) (string-match ffap-url-regexp i
) i
))))
4285 (defun anything-find-library-at-point ()
4286 "Try to find library path at point.
4287 Find inside `require' and `declare-function' sexp."
4288 (require 'find-func
)
4289 (let* ((beg-sexp (save-excursion (search-backward "(" (point-at-bol) t
)))
4290 (end-sexp (save-excursion (search-forward ")" (point-at-eol) t
)))
4291 (sexp (and beg-sexp end-sexp
4292 (buffer-substring-no-properties
4293 (1+ beg-sexp
) (1- end-sexp
)))))
4295 (cond ((and sexp
(string-match "require \'.+[^)]" sexp
))
4297 (replace-regexp-in-string
4299 ;; If require use third arg, ignore it,
4300 ;; always use library path found in `load-path'.
4301 (second (split-string (match-string 0 sexp
))))))
4302 ((and sexp
(string-match-p "^declare-function" sexp
))
4304 (replace-regexp-in-string
4306 (third (split-string sexp
)))))
4309 ;;; Anything completion for `write-file'.==> C-x C-w
4310 (defvar anything-c-source-write-file
4311 `((name .
"Write File")
4312 (header-name .
(lambda (name)
4313 (concat name anything-c-find-files-doc-header
)))
4314 ;; It is needed for filenames with capital letters
4316 (candidates . anything-find-files-get-candidates
)
4317 (filtered-candidate-transformer anything-c-find-files-transformer
)
4318 (persistent-action . anything-find-files-persistent-action
)
4319 (persistent-help .
"Expand Candidate")
4322 (("Write File" .
(lambda (candidate)
4323 (write-file candidate
'confirm
)))))))
4325 ;;; Anything completion for `insert-file'.==> C-x i
4326 (defvar anything-c-source-insert-file
4327 `((name .
"Insert File")
4328 (header-name .
(lambda (name)
4329 (concat name anything-c-find-files-doc-header
)))
4330 ;; It is needed for filenames with capital letters
4332 (candidates . anything-find-files-get-candidates
)
4333 (filtered-candidate-transformer anything-c-find-files-transformer
)
4334 (persistent-action . anything-find-files-persistent-action
)
4335 (persistent-help .
"Expand Candidate")
4338 (("Insert File" .
(lambda (candidate)
4339 (when (y-or-n-p (format "Really insert %s in %s "
4340 candidate anything-current-buffer
))
4341 (insert-file-contents candidate
))))))))
4343 ;;; Anything completion for copy, rename and (rel)sym/hard/link files from dired.
4344 (defvar anything-c-source-copy-files
4345 `((name .
"Copy Files")
4346 (header-name .
(lambda (name)
4347 (concat name anything-c-find-files-doc-header
)))
4348 ;; It is needed for filenames with capital letters
4350 (candidates . anything-find-files-get-candidates
)
4351 (filtered-candidate-transformer anything-c-find-files-transformer
)
4352 (persistent-action . anything-find-files-persistent-action
)
4353 (persistent-help .
"Expand Candidate")
4357 .
(lambda (candidate)
4358 (anything-dired-action candidate
:action
'copy
)))
4360 .
(lambda (candidate)
4361 (anything-dired-action candidate
:action
'copy
:follow t
)))))))
4364 (defvar anything-c-source-rename-files
4365 `((name .
"Rename Files")
4366 (header-name .
(lambda (name)
4367 (concat name anything-c-find-files-doc-header
)))
4368 ;; It is needed for filenames with capital letters
4370 (candidates . anything-find-files-get-candidates
)
4371 (filtered-candidate-transformer anything-c-find-files-transformer
)
4372 (persistent-action . anything-find-files-persistent-action
)
4373 (persistent-help .
"Expand Candidate")
4377 .
(lambda (candidate)
4378 (anything-dired-action candidate
:action
'rename
)))
4379 ("Rename and Follow"
4380 .
(lambda (candidate)
4381 (anything-dired-action candidate
:action
'rename
:follow t
)))))))
4383 (defvar anything-c-source-symlink-files
4384 `((name .
"Symlink Files")
4385 (header-name .
(lambda (name)
4386 (concat name anything-c-find-files-doc-header
)))
4387 ;; It is needed for filenames with capital letters
4389 (candidates . anything-find-files-get-candidates
)
4390 (filtered-candidate-transformer anything-c-find-files-transformer
)
4391 (persistent-action . anything-find-files-persistent-action
)
4392 (persistent-help .
"Expand Candidate")
4396 .
(lambda (candidate)
4397 (anything-dired-action candidate
:action
'symlink
)))
4399 .
(lambda (candidate)
4400 (anything-dired-action candidate
:action
'relsymlink
)))))))
4403 (defvar anything-c-source-hardlink-files
4404 `((name .
"Hardlink Files")
4405 (header-name .
(lambda (name)
4406 (concat name anything-c-find-files-doc-header
)))
4407 ;; It is needed for filenames with capital letters
4409 (candidates . anything-find-files-get-candidates
)
4410 (filtered-candidate-transformer anything-c-find-files-transformer
)
4411 (persistent-action . anything-find-files-persistent-action
)
4412 (persistent-help .
"Expand Candidate")
4416 .
(lambda (candidate)
4417 (anything-dired-action candidate
:action
'hardlink
)))))))
4419 (defun* anything-dired-action
(candidate &key action follow
(files (dired-get-marked-files)))
4420 "Copy, rename or symlink file at point or marked files in dired to CANDIDATE.
4421 ACTION is a key that can be one of 'copy, 'rename, 'symlink, 'relsymlink."
4422 (when (get-buffer dired-log-buffer
) (kill-buffer dired-log-buffer
))
4423 (let ((fn (case action
4424 ('copy
'dired-copy-file
)
4425 ('rename
'dired-rename-file
)
4426 ('symlink
'make-symbolic-link
)
4427 ('relsymlink
'dired-make-relative-symlink
)
4428 ('hardlink
'dired-hardlink
)))
4429 (marker (case action
4430 ((copy rename
) dired-keep-marker-copy
)
4431 ('symlink dired-keep-marker-symlink
)
4432 ('relsymlink dired-keep-marker-relsymlink
)
4433 ('hardlink dired-keep-marker-hardlink
)))
4434 (dirflag (and (= (length files
) 1)
4435 (file-directory-p (car files
))
4436 (not (file-directory-p candidate
)))))
4438 fn
(symbol-name action
) files
4439 ;; CANDIDATE is the destination.
4440 (if (file-directory-p candidate
)
4441 ;; When CANDIDATE is a directory, build file-name in this directory.
4442 ;; Else we use CANDIDATE.
4444 (expand-file-name (file-name-nondirectory from
) candidate
))
4445 #'(lambda (from) candidate
))
4447 (push (file-name-as-directory
4448 (if (file-directory-p candidate
)
4449 candidate
(file-name-directory candidate
)))
4450 anything-ff-history
)
4451 (when (and follow
(not (get-buffer dired-log-buffer
)))
4452 (let ((target (directory-file-name candidate
)))
4455 (setq anything-ff-cand-to-mark
4456 (anything-get-dest-fnames-from-list files candidate dirflag
))
4457 (if (and dirflag
(eq action
'rename
))
4458 (anything-find-files-1 (file-name-directory target
)
4459 (if anything-ff-transformer-show-only-basename
4460 (anything-c-basename target
) target
))
4461 (anything-find-files-1 (expand-file-name candidate
))))
4462 (setq anything-ff-cand-to-mark nil
))))))
4465 (defun anything-c-basename (fname)
4466 "Resolve basename of file or directory named FNAME."
4467 (file-name-nondirectory (directory-file-name fname
)))
4469 (defun anything-get-dest-fnames-from-list (flist dest-cand rename-dir-flag
)
4470 "Transform filenames of FLIST to abs of DEST-CAND.
4471 If RENAME-DIR-FLAG is non--nil collect the `directory-file-name' of transformed
4473 ;; At this point files have been renamed/copied at destination.
4474 ;; That's mean DEST-CAND exists.
4476 with dest
= (expand-file-name dest-cand
)
4478 for basename-src
= (anything-c-basename src
)
4479 for fname
= (cond (rename-dir-flag (directory-file-name dest
))
4480 ((file-directory-p dest
)
4481 (concat (file-name-as-directory dest
) basename-src
))
4483 when
(file-exists-p fname
)
4484 collect fname into tmp-list
4485 finally return
(sort tmp-list
'string
<)))
4487 (defun anything-ff-maybe-mark-candidates ()
4488 "Mark all candidates of list `anything-ff-cand-to-mark'."
4489 (when (and (string= (assoc-default 'name
(anything-get-current-source))
4490 (assoc-default 'name anything-c-source-find-files
))
4491 anything-ff-cand-to-mark
)
4492 (with-anything-window
4493 (while anything-ff-cand-to-mark
4494 (if (string= (car anything-ff-cand-to-mark
) (anything-get-selection))
4496 (anything-make-visible-mark)
4497 (anything-next-line)
4498 (setq anything-ff-cand-to-mark
(cdr anything-ff-cand-to-mark
)))
4499 (anything-next-line)))
4500 (unless (anything-this-visible-mark)
4501 (anything-prev-visible-mark)))))
4503 (add-hook 'anything-after-update-hook
#'anything-ff-maybe-mark-candidates
)
4505 (defun* anything-dired-do-action-on-file
(&key action
)
4506 (let* ((files (dired-get-marked-files))
4507 (len (length files
))
4508 (fname (if (> len
1)
4509 (format "* %d Files" len
)
4511 (source (case action
4512 ('copy
'anything-c-source-copy-files
)
4513 ('rename
'anything-c-source-rename-files
)
4514 ('symlink
'anything-c-source-symlink-files
)
4515 ('hardlink
'anything-c-source-hardlink-files
)))
4516 (prompt-fm (case action
4517 ('copy
"Copy %s to: ")
4518 ('rename
"Rename %s to: ")
4519 ('symlink
"Symlink %s to: ")
4520 ('hardlink
"Hardlink %s to: ")))
4521 (buffer (case action
4522 ('copy
"*Anything Copy Files*")
4523 ('rename
"*Anything Rename Files*")
4524 ('symlink
"*Anything Symlink Files*")
4525 ('hardlink
"*Anything Hardlink Files*")))
4526 (anything-mp-highlight-delay nil
))
4527 (anything :sources source
4528 :input
(or (dired-dwim-target-directory)
4529 (expand-file-name (anything-c-current-directory)))
4530 :preselect
(dired-get-filename)
4531 :prompt
(format prompt-fm fname
)
4532 :keymap anything-c-read-file-map
4536 (define-minor-mode anything-dired-mode
()
4537 "Enable anything completion in Dired functions.
4538 Bindings affected are C, R, S, H.
4539 This is deprecated for Emacs24+ users, use `ac-mode' instead."
4540 :group
'anything-config
4542 (if anything-dired-mode
4544 (substitute-key-definition
4545 'dired-do-copy
'anything-dired-copy-file dired-mode-map
)
4546 (substitute-key-definition
4547 'dired-do-rename
'anything-dired-rename-file dired-mode-map
)
4548 (substitute-key-definition
4549 'dired-do-symlink
'anything-dired-symlink-file dired-mode-map
)
4550 (substitute-key-definition
4551 'dired-do-hardlink
'anything-dired-hardlink-file dired-mode-map
))
4552 (substitute-key-definition
4553 'anything-dired-copy-file
'dired-do-copy dired-mode-map
)
4554 (substitute-key-definition
4555 'anything-dired-rename-file
'dired-do-rename dired-mode-map
)
4556 (substitute-key-definition
4557 'anything-dired-symlink-file
'dired-do-symlink dired-mode-map
)
4558 (substitute-key-definition
4559 'anything-dired-hardlink-file
'dired-do-hardlink dired-mode-map
)))
4561 (defalias 'anything-dired-bindings
'anything-dired-mode
)
4563 (defun* anything-c-read-file-name
(prompt
4565 (name "Read File Name")
4566 (initial-input (expand-file-name default-directory
))
4567 (buffer "*Anything Completions*")
4571 (marked-candidates nil
)
4573 (persistent-action 'anything-find-files-persistent-action
)
4574 (persistent-help "Hit1 Expand Candidate, Hit2 or (C-u) Find file"))
4575 "Anything `read-file-name' emulation.
4576 INITIAL-INPUT is a valid path, TEST is a predicate that take one arg."
4577 (when (get-buffer anything-action-buffer
)
4578 (kill-buffer anything-action-buffer
))
4579 (let ((anything-mp-highlight-delay nil
)
4580 ;; Be sure we don't erase the underlying minibuffer if some.
4581 (anything-ff-auto-update-initial-value
4582 (not (minibuffer-window-active-p (minibuffer-window))))
4583 anything-same-window
4584 (hist (and history
(anything-comp-read-get-candidates
4585 history nil nil alistp
))))
4586 (flet ((action-fn (candidate)
4587 (if marked-candidates
4588 (anything-marked-candidates)
4589 (identity candidate
))))
4592 `(((name .
,(format "%s History" name
))
4593 (header-name .
(lambda (name)
4594 (concat name anything-c-find-files-doc-header
)))
4596 (mode-line . anything-read-file-name-mode-line-string
)
4598 (persistent-action .
,persistent-action
)
4599 (persistent-help .
,persistent-help
)
4600 (action .
,'action-fn
))
4602 (header-name .
(lambda (name)
4603 (concat name anything-c-find-files-doc-header
)))
4605 (setq anything-ff-auto-update-flag
4606 anything-ff-auto-update-initial-value
)))
4607 ;; It is needed for filenames with capital letters
4609 (mode-line . anything-read-file-name-mode-line-string
)
4610 (candidates .
(lambda ()
4611 (let ((seq (anything-find-files-get-candidates)))
4613 (loop for fname in seq
4614 when
(funcall test fname
) collect fname
)
4616 (filtered-candidate-transformer anything-c-find-files-transformer
)
4617 (persistent-action .
,persistent-action
)
4618 (candidate-number-limit .
9999)
4619 (toggle-auto-update . anything-ff-toggle-auto-update
)
4620 (persistent-help .
,persistent-help
)
4622 (action .
,'action-fn
)))
4623 :input initial-input
4625 :keymap anything-c-read-file-map
4628 :preselect preselect
)
4633 (defvar anything-c-file-cache-initialized-p nil
)
4635 (defvar anything-c-file-cache-files nil
)
4637 (defvar anything-c-source-file-cache
4638 '((name .
"File Cache")
4641 (require 'filecache nil t
)
4642 (unless anything-c-file-cache-initialized-p
4643 (setq anything-c-file-cache-files
4644 (loop for item in file-cache-alist append
4645 (destructuring-bind (base &rest dirs
) item
4646 (loop for dir in dirs collect
4647 (concat dir base
)))))
4648 (defadvice file-cache-add-file
(after file-cache-list activate
)
4649 (add-to-list 'anything-c-file-cache-files
(expand-file-name file
)))
4650 (setq anything-c-file-cache-initialized-p t
))))
4651 (candidates . anything-c-file-cache-files
)
4652 (match anything-c-match-on-basename
)
4654 ;; (anything 'anything-c-source-file-cache)
4660 ;; NOTE for WINDOZE users:
4661 ;; You have to install Everything with his command line interface here:
4662 ;; http://www.voidtools.com/download.php
4664 (defun anything-locate-1 (&optional localdb init
)
4665 "Generic function to run Locate.
4666 if LOCALDB is non--nil search and use a local locate db file.
4667 INIT is a string to use as initial input in prompt.
4668 See `anything-locate-with-db' and `anything-locate'."
4669 (anything-locate-with-db
4671 (anything-c-read-file-name
4673 :marked-candidates t
4674 :preselect anything-locate-db-file-regexp
4676 (if anything-locate-db-file-regexp
4677 ;; Select only locate db files and directories
4678 ;; to allow navigation.
4680 anything-locate-db-file-regexp x
)
4681 (file-directory-p x
))
4684 ;; (anything-locate-1 t)
4686 (defun anything-locate-with-db (&optional db initial-input
)
4688 If DB is not given or nil use locate without -d option.
4689 Argument DB can be given as a string or list of db files.
4690 Argument INITIAL-INPUT is a string to use as initial-input.
4691 See also `anything-locate'."
4692 (when (and db
(stringp db
)) (setq db
(list db
)))
4693 (let ((anything-c-locate-command
4695 (replace-regexp-in-string
4697 (format "locate -d %s"
4698 (mapconcat 'identity
4699 ;; Remove eventually
4700 ;; marked directories by error.
4702 unless
(file-directory-p i
)
4704 anything-c-locate-command
)
4705 anything-c-locate-command
)))
4706 (anything :sources
'anything-c-source-locate
4707 :buffer
"*anything locate*"
4708 :input initial-input
4709 :keymap anything-generic-files-map
)))
4710 ;; (anything-locate-with-db "~/locate.db")
4712 (defun anything-c-locate-init ()
4713 "Initialize async locate process for `anything-c-source-locate'."
4714 (setq mode-line-format
4715 '(" " mode-line-buffer-identification
" "
4716 (line-number-mode "%l") " "
4717 (:eval
(propertize "(Locate Process Running) "
4718 'face
'((:foreground
"red"))))))
4720 (start-process-shell-command "locate-process" nil
4721 (format anything-c-locate-command
4723 (set-process-sentinel (get-process "locate-process")
4724 #'(lambda (process event
)
4725 (when (string= event
"finished\n")
4726 (with-anything-window
4727 (force-mode-line-update nil
)
4728 (anything-update-move-first-line)))))))
4730 (defvar anything-c-source-locate
4732 (candidates . anything-c-locate-init
)
4734 (properties-action . anything-ff-properties
)
4735 (requires-pattern .
3)
4736 (candidate-number-limit .
9999)
4737 (mode-line . anything-generic-file-mode-line-string
)
4739 "Find files matching the current input pattern with locate.")
4740 ;; (anything 'anything-c-source-locate)
4742 (defun anything-c-locate-read-file-name (prompt &optional init
)
4743 "Search a file with locate and return it's filename.
4744 Use argument PROMPT and INIT for `anything' arguments
4748 (candidates . anything-c-locate-init
)
4750 (properties-action . anything-ff-properties
)
4751 (requires-pattern .
3)
4752 (candidate-number-limit .
9999)
4753 (mode-line . anything-generic-file-mode-line-string
)
4757 :buffer
"*anything locate rfn*"))
4761 ;;; Anything Incremental Grep.
4764 ;; Allow to grep incrementally with anything interface.
4765 ;; It allow also to Grep files recursively without using 'find' shell command.
4766 ;; On Windows you will need at least Grep version 2.5.4 of Gnuwin32.
4767 (defvar anything-c-grep-default-command
4768 "grep -d skip %e -niH -e %p %f"
4769 "Default grep format command for `anything-do-grep-1'.
4771 '%e' format spec is for --exclude or --include grep options.
4772 '%p' format spec is for pattern.
4773 '%f' format spec is for filenames.")
4775 (defvar anything-c-grep-default-recurse-command
4776 "grep -d recurse %e -niH -e %p %f"
4777 "Default recursive grep format command for `anything-do-grep-1'.
4778 See `anything-c-grep-default-command' for format specs.")
4780 (defvar anything-c-default-zgrep-command
"zgrep -niH -e %p %f")
4782 (defvar anything-c-rzgrep-cache
(make-hash-table :test
'equal
))
4784 (defvar anything-c-grep-default-function
'anything-c-grep-init
)
4786 (defvar anything-c-grep-debug-command-line nil
4787 "Turn on anything grep command-line debugging when non--nil.")
4789 (defvar anything-c-zgrep-recurse-flag nil
)
4791 (defvar anything-c-grep-history nil
)
4793 (defvar anything-c-grep-max-length-history
100
4794 "*Max number of elements to save in `anything-c-grep-history'.")
4796 (defun anything-c-grep-prepare-candidates (candidates)
4797 "Prepare filenames and directories CANDIDATES for grep command line."
4798 ;; If one or more candidate is a directory, search in all files
4799 ;; of this candidate (e.g /home/user/directory/*).
4800 ;; If r option is enabled search also in subdidrectories.
4801 ;; We need here to expand wildcards to support crap windows filenames
4802 ;; as grep don't accept quoted wildcards (e.g "dir/*.el").
4803 (if anything-c-zgrep-recurse-flag
4804 (mapconcat 'shell-quote-argument candidates
" ")
4805 (loop for i in candidates append
4806 (cond ( ;; Candidate is a directory and we use recursion.
4807 (and (file-directory-p i
)
4808 (anything-c-grep-recurse-p))
4809 (list (expand-file-name i
)))
4810 ;; Candidate is a directory, search in all files.
4811 ((file-directory-p i
)
4812 (file-expand-wildcards
4813 (concat (file-name-as-directory (expand-file-name i
)) "*") t
))
4814 ;; Candidate is a file or wildcard and we use recursion, use the
4815 ;; current directory instead of candidate.
4816 ((and (or (file-exists-p i
) (string-match "\*" i
))
4817 (anything-c-grep-recurse-p))
4818 (list (expand-file-name
4819 (directory-file-name ; Needed for windoze.
4820 (file-name-directory (directory-file-name i
))))))
4821 ;; Candidate use wildcard.
4822 ((string-match "^\*" (anything-c-basename i
))
4823 (file-expand-wildcards i t
))
4824 ;; Else should be one or more file.
4825 (t (list i
))) into all-files
4827 (mapconcat 'shell-quote-argument all-files
" "))))
4829 (defun anything-c-grep-recurse-p ()
4830 "Check if `anything-do-grep-1' have switched to recursive."
4831 (let ((args (replace-regexp-in-string
4832 "grep" "" anything-c-grep-default-command
)))
4833 (string-match-p "r\\|recurse" args
)))
4835 (defun anything-c-grep-init (only-files &optional include zgrep
)
4836 "Start an asynchronous grep process in ONLY-FILES list."
4837 (let* ((fnargs (anything-c-grep-prepare-candidates
4838 (if (file-remote-p anything-ff-default-directory
)
4839 (mapcar #'(lambda (x)
4840 (file-remote-p x
'localname
))
4843 (ignored-files (mapconcat
4845 (concat "--exclude=" (shell-quote-argument x
)))
4846 grep-find-ignored-files
" "))
4847 (ignored-dirs (mapconcat
4848 ;; Need grep version 2.5.4 of Gnuwin32 on windoze.
4850 (concat "--exclude-dir=" (shell-quote-argument x
)))
4851 grep-find-ignored-directories
" "))
4852 (exclude (if (anything-c-grep-recurse-p)
4853 (concat (or include ignored-files
) " " ignored-dirs
)
4855 (cmd-line (format-spec
4856 anything-c-grep-default-command
4858 (list (unless zgrep
(cons ?e exclude
))
4859 (cons ?p
(shell-quote-argument anything-pattern
))
4860 (cons ?f fnargs
))))))
4861 (when anything-c-grep-debug-command-line
4862 (with-current-buffer (get-buffer-create "*any grep debug*")
4863 (goto-char (point-max))
4864 (insert (concat ">>> " cmd-line
"\n\n"))))
4865 (setq mode-line-format
4866 '(" " mode-line-buffer-identification
" "
4867 (line-number-mode "%l") " "
4868 (:eval
(when (get-process "grep-process")
4869 (propertize "[Grep Process Running] "
4870 'face
'anything-grep-running
)))))
4871 (force-mode-line-update nil
)
4873 (let ((default-directory anything-ff-default-directory
))
4874 (start-file-process-shell-command "grep-process" nil cmd-line
))
4876 (set-process-sentinel
4877 (get-process "grep-process")
4878 #'(lambda (process event
)
4879 (when (string= event
"finished\n")
4880 (with-anything-window
4881 (anything-update-move-first-line)
4882 (setq mode-line-format
4883 '(" " mode-line-buffer-identification
" "
4884 (line-number-mode "%l") " "
4886 (format "[Grep Process Finished - (%s results)] "
4887 (let ((nlines (1- (count-lines
4890 (if (> nlines
0) nlines
0)))
4891 'face
'anything-grep-finish
))))
4892 (force-mode-line-update nil
))))))))
4894 (defun anything-c-grep-action (candidate &optional where mark
)
4895 "Define a default action for `anything-do-grep' on CANDIDATE.
4896 WHERE can be one of other-window, elscreen, other-frame."
4897 (let* ((split (anything-c-grep-split-line candidate
))
4898 (lineno (string-to-number (nth 1 split
)))
4899 (loc-fname (car split
))
4900 (tramp-method (file-remote-p anything-ff-default-directory
'method
))
4901 (tramp-host (file-remote-p anything-ff-default-directory
'host
))
4902 (tramp-prefix (concat "/" tramp-method
":" tramp-host
":"))
4903 (fname (if tramp-host
4904 (concat tramp-prefix loc-fname
) loc-fname
)))
4906 (other-window (find-file-other-window fname
))
4907 (elscreen (anything-elscreen-find-file fname
))
4908 (other-frame (find-file-other-frame fname
))
4909 (t (find-file fname
)))
4910 (anything-goto-line lineno
)
4912 (set-marker (mark-marker) (point))
4913 (push-mark (point) 'nomsg
))
4915 (unless (or anything-in-persistent-action
4916 (string= anything-pattern
""))
4917 (setq anything-c-grep-history
4918 (cons anything-pattern
4919 (delete anything-pattern anything-c-grep-history
)))
4920 (when (> (length anything-c-grep-history
)
4921 anything-c-grep-max-length-history
)
4922 (setq anything-c-grep-history
4923 (delete (car (last anything-c-grep-history
))
4924 anything-c-grep-history
))))))
4926 (defun anything-c-grep-other-window (candidate)
4927 "Jump to result in other window from anything grep."
4928 (anything-c-grep-action candidate
'other-window
))
4930 (defun anything-c-grep-other-frame (candidate)
4931 "Jump to result in other frame from anything grep."
4932 (anything-c-grep-action candidate
'other-frame
))
4934 (defun anything-c-grep-jump-elscreen (candidate)
4935 "Jump to result in elscreen from anything grep."
4936 (anything-c-grep-action candidate
'elscreen
))
4938 (defun anything-c-grep-save-results (candidate)
4939 "Save anything grep result in a `grep-mode' buffer."
4940 (let ((buf "*grep*")
4942 (when (get-buffer buf
)
4943 (setq new-buf
(read-string "GrepBufferName: " buf
))
4944 (loop for b in
(anything-c-buffer-list)
4945 when
(and (string= new-buf b
)
4947 (format "Buffer `%s' already exists overwrite? "
4949 do
(setq new-buf
(read-string "GrepBufferName: " "*grep ")))
4951 (with-current-buffer (get-buffer-create buf
)
4952 (let ((inhibit-read-only t
))
4954 (insert "-*- mode: grep -*-\n\n"
4955 (format "Grep Results for `%s':\n\n" anything-pattern
))
4957 (insert (with-current-buffer anything-buffer
4959 (buffer-substring (point) (point-max))))
4961 (message "Anything Grep Results saved in `%s' buffer" buf
)))
4963 (defun anything-c-grep-persistent-action (candidate)
4964 "Persistent action for `anything-do-grep'.
4965 With a prefix arg record CANDIDATE in `mark-ring'."
4966 (if current-prefix-arg
4967 (anything-c-grep-action candidate nil
'mark
)
4968 (anything-c-grep-action candidate
))
4969 (anything-match-line-color-current-line))
4971 (defun anything-c-grep-guess-extensions (files)
4972 "Try to guess file extensions in FILES list when using grep recurse.
4973 These extensions will be added to command line with --include arg of grep."
4975 with glob-list
= nil
4976 with lst
= (if (file-directory-p (car files
))
4979 directory-files-no-dot-files-regexp
)
4982 for ext
= (file-name-extension i t
)
4983 for glob
= (and ext
(not (string= ext
""))
4985 unless
(or (not glob
)
4986 (member glob glob-list
)
4987 (member glob grep-find-ignored-files
))
4988 collect glob into glob-list
4989 finally return glob-list
))
4991 (defun anything-do-grep-1 (only &optional recurse zgrep
)
4992 "Launch grep with a list of ONLY files.
4993 When RECURSE is given use -r option of grep and prompt user
4994 to set the --include args of grep.
4995 You can give more than one arg separated by space.
4996 e.g *.el *.py *.tex.
4997 If it's empty --exclude `grep-find-ignored-files' is used instead."
4998 (let* ((anything-compile-source-functions
4999 ;; rule out anything-match-plugin because the input is one regexp.
5000 (delq 'anything-compile-source--match-plugin
5001 (copy-sequence anything-compile-source-functions
)))
5002 (exts (anything-c-grep-guess-extensions only
))
5003 (globs (and (not zgrep
) (mapconcat 'identity exts
" ")))
5004 (include-files (and recurse
(not zgrep
)
5005 (read-string "OnlyExt(*.[ext]): "
5007 ;; Set `minibuffer-history' AFTER includes-files
5008 ;; to avoid storing wild-cards here.
5009 (minibuffer-history anything-c-grep-history
)
5010 (anything-c-grep-default-command (cond ((and recurse zgrep
) anything-c-default-zgrep-command
)
5011 (recurse anything-c-grep-default-recurse-command
)
5012 (zgrep anything-c-default-zgrep-command
)
5013 (t anything-c-grep-default-command
)))
5014 ;; Disable match-plugin and use here own highlighting.
5015 (anything-mp-highlight-delay nil
))
5018 (and (not (string= include-files
""))
5019 (mapconcat #'(lambda (x)
5020 (concat "--include=" (shell-quote-argument x
)))
5021 (split-string include-files
) " "))))
5022 ;; When called as action from an other source e.g *-find-files
5023 ;; we have to kill action buffer.
5024 (when (get-buffer anything-action-buffer
)
5025 (kill-buffer anything-action-buffer
))
5026 ;; `anything-find-files' haven't already started,
5027 ;; give a default value to `anything-ff-default-directory'.
5028 (setq anything-ff-default-directory
(or anything-ff-default-directory
5032 `(((name .
"Grep (C-c ? Help)")
5035 (funcall anything-c-grep-default-function only include-files zgrep
)))
5036 (filtered-candidate-transformer anything-c-grep-cand-transformer
)
5037 (candidate-number-limit .
9999)
5038 (mode-line . anything-grep-mode-line-string
)
5039 (jump-persistent . anything-c-grep-persistent-action
)
5042 `(("Find File" . anything-c-grep-action
)
5043 ("Find file other frame" . anything-c-grep-other-frame
)
5044 ,(and (locate-library "elscreen")
5045 '("Find file in Elscreen"
5046 . anything-c-grep-jump-elscreen
))
5047 ("Save results in grep buffer" . anything-c-grep-save-results
)
5048 ("Find file other window" . anything-c-grep-other-window
))))
5049 (persistent-action . anything-c-grep-persistent-action
)
5050 (persistent-help .
"Jump to line (`C-u' Record in mark ring)")
5051 (requires-pattern .
3)
5053 :keymap anything-c-grep-map
5054 :buffer
"*anything grep*")))
5056 (defun anything-ff-zgrep-1 (flist recursive
)
5058 (let* ((def-dir (or anything-ff-default-directory
5061 (or (gethash def-dir anything-c-rzgrep-cache
)
5064 (anything-c-walk-directory
5068 :match
".*\\(\.gz\\|\.bz\\|\.xz\\|\.lzma\\)$")
5069 anything-c-rzgrep-cache
))
5071 (when recursive
(setq anything-c-zgrep-recurse-flag t
))
5072 (anything-do-grep-1 only recursive
'zgrep
))
5073 (setq anything-c-zgrep-recurse-flag nil
)))
5075 (defun anything-c-grep-split-line (line)
5076 "Split a grep output line."
5077 (let (beg fname lineno str
)
5078 ;; Don't print until grep line is valid.
5079 (when (string-match "\\(.*\\)\\(:[0-9]+:\\)\\(.*\\)" line
)
5082 (goto-char (point-min))
5085 (re-search-forward ":" nil t
)
5086 (setq fname
(buffer-substring-no-properties beg
(1- (point))))
5088 (re-search-forward ":" nil t
)
5089 (setq lineno
(buffer-substring-no-properties beg
(1- (point))))
5090 (setq str
(buffer-substring-no-properties (point) (point-at-eol))))
5091 (list fname lineno str
))))
5093 (defun anything-c-grep-cand-transformer (candidates sources
)
5094 "Filtered candidate transformer function for `anything-do-grep'."
5095 (loop for i in candidates
5096 for split
= (and i
(anything-c-grep-split-line i
))
5097 for fname
= (car split
)
5098 for lineno
= (nth 1 split
)
5099 for str
= (nth 2 split
)
5100 when
(and fname lineno str
)
5102 (cons (concat (propertize (file-name-nondirectory fname
)
5103 'face
'anything-grep-file
5104 'help-echo fname
) ":"
5105 (propertize lineno
'face
'anything-grep-lineno
) ":"
5106 (anything-c-grep-highlight-match str
))
5109 (defun anything-c-grep-highlight-match (str)
5110 "Highlight in string STR all occurences matching `anything-pattern'."
5114 (goto-char (point-min))
5115 (while (and (re-search-forward anything-pattern nil t
)
5116 (> (- (match-end 0) (match-beginning 0)) 0))
5117 (add-text-properties
5118 (match-beginning 0) (match-end 0)
5119 '(face anything-grep-match
)))
5123 ;; Go to next or precedent file (common to etags and grep).
5124 (defun anything-c-goto-next-or-prec-file (n)
5125 "Go to next or precedent candidate file in anything grep/etags buffers.
5126 If N is positive go forward otherwise go backward."
5127 (with-anything-window
5128 (let* ((current-line-list (split-string
5131 (point-at-eol)) ":"))
5132 (current-fname (nth 0 current-line-list
))
5133 (fn-b-o-f (if (eq n
1) 'eobp
'bobp
)))
5135 (while (not (funcall fn-b-o-f
))
5136 (forward-line n
) ; Go forward or backward depending of n value.
5137 (unless (search-forward current-fname
(point-at-eol) t
)
5138 (anything-mark-current-line)
5139 (throw 'break nil
))))
5140 (cond ((and (eq n
1) (eobp))
5141 (re-search-backward ".")
5143 (anything-mark-current-line))
5144 ((and (< n
1) (bobp))
5146 (anything-mark-current-line))))))
5149 (defun anything-c-goto-precedent-file ()
5150 "Go to precedent file in anything grep/etags buffers."
5152 (anything-c-goto-next-or-prec-file -
1))
5155 (defun anything-c-goto-next-file ()
5156 "Go to precedent file in anything grep/etags buffers."
5158 (anything-c-goto-next-or-prec-file 1))
5161 (defun anything-c-grep-run-persistent-action ()
5162 "Run grep persistent action from `anything-do-grep-1'."
5164 (anything-execute-persistent-action 'jump-persistent
))
5167 (defun anything-c-grep-run-default-action ()
5168 "Run grep default action from `anything-do-grep-1'."
5170 (anything-c-quit-and-execute-action 'anything-c-grep-action
))
5173 (defun anything-c-grep-run-other-window-action ()
5174 "Run grep goto other window action from `anything-do-grep-1'."
5176 (anything-c-quit-and-execute-action 'anything-c-grep-other-window
))
5179 (defun anything-c-grep-run-save-buffer ()
5180 "Run grep save results action from `anything-do-grep-1'."
5182 (anything-c-quit-and-execute-action 'anything-c-grep-save-results
))
5185 (defun anything-c-grep-buffers-1 (candidate &optional zgrep
)
5186 "Run grep on all file--buffers or CANDIDATE if it is a file--buffer.
5187 If one of selected buffers is not a file--buffer,
5188 it is ignored and grep will run on all others file--buffers.
5189 If only one candidate is selected and it is not a file--buffer,
5190 switch to this buffer and run `anything-occur'.
5191 If a prefix arg is given run grep on all buffers ignoring non--file-buffers."
5192 (let* ((prefarg (or current-prefix-arg anything-current-prefix-arg
))
5195 (anything-marked-candidates)))
5196 (win-conf (current-window-configuration))
5197 ;; Non--fname buffers are ignored.
5198 (bufs (loop for buf in cands
5199 for fname
= (buffer-file-name (get-buffer buf
))
5201 collect
(expand-file-name fname
))))
5204 (anything-do-grep-1 bufs nil
'zgrep
)
5205 (anything-do-grep-1 bufs
))
5206 ;; bufs is empty, thats mean we have only CANDIDATE
5207 ;; and it is not a buffer-filename, fallback to occur.
5208 (anything-c-switch-to-buffer candidate
)
5209 (when (get-buffer anything-action-buffer
)
5210 (kill-buffer anything-action-buffer
))
5212 (when (eq anything-exit-status
1)
5213 (set-window-configuration win-conf
)))))
5215 (defun anything-c-grep-buffers (candidate)
5216 "Action to grep buffers."
5217 (anything-c-grep-buffers-1 candidate
))
5219 (defun anything-c-zgrep-buffers (candidate)
5220 "Action to zgrep buffers."
5221 (anything-c-grep-buffers-1 candidate
'zgrep
))
5224 ;;; Anything interface for pdfgrep
5225 ;; pdfgrep program <http://pdfgrep.sourceforge.net/>
5226 ;; and a pdf-reader (e.g xpdf) are needed.
5228 (defvar anything-c-pdfgrep-default-command
"pdfgrep --color never -niH %s %s")
5229 (defvar anything-c-pdfgrep-default-function
'anything-c-pdfgrep-init
)
5230 (defvar anything-c-pdfgrep-debug-command-line nil
)
5232 (defun anything-c-pdfgrep-init (only-files)
5233 "Start an asynchronous pdfgrep process in ONLY-FILES list."
5234 (let* ((fnargs (anything-c-grep-prepare-candidates
5235 (if (file-remote-p anything-ff-default-directory
)
5236 (mapcar #'(lambda (x)
5237 (file-remote-p x
'localname
))
5240 (cmd-line (format anything-c-pdfgrep-default-command
5243 (when anything-c-pdfgrep-debug-command-line
5244 (with-current-buffer (get-buffer-create "*any pdfgrep debug*")
5245 (goto-char (point-max))
5246 (insert (concat ">>> " cmd-line
"\n\n"))))
5247 (setq mode-line-format
5248 '(" " mode-line-buffer-identification
" "
5249 (line-number-mode "%l") " "
5250 (:eval
(propertize "(Pdfgrep Process Running) "
5251 'face
'((:foreground
"red"))))))
5253 (let ((default-directory anything-ff-default-directory
))
5254 (start-file-process-shell-command "pdfgrep-process" nil cmd-line
))
5256 (set-process-sentinel
5257 (get-process "pdfgrep-process")
5258 #'(lambda (process event
)
5259 (when (string= event
"finished\n")
5260 (with-anything-window
5261 (anything-update-move-first-line))
5262 (force-mode-line-update nil
)))))))
5265 (defun anything-do-pdfgrep-1 (only)
5266 "Launch pdfgrep with a list of ONLY files."
5267 (unless (executable-find "pdfgrep")
5268 (error "Error: No such program `pdfgrep'."))
5269 (let* ((anything-compile-source-functions
5270 ;; rule out anything-match-plugin because the input is one regexp.
5271 (delq 'anything-compile-source--match-plugin
5272 (copy-sequence anything-compile-source-functions
)))
5273 ;; Disable match-plugin and use here own highlighting.
5274 (anything-mp-highlight-delay nil
))
5275 ;; When called as action from an other source e.g *-find-files
5276 ;; we have to kill action buffer.
5277 (when (get-buffer anything-action-buffer
)
5278 (kill-buffer anything-action-buffer
))
5279 ;; If `anything-find-files' haven't already started,
5280 ;; give a default value to `anything-ff-default-directory'.
5281 (setq anything-ff-default-directory
(or anything-ff-default-directory
5285 `(((name .
"PdfGrep")
5288 (funcall anything-c-pdfgrep-default-function only
)))
5289 (filtered-candidate-transformer anything-c-grep-cand-transformer
)
5290 (candidate-number-limit .
9999)
5291 (mode-line . anything-pdfgrep-mode-line-string
)
5292 (action . anything-c-pdfgrep-action
)
5293 (persistent-help .
"Jump to PDF Page")
5294 (requires-pattern .
3)
5296 :keymap anything-c-pdfgrep-map
5297 :buffer
"*anything grep*")))
5300 (defun anything-c-pdfgrep-action (candidate)
5301 (let* ((split (anything-c-grep-split-line candidate
))
5302 (pageno (nth 1 split
))
5303 (fname (car split
)))
5304 (start-file-process-shell-command
5306 (format-spec anything-c-pdfgrep-default-read-command
5307 (list (cons ?f fname
) (cons ?p pageno
))))))
5309 (defun anything-do-pdfgrep ()
5311 (let ((only (anything-c-read-file-name
5312 "Search in file(s): "
5313 :marked-candidates t
5314 :test
#'(lambda (file)
5315 (or (string= (file-name-extension file
) "pdf")
5316 (string= (file-name-extension file
) "PDF")
5317 (file-directory-p file
)))
5318 :preselect
(or (dired-get-filename nil t
)
5319 (buffer-file-name (current-buffer)))))
5320 (anything-c-grep-default-function 'anything-c-pdfgrep-init
))
5321 (anything-do-pdfgrep-1 only
)))
5324 ;; Yank text at point.
5328 (defvar anything-yank-point nil
)
5331 (defun anything-yank-text-at-point ()
5332 "Yank text at point in minibuffer."
5335 (flet ((insert-in-minibuffer (word)
5336 (with-selected-window (minibuffer-window)
5337 (let ((str anything-pattern
))
5338 (delete-minibuffer-contents)
5339 (set-text-properties 0 (length word
) nil word
)
5340 (insert (concat str word
))))))
5341 (with-anything-current-buffer
5342 ;; Start to initial point if C-w have never been hit.
5343 (unless anything-yank-point
(setq anything-yank-point
(point)))
5344 (and anything-yank-point
(goto-char anything-yank-point
))
5346 (setq input
(buffer-substring-no-properties anything-yank-point
(point)))
5347 (setq anything-yank-point
(point))) ; End of last forward-word
5348 (insert-in-minibuffer input
))))
5350 (defun anything-reset-yank-point ()
5351 (setq anything-yank-point nil
))
5353 (add-hook 'anything-after-persistent-action-hook
'anything-reset-yank-point
)
5354 (add-hook 'anything-cleanup-hook
'anything-reset-yank-point
)
5360 (defvar anything-c-source-recentf
5361 '((name .
"Recentf")
5364 (or recentf-mode
(recentf-mode 1))))
5365 (disable-shortcuts) ;; Needed for filenames with capitals letters.
5366 (candidates . recentf-list
)
5367 (match anything-c-match-on-basename
)
5369 "See (info \"(emacs)File Conveniences\").
5370 Set `recentf-max-saved-items' to a bigger value if default is too small.")
5371 ;; (anything 'anything-c-source-recentf)
5374 (eval-when-compile (require 'ffap
))
5375 (defvar anything-c-source-ffap-guesser
5376 '((name .
"File at point")
5377 (init .
(lambda () (require 'ffap
)))
5378 (candidates .
(lambda ()
5380 (with-anything-current-buffer
5384 ;; (anything 'anything-c-source-ffap-guesser)
5386 ;;; ffap with line number
5387 (defun anything-c-ffap-file-line-at-point ()
5388 "Get (FILENAME . LINENO) at point."
5389 (anything-aif (let (ffap-alist) (ffap-file-at-point))
5392 (when (and (search-forward it nil t
)
5393 (looking-at ":\\([0-9]+\\)"))
5394 (cons it
(string-to-number (match-string 1)))))))
5396 (defvar anything-c-ffap-line-location nil
5397 "(FILENAME . LINENO) used by `anything-c-source-ffap-line'.
5398 It is cleared after jumping line.")
5400 (defun anything-c-ffap-line-candidates ()
5401 (with-anything-current-buffer
5402 (setq anything-c-ffap-line-location
(anything-c-ffap-file-line-at-point)))
5403 (when anything-c-ffap-line-location
5404 (destructuring-bind (file . line
) anything-c-ffap-line-location
5405 (list (cons (format "%s (line %d)" file line
) file
)))))
5407 ;;; Goto line after opening file by `anything-c-source-ffap-line'.
5408 (defun anything-c-ffap-line-goto-line ()
5409 (when (car anything-c-ffap-line-location
)
5412 (with-selected-window
5414 (get-file-buffer (car anything-c-ffap-line-location
)))
5415 (anything-goto-line (cdr anything-c-ffap-line-location
)))))))
5416 (add-hook 'anything-after-action-hook
'anything-c-ffap-line-goto-line
)
5417 (add-hook 'anything-after-persistent-action-hook
'anything-c-ffap-line-goto-line
)
5419 (defvar anything-c-source-ffap-line
5420 '((name .
"File/Lineno at point")
5421 (init .
(lambda () (require 'ffap
)))
5422 (candidates . anything-c-ffap-line-candidates
)
5424 ;; (anything 'anything-c-source-ffap-line)
5426 ;;; list of files gleaned from every dired buffer
5427 (defun anything-c-files-in-all-dired-candidates ()
5431 (cond ((listp dir
) ;filelist
5433 ((equal "" (file-name-nondirectory dir
)) ;dir
5434 (directory-files dir t
))
5436 (file-expand-wildcards dir t
))))
5438 (mapcar (lambda (buf)
5440 (when (eq major-mode
'dired-mode
)
5441 (if (consp dired-directory
)
5442 (cdr dired-directory
) ;filelist
5443 dired-directory
))) ;dir or wildcard
5445 ;; (dired '("~/" "~/.emacs-custom.el" "~/.emacs.bmk"))
5447 (defvar anything-c-source-files-in-all-dired
5448 '((name .
"Files in all dired buffer.")
5449 (candidates . anything-c-files-in-all-dired-candidates
)
5451 ;; (anything 'anything-c-source-files-in-all-dired)
5453 (defvar anything-c-source-filelist
5454 '((name .
"FileList")
5455 (grep-candidates . anything-c-filelist-file-name
)
5456 (candidate-number-limit .
200)
5457 (requires-pattern .
4)
5459 "Source to find files instantly.
5460 See `anything-c-filelist-file-name' docstring for usage.")
5465 (defvar anything-c-info-pages nil
5466 "All info pages on system.
5467 Will be calculated the first time you invoke anything with this
5470 (defun anything-c-info-pages-init ()
5471 "Collect candidates for initial Info node Top."
5472 (if anything-c-info-pages
5473 anything-c-info-pages
5474 (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
5478 (Info-find-node "dir" "top")
5479 (goto-char (point-min))
5480 (while (re-search-forward info-topic-regexp nil t
)
5481 (push (match-string-no-properties 1) topics
))
5483 (setq anything-c-info-pages topics
))))
5485 (defvar anything-c-source-info-pages
5486 `((name .
"Info Pages")
5487 (init . anything-c-info-pages-init
)
5488 (candidates . anything-c-info-pages
)
5489 (action .
(("Show with Info" .
(lambda (node-str)
5490 (info (replace-regexp-in-string
5491 "^[^:]+: " "" node-str
))))))
5492 (requires-pattern .
2)))
5493 ;; (anything 'anything-c-source-info-pages)
5496 ;; FIXME should be merged in anything.el with `anything-describe-anything-attribute'.
5497 (defun anything-c-describe-attributes (anything-attribute)
5498 "Display the full documentation of ANYTHING-ATTRIBUTE (a symbol).
5499 Same as `anything-describe-anything-attribute' but with anything completion."
5500 (interactive (list (intern
5502 "Describe anything attribute: "
5503 (mapcar 'symbol-name anything-additional-attributes
)
5506 #'(lambda (candidate)
5507 (with-output-to-temp-buffer "*Help*"
5508 (princ (get (intern candidate
) 'anything-attrdoc
))))))))
5509 (with-output-to-temp-buffer "*Help*"
5510 (princ (get anything-attribute
'anything-attrdoc
))))
5513 ;;; Use info-index plug-in.
5516 ;; Note that `name' attribute is not needed since
5517 ;; `anything-c-insert-summary' have been removed.
5519 (defvar anything-c-source-info-elisp
5520 '((name .
"Info index: elisp")
5521 (info-index .
"elisp")))
5522 ;; (anything 'anything-c-source-info-elisp)
5525 (defvar anything-c-source-info-cl
5526 '((name .
"Info index: cl")
5527 (info-index .
"cl")))
5528 ;; (anything 'anything-c-source-info-cl)
5531 (defvar anything-c-source-info-org
5532 '((name .
"Info index: org")
5533 (info-index .
"org")))
5534 ;; (anything 'anything-c-source-info-org)
5537 (defvar anything-c-source-info-gnus
5538 '((name .
"Info index: Gnus")
5539 (info-index .
"gnus")))
5541 ;; Info Index ratpoison
5542 (defvar anything-c-source-info-ratpoison
5543 '((name .
"Info index: ratpoison")
5544 (info-index .
"ratpoison")))
5545 ;; (anything 'anything-c-source-info-ratpoison)
5548 (defvar anything-c-source-info-zsh
5549 '((name .
"Info index: zsh")
5550 (info-index .
"zsh")))
5551 ;; (anything 'anything-c-source-info-zsh)
5554 (defvar anything-c-source-info-bash
5555 '((name .
"Info index: bash")
5556 (info-index .
"bash")))
5557 ;; (anything 'anything-c-source-info-bash)
5559 ;; Info Index coreutils
5560 (defvar anything-c-source-info-coreutils
5561 '((name .
"Info index: coreutils")
5562 (info-index .
"coreutils")))
5563 ;; (anything 'anything-c-source-info-coreutils)
5565 ;; Info Index fileutils
5566 (defvar anything-c-source-info-fileutils
5567 '((name .
"Info index: fileutils")
5568 (info-index .
"fileutils")))
5569 ;; (anything 'anything-c-source-info-fileutils)
5572 (defvar anything-c-source-info-find
5573 '((name .
"Info index: find")
5574 (info-index .
"find")))
5575 ;; (anything 'anything-c-source-info-find)
5577 ;; Info Index sh-utils
5578 (defvar anything-c-source-info-sh-utils
5579 '((name .
"Info index: sh-utils")
5580 (info-index .
"sh-utils")))
5581 ;; (anything 'anything-c-source-info-sh-utils)
5583 ;; Info Index textutils
5584 (defvar anything-c-source-info-textutils
5585 '((name .
"Info index: textutils")
5586 (info-index .
"textutils")))
5587 ;; (anything 'anything-c-source-info-textutils)
5590 (defvar anything-c-source-info-libc
5591 '((name .
"Info index: libc")
5592 (info-index .
"libc")))
5593 ;; (anything 'anything-c-source-info-libc)
5596 (defvar anything-c-source-info-make
5597 '((name .
"Info index: make")
5598 (info-index .
"make")))
5599 ;; (anything 'anything-c-source-info-make)
5601 ;; Info Index automake
5602 (defvar anything-c-source-info-automake
5603 '((name .
"Info index: automake")
5604 (info-index .
"automake")))
5605 ;; (anything 'anything-c-source-info-automake)
5607 ;; Info Index autoconf
5608 (defvar anything-c-source-info-autoconf
5609 '((name .
"Info index: autoconf")
5610 (info-index .
"autoconf")))
5611 ;; (anything 'anything-c-source-info-autoconf)
5613 ;; Info Index emacs-lisp-intro
5614 (defvar anything-c-source-info-emacs-lisp-intro
5615 '((name .
"Info index: emacs-lisp-intro")
5616 (info-index .
"emacs-lisp-intro")))
5617 ;; (anything 'anything-c-source-info-emacs-lisp-intro)
5620 (defvar anything-c-source-info-emacs
5621 '((name .
"Info index: emacs")
5622 (info-index .
"emacs")))
5623 ;; (anything 'anything-c-source-info-emacs)
5626 (defvar anything-c-source-info-elib
5627 '((name .
"Info index: elib")
5628 (info-index .
"elib")))
5629 ;; (anything 'anything-c-source-info-elib)
5632 (defvar anything-c-source-info-eieio
5633 '((name .
"Info index: eieio")
5634 (info-index .
"eieio")))
5635 ;; (anything 'anything-c-source-info-eieio)
5637 ;; Info Index gauche-refe
5638 (defvar anything-c-source-info-gauche-refe
5639 '((name .
"Info index: gauche")
5640 (info-index .
"gauche-refe")))
5641 ;; (anything 'anything-c-source-info-gauche-refe)
5644 (defvar anything-c-source-info-guile
5645 '((name .
"Info index: guile")
5646 (info-index .
"guile")))
5647 ;; (anything 'anything-c-source-info-guile)
5649 ;; Info Index guile-tut
5650 (defvar anything-c-source-info-guile-tut
5651 '((name .
"Info index: guile-tut")
5652 (info-index .
"guile-tut")))
5653 ;; (anything 'anything-c-source-info-guile-tut)
5656 (defvar anything-c-source-info-goops
5657 '((name .
"Info index: goops")
5658 (info-index .
"goops")))
5659 ;; (anything 'anything-c-source-info-goops)
5661 ;; Info Index screen
5662 (defvar anything-c-source-info-screen
5663 '((name .
"Info index: screen")
5664 (info-index .
"screen")
5665 (index-nodes "Concept Index" "Command Index" "Keystroke Index")))
5666 ;; (anything 'anything-c-source-info-screen)
5669 (defvar anything-c-source-info-latex
5670 '((name .
"Info index: latex")
5671 (info-index .
"latex")))
5672 ;; (anything 'anything-c-source-info-latex)
5675 (defvar anything-c-source-info-gawk
5676 '((name .
"Info index: gawk")
5677 (info-index .
"gawk")))
5678 ;; (anything 'anything-c-source-info-gawk)
5681 (defvar anything-c-source-info-sed
5682 '((name .
"Info index: sed")
5683 (info-index .
"sed")))
5684 ;; (anything 'anything-c-source-info-sed)
5687 (defvar anything-c-source-info-m4
5688 '((name .
"Info index: m4")
5689 (info-index .
"m4")))
5690 ;; (anything 'anything-c-source-info-m4)
5693 (defvar anything-c-source-info-wget
5694 '((name .
"Info index: wget")
5695 (info-index .
"wget")))
5696 ;; (anything 'anything-c-source-info-wget)
5698 ;; Info Index binutils
5699 (defvar anything-c-source-info-binutils
5700 '((name .
"Info index: binutils")
5701 (info-index .
"binutils")))
5702 ;; (anything 'anything-c-source-info-binutils)
5705 (defvar anything-c-source-info-as
5706 '((name .
"Info index: as")
5707 (info-index .
"as")))
5708 ;; (anything 'anything-c-source-info-as)
5711 (defvar anything-c-source-info-bfd
5712 '((name .
"Info index: bfd")
5713 (info-index .
"bfd")))
5714 ;; (anything 'anything-c-source-info-bfd)
5717 (defvar anything-c-source-info-gprof
5718 '((name .
"Info index: gprof")
5719 (info-index .
"gprof")))
5720 ;; (anything 'anything-c-source-info-gprof)
5723 (defvar anything-c-source-info-ld
5724 '((name .
"Info index: ld")
5725 (info-index .
"ld")))
5726 ;; (anything 'anything-c-source-info-ld)
5729 (defvar anything-c-source-info-diff
5730 '((name .
"Info index: diff")
5731 (info-index .
"diff")))
5732 ;; (anything 'anything-c-source-info-diff)
5735 (defvar anything-c-source-info-flex
5736 '((name .
"Info index: flex")
5737 (info-index .
"flex")))
5738 ;; (anything 'anything-c-source-info-flex)
5741 (defvar anything-c-source-info-grep
5742 '((name .
"Info index: grep")
5743 (info-index .
"grep")))
5744 ;; (anything 'anything-c-source-info-grep)
5747 (defvar anything-c-source-info-gzip
5748 '((name .
"Info index: gzip")
5749 (info-index .
"gzip")))
5750 ;; (anything 'anything-c-source-info-gzip)
5752 ;; Info Index libtool
5753 (defvar anything-c-source-info-libtool
5754 '((name .
"Info index: libtool")
5755 (info-index .
"libtool")))
5756 ;; (anything 'anything-c-source-info-libtool)
5758 ;; Info Index texinfo
5759 (defvar anything-c-source-info-texinfo
5760 '((name .
"Info index: texinfo")
5761 (info-index .
"texinfo")))
5762 ;; (anything 'anything-c-source-info-texinfo)
5765 (defvar anything-c-source-info-info
5766 '((name .
"Info index: info")
5767 (info-index .
"info")))
5768 ;; (anything 'anything-c-source-info-info)
5771 (defvar anything-c-source-info-gdb
5772 '((name .
"Info index: gdb")
5773 (info-index .
"gdb")))
5774 ;; (anything 'anything-c-source-info-gdb)
5777 (defvar anything-c-source-info-stabs
5778 '((name .
"Info index: stabs")
5779 (info-index .
"stabs")))
5780 ;; (anything 'anything-c-source-info-stabs)
5782 ;; Info Index cvsbook
5783 (defvar anything-c-source-info-cvsbook
5784 '((name .
"Info index: cvsbook")
5785 (info-index .
"cvsbook")))
5786 ;; (anything 'anything-c-source-info-cvsbook)
5789 (defvar anything-c-source-info-cvs
5790 '((name .
"Info index: cvs")
5791 (info-index .
"cvs")))
5792 ;; (anything 'anything-c-source-info-cvs)
5795 (defvar anything-c-source-info-bison
5796 '((name .
"Info index: bison")
5797 (info-index .
"bison")))
5798 ;; (anything 'anything-c-source-info-bison)
5800 ;; Info Index id-utils
5801 (defvar anything-c-source-info-id-utils
5802 '((name .
"Info index: id-utils")
5803 (info-index .
"id-utils")))
5804 ;; (anything 'anything-c-source-info-id-utils)
5806 ;; Info Index global
5807 (defvar anything-c-source-info-global
5808 '((name .
"Info index: global")
5809 (info-index .
"global")))
5810 ;; (anything 'anything-c-source-info-global)
5813 ;;; Man and woman UI
5816 (defvar anything-c-man-pages nil
5817 "All man pages on system.
5818 Will be calculated the first time you invoke anything with this
5821 (defun anything-c-man-default-action (candidate)
5822 "Default action for jumping to a woman or man page from anything."
5823 (let ((wfiles (woman-file-name-all-completions candidate
)))
5825 (if (> (length wfiles
) 1)
5828 "ManFile: " wfiles
:must-match t
))
5830 ;; If woman is unable to format correctly
5832 (error (kill-buffer) ; Kill woman buffer.
5833 (let ((Man-notify-method 'meek
))
5834 (Man-getpage-in-background candidate
))))))
5836 (defvar anything-c-source-man-pages
5837 `((name .
"Manual Pages")
5838 (candidates .
(lambda ()
5839 (if anything-c-man-pages
5840 anything-c-man-pages
5841 ;; XEmacs doesn't have a woman :)
5842 (setq anything-c-man-pages
5845 (woman-file-name "")
5846 (sort (mapcar 'car woman-topic-all-completions
)
5848 (action ("Show with Woman" . anything-c-man-default-action
))
5849 ;; Woman does not work OS X
5850 ;; http://xahlee.org/emacs/modernization_man_page.html
5851 (action-transformer .
(lambda (actions candidate
)
5852 (if (eq system-type
'darwin
)
5853 '(("Show with Man" . man
))
5855 (requires-pattern .
2)))
5856 ;; (anything 'anything-c-source-man-pages)
5860 ;;; Anything M-x - Enhanced M-x UI
5863 ;; Another replacement of `M-x' that act exactly like the
5864 ;; vanilla Emacs one, no problem of windows configuration, prefix args
5865 ;; can be passed before calling `M-x' (e.g C-u M-x..) but also during
5866 ;; anything invocation.
5867 ;; Documentation of commands available without quitting,
5868 ;; Show keybindings of commands.
5870 (defvar anything-M-x-input-history nil
)
5872 (defun* anything-M-x-get-major-mode-command-alist
(mode-map)
5873 "Return alist of MODE-MAP."
5874 (loop for key being the key-seqs of mode-map using
(key-bindings com
)
5875 for str-key
= (key-description key
)
5876 for ismenu
= (string-match "<menu-bar>" str-key
)
5877 unless ismenu collect
(cons str-key com
)))
5879 (defun anything-get-mode-map-from-mode (mode)
5880 "Guess the mode-map name according to MODE.
5881 Some modes don't use conventional mode-map name
5882 so we need to guess mode-map name. e.g python-mode ==> py-mode-map.
5883 Return nil if no mode-map found."
5885 ;; Start with a conventional mode-map name.
5886 with mode-map
= (intern-soft (format "%s-map" mode
))
5887 with mode-string
= (symbol-name mode
)
5888 with mode-name
= (replace-regexp-in-string "-mode" "" mode-string
)
5889 while
(not mode-map
)
5890 for count downfrom
(length mode-name
)
5891 ;; Return when no result after parsing entire string.
5892 when
(eq count
0) return nil
5893 for sub-name
= (substring mode-name
0 count
)
5894 do
(setq mode-map
(intern-soft (format "%s-map" (concat sub-name
"-mode"))))
5895 finally return mode-map
))
5897 (defun anything-M-x-current-mode-map-alist ()
5898 "Return mode-map alist of current `major-mode'."
5899 (let ((map (anything-get-mode-map-from-mode major-mode
)))
5900 (when (and map
(boundp map
))
5901 (anything-M-x-get-major-mode-command-alist (symbol-value map
)))))
5904 (defun anything-M-x-transformer (candidates sources
)
5905 "filtered-candidate-transformer to show bindings in emacs commands.
5906 Show global bindings and local bindings according to current `major-mode'."
5907 (with-anything-current-buffer
5909 with local-map
= (anything-M-x-current-mode-map-alist)
5910 for cand in candidates
5911 for local-key
= (car (rassq cand local-map
))
5912 for key
= (substitute-command-keys (format "\\[%s]" cand
))
5914 (cons (cond ((and (string-match "^M-x" key
) local-key
)
5918 'face
'anything-M-x-key-face
)))
5919 ((string-match "^M-x" key
) cand
)
5920 (t (format "%s (%s)"
5923 'face
'anything-M-x-key-face
))))
5926 (sort ls
#'(lambda (x y
) (string-lessp (car x
) (car y
)))))))
5929 ;;; Complex command history
5932 (defvar anything-c-source-complex-command-history
5933 '((name .
"Complex Command History")
5934 (candidates .
(lambda () (mapcar 'prin1-to-string command-history
)))
5936 ;; (anything 'anything-c-source-complex-command-history)
5938 ;;; M-x history (not related to `anything-M-x')
5941 (defvar anything-c-source-extended-command-history
5942 '((name .
"Emacs Commands History")
5945 (anything-fast-remove-dups extended-command-history
:test
'equal
)))
5947 ;; (anything 'anything-c-source-extended-command-history)
5949 ;;; Emacs commands (Basic source for emacs commands)
5952 (defvar anything-c-source-emacs-commands
5953 '((name .
"Emacs Commands")
5954 (candidates .
(lambda ()
5956 (mapatoms (lambda (a)
5958 (push (symbol-name a
)
5960 (sort commands
'string-lessp
))))
5962 (requires-pattern .
2))
5963 "Source for completing and invoking Emacs commands.
5964 A command is a function with interactive spec that can
5965 be invoked with `M-x'.
5967 To get non-interactive functions listed, use
5968 `anything-c-source-emacs-functions'.")
5969 ;; (anything 'anything-c-source-emacs-commands)
5976 (defvar anything-c-source-emacs-functions
5977 '((name .
"Emacs Functions")
5978 (candidates .
(lambda ()
5980 (mapatoms (lambda (a)
5982 (push (symbol-name a
) commands
))))
5983 (sort commands
'string-lessp
))))
5985 (requires-pattern .
2))
5986 "Source for completing Emacs functions.")
5987 ;; (anything 'anything-c-source-emacs-functions)
5989 ;;; With abbrev expansion
5990 ;;; Similar to my exec-abbrev-cmd.el
5991 ;;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el
5992 (defvar anything-c-function-abbrev-regexp nil
5993 "The regexp for `anything-c-source-emacs-functions-with-abbrevs'.
5994 Regexp built from the current `anything-pattern' interpreting it
5996 Only for internal use.")
5998 (defun anything-c-match-function-by-abbrev (candidate)
5999 "Return non-nil if `anything-pattern' is an abbreviation of the function CANDIDATE.
6001 Abbreviations are made by taking the first character from each
6002 word in the function's name, e.g. \"bb\" is an abbrev for
6003 `bury-buffer', \"stb\" is an abbrev for `anything-c-switch-to-buffer'."
6004 (string-match anything-c-function-abbrev-regexp candidate
))
6006 (defvar anything-c-source-emacs-functions-with-abbrevs
6007 (append anything-c-source-emacs-functions
6008 '((match anything-c-match-function-by-abbrev
6009 anything-c-string-match
))
6012 (defadvice anything-update
6013 (before anything-c-update-function-abbrev-regexp activate
)
6014 (let ((char-list (append anything-pattern nil
))
6016 (dolist (c char-list
)
6017 (setq str
(concat str
(list c
) "[^-]*-")))
6018 (setq str
(concat (substring str
0 (1- (length str
))) "$"))
6019 (setq anything-c-function-abbrev-regexp str
))))))))
6020 ;; (anything 'anything-c-source-emacs-functions-with-abbrevs)
6022 (defvar anything-c-source-advice
6023 '((name .
"Function Advice")
6024 (candidates . anything-c-advice-candidates
)
6025 (action ("Toggle Enable/Disable" . anything-c-advice-toggle
))
6026 (persistent-action . anything-c-advice-persistent-action
)
6028 (persistent-help .
"Describe function / C-u C-z: Toggle advice")))
6029 ;; (anything 'anything-c-source-advice)
6030 ;; (let ((debug-on-signal t))(anything 'anything-c-source-advice))
6033 (defun anything-c-advice-candidates ()
6035 (loop for
(fname) in ad-advised-functions
6036 for function
= (intern fname
)
6038 (loop for class in ad-advice-classes append
6039 (loop for advice in
(ad-get-advice-info-field function class
)
6040 for enabled
= (ad-advice-enabled advice
)
6044 (if enabled
"Enabled " "Disabled")
6045 (propertize fname
'face
'font-lock-function-name-face
)
6046 (ad-make-single-advice-docstring advice class nil
))
6047 (list function class advice
))))))
6049 (defun anything-c-advice-persistent-action (func-class-advice)
6050 (if current-prefix-arg
6051 (anything-c-advice-toggle func-class-advice
)
6052 (describe-function (car func-class-advice
))))
6054 (defun anything-c-advice-toggle (func-class-advice)
6055 (destructuring-bind (function class advice
) func-class-advice
6056 (cond ((ad-advice-enabled advice
)
6057 (ad-advice-set-enabled advice nil
)
6058 (message "Disabled"))
6060 (ad-advice-set-enabled advice t
)
6061 (message "Enabled")))
6062 (ad-activate function
)
6063 (and anything-in-persistent-action
6064 (anything-c-advice-update-current-display-string))))
6066 (defun anything-c-advice-update-current-display-string ()
6067 (anything-edit-current-selection
6068 (let ((newword (cond ((looking-at "Disabled") "Enabled")
6069 ((looking-at "Enabled") "Disabled")))
6072 (delete-region (point) (progn (forward-word 1) (point)))
6073 (insert newword
)))))
6080 (defvar anything-c-source-emacs-variables
6081 '((name .
"Emacs Variables")
6082 (candidates .
(lambda ()
6083 (sort (all-completions "" obarray
'boundp
) 'string-lessp
)))
6085 (requires-pattern .
2))
6086 "Source for completing Emacs variables.")
6087 ;; (anything 'anything-c-source-emacs-variables)
6091 (defvar anything-c-source-lacarte
6092 '((name .
"Lacarte")
6093 (init .
(lambda () (require 'lacarte
)))
6094 (candidates .
(lambda () (delete '(nil) (lacarte-get-overall-menu-item-alist))))
6095 (candidate-number-limit .
9999)
6096 (action . anything-c-call-interactively
))
6099 http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
6100 ;; (anything 'anything-c-source-lacarte)
6106 ;; Bind some faces for bookmarks.
6107 (defvar anything-c-bookmarks-face1
'anything-ff-directory
)
6108 (defvar anything-c-bookmarks-face2
'anything-ff-file
)
6109 (defvar anything-c-bookmarks-face3
'anything-bookmarks-su-face
)
6111 (eval-when-compile (require 'bookmark
))
6112 (defvar anything-c-source-bookmarks
6113 '((name .
"Bookmarks")
6115 (require 'bookmark
)))
6116 (candidates . bookmark-all-names
)
6118 "See (info \"(emacs)Bookmarks\").")
6119 ;; (anything 'anything-c-source-bookmarks)
6122 (defvar anything-c-source-bookmark-set
6123 '((name .
"Set Bookmark")
6125 (action . bookmark-set
))
6126 "See (info \"(emacs)Bookmarks\").")
6127 ;; (anything 'anything-c-source-bookmark-set)
6129 ;;; Visible Bookmarks
6130 ;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el")
6133 ;; http://d.hatena.ne.jp/grandVin/20080911/1221114327
6134 (defvar anything-c-source-bm
6135 '((name .
"Visible Bookmarks")
6136 (init . anything-c-bm-init
)
6137 (candidates-in-buffer)
6141 http://www.nongnu.org/bm/")
6143 (defun anything-c-bm-init ()
6144 "Init function for `anything-c-source-bm'."
6145 (when (require 'bm nil t
)
6147 (let ((bookmarks (bm-lists))
6148 (buf (anything-candidate-buffer 'global
)))
6149 (dolist (bm (sort* (append (car bookmarks
) (cdr bookmarks
))
6150 '< :key
'overlay-start
))
6151 (let ((start (overlay-start bm
))
6152 (end (overlay-end bm
))
6153 (annotation (or (overlay-get bm
'annotation
) "")))
6154 (unless (< (- end start
) 1) ; org => (if (< (- end start) 2)
6155 (let ((str (format "%5d: [%s]: %s\n"
6156 (line-number-at-pos start
)
6158 (buffer-substring start
(1- end
)))))
6159 (with-current-buffer buf
(insert str
))))))))))
6161 ;;; Special bookmarks
6162 (defvar anything-c-source-bookmarks-ssh
6163 '((name .
"Bookmarks-ssh")
6165 (require 'bookmark
)))
6166 (candidates .
(lambda () (anything-c-collect-bookmarks :ssh t
)))
6168 "See (info \"(emacs)Bookmarks\").")
6169 ;; (anything 'anything-c-source-bookmarks-ssh)
6171 (defvar anything-c-source-bookmarks-su
6172 '((name .
"Bookmarks-root")
6174 (require 'bookmark
)))
6175 (candidates .
(lambda () (anything-c-collect-bookmarks :su t
)))
6176 (filtered-candidate-transformer anything-c-highlight-bookmark-su
)
6179 "See (info \"(emacs)Bookmarks\").")
6180 ;; (anything 'anything-c-source-bookmarks-su)
6182 (defvar anything-c-source-bookmarks-local
6183 '((name .
"Bookmarks-Local")
6185 (require 'bookmark
)))
6186 (candidates .
(lambda () (anything-c-collect-bookmarks :local t
)))
6187 (filtered-candidate-transformer
6188 anything-c-adaptive-sort
6189 anything-c-highlight-bookmark
)
6191 "See (info \"(emacs)Bookmarks\").")
6192 ;; (anything 'anything-c-source-bookmarks-local)
6194 (defun* anything-c-collect-bookmarks
(&key local su sudo ssh
)
6195 (let* ((lis-all (bookmark-all-names))
6196 (lis-loc (cond (local (loop for i in lis-all
6197 unless
(string-match "^(ssh)\\|^(su)" i
)
6199 (su (loop for i in lis-all
6200 when
(string-match "^(su)" i
)
6202 (sudo (loop for i in lis-all
6203 when
(string-match "^(sudo)" i
)
6205 (ssh (loop for i in lis-all
6206 when
(string-match "^(ssh)" i
)
6208 (sort lis-loc
'string-lessp
)))
6210 (defun anything-c-bookmark-root-logged-p ()
6212 (dolist (i (mapcar #'buffer-name
(buffer-list)))
6213 (when (string-match (format "*tramp/%s ." anything-su-or-sudo
) i
)
6214 (throw 'break t
)))))
6216 (defun anything-c-highlight-bookmark-su (files source
)
6217 (if (anything-c-bookmark-root-logged-p)
6218 (anything-c-highlight-bookmark files source
)
6219 (anything-c-highlight-not-logged files source
)))
6221 (defun anything-c-highlight-not-logged (files source
)
6222 (loop for i in files
6223 collect
(propertize i
'face anything-c-bookmarks-face3
)))
6225 (defun anything-c-highlight-bookmark (bookmarks source
)
6226 "Used as `candidate-transformer' to colorize bookmarks.
6227 Work both with standard Emacs bookmarks and bookmark-extensions.el."
6228 (loop for i in bookmarks
6229 for isfile
= (bookmark-get-filename i
)
6230 for bufp
= (and (fboundp 'bmkext-get-buffer-name
)
6231 (bmkext-get-buffer-name i
))
6232 for handlerp
= (and (fboundp 'bookmark-get-handler
)
6233 (bookmark-get-handler i
))
6234 for isw3m
= (and (fboundp 'bmkext-w3m-bookmark-p
)
6235 (bmkext-w3m-bookmark-p i
))
6236 for isgnus
= (and (fboundp 'bmkext-gnus-bookmark-p
)
6237 (bmkext-gnus-bookmark-p i
))
6238 for isman
= (and (fboundp 'bmkext-man-bookmark-p
) ; Man
6239 (bmkext-man-bookmark-p i
))
6240 for iswoman
= (and (fboundp 'bmkext-woman-bookmark-p
) ; Woman
6241 (bmkext-woman-bookmark-p i
))
6242 for handlerp
= (bookmark-get-handler i
)
6243 for isannotation
= (bookmark-get-annotation i
)
6244 for isabook
= (string= (bookmark-prop-get i
'type
) "addressbook")
6245 for isinfo
= (eq handlerp
'Info-bookmark-jump
)
6246 ;; Add a * if bookmark have annotation
6247 if
(and isannotation
(not (string-equal isannotation
"")))
6248 do
(setq i
(concat "*" i
))
6249 collect
(cond (;; info buffers
6251 (propertize i
'face
'anything-bmkext-info
'help-echo isfile
))
6254 (propertize i
'face
'anything-bmkext-w3m
'help-echo isfile
))
6257 (propertize i
'face
'anything-bmkext-gnus
'help-echo isfile
))
6260 (propertize i
'face
'anything-bmkext-man
'help-echo isfile
))
6263 (propertize i
'face
'((:foreground
"Tomato"))))
6265 (and isfile
(file-directory-p isfile
))
6266 (propertize i
'face anything-c-bookmarks-face1
'help-echo isfile
))
6269 (propertize i
'face
'anything-bmkext-file
'help-echo isfile
)))))
6273 ;;; Sources to filter bookmark-extensions bookmarks.
6276 ;; Dependency: http://mercurial.intuxication.org/hg/emacs-bookmark-extension
6277 ;; If you want to enable google-maps in addressbook you will need
6278 ;; Julien Danjou google-maps-el package available here:
6279 ;; http://julien.danjou.info/google-maps-el.html
6281 (defun anything-c-bmkext-filter-setup-alist (fn &rest args
)
6282 "Return a filtered `bookmark-alist' sorted alphabetically."
6284 with alist
= (if args
6285 (apply #'(lambda (x) (funcall fn x
)) args
)
6290 finally return
(sort sa
'string-lessp
)))
6295 (defvar anything-c-source-bmkext-addressbook
6296 '((name .
"Bookmark Addressbook")
6298 (require 'bookmark-extensions
)
6299 (bookmark-maybe-load-default-file)))
6300 (candidates . anything-c-bmkext-addressbook-setup-alist
)
6302 .
(lambda (candidate)
6303 (let ((bmk (anything-bookmark-get-bookmark-from-name
6305 (bookmark--jump-via bmk
'pop-to-buffer
))))
6306 (persistent-help .
"Show contact - Prefix with C-u to append")
6307 (filtered-candidate-transformer
6308 anything-c-adaptive-sort
6309 anything-c-highlight-bookmark
)
6310 (action .
(("Show Contact(s)"
6311 .
(lambda (candidate)
6312 (let* ((contacts (anything-marked-candidates))
6313 (current-prefix-arg (or anything-current-prefix-arg
6314 (> (length contacts
) 1))))
6316 (anything-bookmark-get-bookmark-from-name (car contacts
)))
6317 (anything-aif (cdr contacts
)
6318 (loop for bmk in it do
6320 (anything-bookmark-get-bookmark-from-name bmk
)))))))
6322 .
(lambda (candidate)
6323 (let* ((contacts (anything-marked-candidates))
6324 (bmk (anything-bookmark-get-bookmark-from-name
6326 (append (message-buffers)))
6328 (addressbook-set-mail-buffer1 bmk
'append
)
6329 (addressbook-set-mail-buffer1 bmk
))
6330 (setq contacts
(cdr contacts
))
6332 (loop for bmk in contacts do
6333 (addressbook-set-mail-buffer1 bmk
'append
))))))
6335 .
(lambda (candidate)
6336 (let ((bmk (anything-bookmark-get-bookmark-from-name
6338 (addressbook-bookmark-edit
6339 (assoc bmk bookmark-alist
)))))
6340 ("Insert Email at point"
6341 .
(lambda (candidate)
6342 (let* ((bmk (anything-bookmark-get-bookmark-from-name
6344 (mlist (split-string
6346 'email
(assoc bmk bookmark-alist
))
6349 (if (> (length mlist
) 1)
6351 "Insert Mail Address: " mlist
:must-match t
)
6354 .
(lambda (candidate)
6355 (let ((bmk (anything-bookmark-get-bookmark-from-name
6357 (bookmark-show-annotation bmk
))))
6359 .
(lambda (candidate)
6360 (let ((bmk (anything-bookmark-get-bookmark-from-name
6362 (bookmark-edit-annotation bmk
))))
6364 .
(lambda (candidate)
6365 (let* ((bmk (anything-bookmark-get-bookmark-from-name
6367 (full-bmk (assoc bmk bookmark-alist
)))
6368 (addressbook-google-map full-bmk
))))))))
6371 (defun anything-c-bmkext-addressbook-setup-alist ()
6372 "Specialized filter function for bookmarks w3m."
6373 (anything-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only
))
6375 ;; W3m bookmarks from bookmark-extensions.
6376 (defvar anything-c-source-bookmark-w3m
6377 '((name .
"Bookmark W3m")
6379 (require 'bookmark-extensions
)
6380 (bookmark-maybe-load-default-file)))
6381 (candidates . anything-c-bookmark-w3m-setup-alist
)
6382 (filtered-candidate-transformer
6383 anything-c-adaptive-sort
6384 anything-c-highlight-bookmark
)
6386 ;; (anything 'anything-c-source-bookmark-w3m)
6388 (defun anything-c-bookmark-w3m-setup-alist ()
6389 "Specialized filter function for bookmarks w3m."
6390 (anything-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only
))
6393 (defvar anything-c-source-bookmark-images
6394 '((name .
"Bookmark Images")
6396 (require 'bookmark-extensions
)
6397 (bookmark-maybe-load-default-file)))
6398 (candidates . anything-c-bookmark-images-setup-alist
)
6399 (filtered-candidate-transformer
6400 anything-c-adaptive-sort
6401 anything-c-highlight-bookmark
)
6403 ;; (anything 'anything-c-source-bookmark-images)
6405 (defun anything-c-bookmark-images-setup-alist ()
6406 "Specialized filter function for images bookmarks."
6407 (anything-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only
))
6410 (defvar anything-c-source-bookmark-man
6411 '((name .
"Bookmark Woman&Man")
6413 (require 'bookmark-extensions
)
6414 (bookmark-maybe-load-default-file)))
6415 (candidates . anything-c-bookmark-man-setup-alist
)
6416 (filtered-candidate-transformer
6417 anything-c-adaptive-sort
6418 anything-c-highlight-bookmark
)
6420 ;; (anything 'anything-c-source-bookmark-man)
6422 (defun anything-c-bookmark-man-setup-alist ()
6423 "Specialized filter function for bookmarks w3m."
6424 (append (anything-c-bmkext-filter-setup-alist 'bmkext-man-alist-only
)
6425 (anything-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only
)))
6428 (defvar anything-c-source-bookmark-gnus
6429 '((name .
"Bookmark Gnus")
6431 (require 'bookmark-extensions
)
6432 (bookmark-maybe-load-default-file)))
6433 (candidates . anything-c-bookmark-gnus-setup-alist
)
6434 (filtered-candidate-transformer
6435 anything-c-adaptive-sort
6436 anything-c-highlight-bookmark
)
6438 ;; (anything 'anything-c-source-bookmark-gnus)
6440 (defun anything-c-bookmark-gnus-setup-alist ()
6441 "Specialized filter function for bookmarks gnus."
6442 (anything-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only
))
6445 (defvar anything-c-source-bookmark-info
6446 '((name .
"Bookmark Info")
6448 (require 'bookmark-extensions
)
6449 (bookmark-maybe-load-default-file)))
6450 (candidates . anything-c-bookmark-info-setup-alist
)
6451 (filtered-candidate-transformer
6452 anything-c-adaptive-sort
6453 anything-c-highlight-bookmark
)
6455 ;; (anything 'anything-c-source-bookmark-info)
6457 (defun anything-c-bookmark-info-setup-alist ()
6458 "Specialized filter function for bookmarks info."
6459 (anything-c-bmkext-filter-setup-alist 'bmkext-info-alist-only
))
6461 ;; Local Files&directories
6462 (defvar anything-c-source-bookmark-files
&dirs
6463 '((name .
"Bookmark Files&Directories")
6465 (require 'bookmark-extensions
)
6466 (bookmark-maybe-load-default-file)))
6467 (candidates . anything-c-bookmark-local-files-setup-alist
)
6468 (filtered-candidate-transformer
6469 anything-c-adaptive-sort
6470 anything-c-highlight-bookmark
)
6472 ;; (anything 'anything-c-source-bookmark-files&dirs)
6474 (defun anything-c-bookmark-local-files-setup-alist ()
6475 "Specialized filter function for bookmarks locals files."
6476 (anything-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only
))
6478 ;; Su Files&directories
6479 (defvar anything-c-source-bookmark-su-files
&dirs
6480 '((name .
"Bookmark Root-Files&Directories")
6482 (require 'bookmark-extensions
)
6483 (bookmark-maybe-load-default-file)))
6484 (candidates . anything-c-bookmark-su-files-setup-alist
)
6485 (filtered-candidate-transformer
6486 anything-c-adaptive-sort
6487 anything-c-highlight-bookmark-su
)
6489 ;; (anything 'anything-c-source-bookmark-su-files&dirs)
6491 (defun anything-c-bookmark-su-files-setup-alist ()
6492 "Specialized filter function for bookmarks su/sudo files."
6493 (declare (special bmkext-su-or-sudo-regexp
))
6495 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
6497 for isfile
= (bookmark-get-filename i
)
6498 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
6500 (string-match tramp-file-name-regexp isfile
)))
6501 for issu
= (and istramp
6502 (string-match bmkext-su-or-sudo-regexp isfile
))
6506 ;; Ssh Files&directories
6507 (defvar anything-c-source-bookmark-ssh-files
&dirs
6508 '((name .
"Bookmark Ssh-Files&Directories")
6510 (require 'bookmark-extensions
)
6511 (bookmark-maybe-load-default-file)))
6512 (candidates . anything-c-bookmark-ssh-files-setup-alist
)
6513 (filtered-candidate-transformer . anything-c-adaptive-sort
)
6515 ;; (anything 'anything-c-source-bookmark-ssh-files&dirs)
6517 (defun anything-c-bookmark-ssh-files-setup-alist ()
6518 "Specialized filter function for bookmarks ssh files."
6520 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
6522 for isfile
= (bookmark-get-filename i
)
6523 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
6525 (string-match tramp-file-name-regexp isfile
)))
6526 for isssh
= (and istramp
6527 (string-match "/ssh:" isfile
))
6533 ;;; Firefox bookmarks
6536 ;; You will have to set firefox to import bookmarks in his html file bookmarks.html.
6537 ;; (only for firefox versions >=3)
6538 ;; To achieve that, open about:config in firefox and double click on this line to enable value
6540 ;; user_pref("browser.bookmarks.autoExportHTML", false);
6541 ;; You should have now:
6542 ;; user_pref("browser.bookmarks.autoExportHTML", true);
6544 (defvar anything-firefox-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|about\\|file\\)://[^ \"]*")
6545 (defvar anything-firefox-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
6547 (defun anything-get-firefox-user-init-dir ()
6548 "Guess the default Firefox user directory name."
6549 (let* ((moz-dir (concat (getenv "HOME") "/.mozilla/firefox/"))
6551 (with-current-buffer (find-file-noselect (concat moz-dir
"profiles.ini"))
6552 (goto-char (point-min))
6554 (when (search-forward "Path=" nil t
)
6555 (buffer-substring-no-properties (point) (point-at-eol)))
6557 (file-name-as-directory (concat moz-dir moz-user-dir
))))
6559 (defun anything-guess-firefox-bookmark-file ()
6560 "Return the path of the Firefox bookmarks file."
6561 (concat (anything-get-firefox-user-init-dir) "bookmarks.html"))
6563 (defun anything-html-bookmarks-to-alist (file url-regexp bmk-regexp
)
6564 "Parse html bookmark FILE and return an alist with (title . url) as elements."
6565 (let (bookmarks-alist url title
)
6567 (insert-file-contents file
)
6568 (goto-char (point-min))
6569 (while (re-search-forward "href=\\|^ *<DT><A HREF=" nil t
)
6571 (when (re-search-forward url-regexp nil t
)
6572 (setq url
(match-string 0)))
6573 (when (re-search-forward bmk-regexp nil t
)
6574 (setq title
(match-string 1)))
6575 (push (cons title url
) bookmarks-alist
)
6577 (nreverse bookmarks-alist
)))
6579 (defvar anything-c-firefox-bookmarks-alist nil
)
6580 (defvar anything-c-source-firefox-bookmarks
6581 '((name .
"Firefox Bookmarks")
6583 (setq anything-c-firefox-bookmarks-alist
6584 (anything-html-bookmarks-to-alist
6585 (anything-guess-firefox-bookmark-file)
6586 anything-firefox-bookmark-url-regexp
6587 anything-firefox-bookmarks-regexp
))))
6588 (candidates .
(lambda ()
6589 (mapcar #'car anything-c-firefox-bookmarks-alist
)))
6590 (filtered-candidate-transformer
6591 anything-c-adaptive-sort
6592 anything-c-highlight-firefox-bookmarks
)
6593 (action .
(("Browse Url Firefox"
6594 .
(lambda (candidate)
6596 (anything-c-firefox-bookmarks-get-value candidate
))))
6598 .
(lambda (candidate)
6600 (anything-c-firefox-bookmarks-get-value candidate
))))
6603 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))))))
6605 ;; (anything 'anything-c-source-firefox-bookmarks)
6607 (defun anything-c-firefox-bookmarks-get-value (elm)
6608 (assoc-default elm anything-c-firefox-bookmarks-alist
))
6610 (defun anything-c-highlight-firefox-bookmarks (bookmarks source
)
6611 (loop for i in bookmarks
6613 i
'face
'((:foreground
"YellowGreen"))
6614 'help-echo
(anything-c-firefox-bookmarks-get-value i
))))
6618 ;;; W3m bookmark - anything interface.
6621 ;; Some users have the emacs-w3m library in load-path
6622 ;; without having the w3m executable :-;
6623 ;; So check if w3m program is present before trying to load
6626 (when (executable-find "w3m")
6627 (require 'w3m-bookmark nil t
)))
6629 (defvar w3m-bookmark-file
"~/.w3m/bookmark.html")
6630 (defvar anything-w3m-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
6631 (defvar anything-w3m-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|file\\)://[^>]*")
6632 (defvar anything-c-w3m-bookmarks-alist nil
)
6633 (defvar anything-c-source-w3m-bookmarks
6634 '((name .
"W3m Bookmarks")
6636 (setq anything-c-w3m-bookmarks-alist
6637 (anything-html-bookmarks-to-alist
6639 anything-w3m-bookmark-url-regexp
6640 anything-w3m-bookmarks-regexp
))))
6641 (candidates .
(lambda ()
6642 (mapcar #'car anything-c-w3m-bookmarks-alist
)))
6643 (filtered-candidate-transformer
6644 anything-c-adaptive-sort
6645 anything-c-highlight-w3m-bookmarks
)
6646 (action .
(("Browse Url"
6647 .
(lambda (candidate)
6648 (anything-c-w3m-browse-bookmark candidate
)))
6651 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))
6652 ("Browse Url Firefox"
6653 .
(lambda (candidate)
6654 (anything-c-w3m-browse-bookmark candidate t
)))
6656 .
(lambda (candidate)
6657 (anything-c-w3m-delete-bookmark candidate
)))
6659 .
(lambda (candidate)
6660 (anything-c-w3m-rename-bookmark candidate
)))))
6661 (persistent-action .
(lambda (candidate)
6662 (if current-prefix-arg
6663 (anything-c-w3m-browse-bookmark candidate t
)
6664 (anything-c-w3m-browse-bookmark candidate nil t
))))
6665 (persistent-help .
"Open URL with emacs-w3m in new tab / \
6666 C-u \\[anything-execute-persistent-action]: Open URL with Firefox"))
6667 "Needs w3m and emacs-w3m.
6669 http://w3m.sourceforge.net/
6670 http://emacs-w3m.namazu.org/")
6672 ;; (anything 'anything-c-source-w3m-bookmarks)
6674 (defun anything-c-w3m-bookmarks-get-value (elm)
6675 (replace-regexp-in-string
6676 "\"" "" (cdr (assoc elm anything-c-w3m-bookmarks-alist
))))
6678 (defun anything-c-w3m-browse-bookmark (elm &optional use-firefox new-tab
)
6679 (let* ((fn (if use-firefox
'browse-url-firefox
'w3m-browse-url
))
6680 (arg (and (eq fn
'w3m-browse-url
) new-tab
)))
6681 (funcall fn
(anything-c-w3m-bookmarks-get-value elm
) arg
)))
6683 (defun anything-c-highlight-w3m-bookmarks (bookmarks source
)
6684 (loop for i in bookmarks
6686 i
'face
'anything-w3m-bookmarks-face
6687 'help-echo
(anything-c-w3m-bookmarks-get-value i
))))
6690 (defun anything-c-w3m-delete-bookmark (elm)
6691 "Delete w3m bookmark from `w3m-bookmark-file'."
6692 (with-current-buffer
6693 (find-file-literally w3m-bookmark-file
)
6694 (goto-char (point-min))
6695 (when (re-search-forward elm nil t
)
6697 (delete-region (point)
6698 (line-end-position))
6699 (delete-blank-lines))
6703 (defun anything-c-w3m-rename-bookmark (elm)
6704 "Rename w3m bookmark in `w3m-bookmark-file'."
6705 (let* ((old-title (replace-regexp-in-string ">" "" elm
))
6706 (new-title (read-string "NewTitle: " old-title
)))
6707 (with-current-buffer
6708 (find-file-literally w3m-bookmark-file
)
6709 (goto-char (point-min))
6710 (when (re-search-forward (concat elm
"<") nil t
)
6711 (goto-char (1- (point)))
6712 (delete-char (- (length old-title
)))
6719 ;;; Elisp library scan
6722 (defvar anything-c-source-elisp-library-scan
6723 '((name .
"Elisp libraries (Scan)")
6724 (init .
(anything-c-elisp-library-scan-init))
6725 (candidates-in-buffer)
6726 (action ("Find library"
6727 .
(lambda (candidate) (find-file (find-library-name candidate
))))
6728 ("Find library other window"
6729 .
(lambda (candidate)
6730 (find-file-other-window (find-library-name candidate
))))
6732 .
(lambda (candidate) (load-library candidate
))))))
6733 ;; (anything 'anything-c-source-elisp-library-scan)
6735 (defun anything-c-elisp-library-scan-init ()
6736 "Init anything buffer status."
6737 (let ((anything-buffer (anything-candidate-buffer 'global
))
6738 (library-list (anything-c-elisp-library-scan-list)))
6739 (with-current-buffer anything-buffer
6740 (dolist (library library-list
)
6741 (insert (format "%s\n" library
))))))
6743 (defun anything-c-elisp-library-scan-list (&optional dirs string
)
6744 "Do completion for file names passed to `locate-file'.
6745 DIRS is directory to search path.
6746 STRING is string to match."
6747 ;; Use `load-path' as path when ignore `dirs'.
6748 (or dirs
(setq dirs load-path
))
6749 ;; Init with blank when ignore `string'.
6750 (or string
(setq string
""))
6751 ;; Get library list.
6752 (let ((string-dir (file-name-directory string
))
6753 ;; File regexp that suffix match `load-file-rep-suffixes'.
6754 (match-regexp (format "^.*\\.el%s$" (regexp-opt load-file-rep-suffixes
)))
6759 (setq dir default-directory
))
6761 (setq dir
(expand-file-name string-dir dir
)))
6762 (when (file-directory-p dir
)
6763 (dolist (file (file-name-all-completions
6764 (file-name-nondirectory string
) dir
))
6765 ;; Suffixes match `load-file-rep-suffixes'.
6766 (setq name
(if string-dir
(concat string-dir file
) file
))
6767 (if (string-match match-regexp name
)
6768 (add-to-list 'names name
)))))
6779 (defvar anything-c-imenu-delimiter
" / ")
6781 (defvar anything-c-imenu-index-filter nil
)
6782 (make-variable-buffer-local 'anything-c-imenu-index-filter
)
6784 (defvar anything-c-cached-imenu-alist nil
)
6785 (make-variable-buffer-local 'anything-c-cached-imenu-alist
)
6787 (defvar anything-c-cached-imenu-candidates nil
)
6788 (make-variable-buffer-local 'anything-c-cached-imenu-candidates
)
6790 (defvar anything-c-cached-imenu-tick nil
)
6791 (make-variable-buffer-local 'anything-c-cached-imenu-tick
)
6793 (eval-when-compile (require 'imenu
))
6794 (setq imenu-auto-rescan t
)
6796 (defun anything-imenu-create-candidates (entry)
6797 "Create candidates with ENTRY."
6798 (if (listp (cdr entry
))
6801 (if (consp (cdr sub
))
6804 (concat (car entry
) anything-c-imenu-delimiter subentry
))
6805 (anything-imenu-create-candidates sub
))
6806 (list (concat (car entry
) anything-c-imenu-delimiter
(car sub
)))))
6810 (defvar anything-c-source-imenu
6812 (init .
(lambda () (require 'imenu
)))
6813 (candidates . anything-c-imenu-candidates
)
6814 (persistent-action .
(lambda (elm)
6815 (anything-c-imenu-default-action elm
)
6816 (unless (fboundp 'semantic-imenu-tag-overlay
)
6817 (anything-match-line-color-current-line))))
6818 (persistent-help .
"Show this entry")
6819 (action . anything-c-imenu-default-action
))
6820 "See (info \"(emacs)Imenu\")")
6822 ;; (anything 'anything-c-source-imenu)
6824 (defun anything-c-imenu-candidates ()
6825 (with-anything-current-buffer
6826 (let ((tick (buffer-modified-tick)))
6827 (if (eq anything-c-cached-imenu-tick tick
)
6828 anything-c-cached-imenu-candidates
6829 (setq imenu--index-alist nil
)
6830 (setq anything-c-cached-imenu-tick tick
6831 anything-c-cached-imenu-candidates
6834 'anything-imenu-create-candidates
6835 (setq anything-c-cached-imenu-alist
6836 (let ((index (imenu--make-index-alist)))
6837 (if anything-c-imenu-index-filter
6838 (funcall anything-c-imenu-index-filter index
)
6840 (setq anything-c-cached-imenu-candidates
6841 (mapcar #'(lambda (x)
6845 anything-c-cached-imenu-candidates
))))))
6847 (setq imenu-default-goto-function
'imenu-default-goto-function
)
6848 (defun anything-c-imenu-default-action (elm)
6849 "The default action for `anything-c-source-imenu'."
6850 (let ((path (split-string elm anything-c-imenu-delimiter
))
6851 (alist anything-c-cached-imenu-alist
))
6853 (setq alist
(assoc elm alist
)))
6861 (defvar anything-c-ctags-modes
6862 '( c-mode c
++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode
6863 makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode
6864 scheme-mode sh-mode slang-mode sql-mode tcl-mode
))
6866 (defun anything-c-source-ctags-init ()
6867 (when (and buffer-file-name
6868 (memq major-mode anything-c-ctags-modes
)
6869 (anything-current-buffer-is-modified))
6870 (with-current-buffer (anything-candidate-buffer 'local
)
6871 (call-process-shell-command
6872 (if (string-match "\\.el\\.gz$" anything-buffer-file-name
)
6873 (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) "
6874 anything-buffer-file-name
)
6875 (format "ctags -e -u -f- --fields=n %s " anything-buffer-file-name
))
6876 nil
(current-buffer))
6877 (goto-char (point-min))
6879 (delete-region (point-min) (point))
6880 (loop while
(and (not (eobp)) (search-forward "\001" (point-at-eol) t
))
6881 for lineno-start
= (point)
6882 for lineno
= (buffer-substring
6884 (1- (search-forward "," (point-at-eol) t
)))
6887 (insert (format "%5s:" lineno
))
6888 (search-forward "\177" (point-at-eol) t
)
6889 (delete-region (1- (point)) (point-at-eol))
6890 (forward-line 1)))))
6892 (defvar anything-c-source-ctags
6893 '((name .
"Exuberant ctags")
6894 (init . anything-c-source-ctags-init
)
6895 (candidates-in-buffer)
6898 "Needs Exuberant Ctags.
6900 http://ctags.sourceforge.net/")
6901 ;; (anything 'anything-c-source-ctags)
6907 ;; anything-etags.el is deprecated, if this file is found,
6908 ;; warn user at compile time.
6910 (when (locate-library "anything-etags.el")
6913 "You are using obsolete library `anything-etags.el' and should remove it."
6916 (defvar anything-c-etags-tag-file-dir nil
6917 "Etags file directory.")
6918 (defvar anything-c-etags-mtime-alist nil
6919 "Store the last modification time of etags files here.")
6920 (defvar anything-c-etags-cache
(make-hash-table :test
'equal
)
6921 "Cache content of etags files used here for faster access.")
6923 (defun anything-c-etags-get-tag-file (&optional directory
)
6924 "Return the path of etags file if found."
6925 ;; Get tag file from `default-directory' or upper directory.
6926 (let ((current-dir (anything-c-etags-find-tag-file-directory
6927 (or directory default-directory
))))
6928 ;; Return nil if not find tag file.
6930 ;; Set tag file directory.
6931 (setq anything-c-etags-tag-file-dir current-dir
)
6932 (expand-file-name anything-c-etags-tag-file-name current-dir
))))
6934 (defun anything-c-etags-find-tag-file-directory (current-dir)
6935 "Try to find the directory containing tag file.
6936 If not found in CURRENT-DIR search in upper directory."
6937 (flet ((file-exists?
(dir)
6938 (let ((tag-path (expand-file-name
6939 anything-c-etags-tag-file-name dir
)))
6940 (and (stringp tag-path
)
6941 (file-exists-p tag-path
)
6942 (file-readable-p tag-path
)))))
6943 (loop with count
= 0
6944 until
(file-exists? current-dir
)
6945 ;; Return nil if outside the value of
6946 ;; `anything-c-etags-tag-file-search-limit'.
6947 if
(= count anything-c-etags-tag-file-search-limit
)
6949 ;; Or search upper directories.
6952 (setq current-dir
(expand-file-name (concat current-dir
"../")))
6953 finally return current-dir
)))
6955 (defun anything-c-source-etags-header-name (x)
6956 "Create header name for this anything etags session."
6958 (with-anything-current-buffer
6959 (anything-c-etags-get-tag-file))))
6961 (defmacro anything-c-etags-create-buffer
(file)
6962 "Create the `anything-buffer' based on contents of etags tag FILE."
6963 `(let* ((tag-fname ,file
)
6965 (split (with-current-buffer (find-file-noselect tag-fname
)
6967 (split-string (buffer-string) "\n" 'omit-nulls
)
6968 (setq max
(line-number-at-pos (point-max)))
6970 (progress-reporter (make-progress-reporter "Loading tag file..." 0 max
)))
6974 for i in split for count from
0
6975 for elm
= (unless (string-match "^\x0c" i
)
6976 (anything-aif (string-match "\177" i
)
6979 do
(cond ((and elm
(string-match "^\\(.+\\),[0-9]+" elm
))
6980 (setq fname
(match-string 1 elm
)))
6981 (elm (setq cand
(concat fname
": " elm
)))
6982 (t (setq cand nil
)))
6984 (insert (concat cand
"\n"))
6985 (progress-reporter-update progress-reporter count
)))))
6987 (defun anything-c-etags-init ()
6988 "Feed `anything-buffer' using `anything-c-etags-cache' or tag file.
6989 If no entry in cache, create one."
6990 (let ((tagfile (anything-c-etags-get-tag-file)))
6992 (with-current-buffer (anything-candidate-buffer 'global
)
6993 (anything-aif (gethash tagfile anything-c-etags-cache
)
6994 ;; An entry is present in cache, insert it.
6996 ;; No entry, create a new buffer using content of tag file (slower).
6997 (anything-c-etags-create-buffer tagfile
)
6998 ;; Store content of buffer in cache.
6999 (puthash tagfile
(buffer-string) anything-c-etags-cache
)
7000 ;; Store or set the last modification of tag file.
7001 (anything-aif (assoc tagfile anything-c-etags-mtime-alist
)
7002 ;; If an entry exists modify it.
7003 (setcdr it
(anything-c-etags-mtime tagfile
))
7004 ;; No entry create a new one.
7005 (add-to-list 'anything-c-etags-mtime-alist
7006 (cons tagfile
(anything-c-etags-mtime tagfile
)))))))))
7008 (defvar anything-c-source-etags-select
7010 (header-name . anything-c-source-etags-header-name
)
7011 (init . anything-c-etags-init
)
7012 (candidates-in-buffer)
7013 (search .
(anything-c-etags-search-fn))
7014 (mode-line . anything-etags-mode-line-string
)
7015 (action . anything-c-etags-default-action
)
7016 (persistent-action .
(lambda (candidate)
7017 (anything-c-etags-default-action candidate
)
7018 (anything-match-line-color-current-line))))
7019 "Anything source for Etags.")
7021 (defun anything-c-etags-search-fn (pattern)
7022 "Search function for `anything-c-source-etags-select'."
7024 (if anything-c-etags-use-regexp-search
7025 (format anything-c-etags-search-regexp pattern
)
7029 (defun anything-c-etags-default-action (candidate)
7030 "Anything default action to jump to an etags entry."
7031 (let* ((split (split-string candidate
": "))
7032 (fname (expand-file-name
7033 (car split
) anything-c-etags-tag-file-dir
))
7036 (goto-char (point-min))
7037 (search-forward elm nil t
)
7038 (goto-char (match-beginning 0))))
7040 (defun anything-c-etags-mtime (file)
7041 "Last modification time of etags tag FILE."
7042 (cadr (nth 5 (file-attributes file
))))
7044 (defun anything-c-etags-file-modified-p (file)
7045 "Check if tag FILE have been modified in this session.
7046 If FILE is nil return nil."
7047 (let ((last-modif (and file
7048 (assoc-default file anything-c-etags-mtime-alist
))))
7050 (/= last-modif
(anything-c-etags-mtime file
)))))
7057 (defvar anything-semantic-candidates nil
)
7059 (defun anything-semantic-construct-candidates (tags depth
)
7060 (when (require 'semantic nil t
)
7066 (let ((type (semantic-tag-type tag
))
7067 (class (semantic-tag-class tag
)))
7068 (if (or (and (stringp type
)
7069 (or (string= type
"class")
7070 (string= type
"namespace")))
7071 (eq class
'function
)
7072 (eq class
'variable
))
7073 (cons (cons (concat (make-string (* depth
2) ?\s
)
7074 (semantic-format-tag-summarize tag nil t
))
7076 (anything-semantic-construct-candidates
7077 (semantic-tag-components tag
) (1+ depth
)))))))
7080 (defun anything-semantic-default-action (candidate)
7081 (let ((tag (cdr (assoc candidate anything-semantic-candidates
))))
7082 (semantic-go-to-tag tag
)))
7084 (defvar anything-c-source-semantic
7085 '((name .
"Semantic Tags")
7087 (setq anything-semantic-candidates
7088 (ignore-errors (anything-semantic-construct-candidates
7089 (semantic-fetch-tags) 0)))))
7090 (candidates .
(lambda ()
7091 (if anything-semantic-candidates
7092 (mapcar 'car anything-semantic-candidates
))))
7093 (persistent-action .
(lambda (elm)
7094 (anything-semantic-default-action elm
)
7095 (anything-match-line-color-current-line)))
7096 (persistent-help .
"Show this entry")
7097 (action . anything-semantic-default-action
)
7098 "Needs semantic in CEDET.
7100 http://cedet.sourceforge.net/semantic.shtml
7101 http://cedet.sourceforge.net/"))
7103 ;; (anything 'anything-c-source-semantic)
7106 ;;; Anything interface of `simple-call-tree.el'.
7108 ;; <http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el>
7110 ;; Function is called by
7111 (defvar anything-c-source-simple-call-tree-functions-callers
7112 '((name .
"Function is called by")
7113 (init . anything-c-simple-call-tree-functions-callers-init
)
7115 (candidates . anything-c-simple-call-tree-candidates
)
7116 (persistent-action . anything-c-simple-call-tree-persistent-action
)
7117 (persistent-help .
"Show function definitions by rotation")
7118 (action ("Find definition selected by persistent-action" .
7119 anything-c-simple-call-tree-find-definition
)))
7120 "Needs simple-call-tree.el.
7121 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
7123 (defvar anything-c-simple-call-tree-tick nil
)
7124 (make-variable-buffer-local 'anything-c-simple-call-tree-tick
)
7125 (defun anything-c-simple-call-tree-analyze-maybe ()
7126 (unless (eq (buffer-chars-modified-tick) anything-c-simple-call-tree-tick
)
7127 (simple-call-tree-analyze)
7128 (setq anything-c-simple-call-tree-tick
(buffer-chars-modified-tick))))
7130 (defun anything-c-simple-call-tree-init-base (function message
)
7131 (require 'simple-call-tree
)
7133 (when (anything-current-buffer-is-modified)
7134 (anything-c-simple-call-tree-analyze-maybe)
7135 (let ((list (funcall function simple-call-tree-alist
)))
7136 (with-current-buffer (anything-candidate-buffer 'local
)
7137 (dolist (entry list
)
7138 (let ((funcs (concat " " (mapconcat #'identity
(cdr entry
) "\n "))))
7139 (insert (car entry
) message
7140 (if (string= funcs
" ")
7145 (defun anything-c-simple-call-tree-functions-callers-init ()
7146 (anything-c-simple-call-tree-init-base 'simple-call-tree-invert
7149 (defun anything-c-simple-call-tree-candidates ()
7150 (with-current-buffer (anything-candidate-buffer)
7151 (split-string (buffer-string) "\n\n")))
7153 (defvar anything-c-simple-call-tree-related-functions nil
)
7154 (defvar anything-c-simple-call-tree-function-index
0)
7155 (defun anything-c-simple-call-tree-persistent-action (candidate)
7156 (unless (eq last-command
'anything-execute-persistent-action
)
7157 (setq anything-c-simple-call-tree-related-functions
7158 (delete "no functions."
7160 (replace-regexp-in-string " \\| is called by\\| calls "
7163 (setq anything-c-simple-call-tree-function-index -
1))
7164 (incf anything-c-simple-call-tree-function-index
)
7165 (anything-c-simple-call-tree-find-definition candidate
))
7167 (defun anything-c-simple-call-tree-find-definition (candidate)
7170 (nth (mod anything-c-simple-call-tree-function-index
7171 (length anything-c-simple-call-tree-related-functions
))
7172 anything-c-simple-call-tree-related-functions
))))
7174 ;; (anything 'anything-c-source-simple-call-tree-functions-callers)
7177 (defvar anything-c-source-simple-call-tree-callers-functions
7178 '((name .
"Function calls")
7179 (init . anything-c-simple-call-tree-callers-functions-init
)
7181 (candidates . anything-c-simple-call-tree-candidates
)
7182 (persistent-action . anything-c-simple-call-tree-persistent-action
)
7183 (persistent-help .
"Show function definitions by rotation")
7184 (action ("Find definition selected by persistent-action" .
7185 anything-c-simple-call-tree-find-definition
)))
7186 "Needs simple-call-tree.el.
7187 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
7189 (defun anything-c-simple-call-tree-callers-functions-init ()
7190 (anything-c-simple-call-tree-init-base 'identity
" calls \n"))
7192 ;; (anything 'anything-c-source-simple-call-tree-callers-functions)
7196 ;;; Anything UI of auto-document.el
7198 ;; <http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el>
7200 ;; Commands/Options with doc
7201 (defvar anything-c-auto-document-data nil
)
7202 (make-variable-buffer-local 'anything-c-auto-document-data
)
7203 (defvar anything-c-source-commands-and-options-in-file
7204 '((name .
"Commands/Options in file")
7206 .
(lambda (x) (format "Commands/Options in %s"
7207 (buffer-local-value 'buffer-file-name
7208 anything-current-buffer
))))
7209 (candidates . anything-command-and-options-candidates
)
7212 "List Commands and Options with doc. It needs auto-document.el .
7214 http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el")
7216 (eval-when-compile (require 'auto-document nil t
))
7217 (defun anything-command-and-options-candidates ()
7218 (with-anything-current-buffer
7219 (when (and (require 'auto-document nil t
)
7220 (eq major-mode
'emacs-lisp-mode
)
7221 (or (anything-current-buffer-is-modified)
7222 (not anything-c-auto-document-data
)))
7223 (or imenu--index-alist
(imenu--make-index-alist t
))
7224 (setq anything-c-auto-document-data
7225 (destructuring-bind (commands options
)
7226 (adoc-construct anything-current-buffer
)
7228 (loop for
(command . doc
) in commands
7229 for cmdname
= (symbol-name command
)
7232 (format "Command: %s\n %s"
7233 (propertize cmdname
'face font-lock-function-name-face
)
7234 (adoc-first-line doc
))
7235 (assoc cmdname imenu--index-alist
)))
7236 (loop with var-alist
= (cdr (assoc "Variables" imenu--index-alist
))
7237 for
(option doc default
) in options
7238 for optname
= (symbol-name option
)
7241 (format "Option: %s\n %s\n default = %s"
7242 (propertize optname
'face font-lock-variable-name-face
)
7243 (adoc-first-line doc
)
7244 (adoc-prin1-to-string default
))
7247 anything-c-auto-document-data
))
7249 ;; (anything 'anything-c-source-commands-and-options-in-file)
7252 ;;;; <Color and Face>
7258 (defvar anything-c-source-customize-face
7259 '((name .
"Customize Face")
7261 (unless (anything-candidate-buffer)
7262 (save-window-excursion (list-faces-display))
7263 (anything-candidate-buffer (get-buffer "*Faces*")))))
7264 (candidates-in-buffer)
7265 (get-line . buffer-substring
)
7266 (action .
(lambda (line)
7267 (customize-face (intern (car (split-string line
))))))
7268 (requires-pattern .
3))
7269 "See (info \"(emacs)Faces\")")
7270 ;; (anything 'anything-c-source-customize-face)
7275 (defvar anything-c-source-colors
7277 (init .
(lambda () (unless (anything-candidate-buffer)
7278 (save-window-excursion (list-colors-display))
7279 (anything-candidate-buffer (get-buffer "*Colors*")))))
7280 (candidates-in-buffer)
7281 (get-line . buffer-substring
)
7283 ("Copy Name" .
(lambda (candidate)
7284 (kill-new (anything-c-colors-get-name candidate
))))
7285 ("Copy RGB" .
(lambda (candidate)
7286 (kill-new (anything-c-colors-get-rgb candidate
))))
7287 ("Insert Name" .
(lambda (candidate)
7288 (with-anything-current-buffer
7289 (insert (anything-c-colors-get-name candidate
)))))
7290 ("Insert RGB" .
(lambda (candidate)
7291 (with-anything-current-buffer
7292 (insert (anything-c-colors-get-rgb candidate
))))))))
7293 ;; (anything 'anything-c-source-colors)
7295 (defun anything-c-colors-get-name (candidate)
7297 (replace-regexp-in-string
7300 (insert (capitalize candidate
))
7301 (goto-char (point-min))
7302 (search-forward-regexp "\\s-\\{2,\\}")
7303 (delete-region (point) (point-max))
7306 (defun anything-c-colors-get-rgb (candidate)
7308 (replace-regexp-in-string
7311 (insert (capitalize candidate
))
7312 (goto-char (point-max))
7313 (search-backward-regexp "\\s-\\{2,\\}")
7314 (delete-region (point) (point-min))
7318 ;;;; <Search Engine>
7319 ;;; Tracker desktop search
7320 (defvar anything-c-source-tracker-search
7321 '((name .
"Tracker Search")
7322 (candidates .
(lambda ()
7323 (start-process "tracker-search-process" nil
7327 (requires-pattern .
3)
7329 "Source for retrieving files matching the current input pattern
7330 with the tracker desktop search.")
7331 ;; (anything 'anything-c-source-tracker-search)
7333 ;;; Spotlight (MacOS X desktop search)
7334 (defvar anything-c-source-mac-spotlight
7337 .
(lambda () (start-process "mdfind-process" nil
"mdfind" anything-pattern
)))
7339 (requires-pattern .
3)
7341 "Source for retrieving files via Spotlight's command line
7343 ;; (anything 'anything-c-source-mac-spotlight)
7346 (defvar anything-c-source-picklist
7347 '((name .
"Picklist")
7348 (candidates .
(lambda () (mapcar 'car picklist-list
)))
7350 ;; (anything 'anything-c-source-picklist)
7357 (defvar anything-c-source-kill-ring
7358 '((name .
"Kill Ring")
7359 (init .
(lambda () (anything-attrset 'last-command last-command
)))
7360 (candidates . anything-c-kill-ring-candidates
)
7361 (filtered-candidate-transformer anything-c-kill-ring-transformer
)
7362 (action . anything-c-kill-ring-action
)
7366 "Source for browse and insert contents of kill-ring.")
7368 (defun anything-c-kill-ring-candidates ()
7369 (loop for kill in
(anything-fast-remove-dups kill-ring
:test
'equal
)
7370 unless
(or (< (length kill
) anything-kill-ring-threshold
)
7371 (string-match "^[\\s\\t]+$" kill
))
7374 (defun anything-c-kill-ring-transformer (candidates source
)
7375 "Display only the `anything-c-kill-ring-max-lines-number' lines of candidate."
7376 (loop for i in candidates
7377 for nlines
= (with-temp-buffer (insert i
) (count-lines (point-min) (point-max)))
7378 if
(and anything-c-kill-ring-max-lines-number
7379 (> nlines anything-c-kill-ring-max-lines-number
))
7383 (goto-char (point-min))
7388 (forward-line anything-c-kill-ring-max-lines-number
)
7393 (defun anything-c-kill-ring-action (str)
7394 "Insert STR in `kill-ring' and set STR to the head.
7395 If this action is executed just after `yank',
7396 replace with STR as yanked string."
7397 (setq kill-ring
(delete str kill-ring
))
7398 (if (not (eq (anything-attr 'last-command
) 'yank
))
7399 (insert-for-yank str
)
7401 (let ((inhibit-read-only t
)
7402 (before (< (point) (mark t
))))
7404 (funcall (or yank-undo-function
'delete-region
) (point) (mark t
))
7405 (funcall (or yank-undo-function
'delete-region
) (mark t
) (point)))
7406 (setq yank-undo-function nil
)
7407 (set-marker (mark-marker) (point) (current-buffer))
7408 (insert-for-yank str
)
7409 ;; Set the window start back where it was in the yank command,
7411 (set-window-start (selected-window) yank-window-start t
)
7413 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
7414 ;; It is cleaner to avoid activation, even though the command
7415 ;; loop would deactivate the mark because we inserted text.
7416 (goto-char (prog1 (mark t
)
7417 (set-marker (mark-marker) (point) (current-buffer)))))))
7420 ;; (anything 'anything-c-source-kill-ring)
7424 ;; DO NOT include these sources in `anything-sources' use
7425 ;; the commands `anything-mark-ring', `anything-global-mark-ring' or
7426 ;; `anything-all-mark-rings' instead.
7428 (defun anything-c-source-mark-ring-candidates ()
7429 (flet ((get-marks (pos)
7433 (let ((line (car (split-string (thing-at-point 'line
) "[\n\r]"))))
7434 (when (string= "" line
)
7435 (setq line
"<EMPTY LINE>"))
7436 (format "%7d: %s" (line-number-at-pos) line
)))))
7437 (with-anything-current-buffer
7439 with marks
= (if (mark) (cons (mark-marker) mark-ring
) mark-ring
)
7442 for m
= (get-marks i
)
7443 unless
(member m recip
)
7444 collect m into recip
7445 finally return recip
))))
7447 (defvar anything-mark-ring-cache nil
)
7448 (defvar anything-c-source-mark-ring
7449 '((name .
"mark-ring")
7451 (setq anything-mark-ring-cache
7452 (ignore-errors (anything-c-source-mark-ring-candidates)))))
7453 (candidates .
(lambda ()
7454 (anything-aif anything-mark-ring-cache
7456 (action .
(("Goto line"
7457 .
(lambda (candidate)
7458 (anything-goto-line (string-to-number candidate
))))))
7459 (persistent-action .
(lambda (candidate)
7460 (anything-goto-line (string-to-number candidate
))
7461 (anything-match-line-color-current-line)))
7462 (persistent-help .
"Show this line")))
7464 ;; (anything 'anything-c-source-mark-ring)
7466 ;;; Global-mark-ring
7467 (defvar anything-c-source-global-mark-ring
7468 '((name .
"global-mark-ring")
7469 (candidates . anything-c-source-global-mark-ring-candidates
)
7470 (action .
(("Goto line"
7471 .
(lambda (candidate)
7472 (let ((items (split-string candidate
":")))
7473 (anything-c-switch-to-buffer (second items
))
7474 (anything-goto-line (string-to-number (car items
))))))))
7475 (persistent-action .
(lambda (candidate)
7476 (let ((items (split-string candidate
":")))
7477 (anything-c-switch-to-buffer (second items
))
7478 (anything-goto-line (string-to-number (car items
)))
7479 (anything-match-line-color-current-line))))
7480 (persistent-help .
"Show this line")))
7482 (defun anything-c-source-global-mark-ring-candidates ()
7484 (with-current-buffer (marker-buffer m
)
7488 (if (string= "" line
)
7489 (setq line
"<EMPTY LINE>")
7490 (setq line
(car (split-string (thing-at-point 'line
)
7492 (format "%7d:%s: %s"
7493 (line-number-at-pos) (marker-buffer m
) line
)))))
7495 with marks
= global-mark-ring
7498 for gm
= (unless (or (string-match
7499 "^ " (format "%s" (marker-buffer i
)))
7500 (null (marker-buffer i
)))
7502 when
(and gm
(not (member gm recip
)))
7503 collect gm into recip
7504 finally return recip
)))
7506 ;; (anything 'anything-c-source-global-mark-ring)
7510 ;;; Insert from register
7511 (defvar anything-c-source-register
7512 '((name .
"Registers")
7513 (candidates . anything-c-register-candidates
)
7514 (action-transformer . anything-c-register-action-transformer
)
7517 "See (info \"(emacs)Registers\")")
7519 (defun anything-c-register-candidates ()
7520 "Collecting register contents and appropriate commands."
7521 (loop for
(char . val
) in register-alist
7522 for key
= (single-key-description char
)
7523 for string-actions
=
7526 (list (int-to-string val
)
7528 'increment-register
))
7530 (let ((buf (marker-buffer val
)))
7532 (list "a marker in no buffer")
7534 "a buffer position:"
7537 (int-to-string (marker-position val
)))
7539 'insert-register
))))
7540 ((and (consp val
) (window-configuration-p (car val
)))
7541 (list "window configuration."
7543 ((and (consp val
) (frame-configuration-p (car val
)))
7544 (list "frame configuration."
7546 ((and (consp val
) (eq (car val
) 'file
))
7547 (list (concat "file:"
7548 (prin1-to-string (cdr val
))
7551 ((and (consp val
) (eq (car val
) 'file-query
))
7552 (list (concat "file:a file-query reference: file "
7555 (int-to-string (car (cdr (cdr val
))))
7559 (let ((lines (format "%4d" (length val
))))
7560 (list (format "%s: %s\n" lines
7561 (truncate-string-to-width
7562 (mapconcat 'identity
(list (car val
))
7563 ;; (mapconcat (lambda (y) y) val
7564 "^J") (- (window-width) 15)))
7567 (list ;; without properties
7568 (substring-no-properties val
)
7571 'prepend-to-register
))
7574 collect
(cons (format "register %3s: %s" key
(car string-actions
))
7575 (cons char
(cdr string-actions
)))))
7577 (defun anything-c-register-action-transformer (actions register-and-functions
)
7578 "Decide actions by the contents of register."
7579 (loop with func-actions
=
7582 (lambda (c) (insert-register (car c
))))
7584 "Jump to Register" .
7585 (lambda (c) (jump-to-register (car c
))))
7587 "Append Region to Register" .
7588 (lambda (c) (append-to-register
7589 (car c
) (region-beginning) (region-end))))
7590 (prepend-to-register
7591 "Prepend Region to Register" .
7592 (lambda (c) (prepend-to-register
7593 (car c
) (region-beginning) (region-end))))
7595 "Increment Prefix Arg to Register" .
7596 (lambda (c) (increment-register
7597 anything-current-prefix-arg
(car c
)))))
7598 for func in
(cdr register-and-functions
)
7599 for cell
= (assq func func-actions
)
7601 collect
(cdr cell
)))
7603 ;; (anything 'anything-c-source-register)
7606 ;;; Latex completion
7607 (defun anything-c-latex-math-candidates ()
7608 "Collect candidates for latex math completion."
7609 (declare (special LaTeX-math-menu
))
7610 (loop for i in
(cddr LaTeX-math-menu
)
7611 for elm
= (loop for s in i when
(vectorp s
)
7612 collect
(cons (aref s
0) (aref s
1)))
7615 (defvar anything-c-source-latex-math
7616 '((name .
"Latex Math Menu")
7618 (with-anything-current-buffer
7619 (LaTeX-math-mode 1))))
7620 (candidate-number-limit .
9999)
7621 (candidates . anything-c-latex-math-candidates
)
7622 (action .
(lambda (candidate)
7623 (call-interactively candidate
)))))
7626 ;;;; <Headline Extraction>
7627 (defvar anything-c-source-fixme
7628 '((name .
"TODO/FIXME/DRY comments")
7629 (headline .
"^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$")
7632 "Show TODO/FIXME/DRY comments in current file.")
7633 ;; (anything 'anything-c-source-fixme)
7635 (defvar anything-c-source-rd-headline
7636 '((name .
"RD HeadLine")
7637 (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$")
7638 (condition .
(memq major-mode
'(rdgrep-mode rd-mode
)))
7644 http://en.wikipedia.org/wiki/Ruby_Document_format")
7645 ;; (anything 'anything-c-source-rd-headline)
7647 (defvar anything-c-source-oddmuse-headline
7648 '((name .
"Oddmuse HeadLine")
7649 (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$"
7650 "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$")
7651 (condition .
(memq major-mode
'(oddmuse-mode yaoddmuse-mode
)))
7654 "Show Oddmuse headlines, such as EmacsWiki.")
7655 ;; (anything 'anything-c-source-oddmuse-headline)
7657 (defvar anything-c-source-emacs-source-defun
7658 '((name .
"Emacs Source DEFUN")
7659 (headline .
"DEFUN\\|DEFVAR")
7660 (condition .
(string-match "/emacs2[0-9].+/src/.+c$"
7661 (or buffer-file-name
""))))
7662 "Show DEFUN/DEFVAR in Emacs C source file.")
7663 ;; (anything 'anything-c-source-emacs-source-defun)
7665 (defvar anything-c-source-emacs-lisp-expectations
7666 '((name .
"Emacs Lisp Expectations")
7667 (headline .
"(desc[ ]\\|(expectations")
7668 (condition .
(eq major-mode
'emacs-lisp-mode
)))
7669 "Show descriptions (desc) in Emacs Lisp Expectations.
7671 http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
7672 ;; (anything 'anything-c-source-emacs-lisp-expectations)
7674 (defvar anything-c-source-emacs-lisp-toplevels
7675 '((name .
"Emacs Lisp Toplevel / Level 4 Comment / Linkd Star")
7676 (headline .
"^(\\|(@\\*\\|^;;;;")
7677 (get-line . buffer-substring
)
7678 (condition .
(eq major-mode
'emacs-lisp-mode
))
7680 "Show top-level forms, level 4 comments and linkd stars (optional) in Emacs Lisp.
7681 linkd.el is optional because linkd stars are extracted by regexp.
7682 http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el")
7683 ;; (anything 'anything-c-source-emacs-lisp-toplevels)
7686 ;;; Anything yaoddmuse
7688 ;; Be sure to have yaoddmuse.el installed
7689 ;; install-elisp may be required if you want to install elisp file from here.
7690 (defvar anything-yaoddmuse-use-cache-file nil
)
7691 (defvar anything-c-yaoddmuse-cache-file
"~/.emacs.d/yaoddmuse-cache.el")
7692 (defvar anything-c-yaoddmuse-ew-cache nil
)
7694 (defun anything-yaoddmuse-get-candidates ()
7695 (declare (special yaoddmuse-pages-hash
))
7696 (if anything-yaoddmuse-use-cache-file
7698 (unless anything-c-yaoddmuse-ew-cache
7699 (load anything-c-yaoddmuse-cache-file
)
7700 (setq anything-c-yaoddmuse-ew-cache
7701 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
7702 anything-c-yaoddmuse-ew-cache
)
7703 (yaoddmuse-update-pagename t
)
7704 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
7706 (defvar anything-c-source-yaoddmuse-emacswiki-edit-or-view
7707 '((name .
"Yaoddmuse Edit or View (EmacsWiki)")
7708 (candidates . anything-yaoddmuse-get-candidates
)
7709 (action .
(("Edit page" .
(lambda (candidate)
7710 (yaoddmuse-edit "EmacsWiki" candidate
)))
7712 .
(lambda (candidate)
7713 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
7714 ("Browse page other window"
7715 .
(lambda (candidate)
7717 (split-window-vertically))
7718 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
7720 .
(lambda (candidate)
7721 (yaoddmuse-browse-page-diff "EmacsWiki" candidate
)))
7723 .
(lambda (candidate)
7724 (kill-new (yaoddmuse-url "EmacsWiki" candidate
))
7725 (message "Have copy page %s's URL to yank." candidate
)))
7727 .
(lambda (candidate)
7728 (yaoddmuse-edit "EmacsWiki" anything-input
)))
7730 .
(lambda (candidate)
7731 (if anything-yaoddmuse-use-cache-file
7733 (anything-yaoddmuse-cache-pages t
)
7734 (setq anything-c-yaoddmuse-ew-cache
7735 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
7736 (yaoddmuse-update-pagename))))))
7737 (action-transformer anything-c-yaoddmuse-action-transformer
))
7738 "Needs yaoddmuse.el.
7740 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
7742 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view)
7744 (defvar anything-c-source-yaoddmuse-emacswiki-post-library
7745 '((name .
"Yaoddmuse Post library (EmacsWiki)")
7746 (init .
(anything-yaoddmuse-init))
7747 (candidates-in-buffer)
7748 (action .
(("Post library and Browse"
7749 .
(lambda (candidate)
7750 (yaoddmuse-post-file
7751 (find-library-name candidate
)
7753 (file-name-nondirectory (find-library-name candidate
))
7756 .
(lambda (candidate)
7757 (yaoddmuse-post-file
7758 (find-library-name candidate
)
7760 (file-name-nondirectory
7761 (find-library-name candidate
))))))))
7762 "Needs yaoddmuse.el.
7764 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
7766 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-post-library)
7768 (defun anything-c-yaoddmuse-action-transformer (actions candidate
)
7769 "Allow the use of `install-elisp' only on elisp files."
7770 (if (string-match "\.el$" candidate
)
7771 (append actions
'(("Install Elisp"
7773 (install-elisp-from-emacswiki elm
)))))
7777 (defun anything-yaoddmuse-cache-pages (&optional load
)
7778 "Fetch the list of files on emacswiki and create cache file.
7779 If load is non--nil load the file and feed `yaoddmuse-pages-hash'."
7781 (declare (special yaoddmuse-pages-hash
))
7782 (yaoddmuse-update-pagename)
7784 (find-file anything-c-yaoddmuse-cache-file
)
7786 (insert "(puthash \"EmacsWiki\" '(")
7787 (loop for i in
(gethash "EmacsWiki" yaoddmuse-pages-hash
)
7789 (insert (concat "(\"" (car i
) "\") ")))
7790 (insert ") yaoddmuse-pages-hash)\n")
7792 (kill-buffer (current-buffer))
7793 (when (or current-prefix-arg
7795 (load anything-c-yaoddmuse-cache-file
))))
7797 (defun anything-yaoddmuse-init ()
7798 "Init anything buffer status."
7799 (let ((anything-buffer (anything-candidate-buffer 'global
))
7800 (library-list (yaoddmuse-get-library-list)))
7801 (with-current-buffer anything-buffer
7802 ;; Insert library name.
7803 (dolist (library library-list
)
7804 (insert (format "%s\n" library
)))
7806 (sort-lines nil
(point-min) (point-max)))))
7810 (defvar anything-c-source-eev-anchor
7811 '((name .
"Anchors")
7815 (with-anything-current-buffer
7816 (loop initially
(goto-char (point-min))
7817 while
(re-search-forward
7818 (format ee-anchor-format
"\\([^\.].+\\)") nil t
)
7819 for anchor
= (match-string-no-properties 1)
7820 collect
(cons (format "%5d:%s"
7821 (line-number-at-pos (match-beginning 0))
7822 (format ee-anchor-format anchor
))
7824 (persistent-action .
(lambda (item)
7826 (anything-match-line-color-current-line)))
7827 (persistent-help .
"Show this entry")
7828 (action .
(("Goto link" . ee-to
)))))
7829 ;; (anything 'anything-c-source-eev-anchor)
7835 (defvar anything-c-source-org-headline
7836 `((name .
"Org HeadLine")
7840 (format "^\\*\\{%d\\} \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
7842 (number-sequence 1 8)))
7843 (condition .
(eq major-mode
'org-mode
))
7846 (persistent-action .
(lambda (elm)
7847 (anything-c-action-line-goto elm
)
7850 .
(lambda (actions candidate
)
7851 '(("Go to Line" . anything-c-action-line-goto
)
7852 ("Refile to this Headline" . anything-c-org-headline-refile
)
7853 ("Insert Link to This Headline"
7854 . anything-c-org-headline-insert-link-to-headline
)))))
7855 "Show Org headlines.
7856 org-mode is very very much extended text-mode/outline-mode.
7858 See (find-library \"org.el\")
7859 See http://orgmode.org for the latest version.")
7860 ;; (anything 'anything-c-source-org-headline)
7862 (defun anything-c-org-headline-insert-link-to-headline (lineno-and-content)
7865 (anything-goto-line (car lineno-and-content
))
7866 (and (looking-at org-complex-heading-regexp
)
7867 (org-make-link-string (concat "*" (match-string 4)))))))
7869 (defun anything-c-org-headline-refile (lineno-and-content)
7870 "Refile current org entry to LINENO-AND-CONTENT."
7871 (with-anything-current-buffer
7873 (anything-goto-line (car lineno-and-content
))
7874 (org-end-of-subtree t t
)
7875 (let ((org-yank-adjusted-subtrees t
))
7882 (defvar anything-c-source-org-keywords
7883 '((name .
"Org Keywords")
7884 (init . anything-c-org-keywords-init
)
7885 (candidates . anything-c-org-keywords-candidates
)
7886 (action . anything-c-org-keywords-insert
)
7887 (persistent-action . anything-c-org-keywords-show-help
)
7888 (persistent-help .
"Show an example and info page to describe this keyword.")
7891 ;; (anything 'anything-c-source-org-keywords)
7893 (defvar anything-c-org-keywords-info-location
7894 '(("#+TITLE:" .
"(org)Export options")
7895 ("#+AUTHOR:" .
"(org)Export options")
7896 ("#+DATE:" .
"(org)Export options")
7897 ("#+EMAIL:" .
"(org)Export options")
7898 ("#+DESCRIPTION:" .
"(org)Export options")
7899 ("#+KEYWORDS:" .
"(org)Export options")
7900 ("#+LANGUAGE:" .
"(org)Export options")
7901 ("#+TEXT:" .
"(org)Export options")
7902 ("#+TEXT:" .
"(org)Export options")
7903 ("#+OPTIONS:" .
"(org)Export options")
7904 ("#+BIND:" .
"(org)Export options")
7905 ("#+LINK_UP:" .
"(org)Export options")
7906 ("#+LINK_HOME:" .
"(org)Export options")
7907 ("#+LATEX_HEADER:" .
"(org)Export options")
7908 ("#+EXPORT_SELECT_TAGS:" .
"(org)Export options")
7909 ("#+EXPORT_EXCLUDE_TAGS:" .
"(org)Export options")
7910 ("#+INFOJS_OPT" .
"(org)Javascript support")
7911 ("#+BEGIN_HTML" .
"(org)Quoting HTML tags")
7912 ("#+BEGIN_LaTeX" .
"(org)Quoting LaTeX code")
7913 ("#+ORGTBL" .
"(org)Radio tables")
7914 ("#+HTML:" .
"(org)Quoting HTML tags")
7915 ("#+LaTeX:" .
"(org)Quoting LaTeX code")
7916 ("#+BEGIN:" .
"(org)Dynamic blocks") ;clocktable columnview
7917 ("#+BEGIN_EXAMPLE" .
"(org)Literal examples")
7918 ("#+BEGIN_QUOTE" .
"(org)Paragraphs")
7919 ("#+BEGIN_VERSE" .
"(org)Paragraphs")
7920 ("#+BEGIN_SRC" .
"(org)Literal examples")
7921 ("#+CAPTION" .
"(org)Tables in HTML export")
7922 ("#+LABEL" .
"(org)Tables in LaTeX export")
7923 ("#+ATTR_HTML" .
"(org)Links")
7924 ("#+ATTR_LaTeX" .
"(org)Images in LaTeX export")))
7926 (defun anything-c-org-keywords-init ()
7927 (unless (anything-attr 'keywords-examples
)
7929 (anything-attrset 'keywords-examples
7933 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x
)
7934 (cons (match-string 2 x
) (match-string 1 x
)))
7935 (org-split-string (org-get-current-options) "\n"))
7936 (mapcar 'list org-additional-option-like-keywords
)))
7937 (anything-attrset 'keywords
(mapcar 'car
(anything-attr 'keywords-examples
)))))
7939 (defun anything-c-org-keywords-candidates ()
7940 (and (or (eq (buffer-local-value 'major-mode anything-current-buffer
) 'org-mode
)
7941 (eq (buffer-local-value 'major-mode anything-current-buffer
) 'message-mode
))
7942 (anything-attr 'keywords
)))
7944 (defun anything-c-org-keywords-insert (keyword)
7945 (cond ((and (string-match "BEGIN" keyword
)
7946 (anything-region-active-p))
7947 (let ((beg (region-beginning))
7950 (insert "\n#+" (replace-regexp-in-string
7951 "BEGIN" "END" keyword
) "\n")
7953 (insert "#+" keyword
" ")
7954 (save-excursion (insert "\n"))))
7955 ((string-match "BEGIN" keyword
)
7956 (insert "#+" keyword
" ")
7958 (insert "\n#+" (replace-regexp-in-string
7959 "BEGIN" "END" keyword
) "\n")))
7960 (t (insert "#+" keyword
" "))))
7962 (defun anything-c-org-keywords-show-help (keyword)
7963 (info (or (assoc-default (concat "#+" keyword
) anything-c-org-keywords-info-location
)
7964 "(org)In-buffer settings"))
7965 (search-forward (concat "#+" keyword
) nil t
)
7966 (anything-persistent-highlight-point)
7967 (message "%s" (or (cdr (assoc keyword
(anything-attr 'keywords-examples
))) "")))
7974 (defvar bbdb-records
)
7975 (defvar bbdb-buffer-name
)
7977 (defun anything-c-bbdb-candidates ()
7978 "Return a list of all names in the bbdb database. The format
7979 is \"Firstname Lastname\"."
7980 (mapcar (lambda (bbdb-record)
7981 (replace-regexp-in-string
7983 (concat (aref bbdb-record
0) " " (aref bbdb-record
1))))
7986 (defun anything-c-bbdb-create-contact (actions candidate
)
7987 "Action transformer that returns only an entry to add the
7988 current `anything-pattern' as new contact. All other actions are
7990 (if (string= candidate
"*Add to contacts*")
7991 '(("Add to contacts" .
(lambda (actions)
7992 (bbdb-create-internal
7993 (read-from-minibuffer "Name: " anything-c-bbdb-name
)
7994 (read-from-minibuffer "Company: ")
7995 (read-from-minibuffer "Email: ")
7998 (read-from-minibuffer "Note: ")))))
8001 (defun anything-c-bbdb-get-record (candidate)
8002 "Return record that match CANDIDATE."
8003 (bbdb candidate nil
)
8004 (set-buffer "*BBDB*")
8005 (bbdb-current-record))
8007 (defvar anything-c-bbdb-name nil
8008 "Only for internal use.")
8010 (defvar anything-c-source-bbdb
8012 (candidates . anything-c-bbdb-candidates
)
8013 (action ("Send a mail" . anything-c-bbdb-compose-mail
)
8014 ("View person's data" . anything-c-bbdb-view-person-action
))
8015 (filtered-candidate-transformer .
(lambda (candidates source
)
8016 (setq anything-c-bbdb-name anything-pattern
)
8017 (if (not candidates
)
8018 (list "*Add to contacts*")
8020 (action-transformer .
(lambda (actions candidate
)
8021 (anything-c-bbdb-create-contact actions candidate
))))
8024 http://bbdb.sourceforge.net/")
8025 ;; (anything 'anything-c-source-bbdb)
8027 (defun anything-c-bbdb-view-person-action (candidate)
8028 "View BBDB data of single CANDIDATE or marked candidates."
8029 (anything-aif (anything-marked-candidates)
8030 (let ((bbdb-append-records (length it
)))
8032 (bbdb-redisplay-one-record (anything-c-bbdb-get-record i
))))
8033 (bbdb-redisplay-one-record (anything-c-bbdb-get-record candidate
))))
8035 (defun anything-c-bbdb-collect-mail-addresses ()
8036 "Return a list of all mail addresses of records in bbdb buffer."
8037 (with-current-buffer bbdb-buffer-name
8038 (loop for i in bbdb-records
8039 if
(bbdb-record-net (car i
))
8040 collect
(bbdb-dwim-net-address (car i
)))))
8042 (defun anything-c-bbdb-compose-mail (candidate)
8043 "Compose a mail with all records of bbdb buffer."
8044 (anything-c-bbdb-view-person-action candidate
)
8045 (let* ((address-list (anything-c-bbdb-collect-mail-addresses))
8046 (address-str (mapconcat 'identity address-list
",\n ")))
8047 (compose-mail address-str
)))
8050 ;;; Evaluation Result
8054 (defvar anything-eldoc-active-minibuffers-list nil
)
8055 (defvar anything-eval-expression-input-history nil
)
8057 (defvar anything-c-source-evaluation-result
8058 '((name .
"Evaluation Result")
8062 (mode-line .
"C-RET: nl-and-indent, tab: reindent, C-tab:complete, C-p/n: next/prec-line.")
8063 (filtered-candidate-transformer .
(lambda (candidates source
)
8066 (with-anything-current-buffer
8068 (eval (read anything-pattern
))))
8070 (action .
(("Copy result to kill-ring" .
(lambda (candidate)
8071 (with-current-buffer anything-buffer
8072 (let ((end (save-excursion
8073 (goto-char (point-max))
8074 (search-backward "\n")
8076 (kill-region (point) end
)))))
8077 ("copy sexp to kill-ring" .
(lambda (candidate)
8078 (kill-new anything-input
)))))))
8079 ;; (anything 'anything-c-source-evaluation-result)
8081 (defun anything-eval-new-line-and-indent ()
8083 (newline) (lisp-indent-line))
8085 (defun anything-eldoc-store-minibuffer ()
8086 "Store minibuffer buffer name in `anything-eldoc-active-minibuffers-list'."
8087 (with-selected-window (minibuffer-window)
8088 (push (buffer-name) anything-eldoc-active-minibuffers-list
)))
8090 (defun anything-eldoc-show-in-eval ()
8091 "Return eldoc in mode-line for current minibuffer input."
8092 (let ((buf (with-selected-window (minibuffer-window)
8094 (when (member buf anything-eldoc-active-minibuffers-list
)
8095 (let* ((str-all (with-current-buffer buf
8096 (minibuffer-completion-contents)))
8100 (goto-char (point-max))
8101 (unless (looking-back ")\\|\"") (forward-char -
1))
8102 (eldoc-current-symbol))))
8103 (info-fn (eldoc-fnsym-in-current-sexp))
8104 (doc (or (eldoc-get-var-docstring sym
)
8105 (eldoc-get-fnsym-args-string
8106 (car info-fn
) (cadr info-fn
)))))
8107 (when doc
(funcall anything-c-eldoc-in-minibuffer-show-fn doc
))))))
8109 (defun anything-c-show-info-in-mode-line (str)
8110 "Display string STR in mode-line."
8111 (save-window-excursion
8112 (with-current-buffer anything-buffer
8113 (let ((mode-line-format (concat " " str
)))
8114 (force-mode-line-update)
8115 (sit-for anything-c-show-info-in-mode-line-delay
))
8116 (force-mode-line-update))))
8118 ;;; Calculation Result
8121 (defvar anything-c-source-calculation-result
8122 '((name .
"Calculation Result")
8124 (filtered-candidate-transformer .
(lambda (candidates source
)
8127 (calc-eval anything-pattern
)
8129 (action ("Copy result to kill-ring" . kill-new
))))
8130 ;; (anything 'anything-c-source-calculation-result)
8133 ;;; Google Suggestions
8137 (defvar anything-ggs-max-length-real-flag
0)
8138 (defvar anything-ggs-max-length-num-flag
0)
8140 (defun anything-c-google-suggest-fetch (input)
8141 "Fetch suggestions for INPUT from XML buffer.
8142 Return an alist with elements like (data . number_results)."
8143 (setq anything-ggs-max-length-real-flag
0
8144 anything-ggs-max-length-num-flag
0)
8145 (let ((request (concat anything-c-google-suggest-url
8146 (url-hexify-string input
))))
8149 with result-alist
= (xml-get-children
8150 (car (xml-parse-region
8151 (point-min) (point-max)))
8152 'CompleteSuggestion
)
8153 for i in result-alist
8154 for data
= (cdr (caadr (assoc 'suggestion i
)))
8155 for nqueries
= (cdr (caadr (assoc 'num_queries i
)))
8156 for lqueries
= (length (anything-c-ggs-set-number-result
8158 for ldata
= (length data
)
8161 (when (> ldata anything-ggs-max-length-real-flag
)
8162 (setq anything-ggs-max-length-real-flag ldata
))
8163 (when (> lqueries anything-ggs-max-length-num-flag
)
8164 (setq anything-ggs-max-length-num-flag lqueries
)))
8165 collect
(cons data nqueries
) into cont
8166 finally return cont
)))
8167 (if anything-google-suggest-use-curl-p
8169 (call-process "curl" nil t nil request
)
8171 (with-current-buffer
8172 (url-retrieve-synchronously request
)
8175 (defun anything-c-google-suggest-set-candidates (&optional request-prefix
)
8176 "Set candidates with result and number of google results found."
8178 (loop with suggested-results
= (anything-c-google-suggest-fetch
8179 (or (and request-prefix
8180 (concat request-prefix
" " anything-pattern
))
8182 for
(real . numresult
) in suggested-results
8183 ;; Prepare number of results with ","
8184 for fnumresult
= (anything-c-ggs-set-number-result numresult
)
8185 ;; Calculate number of spaces to add before fnumresult
8186 ;; if it is smaller than longest result
8187 ;; `anything-ggs-max-length-num-flag'.
8190 ;; To be sure it is aligned properly.
8191 for nspaces
= (if (< (length fnumresult
) anything-ggs-max-length-num-flag
)
8192 (- anything-ggs-max-length-num-flag
(length fnumresult
))
8194 ;; Add now the spaces before fnumresult.
8195 for align-fnumresult
= (concat (make-string nspaces ?
) fnumresult
)
8196 for interval
= (- anything-ggs-max-length-real-flag
(length real
))
8197 for spaces
= (make-string (+ 2 interval
) ?
)
8198 for display
= (format "%s%s(%s results)" real spaces align-fnumresult
)
8199 collect
(cons display real
))))
8200 (if (loop for
(disp . dat
) in suggestions
8201 thereis
(equal dat anything-pattern
))
8203 ;; if there is no suggestion exactly matching the input then
8204 ;; prepend a Search on Google item to the list
8207 (list (cons (concat "Search for " "'" anything-input
"'" " on Google")
8208 anything-input
))))))
8210 (defun anything-c-ggs-set-number-result (num)
8213 (and (numberp num
) (setq num
(number-to-string num
)))
8214 (loop for i in
(reverse (split-string num
"" t
))
8216 append
(list i
) into C
8218 append
(list ",") into C
8219 and do
(setq count
0)
8221 (replace-regexp-in-string
8222 "^," "" (mapconcat 'identity
(reverse C
) ""))))
8225 (defvar anything-c-google-suggest-default-browser-function nil
8226 "*The browse url function you prefer to use with google suggest.
8227 When nil, use the first browser function available
8228 See `anything-browse-url-default-browser-alist'.")
8230 (defun anything-c-google-suggest-action (candidate)
8231 "Default action to jump to a google suggested candidate."
8232 (let ((arg (concat anything-c-google-suggest-search-url
8233 (url-hexify-string candidate
))))
8234 (anything-aif anything-c-google-suggest-default-browser-function
8236 (anything-c-browse-url arg
))))
8238 (defvar anything-c-google-suggest-default-function
8239 'anything-c-google-suggest-set-candidates
8240 "Default function to use in anything google suggest.")
8242 (defvar anything-c-source-google-suggest
8243 '((name .
"Google Suggest")
8244 (candidates .
(lambda ()
8245 (funcall anything-c-google-suggest-default-function
)))
8246 (action .
(("Google Search" . anything-c-google-suggest-action
)))
8248 (requires-pattern .
3)
8251 (defun anything-c-google-suggest-emacs-lisp ()
8252 "Try to emacs lisp complete with google suggestions."
8253 (anything-c-google-suggest-set-candidates "emacs lisp"))
8255 ;; (anything 'anything-c-source-google-suggest)
8257 ;;; Yahoo suggestions
8260 (defun anything-c-yahoo-suggest-fetch (input)
8261 "Fetch Yahoo suggestions for INPUT from XML buffer.
8262 Return an alist with elements like (data . number_results)."
8263 (let ((request (concat anything-c-yahoo-suggest-url
8264 (url-hexify-string input
))))
8267 with result-alist
= (xml-get-children
8268 (car (xml-parse-region (point-min) (point-max)))
8270 for i in result-alist
8271 collect
(caddr i
))))
8272 (with-current-buffer
8273 (url-retrieve-synchronously request
)
8276 (defun anything-c-yahoo-suggest-set-candidates ()
8277 "Set candidates with Yahoo results found."
8278 (let ((suggestions (anything-c-yahoo-suggest-fetch anything-input
)))
8282 (list (cons (concat "Search for " "'" anything-input
"'" " on Yahoo")
8283 anything-input
))))))
8285 (defun anything-c-yahoo-suggest-action (candidate)
8286 "Default action to jump to a Yahoo suggested candidate."
8287 (anything-c-browse-url (concat anything-c-yahoo-suggest-search-url
8288 (url-hexify-string candidate
))))
8290 (defvar anything-c-source-yahoo-suggest
8291 '((name .
"Yahoo Suggest")
8292 (candidates . anything-c-yahoo-suggest-set-candidates
)
8293 (action .
(("Yahoo Search" . anything-c-yahoo-suggest-action
)))
8295 (requires-pattern .
3)
8298 ;; (anything 'anything-c-source-yahoo-suggest)
8301 ;;; Web browser functions.
8304 (require 'browse-url
)
8305 ;; If default setting of `w3m-command' is not
8306 ;; what you want you and you modify it, you will have to reeval
8307 ;; also `anything-browse-url-default-browser-alist'.
8308 (defvar w3m-command
"/usr/bin/w3m")
8309 (defvar anything-c-home-url
"http://www.google.fr"
8310 "*Default url to use as home url.")
8312 (defvar ac-browse-url-chromium-program
"chromium-browser")
8313 (defvar ac-browse-url-uzbl-program
"uzbl-browser")
8314 (defvar anything-browse-url-default-browser-alist
8315 `((,w3m-command . w3m-browse-url
)
8316 (,browse-url-firefox-program . browse-url-firefox
)
8317 (,ac-browse-url-chromium-program . ac-browse-url-chromium
)
8318 (,ac-browse-url-uzbl-program . ac-browse-url-uzbl
)
8319 (,browse-url-kde-program . browse-url-kde
)
8320 (,browse-url-gnome-moz-program . browse-url-gnome-moz
)
8321 (,browse-url-mozilla-program . browse-url-mozilla
)
8322 (,browse-url-galeon-program . browse-url-galeon
)
8323 (,browse-url-netscape-program . browse-url-netscape
)
8324 (,browse-url-mosaic-program . browse-url-mosaic
)
8325 (,browse-url-xterm-program . browse-url-text-xterm
))
8326 "*Alist of \(executable . function\) to try to find a suitable url browser.")
8328 (defun* anything-c-generic-browser
(url name
&rest args
)
8329 "Browse URL with NAME browser."
8330 (let ((proc (concat name
" " url
)))
8331 (message "Starting %s..." name
)
8332 (apply 'start-process proc nil name
8333 (append args
(list url
)))
8334 (set-process-sentinel
8336 #'(lambda (process event
)
8337 (when (string= event
"finished\n")
8338 (message "%s process %s" process event
))))))
8340 (defun ac-browse-url-chromium (url)
8341 "Browse URL with google chrome browser."
8342 (interactive "sURL: ")
8343 (anything-c-generic-browser
8344 url ac-browse-url-chromium-program
))
8346 (defun ac-browse-url-uzbl (url &optional ignore
)
8347 "Browse URL with uzbl browser."
8348 (interactive "sURL: ")
8349 (anything-c-generic-browser url ac-browse-url-uzbl-program
"-u"))
8351 (defun anything-browse-url-default-browser (url &rest args
)
8352 "Find the first available browser and ask it to load URL."
8353 (let ((default-browser-fn
8354 (loop for
(exe . fn
) in anything-browse-url-default-browser-alist
8355 thereis
(and exe
(executable-find exe
) fn
))))
8356 (if default-browser-fn
8357 (apply default-browser-fn url args
)
8358 (error "No usable browser found"))))
8360 (defun* anything-c-browse-url
(&optional
(url anything-c-home-url
))
8361 "Default command to browse URL."
8362 (if browse-url-browser-function
8364 (anything-browse-url-default-browser url
)))
8369 ;; Need external program surfraw.
8370 ;; <http://surfraw.alioth.debian.org/>
8372 (defvar anything-surfraw-default-browser-function nil
8373 "*The browse url function you prefer to use with surfraw.
8374 When nil, fallback to `browse-url-browser-function'.")
8377 (defvar anything-surfraw-engines-history nil
)
8378 (defvar anything-surfraw-input-history nil
)
8380 (defun anything-c-build-elvi-list ()
8381 "Return list of all engines and descriptions handled by surfraw."
8384 (call-process "surfraw" nil t nil
8386 (split-string (buffer-string) "\n"))))
8392 (defun anything-emms-stream-edit-bookmark (elm)
8393 "Change the information of current emms-stream bookmark from anything."
8394 (declare (special emms-stream-list
))
8395 (let* ((cur-buf anything-current-buffer
)
8396 (bookmark (assoc elm emms-stream-list
))
8397 (name (read-from-minibuffer "Description: "
8399 (url (read-from-minibuffer "URL: "
8401 (fd (read-from-minibuffer "Feed Descriptor: "
8402 (int-to-string (nth 2 bookmark
))))
8403 (type (read-from-minibuffer "Type (url, streamlist, or lastfm): "
8404 (format "%s" (car (last bookmark
))))))
8407 (when (re-search-forward (concat "^" name
) nil t
)
8409 (emms-stream-delete-bookmark)
8410 (emms-stream-add-bookmark name url
(string-to-number fd
) type
)
8411 (emms-stream-save-bookmarks-file)
8413 (anything-c-switch-to-buffer cur-buf
)))))
8415 (defun anything-emms-stream-delete-bookmark (elm)
8416 "Delete an emms-stream bookmark from anything."
8417 (let* ((cur-buf anything-current-buffer
)
8418 (bookmark (assoc elm emms-stream-list
))
8419 (name (nth 0 bookmark
)))
8422 (when (re-search-forward (concat "^" name
) nil t
)
8424 (emms-stream-delete-bookmark)
8425 (emms-stream-save-bookmarks-file)
8427 (anything-c-switch-to-buffer cur-buf
)))))
8429 (defvar anything-c-source-emms-streams
8430 '((name .
"Emms Streams")
8432 (emms-stream-init)))
8433 (candidates .
(lambda ()
8434 (declare (special emms-stream-list
))
8435 (mapcar 'car emms-stream-list
)))
8436 (action .
(("Play" .
(lambda (elm)
8437 (declare (special emms-stream-list
))
8438 (let* ((stream (assoc elm emms-stream-list
))
8439 (fn (intern (concat "emms-play-" (symbol-name (car (last stream
))))))
8440 (url (second stream
)))
8442 ("Delete" . anything-emms-stream-delete-bookmark
)
8443 ("Edit" . anything-emms-stream-edit-bookmark
)))
8444 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
8445 ;; (anything 'anything-c-source-emms-streams)
8447 ;; Don't forget to set `emms-source-file-default-directory'
8448 (defvar anything-c-source-emms-dired
8449 '((name .
"Music Directory")
8450 (candidates .
(lambda ()
8451 (cddr (directory-files emms-source-file-default-directory
))))
8453 (("Play Directory" .
(lambda (item)
8454 (emms-play-directory
8457 emms-source-file-default-directory
))))
8458 ("Open dired in file's directory" .
(lambda (item)
8459 (anything-c-open-dired
8462 emms-source-file-default-directory
))))))
8463 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
8464 ;; (anything 'anything-c-source-emms-dired)
8467 (defun anything-c-emms-files-modifier (candidates source
)
8468 (let ((current-playlist (with-current-emms-playlist
8470 with cur-list
= (emms-playlist-tracks-in-region
8471 (point-min) (point-max))
8473 collect
(assoc-default 'name i
)))))
8474 (loop for i in candidates
8475 if
(member (cdr i
) current-playlist
)
8476 collect
(cons (propertize (car i
)
8477 'face
'anything-emms-playlist
)
8479 else collect i into lis
8480 finally return lis
)))
8482 (defun anything-c-emms-play-current-playlist ()
8483 "Play current playlist."
8484 (with-current-emms-playlist
8485 (emms-playlist-first)
8486 (emms-playlist-mode-play-smart)))
8488 (defvar anything-c-source-emms-files
8489 '((name .
"Emms files")
8490 (candidates .
(lambda ()
8491 (loop for v being the hash-values in emms-cache-db
8492 for name
= (assoc-default 'name v
)
8493 for artist
= (or (assoc-default 'info-artist v
) "unknown")
8494 for genre
= (or (assoc-default 'info-genre v
) "unknown")
8495 for tracknum
= (or (assoc-default 'info-tracknumber v
) "unknown")
8496 for song
= (or (assoc-default 'info-title v
) "unknown")
8497 for info
= (concat artist
" - " genre
" - " tracknum
": " song
)
8498 unless
(string-match "^http:" name
) collect
(cons info name
))))
8499 (filtered-candidate-transformer . anything-c-emms-files-modifier
)
8500 (action .
(("Play file" . emms-play-file
)
8501 ("Add to Playlist and play (C-u clear current)"
8502 .
(lambda (candidate)
8503 (when anything-current-prefix-arg
8504 (emms-playlist-current-clear))
8506 (mapc 'emms-add-playlist-file
(anything-marked-candidates))
8507 (unless emms-player-playing-p
8508 (anything-c-emms-play-current-playlist))))))))
8510 ;; (anything 'anything-c-source-emms-files)
8513 ;;; Jabber Contacts (jabber.el)
8514 (defun anything-c-jabber-online-contacts ()
8515 "List online Jabber contacts."
8518 (dolist (item (jabber-concat-rosters) jids
)
8519 (when (get item
'connected
)
8520 (push (if (get item
'name
)
8521 (cons (get item
'name
) item
)
8522 (cons (symbol-name item
) item
)) jids
))))))
8524 (defvar anything-c-source-jabber-contacts
8525 '((name .
"Jabber Contacts")
8526 (init .
(lambda () (require 'jabber
)))
8527 (candidates .
(lambda () (mapcar 'car
(anything-c-jabber-online-contacts))))
8528 (action .
(lambda (x)
8530 (jabber-read-account)
8532 (cdr (assoc x
(anything-c-jabber-online-contacts)))))))))
8533 ;; (anything 'anything-c-source-jabber-contacts)
8538 (defvar anything-source-select-buffer
"*anything source select*")
8539 (defvar anything-c-source-call-source
8540 `((name .
"Call anything source")
8541 (candidate-number-limit)
8544 (loop for vname in
(all-completions "anything-c-source-" obarray
)
8545 for var
= (intern vname
)
8546 for name
= (ignore-errors (assoc-default 'name
(symbol-value var
)))
8548 (cons (format "%s `%s'"
8549 name
(propertize vname
'face
'font-lock-variable-name-face
))
8552 .
(("Invoke anything with selected source"
8555 (setq anything-candidate-number-limit
9999)
8556 (anything candidate nil nil nil nil
8557 anything-source-select-buffer
)))
8558 ("Describe variable" . describe-variable
)
8559 ("Find variable" . find-variable
)))
8560 (persistent-action . describe-variable
)
8561 (persistent-help .
"Show description of this source")))
8562 ;; (anything 'anything-c-source-call-source)
8564 (defun anything-call-source-from-anything ()
8565 "Call anything source within `anything' session."
8567 (setq anything-input-idle-delay
0)
8568 (anything-set-sources '(anything-c-source-call-source)))
8570 ;;; Execute Preconfigured anything.
8571 (defvar anything-c-source-anything-commands
8572 '((name .
"Preconfigured Anything")
8573 (candidates . anything-c-anything-commands-candidates
)
8575 (candidate-number-limit)))
8576 ;; (anything 'anything-c-source-anything-commands)
8578 (defun anything-c-anything-commands-candidates ()
8579 (loop for
(cmd . desc
) in
(anything-c-list-preconfigured-anything)
8580 collect
(cons (if (where-is-internal cmd nil t
)
8581 (substitute-command-keys (format "M-x %s (\\[%s]) : %s" cmd cmd desc
))
8582 (substitute-command-keys (format "\\[%s] : %s" cmd desc
)))
8589 (defun anything-c-occur-init ()
8590 "Create the initial anything occur buffer.
8591 If region is active use region as buffer contents
8592 instead of whole buffer."
8593 (with-current-buffer (anything-candidate-buffer 'global
)
8596 (with-anything-current-buffer
8597 (if (anything-region-active-p)
8598 (buffer-substring (region-beginning) (region-end))
8599 (buffer-substring (point-min) (point-max))))))
8600 (insert buf-contents
))))
8602 (defun anything-c-occur-get-line (s e
)
8603 (format "%7d:%s" (line-number-at-pos (1- s
)) (buffer-substring s e
)))
8605 (defun anything-c-occur-query-replace-regexp (candidate)
8606 "Query replace regexp starting from CANDIDATE.
8607 If region is active ignore CANDIDATE and replace only in region.
8608 With a prefix arg replace only matches surrounded by word boundaries,
8609 i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b."
8610 (let ((regexp anything-input
))
8611 (unless (anything-region-active-p)
8612 (anything-c-action-line-goto candidate
))
8613 (apply 'query-replace-regexp
8614 (anything-c-query-replace-args regexp
))))
8616 (defvar anything-c-source-occur
8618 (init . anything-c-occur-init
)
8619 (candidates-in-buffer)
8621 (get-line . anything-c-occur-get-line
)
8622 (display-to-real . anything-c-display-to-real-line
)
8623 (action .
(("Go to Line" . anything-c-action-line-goto
)
8624 ("Query replace regexp (C-u Not inside word.)"
8625 . anything-c-occur-query-replace-regexp
)))
8627 (requires-pattern .
1)
8630 ;; (anything 'anything-c-source-occur)
8633 ;;; Anything browse code.
8634 (defun anything-c-browse-code-get-line (beg end
)
8635 "Select line if it match the regexp corresponding to current `major-mode'.
8636 Line is parsed for BEG position to END position."
8637 (let ((str-line (buffer-substring beg end
))
8638 (regexp (assoc-default major-mode
8639 anything-c-browse-code-regexp-alist
))
8640 (num-line (if (string= anything-pattern
"") beg
(1- beg
))))
8641 (when (and regexp
(string-match regexp str-line
))
8642 (format "%4d:%s" (line-number-at-pos num-line
) str-line
))))
8645 (defvar anything-c-source-browse-code
8646 '((name .
"Browse code")
8648 (anything-candidate-buffer anything-current-buffer
)
8649 (with-anything-current-buffer
8650 (jit-lock-fontify-now))))
8651 (candidate-number-limit .
9999)
8652 (candidates-in-buffer)
8653 (get-line . anything-c-browse-code-get-line
)
8658 ;; Do many actions for input
8659 (defvar anything-c-source-create
8663 (action-transformer . anything-create--actions
))
8664 "Do many create actions from `anything-pattern'.
8665 See also `anything-create--actions'.")
8666 ;; (anything 'anything-c-source-create)
8668 (defun anything-create-from-anything ()
8669 "Run `anything-create' from `anything' as a fallback."
8671 (anything-run-after-quit 'anything-create nil anything-pattern
))
8673 (defun anything-create--actions (&rest ignored
)
8674 "Default actions for `anything-create' / `anything-c-source-create'."
8676 (lambda (pair) (and (consp pair
) (functionp (cdr pair
))))
8677 (append anything-create--actions-private
8678 '(("find-file" . find-file
)
8679 ("find-file other window" . find-file-other-window
)
8680 ("New buffer" . anything-c-switch-to-buffer
)
8681 ("New buffer other window" . switch-to-buffer-other-window
)
8682 ("Bookmark Set" . bookmark-set
)
8684 (lambda (x) (set-register (read-char "Register: ") x
)))
8685 ("Insert Linkd star" . linkd-insert-star
)
8686 ("Insert Linkd Tag" . linkd-insert-tag
)
8687 ("Insert Linkd Link" . linkd-insert-link
)
8688 ("Insert Linkd Lisp" . linkd-insert-lisp
)
8689 ("Insert Linkd Wiki" . linkd-insert-wiki
)
8690 ("Google Search" . google
)))))
8693 ;; Minibuffer History
8696 (defvar anything-c-source-minibuffer-history
8697 '((name .
"Minibuffer History")
8698 (header-name .
(lambda (name)
8699 (format "%s (%s)" name minibuffer-history-variable
)))
8702 (let ((history (loop
8703 for i in
(symbol-value minibuffer-history-variable
)
8704 unless
(string= "" i
) collect i
)))
8705 (if (consp (car history
))
8706 (mapcar 'prin1-to-string history
)
8710 ;; (anything 'anything-c-source-minibuffer-history)
8716 (defvar anything-c-source-elscreen
8717 '((name .
"Elscreen")
8718 (candidates .
(lambda ()
8719 (if (cdr (elscreen-get-screen-to-name-alist))
8721 (loop for sname in
(elscreen-get-screen-to-name-alist)
8722 append
(list (format "[%d] %s" (car sname
) (cdr sname
))) into lst
8723 finally
(return lst
))
8724 #'(lambda (a b
) (compare-strings a nil nil b nil nil
))))))
8725 (action .
(("Change Screen".
8727 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))))
8730 (dolist (i (anything-marked-candidates))
8731 (elscreen-goto (- (aref i
1) (aref "0" 0)))
8735 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))
8736 (elscreen-kill-others)))))))
8737 ;; (anything 'anything-c-source-elscreen)
8743 (defvar anything-c-top-command
"COLUMNS=%s top -b -n 1"
8744 "Top command (batch mode). %s is replaced with `frame-width'.")
8745 (defvar anything-c-source-top
8746 '((name .
"Top (Press C-c C-u to refresh)")
8747 (init . anything-c-top-init
)
8748 (candidates-in-buffer)
8749 (display-to-real . anything-c-top-display-to-real
)
8750 (update . anything-c-top-update
)
8751 (persistent-action . anything-c-top-sh-persistent-action
)
8752 (persistent-help .
"SIGTERM")
8754 ("kill (TERM)" .
(lambda (pid) (anything-c-top-sh (format "kill -TERM %s" pid
))))
8755 ("kill (KILL)" .
(lambda (pid) (anything-c-top-sh (format "kill -KILL %s" pid
))))
8756 ("Copy PID" .
(lambda (pid) (kill-new pid
))))))
8757 ;; (anything 'anything-c-source-top)
8759 (defun anything-c-top-sh (cmd)
8760 (message "Executed %s\n%s" cmd
(shell-command-to-string cmd
)))
8762 (defun anything-c-top-sh-persistent-action (pid)
8763 (delete-other-windows)
8764 (anything-c-top-sh (format "kill -TERM %s" pid
))
8765 (anything-force-update))
8767 (defun anything-c-top-init ()
8768 (with-current-buffer (anything-candidate-buffer 'global
)
8769 (call-process-shell-command
8770 (format anything-c-top-command
8771 (- (frame-width) (if anything-enable-digit-shortcuts
4 0)))
8772 nil
(current-buffer))))
8774 (defun anything-c-top-display-to-real (line)
8775 (car (split-string line
)))
8777 (defun anything-c-top-update ()
8778 (let ((anything-source-name (assoc-default 'name anything-c-source-top
))) ;UGLY HACK
8779 (anything-c-top-init)))
8782 (defvar anything-c-source-absolute-time-timers
8783 '((name .
"Absolute Time Timers")
8784 (candidates . timer-list
)
8786 ;; (anything 'anything-c-source-absolute-time-timers)
8788 (defvar anything-c-source-idle-time-timers
8789 '((name .
"Idle Time Timers")
8790 (candidates . timer-idle-list
)
8792 ;; (anything 'anything-c-source-idle-time-timers)
8794 (defun anything-c-timer-real-to-display (timer)
8795 (destructuring-bind (triggered t1 t2 t3 repeat-delay func args idle-delay
)
8796 (append timer nil
) ;use `append' to convert vector->list
8797 (format "%s repeat=%5S %s(%s)"
8798 (let ((time (list t1 t2 t3
)))
8800 (format-time-string "idle-for=%5s" time
)
8801 (format-time-string "%m/%d %T" time
)))
8804 (mapconcat 'prin1-to-string args
" "))))
8806 ;;; X RandR resolution change
8807 ;;; FIXME I do not care multi-display.
8808 (defvar anything-c-xrandr-output
"VGA")
8809 (defvar anything-c-xrandr-screen
"0")
8810 (defvar anything-c-source-xrandr-change-resolution
8811 '((name .
"Change Resolution")
8815 (call-process "xrandr" nil
(current-buffer) nil
8816 "--screen" anything-c-xrandr-screen
"-q")
8818 (loop while
(re-search-forward " \\([0-9]+x[0-9]+\\)" nil t
)
8819 collect
(match-string 1)))))
8821 ("Change Resolution" .
(lambda (mode)
8822 (call-process "xrandr" nil nil nil
8823 "--screen" anything-c-xrandr-screen
8824 "--output" anything-c-xrandr-output
8826 ;; (anything 'anything-c-source-xrandr-change-resolution)
8831 (defun anything-c-persistent-xfont-action (elm)
8832 "Show current font temporarily"
8833 (let ((current-font (cdr (assoc 'font
(frame-parameters))))
8836 (progn (set-frame-font default-font
'keep-size
) (sit-for 2))
8837 (set-frame-font current-font
))))
8839 (defvar anything-c-xfonts-cache nil
)
8840 (defvar anything-c-source-xfonts
8841 '((name .
"X Fonts")
8843 (unless anything-c-xfonts-cache
8844 (setq anything-c-xfonts-cache
8845 (x-list-fonts "*")))))
8846 (candidates . anything-c-xfonts-cache
)
8847 (action .
(("Copy to kill ring" .
(lambda (elm)
8849 ("Set Font" .
(lambda (elm)
8851 (set-frame-font elm
'keep-size
)
8852 (message "New font have been copied to kill ring")))))
8853 (persistent-action . anything-c-persistent-xfont-action
)
8854 (persistent-help .
"Switch to this font temporarily")))
8855 ;; (anything 'anything-c-source-xfonts)
8857 ;;; 𝕌𝕔𝕤 𝕊𝕪𝕞𝕓𝕠𝕝 𝕔𝕠𝕞𝕡𝕝𝕖𝕥𝕚𝕠𝕟
8860 (defvar anything-c-ucs-max-len
0)
8861 (defun anything-c-calculate-ucs-max-len ()
8862 "Calculate the length of longest `ucs-names' candidate."
8863 (loop with count
= 0
8864 for
(n . v
) in
(ucs-names)
8865 for len
= (length n
)
8868 finally return count
))
8870 (defun anything-c-ucs-init ()
8871 "Initialize an anything buffer with ucs symbols.
8872 Only math* symbols are collected."
8873 (unless (> anything-c-ucs-max-len
0)
8874 (setq anything-c-ucs-max-len
8875 (anything-c-calculate-ucs-max-len)))
8876 (with-current-buffer (anything-candidate-buffer
8877 (get-buffer-create "*anything ucs*"))
8878 ;; `ucs-names' fn will not run again, data is cached in
8880 (loop for
(n . v
) in
(ucs-names)
8881 for len
= (length n
)
8882 for diff
= (+ (- anything-c-ucs-max-len len
) 2)
8883 unless
(string= "" n
)
8884 do
(progn (insert (concat
8891 (defun anything-c-ucs-forward-char (candidate)
8892 (with-anything-current-buffer
8895 (defun anything-c-ucs-backward-char (candidate)
8896 (with-anything-current-buffer
8899 (defun anything-c-ucs-delete-backward (candidate)
8900 (with-anything-current-buffer
8903 (defun anything-c-ucs-insert-char (candidate)
8904 (with-anything-current-buffer
8906 (replace-regexp-in-string
8908 (cadr (split-string candidate
":"))))))
8910 (defun anything-c-ucs-persistent-insert ()
8912 (anything-execute-persistent-action 'action-insert
))
8914 (defun anything-c-ucs-persistent-forward ()
8916 (anything-execute-persistent-action 'action-forward
))
8918 (defun anything-c-ucs-persistent-backward ()
8920 (anything-execute-persistent-action 'action-back
))
8922 (defun anything-c-ucs-persistent-delete ()
8924 (anything-execute-persistent-action 'action-delete
))
8926 (defvar anything-c-source-ucs
8927 '((name .
"Ucs names")
8928 (init . anything-c-ucs-init
)
8929 (candidate-number-limit .
9999)
8930 (candidates-in-buffer)
8931 (mode-line . anything-c-ucs-mode-line-string
)
8932 (action-insert . anything-c-ucs-insert-char
)
8933 (action-forward . anything-c-ucs-forward-char
)
8934 (action-back . anything-c-ucs-backward-char
)
8935 (action-delete . anything-c-ucs-delete-backward
)
8936 (action .
(("Insert" . anything-c-ucs-insert-char
)
8937 ("Forward char" . anything-c-ucs-forward-char
)
8938 ("Backward char" . anything-c-ucs-backward-char
)
8939 ("Delete char backward" . anything-c-ucs-delete-backward
))))
8940 "Source for collecting `ucs-names' math symbols.")
8946 (defvar anything-c-source-emacs-process
8947 '((name .
"Emacs Process")
8948 (candidates .
(lambda () (mapcar #'process-name
(process-list))))
8949 (persistent-action .
(lambda (elm)
8950 (delete-process (get-process elm
))
8951 (anything-delete-current-selection)))
8952 (persistent-help .
"Kill Process")
8953 (action ("Kill Process" .
(lambda (elm)
8954 (delete-process (get-process elm
)))))))
8955 ;; (anything 'anything-c-source-emacs-process)
8960 (defvar anything-c-source-time-world
8961 '((name .
"Time World List")
8963 (let ((anything-buffer (anything-candidate-buffer 'global
)))
8964 (with-current-buffer anything-buffer
8965 (display-time-world-display display-time-world-list
)))))
8966 (candidates-in-buffer)))
8970 ;;; Anything interface for Debian/Ubuntu packages (apt-*)
8973 (defvar anything-c-source-apt
8975 (init . anything-c-apt-init
)
8976 (candidates-in-buffer)
8977 (candidate-transformer anything-c-apt-candidate-transformer
)
8978 (display-to-real . anything-c-apt-display-to-real
)
8979 (requires-pattern .
2)
8980 (update . anything-c-apt-refresh
)
8982 ("Show package description" . anything-c-apt-cache-show
)
8983 ("Install package" . anything-c-apt-install
)
8984 ("Remove package" . anything-c-apt-uninstall
)
8985 ("Purge package" . anything-c-apt-purge
))
8986 (persistent-action . anything-c-apt-persistent-action
)
8987 (persistent-help .
"Show package description")))
8988 ;; (anything 'anything-c-source-apt)
8990 (defvar anything-c-apt-query
"emacs")
8991 (defvar anything-c-apt-search-command
"apt-cache search '%s'")
8992 (defvar anything-c-apt-show-command
"apt-cache show '%s'")
8993 (defvar anything-c-apt-installed-packages nil
)
8994 (defvar anything-c-apt-all-packages nil
)
8995 (defvar anything-c-apt-input-history nil
)
8997 (defun anything-c-apt-refresh ()
8998 "Refresh installed candidates list."
8999 (setq anything-c-apt-installed-packages nil
)
9000 (setq anything-c-apt-all-packages nil
))
9002 (defun anything-c-apt-persistent-action (candidate)
9003 "Persistent action for APT source."
9004 (anything-c-apt-cache-show candidate
))
9006 (defun anything-c-apt-candidate-transformer (candidates)
9007 "Show installed candidates in a different color."
9010 for cand in candidates
9011 for name
= (anything-c-apt-display-to-real cand
)
9012 if
(member name anything-c-apt-installed-packages
)
9013 collect
(propertize cand
'face
'anything-apt-installed
) into all
9014 else collect cand into all finally return all
))
9016 (defun anything-c-apt-init ()
9017 "Initialize list of debian packages."
9019 (unless (and anything-c-apt-installed-packages
9020 anything-c-apt-all-packages
)
9021 (message "Loading package list...")
9022 (setq anything-c-apt-installed-packages
9024 (call-process-shell-command "dpkg --get-selections"
9025 nil
(current-buffer))
9026 (loop for i in
(split-string (buffer-string) "\n" t
)
9027 collect
(car (split-string i
)))))
9028 (setq anything-c-apt-all-packages
9029 (with-current-buffer
9030 (anything-candidate-buffer
9031 (get-buffer-create (format "*anything-apt*")))
9033 (call-process-shell-command
9034 (format anything-c-apt-search-command query
)
9035 nil
(current-buffer))))
9036 (message "Loading package list done")
9039 (defun anything-c-apt-display-to-real (line)
9040 "Return only name of a debian package.
9041 LINE is displayed like:
9042 package name - description."
9043 (car (split-string line
" - ")))
9045 (defun anything-c-shell-command-if-needed (command)
9046 "Run shell command COMMAND to describe package.
9047 If a buffer named COMMAND already exists, just switch to it."
9048 (let ((buf (get-buffer command
)))
9049 (anything-c-switch-to-buffer (get-buffer-create command
))
9050 (unless buf
(insert (shell-command-to-string command
)))))
9052 (defun anything-c-apt-cache-show (package)
9053 "Show information on apt package PACKAGE."
9054 (anything-c-shell-command-if-needed
9055 (format anything-c-apt-show-command package
)))
9057 (defun anything-c-apt-install (package)
9058 "Run 'apt-get install' shell command on PACKAGE."
9059 (anything-c-apt-generic-action :action
'install
))
9061 (defun anything-c-apt-uninstall (package)
9062 "Run 'apt-get remove' shell command on PACKAGE."
9063 (anything-c-apt-generic-action :action
'uninstall
))
9065 (defun anything-c-apt-purge (package)
9066 "Run 'apt-get purge' shell command on PACKAGE."
9067 (anything-c-apt-generic-action :action
'purge
))
9069 (defun* anything-c-apt-generic-action
(&key action
)
9070 "Run 'apt-get ACTION'.
9071 Support install, remove and purge actions."
9072 (ansi-term (getenv "SHELL") "anything apt")
9074 (let ((command (case action
9075 ('install
"sudo apt-get install ")
9076 ('uninstall
"sudo apt-get remove ")
9077 ('purge
"sudo apt-get purge ")
9078 (t (error "Unknow action"))))
9081 (cand-list (mapconcat #'(lambda (x) (format "'%s'" x
))
9082 (anything-marked-candidates) " ")))
9083 (goto-char (point-max))
9084 (insert (concat command cand-list
))
9086 (if (y-or-n-p (format "%s package" (symbol-name action
)))
9088 (setq anything-c-external-commands-list nil
)
9089 (setq anything-c-apt-installed-packages nil
)
9090 (term-char-mode) (term-send-input))
9091 (delete-region beg end
) (term-send-eof) (kill-buffer))))
9093 ;; (anything-c-apt-install "jed")
9096 ;;; Anything UI for gentoo portage.
9099 (defvar anything-c-gentoo-use-flags nil
)
9100 (defvar anything-c-gentoo-buffer
"*anything-gentoo-output*")
9101 (defvar anything-c-cache-gentoo nil
)
9102 (defvar anything-c-cache-world nil
)
9103 (defvar anything-c-source-gentoo
9104 '((name .
"Portage sources")
9106 (get-buffer-create anything-c-gentoo-buffer
)
9107 (unless anything-c-cache-gentoo
9108 (anything-c-gentoo-setup-cache))
9109 (unless anything-c-cache-world
9110 (setq anything-c-cache-world
(anything-c-gentoo-get-world)))
9111 (anything-c-gentoo-init-list)))
9112 (candidates-in-buffer)
9114 (candidate-transformer anything-c-highlight-world
)
9115 (action .
(("Show package" .
(lambda (elm)
9116 (anything-c-gentoo-eshell-action elm
"eix")))
9117 ("Show history" .
(lambda (elm)
9118 (if (member elm anything-c-cache-world
)
9119 (anything-c-gentoo-eshell-action elm
"genlop -qe")
9120 (message "No infos on packages not yet installed"))))
9121 ("Copy in kill-ring" . kill-new
)
9122 ("insert at point" . insert
)
9123 ("Browse HomePage" .
(lambda (elm)
9124 (let ((urls (anything-c-gentoo-get-url elm
)))
9125 (browse-url (anything-comp-read "Url: " urls
:must-match t
)))))
9126 ("Show extra infos" .
(lambda (elm)
9127 (if (member elm anything-c-cache-world
)
9128 (anything-c-gentoo-eshell-action elm
"genlop -qi")
9129 (message "No infos on packages not yet installed"))))
9130 ("Show use flags" .
(lambda (elm)
9131 (anything-c-gentoo-default-action elm
"equery" "-C" "u")
9132 (font-lock-add-keywords nil
'(("^\+.*" . font-lock-variable-name-face
)))
9133 (font-lock-mode 1)))
9134 ("Run emerge pretend" .
(lambda (elm)
9135 (anything-c-gentoo-eshell-action elm
"emerge -p")))
9136 ("Emerge" .
(lambda (elm)
9137 (anything-gentoo-install elm
:action
'install
)))
9138 ("Unmerge" .
(lambda (elm)
9139 (anything-gentoo-install elm
:action
'uninstall
)))
9140 ("Show dependencies" .
(lambda (elm)
9141 (anything-c-gentoo-default-action elm
"equery" "-C" "d")))
9142 ("Show related files" .
(lambda (elm)
9143 (anything-c-gentoo-default-action elm
"equery" "files")))
9144 ("Refresh" .
(lambda (elm)
9145 (anything-c-gentoo-setup-cache)
9146 (setq anything-c-cache-world
(anything-c-gentoo-get-world))))))))
9148 ;; (anything 'anything-c-source-gentoo)
9150 (defun* anything-gentoo-install
(candidate &key action
)
9151 (setq anything-c-external-commands-list nil
)
9152 (ansi-term (getenv "SHELL") "Gentoo emerge")
9154 (let ((command (case action
9155 ('install
"sudo emerge -av ")
9156 ('uninstall
"sudo emerge -avC ")
9157 (t (error "Unknow action"))))
9158 (elms (mapconcat 'identity
(anything-marked-candidates) " "))
9160 (goto-char (point-max))
9161 (insert (concat command elms
))
9163 (term-char-mode) (term-send-input)))
9165 (defun anything-c-gentoo-default-action (elm command
&rest args
)
9166 "Gentoo default action that use `anything-c-gentoo-buffer'."
9167 (if (member elm anything-c-cache-world
)
9169 (anything-c-switch-to-buffer anything-c-gentoo-buffer
)
9171 (let ((com-list (append args
(list elm
))))
9172 (apply #'call-process command nil t nil
9174 (message "No infos on packages not yet installed")))
9176 (defvar anything-c-source-use-flags
9177 '((name .
"Use Flags")
9179 (unless anything-c-gentoo-use-flags
9180 (anything-c-gentoo-setup-use-flags-cache))
9181 (anything-c-gentoo-get-use)))
9182 (candidates-in-buffer)
9184 (candidate-transformer anything-c-highlight-local-use
)
9185 (action .
(("Description"
9187 (anything-c-switch-to-buffer anything-c-gentoo-buffer
)
9189 (apply #'call-process
"euse" nil t nil
9192 (font-lock-add-keywords nil
`((,elm . font-lock-variable-name-face
)))
9193 (font-lock-mode 1)))
9196 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -E")))
9199 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -D")))
9202 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -P")))
9203 ("Show which dep use this flag"
9205 (anything-c-switch-to-buffer anything-c-gentoo-buffer
)
9207 (apply #'call-process
"equery" nil t nil
9213 ;; (anything 'anything-c-source-use-flags)
9215 (defun anything-c-gentoo-init-list ()
9216 "Initialize buffer with all packages in Portage."
9217 (let* ((portage-buf (get-buffer-create "*anything-gentoo*"))
9218 (buf (anything-candidate-buffer 'portage-buf
)))
9219 (with-current-buffer buf
9220 (dolist (i anything-c-cache-gentoo
)
9221 (insert (concat i
"\n"))))))
9223 (defun anything-c-gentoo-setup-cache ()
9224 "Set up `anything-c-cache-gentoo'"
9225 (setq anything-c-cache-gentoo
9226 (split-string (with-temp-buffer
9227 (call-process "eix" nil t nil
9231 (defun anything-c-gentoo-eshell-action (elm command
)
9232 (when (get-buffer "*EShell Command Output*")
9233 (kill-buffer "*EShell Command Output*"))
9234 (message "Wait searching...")
9235 (let ((buf-fname (buffer-file-name anything-current-buffer
)))
9236 (if (and buf-fname
(string-match tramp-file-name-regexp buf-fname
))
9238 (save-window-excursion
9239 (pop-to-buffer "*scratch*")
9240 (eshell-command (format "%s %s" command elm
)))
9241 (pop-to-buffer "*EShell Command Output*"))
9242 (eshell-command (format "%s %s" command elm
)))))
9244 (defun anything-c-gentoo-get-use ()
9245 "Initialize buffer with all use flags."
9246 (let* ((use-buf (get-buffer-create "*anything-gentoo-use*"))
9247 (buf (anything-candidate-buffer 'use-buf
)))
9248 (with-current-buffer buf
9249 (dolist (i anything-c-gentoo-use-flags
)
9250 (insert (concat i
"\n"))))))
9253 (defun anything-c-gentoo-setup-use-flags-cache ()
9254 "Setup `anything-c-gentoo-use-flags'"
9255 (setq anything-c-gentoo-use-flags
9256 (split-string (with-temp-buffer
9257 (call-process "eix" nil t nil
9258 "--print-all-useflags")
9261 (defun anything-c-gentoo-get-url (elm)
9262 "Return a list of urls from eix output."
9264 with url-list
= (split-string
9266 (call-process "eix" nil t nil
9267 elm
"--format" "<homepage>\n")
9271 when
(and (string-match "^http://.*" i
)
9272 (not (member i all
)))
9274 finally return all
))
9276 (defun anything-c-gentoo-get-world ()
9277 "Return list of all installed package on your system."
9278 (split-string (with-temp-buffer
9279 (call-process "qlist" nil t nil
9283 (defun anything-c-gentoo-get-local-use ()
9284 (split-string (with-temp-buffer
9285 (call-process "portageq" nil t nil
9291 (defun anything-c-highlight-world (eix)
9292 "Highlight all installed package."
9294 if
(member i anything-c-cache-world
)
9295 collect
(propertize i
'face
'anything-gentoo-match-face
)
9299 (defun anything-c-highlight-local-use (use-flags)
9300 (let ((local-uses (anything-c-gentoo-get-local-use)))
9301 (loop for i in use-flags
9302 if
(member i local-uses
)
9303 collect
(propertize i
'face
'anything-gentoo-match-face
)
9309 ;;; Anything ratpoison UI
9312 (defvar anything-c-source-ratpoison-commands
9313 '((name .
"Ratpoison Commands")
9314 (init . anything-c-ratpoison-commands-init
)
9315 (candidates-in-buffer)
9316 (action ("Execute the command" . anything-c-ratpoison-commands-execute
))
9317 (display-to-real . anything-c-ratpoison-commands-display-to-real
)
9318 (candidate-number-limit)))
9319 ;; (anything 'anything-c-source-ratpoison-commands)
9321 (defun anything-c-ratpoison-commands-init ()
9322 (unless (anything-candidate-buffer)
9323 (with-current-buffer (anything-candidate-buffer 'global
)
9324 ;; with ratpoison prefix key
9326 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help"))
9327 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
9328 (replace-match "<ratpoison> \\1: \\2"))
9329 (goto-char (point-max))
9332 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help top"))
9333 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
9334 (replace-match "\\1: \\2")))))
9336 (defun anything-c-ratpoison-commands-display-to-real (display)
9337 (and (string-match ": " display
)
9338 (substring display
(match-end 0))))
9340 (defun anything-c-ratpoison-commands-execute (candidate)
9341 (call-process "ratpoison" nil nil nil
"-ic" candidate
))
9345 ;;; Anything `completing-read' replacement
9348 (defun anything-comp-read-get-candidates (collection &optional test sort-fn alistp
)
9349 "Convert COLLECTION to list removing elements that don't match TEST.
9350 See `anything-comp-read' about supported COLLECTION arguments.
9352 SORT-FN is a predicate to sort COLLECTION.
9354 ALISTP when non--nil will not use `all-completions' to collect
9355 candidates because it doesn't handle alists correctly for anything.
9356 i.e In `all-completions' the keys \(cars of elements\)
9357 are the possible completions. In anything we want to use the cdr instead
9358 like \(display . real\).
9362 \(setq A '((a . 1) (b . 2) (c . 3)))
9363 ==>((a . 1) (b . 2) (c . 3))
9364 \(anything-comp-read \"test: \" A :alistp nil
9365 :exec-when-only-one t
9366 :initial-input \"a\")
9368 \(anything-comp-read \"test: \" A :alistp t
9369 :exec-when-only-one t
9370 :initial-input \"1\")
9373 See docstring of `all-completions' for more info.
9375 If COLLECTION is an `obarray', a TEST should be needed. See `obarray'."
9377 (cond ((and (eq collection obarray
) test
)
9378 (all-completions "" collection test
))
9379 ((and (vectorp collection
) test
)
9380 (loop for i across collection when
(funcall test i
) collect i
))
9381 ((vectorp collection
)
9382 (loop for i across collection collect i
))
9384 (loop for i in collection when
(funcall test i
) collect i
))
9385 ((and (symbolp collection
) (boundp collection
))
9386 (symbol-value collection
))
9388 ((and collection test
)
9389 (all-completions "" collection test
))
9390 (t (all-completions "" collection
)))))
9391 (if sort-fn
(sort cands sort-fn
) cands
)))
9393 (defun anything-cr-default-transformer (candidates source
)
9394 "Default filter candidate function for `anything-comp-read'.
9395 Do nothing, just return candidate list unmodified."
9398 (defun* anything-comp-read
(prompt collection
9404 (buffer "*Anything Completions*")
9406 (requires-pattern 0)
9409 (persistent-action nil
)
9410 (persistent-help "DoNothing")
9411 (name "Anything Completions")
9412 candidates-in-buffer
9416 (fc-transformer 'anything-cr-default-transformer
)
9417 (marked-candidates nil
)
9419 "Anything `completing-read' replacement.
9421 - PROMPT is the prompt name to use.
9423 - COLLECTION can be a list, vector, obarray or hash-table.
9424 It can be also a function that receives three arguments:
9425 the values string, predicate and t. See `all-completions' for more details.
9429 - TEST: A predicate called with one arg i.e candidate.
9431 - INITIAL-INPUT: Same as input arg in `anything'.
9433 - PRESELECT: See preselect arg of `anything'.
9435 - DEFAULT: This option is used only for compatibility with regular
9436 Emacs `completing-read'.
9438 - BUFFER: Name of anything-buffer.
9440 - MUST-MATCH: Candidate selected must be one of COLLECTION.
9442 - REQUIRES-PATTERN: Same as anything attribute, default is 0.
9444 - HISTORY: A list containing specific history, default is nil.
9445 When it is non--nil, all elements of HISTORY are displayed in
9446 a special source before COLLECTION.
9448 - INPUT-HISTORY: A symbol. the minibuffer input history will be
9449 stored there, if nil or not provided, `minibuffer-history'
9450 will be used instead.
9452 - PERSISTENT-ACTION: A function called with one arg i.e candidate.
9454 - PERSISTENT-HELP: A string to document PERSISTENT-ACTION.
9456 - NAME: The name related to this local source.
9458 - EXEC-WHEN-ONLY-ONE: Bound `anything-execute-action-at-once-if-one'
9459 to non--nil. (possibles values are t or nil).
9461 - VOLATILE: Use volatile attribute \(enabled by default\).
9463 - SORT: A predicate to give to `sort' e.g `string-lessp'.
9465 - FC-TRANSFORMER: A `filtered-candidate-transformer' function.
9467 - MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list.
9469 - ALISTP: \(default is non--nil\) See `anything-comp-read-get-candidates'.
9471 - CANDIDATES-IN-BUFFER: when non--nil use a source build with
9472 `anything-candidates-in-buffer' which is much faster. It is enabled by default.
9473 Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil.
9475 Any prefix args passed during `anything-comp-read' invocation will be recorded
9476 in `anything-current-prefix-arg', otherwise if prefix args where given before
9477 `anything-comp-read' invocation, the value of `current-prefix-arg' will be used.
9478 That's mean you can pass prefix args before or after calling a command
9479 that use `anything-comp-read' See `anything-M-x' for example."
9480 (when (get-buffer anything-action-buffer
)
9481 (kill-buffer anything-action-buffer
))
9482 (flet ((action-fn (candidate)
9483 (if marked-candidates
9484 (anything-marked-candidates)
9485 (identity candidate
))))
9486 (let* ((src-hist `((name .
,(format "%s History" name
))
9489 (let ((all (anything-comp-read-get-candidates
9490 history nil nil
,alistp
)))
9491 (anything-fast-remove-dups
9492 (if (and default
(not (string= default
"")))
9493 (delq nil
(cons default
(delete default all
)))
9496 (filtered-candidate-transformer
9497 .
(lambda (candidates sources
)
9498 (loop for i in candidates
9499 do
(set-text-properties 0 (length i
) nil i
)
9501 (persistent-action .
,persistent-action
)
9502 (persistent-help .
,persistent-help
)
9503 (action .
,'action-fn
)))
9504 (src `((name .
,name
)
9507 (let ((cands (anything-comp-read-get-candidates
9508 collection test sort alistp
)))
9509 (unless (or must-match
(string= anything-pattern
""))
9510 (setq cands
(append (list anything-pattern
) cands
)))
9511 (if (and default
(not (string= default
"")))
9512 (delq nil
(cons default
(delete default cands
)))
9514 (filtered-candidate-transformer ,fc-transformer
)
9515 (requires-pattern .
,requires-pattern
)
9516 (persistent-action .
,persistent-action
)
9517 (persistent-help .
,persistent-help
)
9518 (action .
,'action-fn
)))
9519 (src-1 `((name .
,name
)
9522 (let ((cands (anything-comp-read-get-candidates
9523 collection test sort alistp
)))
9524 (unless (or must-match
(string= anything-pattern
""))
9525 (setq cands
(append (list anything-pattern
) cands
)))
9526 (with-current-buffer (anything-candidate-buffer 'global
)
9528 (if (and default
(not (string= default
"")))
9529 (delq nil
(cons default
(delete default cands
)))
9531 do
(insert (concat i
"\n")))))))
9532 (candidates-in-buffer)
9533 (filtered-candidate-transformer ,fc-transformer
)
9534 (requires-pattern .
,requires-pattern
)
9535 (persistent-action .
,persistent-action
)
9536 (persistent-help .
,persistent-help
)
9537 (action .
,'action-fn
)))
9538 (src-list (list src-hist
9539 (if candidates-in-buffer
9542 (append src
'((volatile)))
9544 (anything-execute-action-at-once-if-one exec-when-only-one
))
9548 :input initial-input
9550 :preselect preselect
9553 :history input-history
9555 (unless (or (eq anything-exit-status
1) must-match
)
9559 ;; Generic completing-read
9561 ;; Support also function as collection.
9562 ;; e.g M-x man is supported.
9563 ;; Support hash-table and vectors as collection.
9565 ;; Some crap emacs functions may not be supported
9566 ;; like ffap-alternate-file (bad use of completing-read)
9567 ;; and maybe others.
9568 ;; Provide a mode `anything-completion-mode' which turn on
9569 ;; anything in all `completing-read' and `read-file-name' in Emacs.
9571 (defvar anything-completion-mode-string
" AC")
9573 (defvar anything-completion-mode-quit-message
9574 "Anything completion disabled")
9576 (defvar anything-completion-mode-start-message
9577 "Anything completion enabled")
9579 ;;; Specialized handlers
9582 (defun anything-completing-read-symbols
9583 (prompt collection test require-match init
9584 hist default inherit-input-method name buffer
)
9585 "Specialized function for fast symbols completion in `ac-mode'."
9588 :sources
`((name .
,name
)
9590 (with-current-buffer (anything-candidate-buffer 'global
)
9591 (goto-char (point-min))
9592 (when (and default
(stringp default
)
9593 ;; Some defaults args result as
9594 ;; (symbol-name nil) == "nil".
9595 ;; e.g debug-on-entry.
9596 (not (string= default
"nil"))
9597 (not (string= default
"")))
9598 (insert (concat default
"\n")))
9599 (loop with all
= (all-completions "" collection test
)
9601 unless
(and default
(eq sym default
))
9602 do
(insert (concat sym
"\n"))))))
9603 (persistent-action . anything-lisp-completion-persistent-action
)
9604 (persistent-help .
"Show brief doc in mode-line")
9605 (candidates-in-buffer)
9606 (action . identity
))
9612 :default
(or default
""))
9616 ;;; Generic completing read
9619 (defun anything-completing-read-default-1
9620 (prompt collection test require-match
9621 init hist default inherit-input-method
9622 name buffer
&optional cands-in-buffer exec-when-only-one
)
9623 "Call `anything-comp-read' with same args as `completing-read'.
9624 Extra optional arg CANDS-IN-BUFFER mean use `candidates-in-buffer'
9625 method which is faster.
9626 It should be used when candidate list don't need to rebuild dynamically."
9627 (let ((history (or (car-safe hist
) hist
)))
9632 :input-history history
9633 :must-match require-match
9634 :alistp nil
; Be sure `all-completions' is used.
9636 :candidates-in-buffer cands-in-buffer
9637 :exec-when-only-one exec-when-only-one
9639 ;; If DEF is not provided, fallback to empty string
9640 ;; to avoid `thing-at-point' to be appended on top of list
9641 :default
(or default
"")
9642 :initial-input init
)))
9644 (defun anything-completing-read-with-cands-in-buffer
9645 (prompt collection test require-match
9646 init hist default inherit-input-method
9648 "Same as `anything-completing-read-default-1' but use candidates-in-buffer."
9649 ;; Some commands like find-tag may use `read-file-name' from inside
9650 ;; the calculation of collection. in this case it clash with
9651 ;; candidates-in-buffer that reuse precedent data (files) which is wrong.
9652 ;; So (re)calculate collection outside of main anything-session.
9653 (let ((cands (all-completions "" collection
)))
9654 (anything-completing-read-default-1 prompt cands test require-match
9655 init hist default inherit-input-method
9658 (defun* anything-completing-read-default
9659 (prompt collection
&optional
9660 predicate require-match
9661 initial-input hist def
9662 inherit-input-method
)
9663 "An anything replacement of `completing-read'.
9664 This function should be used only as a `completing-read-function'.
9666 Don't use it directly, use instead `anything-comp-read' in your programs.
9668 See documentation of `completing-read' and `all-completions' for details."
9669 (declare (special anything-completion-mode
))
9670 (let* ((current-command this-command
)
9671 (str-command (symbol-name current-command
))
9672 (buf-name (format "*ac-mode-%s*" str-command
))
9673 (entry (assq current-command
9674 anything-completing-read-handlers-alist
))
9675 (def-com (cdr-safe entry
))
9676 (str-defcom (and def-com
(symbol-name def-com
)))
9677 (def-args (list prompt collection predicate require-match
9678 initial-input hist def inherit-input-method
))
9679 ;; Append the two extra args needed to set the buffer and source name
9680 ;; in anything specialized functions.
9681 (any-args (append def-args
(list str-command buf-name
)))
9682 anything-completion-mode-start-message
; Be quiet
9683 anything-completion-mode-quit-message
9684 (minibuffer-completion-table collection
)
9685 (minibuffer-completion-predicate predicate
))
9686 (when (eq def-com
'ido
) (setq def-com
'ido-completing-read
))
9687 (unless (or (not entry
) def-com
)
9688 ;; An entry in *read-handlers-alist exists but have
9689 ;; a nil value, so we exit from here, disable `ac-mode'
9690 ;; and run the command again with it original behavior.
9691 ;; `ac-mode' will be restored on exit.
9692 (return-from anything-completing-read-default
9696 (apply completing-read-function def-args
))
9698 ;; If we use now `completing-read' we MUST turn off `ac-mode'
9699 ;; to avoid infinite recursion and CRASH. It will be reenabled on exit.
9700 (when (or (eq def-com
'completing-read
)
9701 ;; All specialized functions are prefixed by "anything"
9702 (and (stringp str-defcom
)
9703 (not (string-match "^anything" str-defcom
))))
9706 (cond (;; An anything specialized function exists, run it.
9707 (and def-com anything-completion-mode
)
9708 (apply def-com any-args
))
9709 (;; Try to handle `ido-completing-read' everywhere.
9710 (and def-com
(eq def-com
'ido-completing-read
))
9711 (setcar (memq collection def-args
)
9712 (all-completions "" collection predicate
))
9713 (apply def-com def-args
))
9714 (;; User set explicitely `completing-read' or something similar
9715 ;; in *read-handlers-alist, use this with exactly the same
9716 ;; args as in `completing-read'.
9717 ;; If we are here `anything-completion-mode' is now disabled.
9719 (apply def-com def-args
))
9720 (t ; Fall back to classic `anything-comp-read'.
9721 (anything-completing-read-default-1
9722 prompt collection predicate require-match
9723 initial-input hist def inherit-input-method
9724 str-command buf-name
)))
9726 ;; When exiting minibuffer, `this-command' is set to
9727 ;; `anything-exit-minibuffer', which is unwanted when starting
9728 ;; on another `completing-read', so restore `this-command' to
9729 ;; initial value when exiting.
9730 (setq this-command current-command
))))
9732 (defun* anything-generic-read-file-name
9733 (prompt &optional dir default-filename mustmatch initial predicate
)
9734 "An anything replacement of `read-file-name'."
9735 (declare (special anything-completion-mode
))
9736 (let* ((default (and default-filename
9737 (if (listp default-filename
)
9738 (car default-filename
)
9740 (init (or default initial dir default-directory
))
9741 (ini-input (and init
(expand-file-name init
)))
9742 (current-command this-command
)
9743 (str-command (symbol-name current-command
))
9744 (anything-file-completion-sources
9746 (remove str-command anything-file-completion-sources
)))
9747 (buf-name (format "*ac-mode-%s*" str-command
))
9748 (entry (assq current-command
9749 anything-completing-read-handlers-alist
))
9750 (def-com (cdr-safe entry
))
9751 (str-defcom (symbol-name def-com
))
9752 (def-args (list prompt dir default-filename mustmatch initial predicate
))
9753 ;; Append the two extra args needed to set the buffer and source name
9754 ;; in anything specialized functions.
9755 (any-args (append def-args
(list str-command buf-name
)))
9756 (ido-state ido-mode
)
9757 anything-completion-mode-start-message
; Be quiet
9758 anything-completion-mode-quit-message
; Same here
9760 ;; Some functions that normally call `completing-read' can switch
9761 ;; brutally to `read-file-name' (e.g find-tag), in this case
9762 ;; the anything specialized function will fail because it is build
9763 ;; for `completing-read', so set it to 'incompatible to be sure
9764 ;; we switch to `anything-c-read-file-name' and don't try to call it
9765 ;; with wrong number of args.
9766 (when (and def-com
(> (length (help-function-arglist def-com
)) 8))
9767 (setq def-com
'incompatible
))
9768 (when (eq def-com
'ido
) (setq def-com
'ido-read-file-name
))
9769 (unless (or (not entry
) def-com
)
9770 (return-from anything-generic-read-file-name
9774 (apply read-file-name-function def-args
))
9776 ;; If we use now `read-file-name' we MUST turn off `ac-mode'
9777 ;; to avoid infinite recursion and CRASH. It will be reenabled on exit.
9778 (when (or (eq def-com
'read-file-name
)
9779 (eq def-com
'ido-read-file-name
)
9780 (and (stringp str-defcom
)
9781 (not (string-match "^anything" str-defcom
))))
9785 (cond (;; A specialized function exists, run it
9786 ;; with the two extra args specific to anything..
9787 (and def-com anything-completion-mode
9788 (not (eq def-com
'ido-read-file-name
))
9789 (not (eq def-com
'incompatible
)))
9790 (apply def-com any-args
))
9791 (;; Def-com value is `ido-read-file-name'
9792 ;; run it with default args.
9793 (and def-com
(eq def-com
'ido-read-file-name
))
9795 (apply def-com def-args
))
9796 (;; Def-com value is `read-file-name'
9797 ;; run it with default args.
9798 (eq def-com
'read-file-name
)
9799 (apply def-com def-args
))
9800 (t ; Fall back to classic `anything-c-read-file-name'.
9801 (anything-c-read-file-name
9805 :initial-input
(expand-file-name init dir
)
9809 (ido-mode (if ido-state
1 -
1))
9810 ;; Same comment as in `anything-completing-read-default'.
9811 (setq this-command current-command
))
9812 (if (and mustmatch
(not (file-exists-p fname
)))
9813 (if (y-or-n-p "File does not exists, create buffer?")
9814 fname
(error "Abort file does not exists"))
9818 (define-minor-mode anything-completion-mode
9819 "Toggle generic anything completion.
9821 All functions in Emacs that use `completing-read'
9822 or `read-file-name' and friends will use anything interface
9823 when this mode is turned on.
9824 However you can modify this behavior for functions of your choice
9825 with `anything-completing-read-handlers-alist'.
9827 Called with a positive arg, turn on unconditionally, with a
9828 negative arg turn off.
9829 You can turn it on with `ac-mode'.
9831 Some crap emacs functions may not be supported,
9832 e.g `ffap-alternate-file' and maybe others
9833 You can add such functions to `anything-completing-read-handlers-alist'
9836 Note: This mode will work only partially on Emacs23."
9839 :lighter anything-completion-mode-string
9840 (declare (special completing-read-function
))
9841 (if anything-completion-mode
9843 (setq completing-read-function
'anything-completing-read-default
9844 read-file-name-function
'anything-generic-read-file-name
)
9845 (message anything-completion-mode-start-message
))
9846 (setq completing-read-function
(and (fboundp 'completing-read-default
)
9847 'completing-read-default
)
9848 read-file-name-function
(and (fboundp 'read-file-name-default
)
9849 'read-file-name-default
))
9850 (message anything-completion-mode-quit-message
)))
9852 (defalias 'ac-mode
'anything-completion-mode
)
9856 ;;; Eshell completion.
9858 ;; Enable like this in .emacs:
9860 ;; (add-hook 'eshell-mode-hook
9862 ;; (define-key eshell-mode-map [remap pcomplete] 'anything-esh-pcomplete)))
9864 (defvar anything-c-source-esh
9865 '((name .
"Eshell completions")
9867 (setq pcomplete-current-completions nil
9868 pcomplete-last-completion-raw nil
)
9869 ;; Eshell-command add this hook in all minibuffers
9870 ;; Remove it for the anything one. (Fixed in Emacs24)
9871 (remove-hook 'minibuffer-setup-hook
'eshell-mode
)))
9872 (candidates . anything-esh-get-candidates
)
9873 (action . anything-ec-insert
))
9874 "Anything source for Eshell completion.")
9877 (defvar anything-ec-target
"")
9878 (defun anything-ec-insert (candidate)
9879 "Insert CANDIDATE at point.
9880 This is the same as `ac-insert', just inlined here for compatibility."
9882 (when (and anything-ec-target
9883 (search-backward anything-ec-target nil t
)
9884 (string= (buffer-substring (point) pt
) anything-ec-target
))
9885 (delete-region (point) pt
)))
9888 (defun anything-esh-get-candidates ()
9889 "Get candidates for eshell completion using `pcomplete'."
9891 (let* ((pcomplete-stub)
9892 pcomplete-seen pcomplete-norm-func
9893 pcomplete-args pcomplete-last pcomplete-index
9894 (pcomplete-autolist pcomplete-autolist
)
9895 (pcomplete-suffix-list pcomplete-suffix-list
))
9896 (with-anything-current-buffer
9898 with table
= (pcomplete-completions)
9899 with entry
= (condition-case nil
9901 (try-completion anything-pattern
(pcomplete-entries))
9902 ;; Fall back to this in Emacs23 as pcomplete-entries seem broken.
9905 (let ((fc (car (last (pcomplete-parse-arguments)))))
9906 ;; Check if last arg require fname completion.
9907 (and (file-name-directory fc
) fc
))))
9908 for i in
(if (listp table
) table
; Emacs23 or commands.
9909 (all-completions pcomplete-stub table
)) ; Emacs24
9910 for file-cand
= (and entry
9911 (if (file-remote-p i
) i
9912 (expand-file-name i
(file-name-directory entry
))))
9913 if
(and file-cand
(or (file-remote-p file-cand
) (file-exists-p file-cand
)))
9914 collect file-cand into ls
9915 else collect i into ls
9917 (if (and entry
(not (string= entry
"")) (file-exists-p entry
))
9918 (append (list (expand-file-name entry default-directory
)) ls
) ls
))))))
9923 (defvar anything-c-source-eshell-history
9924 '((name .
"Eshell history")
9926 (let (eshell-hist-ignoredups)
9927 ;; Write the content's of ring to file.
9928 (eshell-write-history eshell-history-file-name t
)
9929 (with-current-buffer (anything-candidate-buffer 'global
)
9930 (insert-file-contents eshell-history-file-name
)))
9931 ;; Same comment as in `anything-c-source-esh'
9932 (remove-hook 'minibuffer-setup-hook
'eshell-mode
)))
9933 (candidates-in-buffer)
9934 (filtered-candidate-transformer .
(lambda (candidates sources
)
9935 (reverse candidates
)))
9936 (candidate-number-limit .
9999)
9937 (action .
(lambda (candidate)
9939 (insert candidate
))))
9940 "Anything source for Eshell history.")
9943 ;;; Show completion - an alternative of anything-show-completion.el.
9945 ;; Provide show completion with macro `with-anything-show-completion'.
9948 ;; Called each time cursor move in anything-buffer.
9949 (defun anything-c-show-completion ()
9950 (with-anything-current-buffer
9951 (overlay-put anything-c-show-completion-overlay
9952 'display
(anything-get-selection))))
9954 (defun anything-c-show-completion-init-overlay (beg end
)
9955 (and anything-c-turn-on-show-completion
9956 (setq anything-c-show-completion-overlay
(make-overlay beg end
))
9957 (overlay-put anything-c-show-completion-overlay
9958 'face
'anything-lisp-show-completion
)))
9960 (defmacro with-anything-show-completion
(beg end
&rest body
)
9961 "Show anything candidate in an overlay at point.
9962 BEG and END are the beginning and end position of the current completion
9963 in `anything-current-buffer'.
9964 BODY is an anything call where we want to enable show completion.
9965 If `anything-c-turn-on-show-completion' is nil just do nothing."
9966 (declare (indent 2) (debug t
))
9967 `(let ((anything-move-selection-after-hook
9968 (and anything-c-turn-on-show-completion
9969 (append (list 'anything-c-show-completion
)
9970 anything-move-selection-after-hook
))))
9972 (progn (anything-c-show-completion-init-overlay ,beg
,end
)
9974 (and anything-c-turn-on-show-completion
9975 (delete-overlay anything-c-show-completion-overlay
)))))
9978 ;;; Lisp symbol completion.
9982 (defun anything-lisp-completion-at-point ()
9983 "Anything lisp symbol completion at point."
9985 (let* ((data (lisp-completion-at-point))
9987 (end (point)) ; 'cadr data' is wrong when no space after point.
9988 (plist (nthcdr 3 data
))
9989 (pred (plist-get plist
:predicate
))
9991 (target (and beg end
(buffer-substring-no-properties beg end
)))
9992 (candidates (all-completions target
(nth 2 data
) pred
))
9993 (anything-quit-if-no-candidate t
)
9994 (anything-execute-action-at-once-if-one t
)
9995 (anything-match-plugin-enabled
9996 (member 'anything-compile-source--match-plugin
9997 anything-compile-source-functions
)))
9999 (with-anything-show-completion beg end
10000 ;; Overlay is initialized now in anything-current-buffer.
10003 '((name .
"Lisp completion")
10005 (with-current-buffer (anything-candidate-buffer 'global
)
10006 (loop for sym in candidates
10007 for len
= (length sym
)
10008 when
(> len lgst-len
) do
(setq lgst-len len
)
10009 do
(insert (concat sym
"\n"))))))
10010 (candidates-in-buffer)
10011 (persistent-action . anything-lisp-completion-persistent-action
)
10012 (persistent-help .
"Show brief doc in mode-line")
10013 (filtered-candidate-transformer anything-lisp-completion-transformer
)
10014 (action .
(lambda (candidate)
10015 (delete-region beg end
)
10016 (insert candidate
))))
10017 :input
(if anything-match-plugin-enabled
(concat target
" ") target
)))
10018 (message "[No Match]"))))
10020 (defun anything-lisp-completion-persistent-action (candidate)
10021 (let ((cursor-in-echo-area t
)
10022 mode-line-in-non-selected-windows
)
10023 (anything-c-show-info-in-mode-line
10025 (anything-c-get-first-line-documentation
10026 (intern candidate
))
10027 'face
'anything-lisp-completion-info
))))
10029 (defun anything-lisp-completion-transformer (candidates source
)
10030 "Anything candidates transformer for lisp completion."
10031 (declare (special lgst-len
))
10032 (loop for c in candidates
10033 for sym
= (intern c
)
10034 for annot
= (cond ((commandp sym
) " (Com)")
10035 ((fboundp sym
) " (Fun)")
10036 ((boundp sym
) " (Var)")
10037 ((facep sym
) " (Face)"))
10038 for spaces
= (make-string (- lgst-len
(length c
)) ?
)
10039 collect
(cons (concat c spaces annot
) c
)))
10041 (defun anything-c-get-first-line-documentation (sym)
10042 "Return first line documentation of symbol SYM.
10043 If SYM is not documented, return \"Not documented\"."
10044 (let ((doc (cond ((fboundp sym
)
10045 (documentation sym t
))
10047 (documentation-property sym
'variable-documentation t
))
10049 (face-documentation sym
))
10051 (if (and doc
(not (string= doc
""))
10052 ;; `documentation' return "\n\n(args...)"
10053 ;; for CL-style functions.
10054 (not (string-match-p "^\n\n" doc
)))
10055 (car (split-string doc
"\n"))
10056 "Not documented")))
10058 ;;; File completion.
10060 ;; Complete file name at point.
10061 (defun anything-c-thing-before-point ()
10062 "Get symbol name before point.
10063 Borrowed from anything-complete.el, inlined here for compatibility."
10065 (let ((beg (point)))
10066 ;; older regexp "\(\\|\\s-\\|^\\|\\_<\\|\r\\|'\\|#'"
10067 (when (re-search-backward
10068 "\\_<" (field-beginning nil nil
(point-at-bol)) t
)
10069 (buffer-substring-no-properties beg
(match-end 0))))))
10072 (defun anything-c-complete-file-name-at-point ()
10073 "Complete file name at point."
10075 (let* ((init (substring-no-properties (thing-at-point 'filename
)))
10077 (beg (- (point) (length init
)))
10078 (anything-quit-if-no-candidate t
)
10079 (anything-execute-action-at-once-if-one t
)
10081 (with-anything-show-completion beg end
10082 (setq completion
(anything-c-read-file-name "FileName: "
10083 :initial-input init
)))
10084 (anything-c-insert-file-name-completion-at-point completion
)))
10087 (defvar anything-lisp-completion-counter
0)
10089 (defun anything-lisp-completion-at-point-or-indent (arg)
10090 "First call indent and second call complete lisp symbol.
10091 The second call should happen before `anything-lisp-completion-or-indent-delay',
10092 after this delay, next call will indent again.
10093 After completion, next call is always indent.
10094 See that like click and double mouse click.
10095 One hit indent, two quick hits maybe indent and complete."
10097 ;; Be sure `indent-for-tab-command' will not try
10098 ;; to use `completion-at-point'.
10099 (let ((tab-always-indent (if (eq tab-always-indent
'complete
)
10100 t tab-always-indent
)))
10101 (incf anything-lisp-completion-counter
)
10103 (if (> anything-lisp-completion-counter
1)
10104 (anything-lisp-completion-or-file-name-at-point)
10105 (indent-for-tab-command arg
))
10106 ;; After `anything-lisp-completion-or-indent-delay' seconds
10108 (run-with-timer anything-lisp-completion-or-indent-delay nil
10110 (setq anything-lisp-completion-counter
0)))
10111 ;; Always reset to 0 at second hit.
10112 (when (eq anything-lisp-completion-counter
2)
10113 (setq anything-lisp-completion-counter
0)))))
10116 (defun anything-lisp-completion-or-file-name-at-point ()
10117 "Complete lisp symbol or filename at point.
10118 Filename completion happen if filename is started in
10119 or between double quotes."
10121 (let ((tap (substring-no-properties (thing-at-point 'filename
))))
10122 (if (and tap
(string-match "^\\(~/\\|/\\|[a-zA-Z]\:/\\).*" tap
)
10123 (save-excursion (search-backward "\"" (point-at-bol) t
)))
10124 (anything-c-complete-file-name-at-point)
10125 (anything-lisp-completion-at-point))))
10127 (defun anything-c-apropos-init (test default
)
10128 "Init candidates buffer for `anything-c-apropos' sources."
10129 (with-current-buffer (anything-candidate-buffer 'global
)
10130 (goto-char (point-min))
10131 (when (and default
(stringp default
)
10132 ;; Some defaults args result as
10133 ;; (symbol-name nil) == "nil".
10134 ;; e.g debug-on-entry.
10135 (not (string= default
"nil"))
10136 (funcall test
(intern default
)))
10137 (insert (concat default
"\n")))
10138 (loop with all
= (all-completions "" obarray test
)
10140 unless
(and default
(eq sym default
))
10141 do
(insert (concat sym
"\n")))))
10144 ;;; Run Externals commands within Emacs with anything completion
10147 (defvar anything-external-command-history nil
)
10149 (defun anything-c-external-commands-list-1 (&optional sort
)
10150 "Returns a list of all external commands the user can execute.
10151 If `anything-c-external-commands-list' is non-nil it will
10152 return its contents. Else it calculates all external commands
10153 and sets `anything-c-external-commands-list'."
10154 (if anything-c-external-commands-list
10155 anything-c-external-commands-list
10156 (setq anything-c-external-commands-list
10158 with paths
= (split-string (getenv "PATH") path-separator
)
10159 with completions
= ()
10161 when
(and (file-exists-p dir
) (file-accessible-directory-p dir
))
10162 for lsdir
= (loop for i in
(directory-files dir t
)
10163 for bn
= (file-name-nondirectory i
)
10164 when
(and (not (member bn completions
))
10165 (not (file-directory-p i
))
10166 (file-executable-p i
))
10168 append lsdir into completions
10169 finally return
(if sort
(sort completions
'string-lessp
) completions
)))))
10171 (defun anything-run-or-raise (exe &optional file
)
10172 "Generic command that run asynchronously EXE.
10173 If EXE is already running just jump to his window if `anything-raise-command'
10175 When FILE argument is provided run EXE with FILE.
10176 In this case EXE must be provided as \"EXE %s\"."
10177 (lexical-let* ((real-com (car (split-string (replace-regexp-in-string
10179 (proc (if file
(concat real-com
" " file
) real-com
)))
10180 (if (get-process proc
)
10181 (if anything-raise-command
10182 (shell-command (format anything-raise-command real-com
))
10183 (error "Error: %s is already running" real-com
))
10184 (when (loop for i in anything-c-external-commands-list thereis real-com
)
10185 (message "Starting %s..." real-com
)
10187 (start-process-shell-command
10188 proc nil
(format exe
(shell-quote-argument file
)))
10189 (start-process-shell-command proc nil real-com
))
10190 (set-process-sentinel
10192 #'(lambda (process event
)
10193 (when (and (string= event
"finished\n")
10194 anything-raise-command
10195 (not (anything-c-get-pid-from-process-name real-com
)))
10196 (shell-command (format anything-raise-command
"emacs")))
10197 (message "%s process...Finished." process
))))
10198 (setq anything-c-external-commands-list
10200 (delete real-com anything-c-external-commands-list
))))))
10204 ;;; Generic action functions
10207 (defun anything-c-file-buffers (filename)
10208 "Returns a list of buffer names corresponding to FILENAME."
10209 (let ((name (expand-file-name filename
))
10211 (dolist (buf (buffer-list) buf-list
)
10212 (let ((bfn (buffer-file-name buf
)))
10213 (when (and bfn
(string= name bfn
))
10214 (push (buffer-name buf
) buf-list
))))))
10216 (defun anything-revert-buffer (candidate)
10217 (with-current-buffer candidate
10218 (when (or (buffer-modified-p)
10219 (not (verify-visited-file-modtime
10220 (get-buffer candidate
))))
10221 (revert-buffer t t
))))
10223 (defun anything-revert-marked-buffers (ignore)
10224 (mapc 'anything-revert-buffer
(anything-marked-candidates)))
10226 (defun anything-kill-marked-buffers (ignore)
10227 (mapc 'kill-buffer
(anything-marked-candidates)))
10229 (defun anything-c-delete-file (file)
10230 "Delete the given file after querying the user.
10231 Ask to kill buffers associated with that file, too."
10232 (let ((buffers (anything-c-file-buffers file
)))
10233 (if (< emacs-major-version
24)
10234 ;; `dired-delete-file' in Emacs versions < 24
10235 ;; doesn't support delete-by-moving-to-trash
10236 ;; so use `delete-directory' and `delete-file'
10238 (cond ((and (not (file-symlink-p file
))
10239 (file-directory-p file
)
10240 (directory-files file t dired-re-no-dot
))
10241 (when (y-or-n-p (format "Recursive delete of `%s'? " file
))
10242 (delete-directory file
'recursive
)))
10243 ((and (not (file-symlink-p file
))
10244 (file-directory-p file
))
10245 (delete-directory file
))
10246 (t (delete-file file
)))
10248 file
'dired-recursive-deletes delete-by-moving-to-trash
))
10250 (dolist (buf buffers
)
10251 (when (y-or-n-p (format "Kill buffer %s, too? " buf
))
10252 (kill-buffer buf
))))))
10254 (defun anything-get-mailcap-for-file (filename)
10255 "Get the command to use for FILENAME from mailcap files.
10256 The command is like <command %s> and is meant to use with `format'."
10257 (mailcap-parse-mailcaps)
10258 (let* ((ext (file-name-extension filename
))
10259 (mime (when ext
(mailcap-extension-to-mime ext
)))
10260 (result (when mime
(mailcap-mime-info mime
))))
10261 ;; If elisp file have no associations in .mailcap
10262 ;; `mailcap-maybe-eval' is returned, in this case just return nil.
10263 (when (stringp result
) result
)))
10265 (defun anything-get-default-program-for-file (filename)
10266 "Try to find a default program to open FILENAME.
10267 Try first in `anything-c-external-programs-associations' and then in mailcap file
10268 if nothing found return nil."
10269 (let* ((ext (file-name-extension filename
))
10270 (def-prog (assoc-default ext anything-c-external-programs-associations
)))
10271 (cond ((and def-prog
(not (string= def-prog
"")))
10272 (concat def-prog
" %s"))
10273 ((and anything-c-default-external-file-browser
10274 (file-directory-p filename
))
10275 (concat anything-c-default-external-file-browser
" %s"))
10276 (t (anything-get-mailcap-for-file filename
)))))
10278 (defun anything-c-open-file-externally (file)
10279 "Open FILE with an external program.
10280 Try to guess which program to use with `anything-get-default-program-for-file'.
10281 If not found or a prefix arg is given query the user which tool to use."
10282 (let* ((fname (expand-file-name file
))
10283 (collection (anything-c-external-commands-list-1 'sort
))
10284 (def-prog (anything-get-default-program-for-file fname
))
10285 (real-prog-name (if (or anything-current-prefix-arg
(not def-prog
))
10286 ;; Prefix arg or no default program.
10288 (anything-comp-read
10289 "Program: " collection
10291 :name
"Open file Externally"
10292 :history anything-external-command-history
)
10293 ;; Always prompt to set this program as default.
10294 (setq def-prog nil
))
10295 ;; No prefix arg or default program exists.
10296 (replace-regexp-in-string " %s\\| '%s'" "" def-prog
)))
10297 (program (concat real-prog-name
" %s")))
10298 (unless (or def-prog
; Association exists, no need to record it.
10299 ;; Don't try to record non--filenames associations (e.g urls).
10300 (not (file-exists-p fname
)))
10304 "Do you want to make `%s' the default program for this kind of files? "
10306 (anything-aif (assoc (file-name-extension fname
)
10307 anything-c-external-programs-associations
)
10308 (setq anything-c-external-programs-associations
10309 (delete it anything-c-external-programs-associations
)))
10310 (push (cons (file-name-extension fname
)
10312 "Program (Add args maybe and confirm): " real-prog-name
))
10313 anything-c-external-programs-associations
)
10314 (customize-save-variable 'anything-c-external-programs-associations
10315 anything-c-external-programs-associations
)))
10316 (anything-run-or-raise program file
)
10317 (setq anything-external-command-history
10318 (cons real-prog-name
10319 (delete real-prog-name
10320 (loop for i in anything-external-command-history
10321 when
(executable-find i
) collect i
))))))
10323 (defun anything-c-find-file-or-marked (candidate)
10324 "Open file CANDIDATE or open anything marked files in background."
10325 (let ((marked (anything-marked-candidates))
10326 (ffap-newfile-prompt anything-ff-newfile-prompt-p
)
10327 (find-file-wildcards nil
))
10328 (if (> (length marked
) 1)
10329 ;; Open all marked files in background and display
10331 (progn (mapc 'find-file-noselect
(cdr marked
))
10332 (find-file (car marked
)))
10333 (if (and (not (file-exists-p candidate
))
10334 (and ffap-url-regexp
10335 (not (string-match ffap-url-regexp candidate
)))
10336 (string-match "/$" candidate
))
10337 ;; A a non--existing filename ending with /
10338 ;; Create a directory and jump to it.
10339 (when (y-or-n-p (format "Create directory `%s'? " candidate
))
10340 (let ((dirfname (directory-file-name candidate
)))
10341 (if (file-exists-p dirfname
)
10342 (error "Mkdir: Unable to create directory `%s': file exists."
10343 (anything-c-basename dirfname
))
10344 (make-directory candidate
'parent
)))
10345 (anything-find-files-1 candidate
))
10346 ;; A non--existing filename NOT ending with / or
10347 ;; an existing filename, create or jump to it.
10348 (find-file-at-point (car marked
))))))
10350 (defun anything-delete-marked-files (ignore)
10351 (let* ((files (anything-marked-candidates))
10352 (len (length files
)))
10354 (format "Delete *%s File(s):\n%s"
10356 (mapconcat (lambda (f) (format "- %s\n" f
)) files
""))))
10357 (message "(No deletions performed)")
10359 (set-text-properties 0 (length i
) nil i
)
10360 (anything-c-delete-file i
))
10361 (message "%s File(s) deleted" len
))))
10363 (defun anything-ediff-marked-buffers (candidate &optional merge
)
10364 "Ediff 2 marked buffers or CANDIDATE and `anything-current-buffer'.
10365 With optional arg MERGE call `ediff-merge-buffers'."
10366 (let ((lg-lst (length (anything-marked-candidates)))
10370 (error "Error:You have to mark at least 1 buffer"))
10372 (setq buf1 anything-current-buffer
10373 buf2
(first (anything-marked-candidates))))
10375 (setq buf1
(first (anything-marked-candidates))
10376 buf2
(second (anything-marked-candidates))))
10378 (error "Error:To much buffers marked!")))
10380 (ediff-merge-buffers buf1 buf2
)
10381 (ediff-buffers buf1 buf2
))))
10383 (defun anything-ediff-marked-buffers-merge (candidate)
10384 "Ediff merge `anything-current-buffer' with CANDIDATE.
10385 See `anything-ediff-marked-buffers'."
10386 (anything-ediff-marked-buffers candidate t
))
10388 (defun anything-bookmark-get-bookmark-from-name (bmk)
10389 "Return bookmark name even if it is a bookmark with annotation.
10390 e.g prepended with *.
10391 Return nil if bmk is not a valid bookmark."
10392 (let ((bookmark (replace-regexp-in-string "\*" "" bmk
)))
10393 (if (assoc bookmark bookmark-alist
)
10395 (when (assoc bmk bookmark-alist
)
10398 (defun anything-delete-marked-bookmarks (ignore)
10399 "Delete this bookmark or all marked bookmarks."
10400 (dolist (i (anything-marked-candidates))
10401 (bookmark-delete (anything-bookmark-get-bookmark-from-name i
)
10404 (defun anything-require-or-error (feature function
)
10405 (or (require feature nil t
)
10406 (error "Need %s to use `%s'." feature function
)))
10408 (defun anything-find-buffer-on-elscreen (candidate)
10409 "Open buffer in new screen, if marked buffers open all in elscreens."
10410 (anything-require-or-error 'elscreen
'anything-find-buffer-on-elscreen
)
10411 (anything-aif (anything-marked-candidates)
10413 (let ((target-screen (elscreen-find-screen-by-buffer
10414 (get-buffer i
) 'create
)))
10415 (elscreen-goto target-screen
)))
10416 (let ((target-screen (elscreen-find-screen-by-buffer
10417 (get-buffer candidate
) 'create
)))
10418 (elscreen-goto target-screen
))))
10420 (defun anything-elscreen-find-file (file)
10421 (anything-require-or-error 'elscreen
'anything-elscreen-find-file
)
10422 (elscreen-find-file file
))
10425 (defun w32-shell-execute-open-file (file)
10426 (interactive "fOpen file:")
10428 (w32-shell-execute "open" (replace-regexp-in-string ;for UNC paths
10430 (replace-regexp-in-string ; strip cygdrive paths
10431 "/cygdrive/\\(.\\)" "\\1:"
10432 file nil nil
) nil t
))))
10434 (defun anything-c-open-file-with-default-tool (file)
10435 "Open FILE with the default tool on this platform."
10436 (if (eq system-type
'windows-nt
)
10437 (w32-shell-execute-open-file file
)
10438 (start-process "anything-c-open-file-with-default-tool"
10440 (cond ((eq system-type
'gnu
/linux
)
10442 ((or (eq system-type
'darwin
) ;; Mac OS X
10443 (eq system-type
'macos
)) ;; Mac OS 9
10447 (defun anything-c-open-dired (file)
10448 "Opens a dired buffer in FILE's directory. If FILE is a
10449 directory, open this directory."
10450 (if (file-directory-p file
)
10452 (dired (file-name-directory file
))
10453 (dired-goto-file file
)))
10455 (defun anything-c-display-to-real-line (candidate)
10456 (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate
)
10457 (list (string-to-number (match-string 1 candidate
)) (match-string 2 candidate
))
10458 (error "Line number not found")))
10460 (defun anything-c-action-line-goto (lineno-and-content)
10461 (apply #'anything-goto-file-line
(anything-interpret-value (anything-attr 'target-file
))
10462 (append lineno-and-content
10463 (list (if (and (anything-attr-defined 'target-file
)
10464 (not anything-in-persistent-action
))
10465 'find-file-other-window
10468 (defun* anything-c-action-file-line-goto
(file-line-content &optional
(find-file-function #'find-file
))
10469 (apply #'anything-goto-file-line
10470 (if (stringp file-line-content
)
10471 ;; Case: filtered-candidate-transformer is skipped
10472 (cdr (anything-c-filtered-candidate-transformer-file-line-1 file-line-content
))
10473 file-line-content
)))
10476 (defun anything-c-filtered-candidate-transformer-file-line (candidates source
)
10477 (delq nil
(mapcar 'anything-c-filtered-candidate-transformer-file-line-1 candidates
)))
10479 (defun anything-c-filtered-candidate-transformer-file-line-1 (candidate)
10480 (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate
)
10481 (let ((filename (match-string 1 candidate
))
10482 (lineno (match-string 2 candidate
))
10483 (content (match-string 3 candidate
)))
10484 (cons (format "%s:%s\n %s"
10485 (propertize filename
'face compilation-info-face
)
10486 (propertize lineno
'face compilation-line-face
)
10488 (list (expand-file-name
10490 (or (anything-interpret-value (anything-attr 'default-directory
))
10491 (and (anything-candidate-buffer)
10492 (buffer-local-value
10493 'default-directory
(anything-candidate-buffer)))))
10494 (string-to-number lineno
) content
)))))
10496 (defun* anything-goto-file-line
(file lineno content
&optional
(find-file-function #'find-file
))
10497 (anything-aif (anything-attr 'before-jump-hook
)
10499 (when file
(funcall find-file-function file
))
10500 (if (anything-attr-defined 'adjust
)
10501 (anything-c-goto-line-with-adjustment lineno content
)
10502 (anything-goto-line lineno
))
10503 (unless (anything-attr-defined 'recenter
)
10504 (set-window-start (get-buffer-window anything-current-buffer
) (point)))
10505 (anything-aif (anything-attr 'after-jump-hook
)
10507 (when anything-in-persistent-action
10508 (anything-match-line-color-current-line)))
10510 (defun anything-find-file-as-root (candidate)
10511 (find-file (concat "/" anything-su-or-sudo
"::" (expand-file-name candidate
))))
10513 (defun anything-find-many-files (ignore)
10514 (mapc 'find-file
(anything-marked-candidates)))
10516 ;; borrowed from etags.el
10517 ;; (anything-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el")
10518 (defun anything-c-goto-line-with-adjustment (line line-content
)
10521 ;; This constant is 1/2 the initial search window.
10522 ;; There is no sense in making it too small,
10523 ;; since just going around the loop once probably
10524 ;; costs about as much as searching 2000 chars.
10527 pat
(concat (if (eq selective-display t
)
10528 "\\(^\\|\^m\\) *" "^ *") ;allow indent
10529 (regexp-quote line-content
)))
10530 ;; If no char pos was given, try the given line number.
10531 (setq startpos
(progn (anything-goto-line line
) (point)))
10532 (or startpos
(setq startpos
(point-min)))
10533 ;; First see if the tag is right at the specified location.
10534 (goto-char startpos
)
10535 (setq found
(looking-at pat
))
10536 (while (and (not found
)
10538 (goto-char (- startpos offset
))
10541 (re-search-forward pat
(+ startpos offset
) t
)
10542 offset
(* 3 offset
))) ; expand search window
10544 (re-search-forward pat nil t
)
10545 (error "not found")))
10546 ;; Position point at the right place
10547 ;; if the search string matched an extra Ctrl-m at the beginning.
10548 (and (eq selective-display t
)
10551 (beginning-of-line))
10553 (anything-document-attribute 'default-directory
"type . file-line"
10554 "`default-directory' to interpret file.")
10555 (anything-document-attribute 'before-jump-hook
"type . file-line / line"
10556 "Function to call before jumping to the target location.")
10557 (anything-document-attribute 'after-jump-hook
"type . file-line / line"
10558 "Function to call after jumping to the target location.")
10559 (anything-document-attribute 'adjust
"type . file-line"
10560 "Search around line matching line contents.")
10561 (anything-document-attribute 'recenter
"type . file-line / line"
10562 "`recenter' after jumping.")
10563 (anything-document-attribute 'target-file
"type . line"
10564 "Goto line of target-file.")
10567 (defun anything-c-call-interactively (cmd-or-name)
10568 "Execute CMD-OR-NAME as Emacs command.
10569 It is added to `extended-command-history'.
10570 `anything-current-prefix-arg' is used as the command's prefix argument."
10571 (setq extended-command-history
10572 (cons (anything-c-stringify cmd-or-name
)
10573 (delete (anything-c-stringify cmd-or-name
) extended-command-history
)))
10574 (let ((current-prefix-arg anything-current-prefix-arg
)
10575 (cmd (anything-c-symbolify cmd-or-name
)))
10576 (if (stringp (symbol-function cmd
))
10577 (execute-kbd-macro (symbol-function cmd
))
10578 (setq this-command cmd
)
10579 (call-interactively cmd
))))
10582 (defun anything-c-set-variable (var)
10583 "Set value to VAR interactively."
10585 (let ((sym (anything-c-symbolify var
)))
10586 (set sym
(eval-minibuffer (format "Set %s: " var
)
10587 (prin1-to-string (symbol-value sym
))))))
10589 ;; (anything-c-set-variable 'hh)
10593 ;;; Persistent Action Helpers
10596 (defvar anything-match-line-overlay-face nil
)
10597 (defvar anything-match-line-overlay nil
)
10599 (defun anything-match-line-color-current-line (&optional start end buf face rec
)
10600 "Highlight and underline current position"
10601 (let ((args (list (or start
(line-beginning-position))
10602 (or end
(1+ (line-end-position)))
10604 (if (not anything-match-line-overlay
)
10605 (setq anything-match-line-overlay
(apply 'make-overlay args
))
10606 (apply 'move-overlay anything-match-line-overlay args
)))
10607 (overlay-put anything-match-line-overlay
10608 'face
(or face anything-match-line-overlay-face
))
10613 (defalias 'anything-persistent-highlight-point
'anything-match-line-color-current-line
)
10616 (setq anything-match-line-overlay-face
'anything-overlay-line-face
)
10618 (defun anything-match-line-cleanup ()
10619 (when anything-match-line-overlay
10620 (delete-overlay anything-match-line-overlay
)
10621 (setq anything-match-line-overlay nil
)))
10623 (defun anything-match-line-update ()
10624 (when anything-match-line-overlay
10625 (delete-overlay anything-match-line-overlay
)
10626 (anything-match-line-color-current-line)))
10628 (add-hook 'anything-cleanup-hook
'anything-match-line-cleanup
)
10629 (add-hook 'anything-after-persistent-action-hook
'anything-match-line-update
)
10632 ;;; Actions Transformers
10636 (defun anything-c-transform-file-load-el (actions candidate
)
10637 "Add action to load the file CANDIDATE if it is an emacs lisp
10638 file. Else return ACTIONS unmodified."
10639 (if (member (file-name-extension candidate
) '("el" "elc"))
10640 (append actions
'(("Load Emacs Lisp File" . load-file
)))
10643 (defun anything-c-transform-file-browse-url (actions candidate
)
10644 "Add an action to browse the file CANDIDATE if it in a html
10645 file or URL. Else return ACTIONS unmodified."
10646 (let ((browse-action '("Browse with Browser" . browse-url
)))
10647 (cond ((string-match "^http\\|^ftp" candidate
)
10648 (cons browse-action actions
))
10649 ((string-match "\\.html?$" candidate
)
10650 (append actions
(list browse-action
)))
10654 (defun anything-c-transform-function-call-interactively (actions candidate
)
10655 "Add an action to call the function CANDIDATE interactively if
10656 it is a command. Else return ACTIONS unmodified."
10657 (if (commandp (intern-soft candidate
))
10658 (append actions
'(("Call Interactively"
10660 anything-c-call-interactively
)))
10664 (defun anything-c-transform-sexp-eval-command-sexp (actions candidate
)
10665 "If CANDIDATE's `car' is a command, then add an action to
10666 evaluate it and put it onto the `command-history'."
10667 (if (commandp (car (read candidate
)))
10668 ;; Make it first entry
10669 (cons '("Eval and put onto command-history" .
10671 (let ((sym (read sexp
)))
10673 (setq command-history
10674 (cons sym command-history
)))))
10679 ;;; Candidate Transformers
10683 (defun anything-c-skip-boring-buffers (buffers)
10684 (anything-c-skip-entries buffers anything-c-boring-buffer-regexp
))
10686 (defun anything-c-skip-current-buffer (buffers)
10687 (if anything-allow-skipping-current-buffer
10688 (remove (buffer-name anything-current-buffer
) buffers
)
10691 (defun anything-c-shadow-boring-buffers (buffers)
10692 "Buffers matching `anything-c-boring-buffer-regexp' will be
10693 displayed with the `file-name-shadow' face if available."
10694 (anything-c-shadow-entries buffers anything-c-boring-buffer-regexp
))
10696 (defvar anything-c-buffer-display-string-functions
10697 '(anything-c-buffer-display-string--compilation
10698 anything-c-buffer-display-string--shell
10699 anything-c-buffer-display-string--eshell
)
10700 "Functions to setup display string for buffer.
10702 Function has one argument, buffer name.
10703 If it returns string, use it.
10704 If it returns nil, display buffer name.
10705 See `anything-c-buffer-display-string--compilation' for example.")
10707 (defun anything-c-transform-buffer-display-string (buffers)
10708 "Setup display string for buffer candidates
10709 using `anything-c-buffer-display-string-functions'."
10710 (loop for buf in buffers
10714 for disp
= (progn (set-buffer buf
)
10715 (run-hook-with-args-until-success
10716 'anything-c-buffer-display-string-functions buf
))
10717 collect
(if disp
(cons disp buf
) buf
)))
10719 (defun anything-c-buffer-display-string--compilation (buf)
10720 (anything-aif (car compilation-arguments
)
10721 (format "%s: %s [%s]" buf it default-directory
)))
10723 (defun anything-c-buffer-display-string--eshell (buf)
10724 (declare (special eshell-history-ring
))
10725 (when (eq major-mode
'eshell-mode
)
10726 (format "%s: %s [%s]" buf
10727 (ignore-errors (ring-ref eshell-history-ring
0))
10728 default-directory
)))
10730 (defun anything-c-buffer-display-string--shell (buf)
10731 (when (eq major-mode
'shell-mode
)
10732 (format "%s: %s [%s]" buf
10733 (ignore-errors (ring-ref comint-input-ring
0))
10734 default-directory
)))
10737 (defun anything-c-shadow-boring-files (files)
10738 "Files matching `anything-c-boring-file-regexp' will be
10739 displayed with the `file-name-shadow' face if available."
10740 (anything-c-shadow-entries files anything-c-boring-file-regexp
))
10742 (defun anything-c-skip-boring-files (files)
10743 "Files matching `anything-c-boring-file-regexp' will be skipped."
10744 (anything-c-skip-entries files anything-c-boring-file-regexp
))
10745 ;; (anything-c-skip-boring-files '("README" "/src/.svn/hoge"))
10747 (defun anything-c-skip-current-file (files)
10748 "Current file will be skipped."
10749 (remove (buffer-file-name anything-current-buffer
) files
))
10751 (defun anything-c-w32-pathname-transformer (args)
10752 "Change undesirable features of windows pathnames to ones more acceptable to
10753 other candidate transformers."
10754 (if (eq system-type
'windows-nt
)
10755 (mapcar (lambda (x)
10756 (replace-regexp-in-string "/cygdrive/\\(.\\)" "\\1:" x
))
10757 (mapcar (lambda (y)
10758 (replace-regexp-in-string "\\\\" "/" y
)) args
))
10761 (defun anything-c-shorten-home-path (files)
10762 "Replaces /home/user with ~."
10763 (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows...
10765 (mapcar (lambda (file)
10766 (if (and (stringp file
) (string-match home file
))
10767 (cons (replace-match "~" nil nil file
) file
)
10772 (defun anything-c-mark-interactive-functions (functions)
10773 "Mark interactive functions (commands) with (i) after the function name."
10775 (loop for function in functions
10776 do
(push (cons (concat function
10777 (when (commandp (intern-soft function
)) " (i)"))
10780 finally
(return (nreverse list
)))))
10783 ;;; Adaptive Sorting of Candidates
10787 (defvar anything-c-adaptive-done nil
10788 "nil if history information is not yet stored for the current
10791 (defvar anything-c-adaptive-history nil
10792 "Contains the stored history information.
10793 Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")
10795 (defadvice anything-initial-setup
(before anything-c-adaptive-initialize activate
)
10796 "Reset `anything-c-adaptive-done' when anything is started."
10797 (when anything-c-use-adaptative-sorting
10798 (setq anything-c-adaptive-done nil
)))
10800 (defadvice anything-exit-minibuffer
(before anything-c-adaptive-exit-minibuffer activate
)
10801 "Store history information when action is executed on selected candidate."
10802 (when anything-c-use-adaptative-sorting
10803 (anything-c-adaptive-store-selection)))
10805 (defadvice anything-select-action
(before anything-c-adaptive-select-action activate
)
10806 "Store history information when the user goes to the action buffer."
10807 (when anything-c-use-adaptative-sorting
10808 (anything-c-adaptive-store-selection)))
10810 (defun anything-c-source-use-adaptative-p (&optional source-name
)
10811 "Return current source only if it use adaptative history, nil otherwise."
10812 (when anything-c-use-adaptative-sorting
10813 (let* ((source (or source-name
(anything-get-current-source)))
10814 (adapt-source (or (assoc-default 'filtered-candidate-transformer
10815 (assoc (assoc-default 'type source
)
10816 anything-type-attributes
))
10817 (assoc-default 'candidate-transformer
10818 (assoc (assoc-default 'type source
)
10819 anything-type-attributes
))
10820 (assoc-default 'filtered-candidate-transformer source
)
10821 (assoc-default 'candidate-transformer source
))))
10822 (if (listp adapt-source
)
10823 (when (member 'anything-c-adaptive-sort adapt-source
) source
)
10824 (when (eq adapt-source
'anything-c-adaptive-sort
) source
)))))
10826 (defun anything-c-adaptive-store-selection ()
10827 "Store history information for the selected candidate."
10828 (unless anything-c-adaptive-done
10829 (setq anything-c-adaptive-done t
)
10830 (let ((source (anything-c-source-use-adaptative-p)))
10832 (let* ((source-name (or (assoc-default 'type source
)
10833 (assoc-default 'name source
)))
10834 (source-info (or (assoc source-name anything-c-adaptive-history
)
10836 (push (list source-name
) anything-c-adaptive-history
)
10837 (car anything-c-adaptive-history
))))
10838 (selection (anything-get-selection))
10839 (selection-info (progn
10840 (setcdr source-info
10842 (let ((found (assoc selection
(cdr source-info
))))
10847 ;; move entry to the beginning of the
10848 ;; list, so that it doesn't get
10849 ;; trimmed when the history is
10851 (setcdr source-info
10852 (delete found
(cdr source-info
)))
10854 (cdr source-info
)))
10855 (cadr source-info
)))
10856 (pattern-info (progn
10857 (setcdr selection-info
10859 (let ((found (assoc anything-pattern
(cdr selection-info
))))
10862 (cons anything-pattern
0)
10864 ;; move entry to the beginning of the
10865 ;; list, so if two patterns used the
10866 ;; same number of times then the one
10867 ;; used last appears first in the list
10868 (setcdr selection-info
10869 (delete found
(cdr selection-info
)))
10871 (cdr selection-info
)))
10872 (cadr selection-info
))))
10874 ;; increase usage count
10875 (setcdr pattern-info
(1+ (cdr pattern-info
)))
10877 ;; truncate history if needed
10878 (if (> (length (cdr selection-info
)) anything-c-adaptive-history-length
)
10879 (setcdr selection-info
10880 (subseq (cdr selection-info
) 0 anything-c-adaptive-history-length
))))))))
10882 (defun anything-c-adaptative-maybe-load-history ()
10883 (when (and anything-c-use-adaptative-sorting
10884 (file-readable-p anything-c-adaptive-history-file
))
10885 (load-file anything-c-adaptive-history-file
)))
10887 (add-hook 'emacs-startup-hook
'anything-c-adaptative-maybe-load-history
)
10888 (add-hook 'kill-emacs-hook
'anything-c-adaptive-save-history
)
10890 (defun anything-c-adaptive-save-history (&optional arg
)
10891 "Save history information to file given by `anything-c-adaptive-history-file'."
10893 (when anything-c-use-adaptative-sorting
10896 ";; -*- mode: emacs-lisp -*-\n"
10897 ";; History entries used for anything adaptive display.\n")
10898 (prin1 `(setq anything-c-adaptive-history
',anything-c-adaptive-history
)
10901 (write-region (point-min) (point-max) anything-c-adaptive-history-file nil
10902 (unless arg
'quiet
)))))
10904 (defun anything-c-adaptive-sort (candidates source
)
10905 "Sort the CANDIDATES for SOURCE by usage frequency.
10906 This is a filtered candidate transformer you can use for the
10907 attribute `filtered-candidate-transformer' of a source in
10908 `anything-sources' or a type in `anything-type-attributes'."
10909 (let* ((source-name (or (assoc-default 'type source
)
10910 (assoc-default 'name source
)))
10911 (source-info (assoc source-name anything-c-adaptive-history
)))
10914 ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT)
10916 (mapcar (lambda (candidate-info)
10918 (dolist (pattern-info (cdr candidate-info
))
10919 (if (not (equal (car pattern-info
)
10921 (incf count
(cdr pattern-info
))
10923 ;; if current pattern is equal to the previously
10924 ;; used one then this candidate has priority
10925 ;; (that's why its count is boosted by 10000) and
10926 ;; it only has to compete with other candidates
10927 ;; which were also selected with the same pattern
10928 (setq count
(+ 10000 (cdr pattern-info
)))
10930 (cons (car candidate-info
) count
)))
10931 (cdr source-info
)))
10933 (if (and usage
(consp usage
))
10934 ;; sort the list in descending order, so candidates with highest
10935 ;; priorty come first
10937 (setq usage
(sort usage
(lambda (first second
)
10938 (> (cdr first
) (cdr second
)))))
10940 ;; put those candidates first which have the highest usage count
10941 (dolist (info usage
)
10942 (when (member* (car info
) candidates
10943 :test
'anything-c-adaptive-compare
)
10944 (push (car info
) sorted
)
10945 (setq candidates
(remove* (car info
) candidates
10946 :test
'anything-c-adaptive-compare
))))
10948 ;; and append the rest
10949 (append (reverse sorted
) candidates nil
))
10950 (message "Your `%s' is maybe corrupted or too old, \
10951 you should reinitialize it with `anything-c-reset-adaptative-history'"
10952 anything-c-adaptive-history-file
)
10955 ;; if there is no information stored for this source then do nothing
10959 (defun anything-c-reset-adaptative-history ()
10960 "Delete all `anything-c-adaptive-history' and his file.
10961 Useful when you have a old or corrupted `anything-c-adaptive-history-file'."
10963 (when (y-or-n-p "Really delete all your `anything-c-adaptive-history'? ")
10964 (setq anything-c-adaptive-history nil
)
10965 (delete-file anything-c-adaptive-history-file
)))
10967 (defun anything-c-adaptive-compare (x y
)
10968 "Compare candidates X and Y taking into account that the
10969 candidate can be in (DISPLAY . REAL) format."
10970 (equal (if (listp x
)
10982 (defvar anything-outline-goto-near-line-flag t
)
10983 (defvar anything-outline-using nil
)
10984 (defun anything-after-update-hook--outline ()
10985 (if (and (eq anything-outline-using t
)
10986 (eq anything-outline-goto-near-line-flag t
))
10987 (anything-outline-goto-near-line)))
10988 (add-hook 'anything-after-update-hook
'anything-after-update-hook--outline
)
10990 (defun anything-outline-goto-near-line ()
10991 (with-anything-window
10992 ;; TODO need consideration whether to update position by every input.
10993 (when t
; (equal anything-pattern "")
10994 (anything-goto-line 2)
10995 (let ((lineno (with-anything-current-buffer
10996 (line-number-at-pos (car anything-current-position
)))))
10998 (while (<= (progn (skip-chars-forward " ")
10999 (or (number-at-point) lineno
))
11004 (return-from exit
))))
11006 (and (bobp) (forward-line 1))
11007 (and (anything-pos-header-line-p) (forward-line -
2))
11008 (anything-mark-current-line)))))
11015 ;; Plug-in: info-index
11016 (defun* anything-c-info-init
(&optional
(file (anything-attr 'info-file
)))
11018 (unless (anything-candidate-buffer)
11019 (save-window-excursion
11022 (tobuf (anything-candidate-buffer 'global
))
11023 (infobuf (current-buffer))
11025 (dolist (node (or (anything-attr 'index-nodes
) (Info-index-nodes)))
11026 (Info-goto-node node
)
11027 (goto-char (point-min))
11028 (while (search-forward "\n* " nil t
)
11029 (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t
)
11030 '(save-current-buffer (buffer-substring-no-properties (point-at-bol) (point-at-eol)) result
)
11031 (setq s
(point-at-bol)
11033 (with-current-buffer tobuf
11034 (insert-buffer-substring infobuf s e
)
11035 (insert "\n"))))))))))
11037 (defun anything-c-info-goto (node-line)
11038 (Info-goto-node (car node-line
))
11039 (anything-goto-line (cdr node-line
)))
11041 (defun anything-c-info-display-to-real (line)
11043 ;; This regexp is stolen from Info-apropos-matches
11044 "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line
)
11045 (cons (format "(%s)%s" (anything-attr 'info-file
) (match-string 2 line
))
11046 (string-to-number (or (match-string 3 line
) "1")))))
11048 (defun anything-c-make-info-source (source file
)
11050 (name .
,(concat "Info Index: " file
))
11051 (info-file .
,file
)
11052 (init . anything-c-info-init
)
11053 (display-to-real . anything-c-info-display-to-real
)
11054 (get-line . buffer-substring
)
11055 (candidates-in-buffer)
11056 (action ("Goto node" . anything-c-info-goto
))))
11058 (defun anything-compile-source--info-index (source)
11059 (anything-aif (anything-interpret-value (assoc-default 'info-index source
))
11060 (anything-c-make-info-source source it
)
11062 (add-to-list 'anything-compile-source-functions
'anything-compile-source--info-index
)
11064 (anything-document-attribute 'info-index
"info-index plugin"
11065 "Create a source of info index very easily.
11067 ex. (defvar anything-c-source-info-wget '((info-index . \"wget\"))")
11069 (anything-document-attribute 'index-nodes
"info-index plugin (optional)"
11070 "Index nodes of info file.
11072 If it is omitted, `Info-index-nodes' is used to collect index nodes.
11073 Some info files are missing index specification.
11075 ex. See `anything-c-source-info-screen'.")
11077 ;; Plug-in: candidates-file
11078 (defun anything-compile-source--candidates-file (source)
11079 (if (assoc-default 'candidates-file source
)
11080 `((init anything-p-candidats-file-init
11081 ,@(let ((orig-init (assoc-default 'init source
)))
11082 (cond ((null orig-init
) nil
)
11083 ((functionp orig-init
) (list orig-init
))
11085 (candidates-in-buffer)
11088 (add-to-list 'anything-compile-source-functions
'anything-compile-source--candidates-file
)
11090 (defun anything-p-candidats-file-init ()
11091 (destructuring-bind (file &optional updating
)
11092 (anything-mklist (anything-attr 'candidates-file
))
11093 (setq file
(anything-interpret-value file
))
11094 (with-current-buffer (anything-candidate-buffer (find-file-noselect file
))
11096 (buffer-disable-undo)
11097 (font-lock-mode -
1)
11098 (auto-revert-mode 1)))))
11100 (anything-document-attribute 'candidates-file
"candidates-file plugin"
11101 "Use a file as the candidates buffer.
11103 1st argument is a filename, string or function name or variable name.
11104 If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.")
11106 ;; Plug-in: headline
11107 (defun anything-compile-source--anything-headline (source)
11108 (if (assoc-default 'headline source
)
11109 (append '((init . anything-headline-init
)
11110 (get-line . buffer-substring
)
11113 '((candidates-in-buffer)
11114 (persistent-help .
"Show this line")))
11116 (add-to-list 'anything-compile-source-functions
'anything-compile-source--anything-headline
)
11118 (defun anything-headline-init ()
11119 (when (and (anything-current-buffer-is-modified)
11120 (with-anything-current-buffer
11121 (eval (or (anything-attr 'condition
) t
))))
11122 (anything-headline-make-candidate-buffer
11123 (anything-interpret-value (anything-attr 'headline
))
11124 (anything-interpret-value (anything-attr 'subexp
)))))
11126 (anything-document-attribute 'headline
"Headline plug-in"
11127 "Regexp string for anything-headline to scan.")
11128 (anything-document-attribute 'condition
"Headline plug-in"
11129 "A sexp representing the condition to use anything-headline.")
11130 (anything-document-attribute 'subexp
"Headline plug-in"
11131 "Display (match-string-no-properties subexp).")
11133 ;; Le Wang: Note on how `anything-head-line-get-candidates' works with a list
11136 ;; 1. Create list of ((title . start-of-match) . hiearchy)
11137 ;; 2. Sort this list by start-of-match.
11138 ;; 3. Go through sorted list and return titles that reflect full hiearchy.
11140 ;; It's quite brilliantly written.
11144 (defun anything-headline-get-candidates (regexp subexp
)
11145 (with-anything-current-buffer
11147 (goto-char (point-min))
11148 (if (functionp regexp
) (setq regexp
(funcall regexp
)))
11149 (let (hierarchy curhead
)
11151 (if (numberp subexp
)
11152 (cons (match-string-no-properties subexp
) (match-beginning subexp
))
11153 (cons (buffer-substring (point-at-bol) (point-at-eol))
11155 (hierarchies (headlines)
11156 (1+ (loop for
(_ . hierarchy
) in headlines
11157 maximize hierarchy
)))
11159 (loop for i from
0 to hierarchy
11160 collecting
(aref curhead i
)))
11161 (arrange (headlines)
11162 (unless (null headlines
) ; FIX headlines empty bug!
11163 (loop with curhead
= (make-vector (hierarchies headlines
) "")
11164 for
((str . pt
) . hierarchy
) in headlines
11165 do
(aset curhead hierarchy str
)
11168 (format "H%d:%s" (1+ hierarchy
)
11169 (mapconcat 'identity
(vector-0-n curhead hierarchy
) " / "))
11174 (loop for re in regexp
11175 for hierarchy from
0
11176 do
(goto-char (point-min))
11179 while
(re-search-forward re nil t
)
11180 collect
(cons (matched) hierarchy
)))
11181 (lambda (a b
) (> (cdar b
) (cdar a
)))))
11182 (loop while
(re-search-forward regexp nil t
)
11183 collect
(matched))))))))
11186 (defun anything-headline-make-candidate-buffer (regexp subexp
)
11187 (with-current-buffer (anything-candidate-buffer 'local
)
11188 (loop for
(content . pos
) in
(anything-headline-get-candidates regexp subexp
)
11191 (with-anything-current-buffer
11192 (line-number-at-pos pos
))
11195 (defun anything-headline-goto-position (pos recenter
)
11198 (set-window-start (get-buffer-window anything-current-buffer
) (point))))
11201 ;; Plug-in: persistent-help
11202 (defun anything-compile-source--persistent-help (source)
11203 (append source
'((header-line . anything-persistent-help-string
))))
11204 (add-to-list 'anything-compile-source-functions
'anything-compile-source--persistent-help
)
11206 (defun anything-persistent-help-string ()
11207 (substitute-command-keys
11208 (concat "\\<anything-map>\\[anything-execute-persistent-action]: "
11209 (or (anything-interpret-value (anything-attr 'persistent-help
))
11210 (anything-aif (or (assoc-default 'persistent-action
11211 (anything-get-current-source))
11212 (assoc-default 'action
11213 (anything-get-current-source)))
11214 (cond ((symbolp it
) (symbol-name it
))
11215 ((listp it
) (or (ignore-errors (caar it
)) ""))))
11217 " (keeping session)")))
11219 (anything-document-attribute 'persistent-help
"persistent-help plug-in"
11220 "A string to explain persistent-action of this source.
11221 It also accepts a function or a variable name.")
11223 ;;; (anything '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST"))))
11225 ;; Plug-in: Type customize
11226 (defun anything-c-uniq-list (lst)
11227 "Like `remove-duplicates' in CL.
11228 But cut deeper duplicates and test by `equal'. "
11229 (reverse (remove-duplicates (reverse lst
) :test
'equal
)))
11230 (defvar anything-additional-type-attributes nil
)
11231 (defun anything-c-arrange-type-attribute (type spec
)
11232 "Override type attributes by `define-anything-type-attribute'.
11234 The SPEC is like source. The symbol `REST' is replaced with original attribute value.
11236 Example: Set `play-sound-file' as default action
11237 (anything-c-arrange-type-attribute 'file
11238 '((action (\"Play sound\" . play-sound-file)
11239 REST ;; Rest of actions (find-file, find-file-other-window, ...)
11242 (add-to-list 'anything-additional-type-attributes
11244 (loop with typeattr
= (assoc-default type anything-type-attributes
)
11245 for
(attr . value
) in spec
11248 (anything-c-uniq-list
11249 (loop for v in value
11251 append
(assoc-default attr typeattr
)
11255 collect
(cons attr value
)))))
11256 (put 'anything-c-arrange-type-attribute
'lisp-indent-function
1)
11258 (defun anything-compile-source--type-customize (source)
11259 (anything-aif (assoc-default (assoc-default 'type source
) anything-additional-type-attributes
)
11262 (add-to-list 'anything-compile-source-functions
'anything-compile-source--type-customize t
)
11264 ;; Plug-in: default-action
11265 (defun anything-compile-source--default-action (source)
11266 (anything-aif (assoc-default 'default-action source
)
11267 (append `((action ,it
,@(remove it
(assoc-default 'action source
))))
11270 (add-to-list 'anything-compile-source-functions
'anything-compile-source--default-action t
)
11271 (anything-document-attribute 'default-action
"default-action plug-in"
11275 ;;; Toggle anything-match-plugin
11278 (defvar anything-mp-initial-highlight-delay nil
)
11281 (defun anything-c-toggle-match-plugin ()
11282 "Toggle anything-match-plugin."
11284 (let ((anything-match-plugin-enabled
11285 (member 'anything-compile-source--match-plugin
11286 anything-compile-source-functions
)))
11287 (flet ((disable-match-plugin ()
11288 (setq anything-compile-source-functions
11289 (delq 'anything-compile-source--match-plugin
11290 anything-compile-source-functions
))
11291 (setq anything-mp-initial-highlight-delay
11292 anything-mp-highlight-delay
)
11293 (setq anything-mp-highlight-delay nil
))
11294 (enable-match-plugin ()
11295 (require 'anything-match-plugin
)
11296 (unless anything-mp-initial-highlight-delay
11297 (setq anything-mp-initial-highlight-delay
11298 anything-mp-highlight-delay
))
11299 (setq anything-compile-source-functions
11300 (cons 'anything-compile-source--match-plugin
11301 anything-compile-source-functions
))
11302 (unless anything-mp-highlight-delay
11303 (setq anything-mp-highlight-delay
11304 anything-mp-initial-highlight-delay
))))
11305 (if anything-match-plugin-enabled
11306 (when (y-or-n-p "Really disable match-plugin? ")
11307 (disable-match-plugin)
11308 (message "Anything-match-plugin disabled"))
11309 (when (y-or-n-p "Really enable match-plugin? ")
11310 (enable-match-plugin)
11311 (message "Anything-match-plugin enabled"))))))
11315 ;;; Type Attributes
11318 (define-anything-type-attribute 'buffer
11320 ("Switch to buffer" . anything-c-switch-to-buffer
)
11321 ,(and (locate-library "popwin") '("Switch to buffer in popup window" . popwin
:popup-buffer
))
11322 ("Switch to buffer other window" . switch-to-buffer-other-window
)
11323 ("Switch to buffer other frame" . switch-to-buffer-other-frame
)
11324 ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . anything-find-buffer-on-elscreen
))
11325 ("Query replace regexp" . anything-c-buffer-query-replace-regexp
)
11326 ("Query replace" . anything-c-buffer-query-replace
)
11327 ("View buffer" . view-buffer
)
11328 ("Display buffer" . display-buffer
)
11329 ("Grep buffers (C-u grep all buffers)" . anything-c-grep-buffers
)
11330 ("Revert buffer(s)" . anything-revert-marked-buffers
)
11331 ("Insert buffer" . insert-buffer
)
11332 ("Kill buffer(s)" . anything-kill-marked-buffers
)
11333 ("Diff with file" . diff-buffer-with-file
)
11334 ("Ediff Marked buffers" . anything-ediff-marked-buffers
)
11335 ("Ediff Merge marked buffers" .
(lambda (candidate)
11336 (anything-ediff-marked-buffers candidate t
))))
11337 (persistent-help .
"Show this buffer")
11338 (candidate-transformer anything-c-skip-current-buffer
11339 anything-c-skip-boring-buffers
11340 anything-c-transform-buffer-display-string
))
11341 "Buffer or buffer name.")
11343 (define-anything-type-attribute 'file
11345 ("Find file" . anything-find-many-files
)
11346 ,(and (locate-library "popwin") '("Find file in popup window" . popwin
:find-file
))
11347 ("Find file as root" . anything-find-file-as-root
)
11348 ("Find file other window" . find-file-other-window
)
11349 ("Find file other frame" . find-file-other-frame
)
11350 ("Open dired in file's directory" . anything-c-open-dired
)
11351 ("Grep File(s) `C-u recurse'" . anything-find-files-grep
)
11352 ("Zgrep File(s) `C-u Recurse'" . anything-ff-zgrep
)
11353 ("Pdfgrep File(s)" . anything-ff-pdfgrep
)
11354 ("Checksum File" . anything-ff-checksum
)
11355 ("Ediff File" . anything-find-files-ediff-files
)
11356 ("Ediff Merge File" . anything-find-files-ediff-merge-files
)
11357 ("View file" . view-file
)
11358 ("Insert file" . insert-file
)
11359 ("Delete file(s)" . anything-delete-marked-files
)
11360 ("Open file externally (C-u to choose)" . anything-c-open-file-externally
)
11361 ("Open file with default tool" . anything-c-open-file-with-default-tool
)
11362 ("Find file in hex dump" . hexl-find-file
))
11363 (persistent-help .
"Show this file")
11364 (action-transformer anything-c-transform-file-load-el
11365 anything-c-transform-file-browse-url
)
11366 (candidate-transformer anything-c-w32-pathname-transformer
11367 anything-c-skip-current-file
11368 anything-c-skip-boring-files
11369 anything-c-shorten-home-path
))
11372 (let ((actions '(("Describe command" . describe-function
)
11373 ("Add command to kill ring" . anything-c-kill-new
)
11374 ("Go to command's definition" . find-function
)
11375 ("Debug on entry" . debug-on-entry
)
11376 ("Cancel debug on entry" . cancel-debug-on-entry
)
11377 ("Trace function" . trace-function
)
11378 ("Trace function (background)" . trace-function-background
)
11379 ("Untrace function" . untrace-function
))))
11380 (define-anything-type-attribute 'command
11381 `((action ("Call interactively" . anything-c-call-interactively
)
11383 ;; Sort commands according to their usage count.
11384 ;(filtered-candidate-transformer . anything-c-adaptive-sort)
11385 (coerce . anything-c-symbolify
)
11386 (persistent-action . describe-function
))
11387 "Command. (string or symbol)")
11389 (define-anything-type-attribute 'function
11390 `((action .
,actions
)
11391 (action-transformer anything-c-transform-function-call-interactively
)
11392 (candidate-transformer anything-c-mark-interactive-functions
)
11393 (coerce . anything-c-symbolify
))
11394 "Function. (string or symbol)"))
11396 (define-anything-type-attribute 'variable
11397 '((action ("Describe variable" . describe-variable
)
11398 ("Add variable to kill ring" . anything-c-kill-new
)
11399 ("Go to variable's definition" . find-variable
)
11400 ("Set variable" . anything-c-set-variable
))
11401 (coerce . anything-c-symbolify
))
11404 (define-anything-type-attribute 'sexp
11405 '((action ("Eval s-expression" .
(lambda (c) (eval (read c
))))
11406 ("Add s-expression to kill ring" . kill-new
))
11407 (action-transformer anything-c-transform-sexp-eval-command-sexp
))
11408 "String representing S-Expressions.")
11410 (define-anything-type-attribute 'bookmark
11411 `((coerce . anything-bookmark-get-bookmark-from-name
)
11413 ("Jump to bookmark" .
(lambda (bookmark)
11414 (let ((current-prefix-arg anything-current-prefix-arg
))
11415 (bookmark-jump bookmark
))
11416 (anything-update)))
11417 ("Jump to BM other window" .
(lambda (bookmark)
11418 (bookmark-jump-other-window bookmark
)
11419 (anything-update)))
11420 ("Bookmark edit annotation" . bookmark-edit-annotation
)
11421 ("Bookmark show annotation" . bookmark-show-annotation
)
11422 ("Delete bookmark(s)" . anything-delete-marked-bookmarks
)
11423 ,@(and (locate-library "bookmark-extensions")
11424 `(("Edit Bookmark" . bmkext-edit-bookmark
)))
11425 ("Rename bookmark" . bookmark-rename
)
11426 ("Relocate bookmark" . bookmark-relocate
)))
11429 (define-anything-type-attribute 'line
11430 '((display-to-real . anything-c-display-to-real-line
)
11431 (action ("Go to Line" . anything-c-action-line-goto
)))
11432 "LINENO:CONTENT string, eg. \" 16:foo\".
11434 Optional `target-file' attribute is a name of target file.
11436 Optional `before-jump-hook' attribute is a function with no
11437 arguments which is called before jumping to position.
11439 Optional `after-jump-hook' attribute is a function with no
11440 arguments which is called after jumping to position.
11442 If `adjust' attribute is specified, searches the line whose
11443 content is CONTENT near the LINENO.
11445 If `recenter' attribute is specified, the line is displayed at
11446 the center of window, otherwise at the top of window.
11449 (define-anything-type-attribute 'file-line
11450 `((filtered-candidate-transformer anything-c-filtered-candidate-transformer-file-line
)
11452 (action ("Go to" . anything-c-action-file-line-goto
)))
11453 "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\".
11455 Optional `default-directory' attribute is a default-directory
11456 FILENAME is interpreted.
11458 Optional `before-jump-hook' attribute is a function with no
11459 arguments which is called before jumping to position.
11461 Optional `after-jump-hook' attribute is a function with no
11462 arguments which is called after jumping to position.
11464 If `adjust' attribute is specified, searches the line whose
11465 content is CONTENT near the LINENO.
11467 If `recenter' attribute is specified, the line is displayed at
11468 the center of window, otherwise at the top of window.
11471 (define-anything-type-attribute 'timer
11472 '((real-to-display . anything-c-timer-real-to-display
)
11473 (action ("Cancel Timer" . cancel-timer
)
11474 ("Describe Function" .
(lambda (tm) (describe-function (timer--function tm
))))
11475 ("Find Function" .
(lambda (tm) (find-function (timer--function tm
)))))
11476 (persistent-action .
(lambda (tm) (describe-function (timer--function tm
))))
11477 (persistent-help .
"Describe Function"))
11481 ;;; Default `anything-sources'
11482 ;; Setting `anything-sources' is DEPRECATED, but it seems that newbies
11483 ;; tend to invoke M-x anything directly. So I offer default setting.
11484 (setq anything-sources
11485 '(anything-c-source-buffers-list
11486 anything-c-source-recentf
11487 anything-c-source-files-in-current-dir
+))
11490 ;;; Preconfigured Anything
11494 (defun anything-mini ()
11495 "Preconfigured `anything' lightweight version \(buffer -> recentf\)."
11497 (anything-other-buffer '(anything-c-source-buffers-list
11498 anything-c-source-recentf
11499 anything-c-source-buffer-not-found
)
11500 "*anything mini*"))
11502 (defun anything-for-files ()
11503 "Preconfigured `anything' for opening files.
11504 ffap -> recentf -> buffer -> bookmark -> file-cache -> files-in-current-dir -> locate."
11506 (anything-other-buffer anything-for-files-prefered-list
"*anything for files*"))
11509 (defun anything-recentf ()
11510 "Preconfigured `anything' for `recentf'."
11512 (anything-other-buffer 'anything-c-source-recentf
"*anything recentf*"))
11515 (defun anything-info-at-point (arg)
11516 "Preconfigured `anything' for searching info at point.
11517 With a prefix-arg insert symbol at point."
11519 (let ((anything-c-google-suggest-default-function
11520 'anything-c-google-suggest-emacs-lisp
))
11521 (anything :sources
'(anything-c-source-info-elisp
11522 anything-c-source-info-cl
11523 anything-c-source-info-pages
11524 anything-c-source-google-suggest
)
11525 :input
(and arg
(thing-at-point 'symbol
))
11526 :buffer
"*anything info*")))
11529 (defun anything-info-emacs ()
11530 "Preconfigured anything for Emacs manual index."
11532 (anything-other-buffer 'anything-c-source-info-emacs
"*info emacs*"))
11535 (defun anything-show-kill-ring ()
11536 "Preconfigured `anything' for `kill-ring'.
11537 It is drop-in replacement of `yank-pop'.
11538 You may bind this command to M-y.
11539 First call open the kill-ring browser, next calls move to next line."
11541 (let ((buf "*anything kill-ring*"))
11542 (if (get-buffer-window buf
)
11543 (with-anything-window
11544 (if (eq (overlay-end anything-selection-overlay
) (point-max))
11545 (anything-beginning-of-buffer)
11546 (anything-next-line)))
11547 (anything-other-buffer 'anything-c-source-kill-ring buf
))))
11550 (defun anything-minibuffer-history ()
11551 "Preconfigured `anything' for `minibuffer-history'."
11553 (let ((enable-recursive-minibuffers t
))
11554 (anything-other-buffer 'anything-c-source-minibuffer-history
11555 "*anything minibuffer-history*")))
11558 (defun anything-gentoo ()
11559 "Preconfigured `anything' for gentoo linux."
11561 (anything-other-buffer '(anything-c-source-gentoo
11562 anything-c-source-use-flags
)
11563 "*anything gentoo*"))
11566 (defun anything-imenu ()
11567 "Preconfigured `anything' for `imenu'."
11569 (anything :sources
'anything-c-source-imenu
11570 :buffer
"*anything imenu*"))
11573 (defun anything-google-suggest ()
11574 "Preconfigured `anything' for google search with google suggest."
11576 (anything-other-buffer 'anything-c-source-google-suggest
"*anything google*"))
11579 (defun anything-yahoo-suggest ()
11580 "Preconfigured `anything' for Yahoo searching with Yahoo suggest."
11582 (anything-other-buffer 'anything-c-source-yahoo-suggest
"*anything yahoo*"))
11584 ;;; Converted from anything-show-*-only
11586 (defun anything-for-buffers ()
11587 "Preconfigured `anything' for buffer."
11589 (anything-other-buffer 'anything-c-source-buffers
"*anything for buffers*"))
11592 (defun anything-buffers-list ()
11593 "Enhanced preconfigured `anything' for buffer."
11595 (anything :sources
'(anything-c-source-buffers-list
11596 anything-c-source-buffer-not-found
)
11597 :buffer
"*anything buffers*" :keymap anything-c-buffer-map
))
11600 (defun anything-bbdb ()
11601 "Preconfigured `anything' for BBDB.
11605 http://bbdb.sourceforge.net/"
11607 (anything-other-buffer 'anything-c-source-bbdb
"*anything bbdb*"))
11610 (defun anything-locate (arg)
11611 "Preconfigured `anything' for Locate.
11612 Note: you can add locate options after entering pattern.
11613 See 'man locate' for valid options.
11615 You can specify a specific database with prefix argument ARG \(C-u\).
11616 Many databases can be used: navigate and mark them.
11617 See also `anything-locate-with-db'.
11619 To create a user specific db, use
11620 \"updatedb -l 0 -o db_path -U directory\".
11621 Where db_path is a filename matched by
11622 `anything-locate-db-file-regexp'."
11624 (anything-locate-1 arg
))
11627 (defun anything-w3m-bookmarks ()
11628 "Preconfigured `anything' for w3m bookmark.
11630 Needs w3m and emacs-w3m.
11632 http://w3m.sourceforge.net/
11633 http://emacs-w3m.namazu.org/"
11635 (anything-other-buffer 'anything-c-source-w3m-bookmarks
11636 "*anything w3m bookmarks*"))
11639 (defun anything-firefox-bookmarks ()
11640 "Preconfigured `anything' for firefox bookmark.
11641 You will have to enable html bookmarks in firefox:
11642 open about:config in firefox and double click on this line to enable value \
11645 user_pref(\"browser.bookmarks.autoExportHTML\", false);
11647 You should have now:
11649 user_pref(\"browser.bookmarks.autoExportHTML\", true);
11651 After closing firefox, you will be able to browse you bookmarks.
11654 (anything-other-buffer 'anything-c-source-firefox-bookmarks
11655 "*Anything Firefox*"))
11658 (defun anything-colors ()
11659 "Preconfigured `anything' for color."
11661 (anything-other-buffer
11662 '(anything-c-source-colors anything-c-source-customize-face
)
11663 "*anything colors*"))
11666 (defun anything-bookmarks ()
11667 "Preconfigured `anything' for bookmarks."
11669 (anything-other-buffer 'anything-c-source-bookmarks
"*anything bookmarks*"))
11672 (defun anything-c-pp-bookmarks ()
11673 "Preconfigured `anything' for bookmarks (pretty-printed)."
11675 (anything-other-buffer '(anything-c-source-bookmarks-local
11676 anything-c-source-bookmarks-su
11677 anything-c-source-bookmarks-ssh
)
11678 "*anything pp bookmarks*"))
11681 (defun anything-c-insert-latex-math ()
11682 "Preconfigured anything for latex math symbols completion."
11684 (anything-other-buffer 'anything-c-source-latex-math
"*anything latex*"))
11687 (defun anything-register ()
11688 "Preconfigured `anything' for Emacs registers."
11690 (anything-other-buffer 'anything-c-source-register
"*anything register*"))
11693 (defun anything-man-woman ()
11694 "Preconfigured `anything' for Man and Woman pages."
11696 (anything-other-buffer 'anything-c-source-man-pages
"*Anything man woman*"))
11699 (defun anything-org-keywords ()
11700 "Preconfigured `anything' for org keywords."
11702 (anything-other-buffer 'anything-c-source-org-keywords
"*org keywords*"))
11705 (defun anything-emms ()
11706 "Preconfigured `anything' for emms sources."
11708 (anything :sources
'(anything-c-source-emms-streams
11709 anything-c-source-emms-files
11710 anything-c-source-emms-dired
)
11711 :buffer
"*Anything Emms*"))
11714 (defun anything-eev-anchors ()
11715 "Preconfigured `anything' for eev anchors."
11717 (anything-other-buffer 'anything-c-source-eev-anchor
"*Anything eev anchors*"))
11720 (defun anything-bm-list ()
11721 "Preconfigured `anything' for visible bookmarks.
11725 http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el"
11727 (let ((anything-outline-using t
))
11728 (anything-other-buffer 'anything-c-source-bm
"*anything bm list*")))
11731 (defun anything-timers ()
11732 "Preconfigured `anything' for timers."
11734 (anything-other-buffer '(anything-c-source-absolute-time-timers
11735 anything-c-source-idle-time-timers
)
11736 "*anything timers*"))
11739 (defun anything-list-emacs-process ()
11740 "Preconfigured `anything' for emacs process."
11742 (anything-other-buffer 'anything-c-source-emacs-process
"*anything process*"))
11745 (defun anything-occur ()
11746 "Preconfigured Anything for Occur source.
11747 If region is active, search only in region,
11748 otherwise search in whole buffer."
11750 (let ((anything-compile-source-functions
11751 ;; rule out anything-match-plugin because the input is one regexp.
11752 (delq 'anything-compile-source--match-plugin
11753 (copy-sequence anything-compile-source-functions
))))
11754 (anything-other-buffer 'anything-c-source-occur
"*Anything Occur*")))
11757 (defun anything-browse-code ()
11758 "Preconfigured anything to browse code."
11760 (anything :sources
'anything-c-source-browse-code
11761 :buffer
"*anything browse code*"
11762 :default
(thing-at-point 'symbol
)))
11765 (defun anything-org-headlines ()
11766 "Preconfigured anything to show org headlines."
11768 (anything-other-buffer 'anything-c-source-org-headline
"*org headlines*"))
11771 (defun anything-info-gnus ()
11772 "Preconfigured anything to browse Gnus Manual."
11774 (anything-other-buffer 'anything-c-source-info-gnus
"*info Gnus*"))
11777 (defun anything-regexp ()
11778 "Preconfigured anything to build regexps.
11779 `query-replace-regexp' can be run from there against found regexp."
11782 (let ((anything-compile-source-functions
11783 ;; rule out anything-match-plugin because the input is one regexp.
11784 (delq 'anything-compile-source--match-plugin
11785 (copy-sequence anything-compile-source-functions
))))
11786 (when (and (anything-region-active-p)
11787 ;; Don't narrow to region if buffer is already narrowed.
11788 (not (anything-current-buffer-narrowed-p)))
11789 (narrow-to-region (region-beginning) (region-end)))
11790 (anything :sources anything-c-source-regexp
11791 :buffer
"*anything regexp*"
11793 :history
'anything-build-regexp-history
))))
11795 (defun anything-insert-buffer-name ()
11796 "Insert buffer name."
11798 (anything-insert-string
11799 (with-current-buffer anything-current-buffer
11800 (if buffer-file-name
(file-name-nondirectory buffer-file-name
)
11803 (defun anything-insert-symbol ()
11804 "Insert current symbol."
11806 (anything-insert-string
11807 (with-current-buffer anything-current-buffer
11809 (buffer-substring (beginning-of-thing 'symbol
)
11810 (end-of-thing 'symbol
))))))
11812 (defun anything-insert-selection ()
11813 "Insert current selection."
11815 (anything-insert-string
11816 (with-current-buffer anything-current-buffer
11817 (anything-get-selection))))
11819 (defun anything-c-copy-files-async ()
11820 "Preconfigured anything to copy file list FLIST to DEST asynchronously."
11822 (let* ((flist (anything-c-read-file-name
11823 "Copy File async: "
11824 :marked-candidates t
))
11825 (dest (anything-c-read-file-name
11826 "Copy File async To: "
11827 :preselect
(car flist
)
11828 :initial-input
(car anything-ff-history
)
11829 :history
(anything-find-files-history :comp-read nil
))))
11830 (anything-c-copy-async-with-log flist dest
)))
11833 (defun anything-find-files (arg)
11834 "Preconfigured `anything' for anything implementation of `find-file'.
11835 Called with a prefix arg show history if some.
11836 Don't call it from programs, use `anything-find-files-1' instead.
11837 This is the starting point for nearly all actions you can do on files."
11839 (let ((any-input (if (and arg anything-ff-history
)
11840 (anything-find-files-history)
11841 (anything-find-files-initial-input)))
11842 (presel (buffer-file-name (current-buffer))))
11843 (when (and (eq major-mode
'org-agenda-mode
)
11846 (setq any-input
(expand-file-name org-directory
)))
11847 (set-text-properties 0 (length any-input
) nil any-input
)
11849 (anything-find-files-1 any-input
)
11850 (setq any-input
(expand-file-name (anything-c-current-directory)))
11851 (anything-find-files-1
11852 any-input
(if anything-ff-transformer-show-only-basename
11853 (and presel
(anything-c-basename presel
))
11857 (defun anything-write-file ()
11858 "Preconfigured `anything' providing completion for `write-file'."
11860 (let ((anything-mp-highlight-delay nil
))
11861 (anything :sources
'anything-c-source-write-file
11862 :input
(expand-file-name default-directory
)
11863 :prompt
"Write buffer to file: "
11864 :buffer
"*Anything write file*")))
11867 (defun anything-insert-file ()
11868 "Preconfigured `anything' providing completion for `insert-file'."
11870 (let ((anything-mp-highlight-delay nil
))
11871 (anything :sources
'anything-c-source-insert-file
11872 :input
(expand-file-name default-directory
)
11873 :prompt
"Insert file: "
11874 :buffer
"*Anything insert file*")))
11877 (defun anything-dired-rename-file ()
11878 "Preconfigured `anything' to rename files from dired."
11880 (anything-dired-do-action-on-file :action
'rename
))
11883 (defun anything-dired-copy-file ()
11884 "Preconfigured `anything' to copy files from dired."
11886 (anything-dired-do-action-on-file :action
'copy
))
11889 (defun anything-dired-symlink-file ()
11890 "Preconfigured `anything' to symlink files from dired."
11892 (anything-dired-do-action-on-file :action
'symlink
))
11895 (defun anything-dired-hardlink-file ()
11896 "Preconfigured `anything' to hardlink files from dired."
11898 (anything-dired-do-action-on-file :action
'hardlink
))
11901 (defun anything-do-grep ()
11902 "Preconfigured anything for grep.
11903 Contrarily to Emacs `grep' no default directory is given, but
11904 the full path of candidates in ONLY.
11905 That allow to grep different files not only in `default-directory' but anywhere
11906 by marking them (C-<SPACE>). If one or more directory is selected
11907 grep will search in all files of these directories.
11908 You can use also wildcard in the base name of candidate.
11909 If a prefix arg is given use the -r option of grep.
11910 The prefix arg can be passed before or after start.
11911 See also `anything-do-grep-1'."
11913 (let ((only (anything-c-read-file-name
11914 "Search in file(s): "
11915 :marked-candidates t
11916 :preselect
(or (dired-get-filename nil t
)
11917 (buffer-file-name (current-buffer)))))
11918 (prefarg (or current-prefix-arg anything-current-prefix-arg
)))
11919 (anything-do-grep-1 only prefarg
)))
11922 (defun anything-do-zgrep (candidate)
11923 "Preconfigured anything for zgrep."
11924 (let ((prefarg (or current-prefix-arg anything-current-prefix-arg
))
11925 (ls (anything-c-read-file-name
11926 "Search in file(s): "
11927 :marked-candidates t
11928 :preselect
(or (dired-get-filename nil t
)
11929 (buffer-file-name (current-buffer))))))
11930 (anything-ff-zgrep-1 ls prefarg
)))
11932 (defun anything-c-etags-select (arg)
11933 "Preconfigured anything for etags.
11934 Called with one prefix arg use symbol at point as initial input.
11935 Called with two prefix arg reinitialize cache.
11936 If tag file have been modified reinitialize cache."
11938 (let ((tag (anything-c-etags-get-tag-file))
11939 (init (and (equal arg
'(4)) (thing-at-point 'symbol
)))
11940 (anything-quit-if-no-candidate t
)
11941 (anything-execute-action-at-once-if-one t
)
11942 (anything-compile-source-functions
11943 (if anything-c-etags-use-regexp-search
11944 ;; rule out anything-match-plugin because the input is one regexp.
11945 (delq 'anything-compile-source--match-plugin
11946 (copy-sequence anything-compile-source-functions
))
11947 anything-compile-source-functions
)))
11948 (when (or (equal arg
'(16))
11949 (and anything-c-etags-mtime-alist
11950 (anything-c-etags-file-modified-p tag
)))
11951 (remhash tag anything-c-etags-cache
))
11952 (if (and tag
(file-exists-p tag
))
11953 (anything :sources
'anything-c-source-etags-select
11954 :keymap anything-c-etags-map
11956 :buffer
"*anything etags*")
11957 (message "Error: No tag file found, please create one with etags shell command."))))
11960 (defun anything-filelist ()
11961 "Preconfigured `anything' to open files instantly.
11963 See `anything-c-filelist-file-name' docstring for usage."
11965 (anything-other-buffer 'anything-c-source-filelist
"*anything file list*"))
11968 (defun anything-filelist+ ()
11969 "Preconfigured `anything' to open files/buffers/bookmarks instantly.
11971 This is a replacement for `anything-for-files'.
11972 See `anything-c-filelist-file-name' docstring for usage."
11974 (anything-other-buffer
11975 '(anything-c-source-ffap-line
11976 anything-c-source-ffap-guesser
11977 anything-c-source-buffers-list
11978 anything-c-source-recentf
11979 anything-c-source-bookmarks
11980 anything-c-source-file-cache
11981 anything-c-source-filelist
)
11982 "*anything file list*"))
11985 (defun anything-M-x ()
11986 "Preconfigured `anything' for Emacs commands.
11987 It is `anything' replacement of regular `M-x' `execute-extended-command'."
11991 special-display-buffer-names
11992 special-display-regexps
11993 anything-persistent-action-use-special-display
11994 (history (loop with hist
11995 for i in extended-command-history
11996 for com
= (intern i
)
11998 collect i into hist finally return hist
)))
11999 (flet ((pers-help (candidate)
12000 (let ((hbuf (get-buffer (help-buffer))))
12001 (if (and in-help
(string= candidate help-cand
))
12003 ;; When M-x is started from a help buffer,
12004 ;; Don't kill it as it is anything-current-buffer.
12005 (unless (equal hbuf anything-current-buffer
)
12006 (kill-buffer hbuf
))
12007 (setq in-help nil
))
12008 ;; Be sure anything-current-buffer
12009 ;; have not a dedicated window.
12010 (set-window-dedicated-p
12011 (get-buffer-window anything-current-buffer
) nil
)
12012 (describe-function (intern candidate
))
12013 (message nil
) ; Erase the new stupid message Type "q"[...]
12015 (setq help-cand candidate
))))
12020 `(((name .
"Emacs Commands history")
12021 (candidates .
,history
)
12022 (filtered-candidate-transformer
12023 .
(lambda (candidates sources
)
12024 (loop for i in candidates
12025 do
(set-text-properties 0 (length i
) nil i
)
12027 (persistent-action . pers-help
)
12028 (persistent-help .
"Describe this command")
12029 (action . identity
))
12030 ((name .
"Emacs Commands")
12033 (with-current-buffer (anything-candidate-buffer 'global
)
12034 (goto-char (point-min))
12036 (all-completions "" obarray
'commandp
)
12037 do
(insert (concat sym
"\n"))))))
12038 (persistent-action . pers-help
)
12039 (persistent-help .
"Describe this command")
12040 (filtered-candidate-transformer . anything-M-x-transformer
)
12041 (candidates-in-buffer)
12042 (action . identity
)))
12045 :history
'anything-M-x-input-history
12046 :buffer
"*anything M-x*")
12048 (sym-com (intern command
)))
12049 (unless current-prefix-arg
12050 (setq current-prefix-arg anything-current-prefix-arg
))
12051 ;; Avoid having `this-command' set to *exit-minibuffer.
12052 (setq this-command sym-com
)
12053 (call-interactively sym-com
)
12054 (setq extended-command-history
12055 (cons command
(delete command history
)))))))
12058 (defun anything-manage-advice ()
12059 "Preconfigured `anything' to disable/enable function advices."
12061 (anything-other-buffer 'anything-c-source-advice
"*anything advice*"))
12064 (defun anything-bookmark-ext ()
12065 "Preconfigured `anything' for bookmark-extensions sources.
12066 Needs bookmark-ext.el:
12067 <http://mercurial.intuxication.org/hg/emacs-bookmark-extension>.
12068 Contain also `anything-c-source-google-suggest'."
12072 '(anything-c-source-bookmark-files&dirs
12073 anything-c-source-bookmark-w3m
12074 anything-c-source-google-suggest
12075 anything-c-source-bmkext-addressbook
12076 anything-c-source-bookmark-gnus
12077 anything-c-source-bookmark-info
12078 anything-c-source-bookmark-man
12079 anything-c-source-bookmark-images
12080 anything-c-source-bookmark-su-files
&dirs
12081 anything-c-source-bookmark-ssh-files
&dirs
)
12082 :prompt
"SearchBookmark: "
12083 :buffer
"*anything bmkext*"))
12086 (defun anything-simple-call-tree ()
12087 "Preconfigured `anything' for simple-call-tree. List function relationships.
12089 Needs simple-call-tree.el.
12090 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el"
12092 (anything-other-buffer
12093 '(anything-c-source-simple-call-tree-functions-callers
12094 anything-c-source-simple-call-tree-callers-functions
)
12095 "*anything simple-call-tree*"))
12098 (defun anything-mark-ring ()
12099 "Preconfigured `anything' for `anything-c-source-mark-ring'."
12101 (anything :sources
'anything-c-source-mark-ring
))
12104 (defun anything-global-mark-ring ()
12105 "Preconfigured `anything' for `anything-c-source-global-mark-ring'."
12107 (anything :sources
'anything-c-source-global-mark-ring
))
12110 (defun anything-all-mark-rings ()
12111 "Preconfigured `anything' for `anything-c-source-global-mark-ring' and \
12112 `anything-c-source-mark-ring'."
12114 (anything :sources
'(anything-c-source-mark-ring
12115 anything-c-source-global-mark-ring
)))
12118 (defun anything-yaoddmuse-emacswiki-edit-or-view ()
12119 "Preconfigured `anything' to edit or view EmacsWiki page.
12121 Needs yaoddmuse.el.
12123 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
12125 (anything :sources
'anything-c-source-yaoddmuse-emacswiki-edit-or-view
))
12128 (defun anything-yaoddmuse-emacswiki-post-library ()
12129 "Preconfigured `anything' to post library to EmacsWiki.
12131 Needs yaoddmuse.el.
12133 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
12135 (anything :sources
'anything-c-source-yaoddmuse-emacswiki-post-library
))
12138 (defun anything-eval-expression (arg)
12139 "Preconfigured anything for `anything-c-source-evaluation-result'."
12141 (anything :sources
'anything-c-source-evaluation-result
12142 :input
(when arg
(thing-at-point 'sexp
))
12143 :buffer
"*anything eval*"
12144 :history
'anything-eval-expression-input-history
12145 :keymap anything-eval-expression-map
))
12148 (defun anything-eval-expression-with-eldoc ()
12149 "Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. "
12151 (declare (special eldoc-idle-delay
))
12152 (let ((timer (run-with-idle-timer eldoc-idle-delay
12153 'repeat
'anything-eldoc-show-in-eval
))
12154 (minibuffer-completing-symbol t
) ; Enable lisp completion.
12155 (completion-cycle-threshold t
)) ; Always cycle, no pesty completion buffer (emacs24 only).
12157 (minibuffer-with-setup-hook
12158 'anything-eldoc-store-minibuffer
12159 (call-interactively 'anything-eval-expression
))
12160 (and timer
(cancel-timer timer
))
12161 (setq anything-eldoc-active-minibuffers-list
12162 (cdr anything-eldoc-active-minibuffers-list
)))))
12165 (defun anything-calcul-expression ()
12166 "Preconfigured anything for `anything-c-source-calculation-result'."
12168 (anything-other-buffer 'anything-c-source-calculation-result
"*anything calcul*"))
12171 (defun anything-surfraw (pattern engine
)
12172 "Preconfigured `anything' to search PATTERN with search ENGINE."
12173 (interactive (list (read-string "SearchFor: "
12174 nil
'anything-surfraw-input-history
)
12175 (anything-comp-read
12177 (anything-c-build-elvi-list)
12179 :name
"Surfraw Search Engines"
12180 :history anything-surfraw-engines-history
)))
12181 (let* ((engine-nodesc (car (split-string engine
)))
12182 (url (with-temp-buffer
12183 (apply 'call-process
"surfraw" nil t nil
12185 (append (list engine-nodesc
"-p") (split-string pattern
)))
12186 (replace-regexp-in-string
12187 "\n" "" (buffer-string))))
12188 (browse-url-browser-function (or anything-surfraw-default-browser-function
12189 browse-url-browser-function
)))
12190 (if (string= engine-nodesc
"W")
12191 (anything-c-browse-url)
12192 (anything-c-browse-url url
)
12193 (setq anything-surfraw-engines-history
12194 (cons engine
(delete engine anything-surfraw-engines-history
))))))
12197 (defun anything-call-source ()
12198 "Preconfigured `anything' to call anything source."
12200 (anything :sources
'anything-c-source-call-source
12201 :buffer anything-source-select-buffer
))
12204 (defun anything-execute-anything-command ()
12205 "Preconfigured `anything' to execute preconfigured `anything'."
12207 (anything-other-buffer 'anything-c-source-anything-commands
12208 "*anything commands*"))
12211 (defun anything-create (&optional string initial-input
)
12212 "Preconfigured `anything' to do many create actions from STRING.
12213 See also `anything-create--actions'."
12215 (setq string
(or string
(read-string "Create Anything: " initial-input
)))
12216 (anything :sources
'(((name .
"Anything Create")
12217 (header-name .
(lambda (_) (format "Action for \"%s\"" string
)))
12218 (candidates . anything-create--actions
)
12219 (candidate-number-limit)
12220 (action .
(lambda (func) (funcall func string
)))))))
12223 (defun anything-top ()
12224 "Preconfigured `anything' for top command."
12226 (let ((anything-samewindow t
)
12227 (anything-enable-shortcuts)
12228 (anything-display-function 'anything-default-display-buffer
)
12229 (anything-candidate-number-limit 9999))
12230 (save-window-excursion
12231 (delete-other-windows)
12232 (anything-other-buffer 'anything-c-source-top
"*anything top*"))))
12235 (defun anything-select-xfont ()
12236 "Preconfigured `anything' to select Xfont."
12238 (anything-other-buffer 'anything-c-source-xfonts
"*anything select* xfont"))
12241 (defun anything-world-time ()
12242 "Preconfigured `anything' to show world time."
12244 (anything-other-buffer 'anything-c-source-time-world
"*anything world time*"))
12247 (defun anything-apt (arg)
12248 "Preconfigured `anything' : frontend of APT package manager.
12249 With a prefix arg reload cache."
12251 (let ((query (read-string "Search Package: " nil
'anything-c-apt-input-history
)))
12252 (when arg
(anything-c-apt-refresh))
12253 (anything :sources
'anything-c-source-apt
12254 :prompt
"Search Package: "
12256 :history
'anything-c-apt-input-history
)))
12259 (defun anything-esh-pcomplete ()
12260 "Preconfigured anything to provide anything completion in eshell."
12262 (let* ((anything-quit-if-no-candidate t
)
12263 (anything-execute-action-at-once-if-one t
)
12264 (target (thing-at-point 'symbol
))
12266 (beg (or (and target
(- end
(length target
)))
12267 ;; Nothing at point.
12268 (progn (insert " ") (point)))))
12269 (setq anything-ec-target
(or target
" "))
12270 (with-anything-show-completion beg end
12271 (anything :sources
'anything-c-source-esh
12272 :input
(anything-ff-set-pattern ; Handle tramp filenames.
12273 (car (last (ignore-errors ; Needed in lisp symbols completion.
12274 (pcomplete-parse-arguments)))))))))
12277 (defun anything-eshell-history ()
12278 "Preconfigured anything for eshell history."
12280 (let* ((end (point))
12281 (beg (save-excursion (eshell-bol) (point)))
12285 (setq flag-empty t
)
12286 (setq end
(point)))
12288 (with-anything-show-completion beg end
12289 (anything :sources
'anything-c-source-eshell-history
12290 :buffer
"*Eshell history*"))
12291 (when (and flag-empty
12292 (looking-back " "))
12293 (delete-char -
1)))))
12296 (defun anything-c-run-external-command (program)
12297 "Preconfigured `anything' to run External PROGRAM asyncronously from Emacs.
12298 If program is already running exit with error.
12299 You can set your own list of commands with
12300 `anything-c-external-commands-list'."
12302 (anything-comp-read
12304 (anything-c-external-commands-list-1 'sort
)
12306 :name
"External Commands"
12307 :history anything-external-command-history
)))
12308 (anything-run-or-raise program
)
12309 (setq anything-external-command-history
12310 (cons program
(delete program
12311 (loop for i in anything-external-command-history
12312 when
(executable-find i
) collect i
)))))
12315 (defun anything-ratpoison-commands ()
12316 "Preconfigured `anything' to execute ratpoison commands."
12318 (anything-other-buffer 'anything-c-source-ratpoison-commands
12319 "*anything ratpoison commands*"))
12322 (defun anything-ucs ()
12323 "Preconfigured anything for `ucs-names' math symbols."
12325 (anything :sources
'anything-c-source-ucs
12326 :keymap anything-c-ucs-map
))
12329 (defun anything-c-apropos ()
12330 "Preconfigured anything to describe commands, functions, variables and faces."
12332 (let ((default (thing-at-point 'symbol
)))
12334 `(((name .
"Commands")
12336 (anything-c-apropos-init 'commandp
,default
)))
12337 (persistent-action . anything-lisp-completion-persistent-action
)
12338 (persistent-help .
"Show brief doc in mode-line")
12339 (candidates-in-buffer)
12340 (action .
(lambda (candidate)
12341 (describe-function (intern candidate
)))))
12342 ((name .
"Functions")
12344 (anything-c-apropos-init #'(lambda (x) (and (fboundp x
)
12345 (not (commandp x
))))
12347 (persistent-action . anything-lisp-completion-persistent-action
)
12348 (persistent-help .
"Show brief doc in mode-line")
12349 (candidates-in-buffer)
12350 (action .
(lambda (candidate)
12351 (describe-function (intern candidate
)))))
12352 ((name .
"Variables")
12354 (anything-c-apropos-init 'boundp
,default
)))
12355 (persistent-action . anything-lisp-completion-persistent-action
)
12356 (persistent-help .
"Show brief doc in mode-line")
12357 (candidates-in-buffer)
12358 (action .
(lambda (candidate)
12359 (describe-variable (intern candidate
)))))
12362 (anything-c-apropos-init 'facep
,default
)))
12363 (persistent-action . anything-lisp-completion-persistent-action
)
12364 (persistent-help .
"Show brief doc in mode-line")
12365 (candidates-in-buffer)
12366 (filtered-candidate-transformer .
(lambda (candidates source
)
12367 (loop for c in candidates
12368 collect
(propertize c
'face
(intern c
)))))
12369 (action .
(lambda (candidate)
12370 (describe-face (intern candidate
)))))
12371 ((name .
"Anything attributes")
12372 (candidates .
(lambda ()
12373 (mapcar 'symbol-name anything-additional-attributes
)))
12374 (action .
(lambda (candidate)
12375 (with-output-to-temp-buffer "*Help*"
12376 (princ (get (intern candidate
) 'anything-attrdoc
))))))))))
12379 ;;; Unit tests are now in ../developer-tools/unit-test-anything-config.el.
12382 (provide 'anything-config
)
12384 ;;; Local Variables:
12385 ;;; time-stamp-format: "%:y-%02m-%02d %02H:%02M:%02S (%Z) %u"
12388 ;; How to save (DO NOT REMOVE!!)
12389 ;; (progn (magit-push) (emacswiki-post "anything-config.el"))
12390 ;;; anything-config.el ends here
12392 ;;; LocalWords: Tassilo Patrovics Vagn Johansen Dahl Clementson infos
12393 ;;; LocalWords: Kamphausen informations McBrayer Volpiatto bbdb bb
12394 ;;; LocalWords: iswitchb imenu Recentf sym samewindow pos bol eol
12395 ;;; LocalWords: aif str lst func attrib recentf lessp prin mapatoms commandp
12396 ;;; LocalWords: cmd stb Picklist picklist mapcan subentry destructuring dirs
12397 ;;; LocalWords: darwin locat MacOS mdfind Firstname Lastname calc prepend jids
12398 ;;; LocalWords: dotimes Thierry online vname
12399 ;;; LocalWords: csharp javascript lua makefile cperl zcat lineno buf
12400 ;;; LocalWords: multiline href fn cand NewTitle cwd filepath thru ret
12401 ;;; LocalWords: bfn fOpen UNC cygdrive nt xdg macos FILE's elc rx svn hg
12402 ;;; LocalWords: CANDIDATE's darcs facep pathname args pathnames subseq priorty
12403 ;;; LocalWords: Vokes rfind berkeley JST ffap lacarte bos
12404 ;;; LocalWords: Lacarte Minibuf epp LaCarte bm attrset migemo attr conf mklist
12405 ;;; LocalWords: startpos noselect dont desc