1 ;;; anything-config.el --- Predefined configurations for `anything.el'
3 ;; Filename: anything-config.el
5 ;; Description: Predefined configurations for `anything.el'
6 ;; Author: Tassilo Horn <tassilo@member.fsf.org>
7 ;; Maintainer: Tassilo Horn <tassilo@member.fsf.org>
8 ;; rubikitch <rubikitch@ruby-lang.org>
9 ;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
10 ;; Copyright (C) 2007 ~ 2010, Tassilo Horn, all rights reserved.
11 ;; Copyright (C) 2009, Andy Stewart, all rights reserved.
12 ;; Copyright (C) 2009 ~ 2010, rubikitch, all rights reserved.
13 ;; Copyright (C) 2009 ~ 2010, Thierry Volpiatto, all rights reserved.
14 ;; Created: 2009-02-16 21:38:23
16 ;; URL: http://www.emacswiki.org/emacs/download/anything-config.el
17 ;; Keywords: anything, anything-config
18 ;; Compatibility: GNU Emacs 22 ~ 23
20 ;; Features that might be required by this library:
25 ;;; This file is NOT part of GNU Emacs
29 ;; This program is free software; you can redistribute it and/or modify
30 ;; it under the terms of the GNU General Public License as published by
31 ;; the Free Software Foundation; either version 3, or (at your option)
34 ;; This program is distributed in the hope that it will be useful,
35 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 ;; GNU General Public License for more details.
39 ;; You should have received a copy of the GNU General Public License
40 ;; along with this program; see the file COPYING. If not, write to
41 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
42 ;; Floor, Boston, MA 02110-1301, USA.
46 ;; If this file does not work, upgrade anything.el!
47 ;; http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
51 ;; Predefined configurations for `anything.el'
53 ;; For quick start, try `anything-for-files' to open files.
55 ;; To configure anything you should define anything command
56 ;; with your favorite sources, like below:
58 ;; (defun my-anything ()
60 ;; (anything-other-buffer
61 ;; '(anything-c-source-buffers
62 ;; anything-c-source-file-name-history
63 ;; anything-c-source-info-pages
64 ;; anything-c-source-info-elisp
65 ;; anything-c-source-man-pages
66 ;; anything-c-source-locate
67 ;; anything-c-source-emacs-commands)
70 ;; Then type M-x my-anything to use sources.
72 ;; Defining own command is better than setup `anything-sources'
73 ;; directly, because you can define multiple anything commands with
74 ;; different sources. Each anything command should have own anything
75 ;; buffer, because M-x anything-resume revives anything command.
77 ;;; Autodoc documentation:
78 ;; ---------------------
80 ;; * Commands defined here are:
81 ;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "anything-" :docstring t)
82 ;; `anything-configuration'
84 ;; `anything-c-describe-anything-bindings'
85 ;; [OBSOLETE] Describe `anything' bindings.
87 ;; Preconfigured `anything' lightweight version (buffer -> recentf).
88 ;; `anything-for-files'
89 ;; Preconfigured `anything' for opening files.
91 ;; Preconfigured `anything' for `recentf'.
92 ;; `anything-info-at-point'
93 ;; Preconfigured `anything' for searching info at point.
94 ;; `anything-show-kill-ring'
95 ;; Preconfigured `anything' for `kill-ring'. It is drop-in replacement of `yank-pop'.
96 ;; `anything-minibuffer-history'
97 ;; Preconfigured `anything' for `minibuffer-history'.
99 ;; Preconfigured `anything' for gentoo linux.
101 ;; Preconfigured `anything' for `imenu'.
102 ;; `anything-google-suggest'
103 ;; Preconfigured `anything' for google search with google suggest.
104 ;; `anything-yahoo-suggest'
105 ;; Preconfigured `anything' for Yahoo searching with Yahoo suggest.
106 ;; `anything-for-buffers'
107 ;; Preconfigured `anything' for buffer.
108 ;; `anything-buffers+'
109 ;; Enhanced preconfigured `anything' for buffer.
111 ;; Preconfigured `anything' for BBDB.
113 ;; Preconfigured `anything' for Locate.
114 ;; `anything-w3m-bookmarks'
115 ;; Preconfigured `anything' for w3m bookmark.
116 ;; `anything-firefox-bookmarks'
117 ;; Preconfigured `anything' for firefox bookmark.
119 ;; Preconfigured `anything' for color.
120 ;; `anything-bookmarks'
122 ;; `anything-c-pp-bookmarks'
124 ;; `anything-register'
126 ;; `anything-bm-list'
127 ;; Preconfigured `anything' for visible bookmarks.
129 ;; Preconfigured `anything' for timers.
130 ;; `anything-kill-buffers'
131 ;; Preconfigured `anything' to kill buffer you selected.
132 ;; `anything-query-replace-regexp'
133 ;; Preconfigured `anything' : Drop-in replacement of `query-replace-regexp' with building regexp visually.
135 ;; Preconfigured `anything' : It is like `re-builder'. It helps buliding regexp and replacement.
136 ;; `anything-insert-buffer-name'
137 ;; Insert buffer name.
138 ;; `anything-insert-symbol'
139 ;; Insert current symbol.
140 ;; `anything-insert-selection'
141 ;; Insert current selection.
142 ;; `anything-show-buffer-only'
143 ;; [OBSOLETE] Only show sources about buffer.
144 ;; `anything-show-bbdb-only'
145 ;; [OBSOLETE] Only show sources about BBDB.
146 ;; `anything-show-locate-only'
147 ;; [OBSOLETE] Only show sources about Locate.
148 ;; `anything-show-info-only'
149 ;; [OBSOLETE] Only show sources about Info.
150 ;; `anything-show-imenu-only'
151 ;; [OBSOLETE] Only show sources about Imenu.
152 ;; `anything-show-files-only'
153 ;; [OBSOLETE] Only show sources about File.
154 ;; `anything-show-w3m-bookmarks-only'
155 ;; [OBSOLETE] Only show source about w3m bookmark.
156 ;; `anything-show-colors-only'
157 ;; [OBSOLETE] Only show source about color.
158 ;; `anything-show-kill-ring-only'
159 ;; [OBSOLETE] Only show source about kill ring.
160 ;; `anything-show-this-source-only'
161 ;; Only show this source.
162 ;; `anything-test-sources'
163 ;; List all anything sources for test.
164 ;; `anything-select-source'
166 ;; `anything-find-files-down-one-level'
167 ;; Go down one level like unix command `cd ..'.
168 ;; `anything-find-files'
169 ;; Preconfigured `anything' for anything implementation of `find-file'.
170 ;; `anything-write-file'
171 ;; Preconfigured `anything' providing completion for `write-file'.
172 ;; `anything-insert-file'
173 ;; Preconfigured `anything' providing completion for `insert-file'.
174 ;; `anything-dired-rename-file'
175 ;; Preconfigured `anything' to rename files from dired.
176 ;; `anything-dired-copy-file'
177 ;; Preconfigured `anything' to copy files from dired.
178 ;; `anything-dired-symlink-file'
179 ;; Preconfigured `anything' to symlink files from dired.
180 ;; `anything-dired-hardlink-file'
181 ;; Preconfigured `anything' to hardlink files from dired.
182 ;; `anything-dired-bindings'
183 ;; Replace usual dired commands `C' and `R' by anything ones.
185 ;; Anything replacement of regular `M-x' `execute-extended-command'.
186 ;; `anything-manage-advice'
187 ;; Preconfigured `anything' to disable/enable function advices.
188 ;; `anything-bookmark-ext'
189 ;; Preconfigured `anything' for bookmark-extensions sources.
190 ;; `anything-simple-call-tree'
191 ;; Preconfigured `anything' for simple-call-tree. List function relationships.
192 ;; `anything-mark-ring'
193 ;; Preconfigured `anything' for `anything-c-source-mark-ring'.
194 ;; `anything-global-mark-ring'
195 ;; Preconfigured `anything' for `anything-c-source-global-mark-ring'.
196 ;; `anything-all-mark-rings'
197 ;; Preconfigured `anything' for `anything-c-source-global-mark-ring' and `anything-c-source-mark-ring'.
198 ;; `anything-yaoddmuse-cache-pages'
199 ;; Fetch the list of files on emacswiki and create cache file.
200 ;; `anything-yaoddmuse-emacswiki-edit-or-view'
201 ;; Preconfigured `anything' to edit or view EmacsWiki page.
202 ;; `anything-yaoddmuse-emacswiki-post-library'
203 ;; Preconfigured `anything' to post library to EmacsWiki.
204 ;; `anything-eval-expression'
205 ;; Preconfigured anything for `anything-c-source-evaluation-result'.
206 ;; `anything-eval-expression-with-eldoc'
207 ;; Same as `anything-eval-expression' but with `eldoc' support.
208 ;; `anything-surfraw'
209 ;; Search PATTERN with search ENGINE.
210 ;; `anything-emms-stream-edit-bookmark'
211 ;; Change the information of current emms-stream bookmark from anything.
212 ;; `anything-emms-stream-delete-bookmark'
213 ;; Delete an emms-stream bookmark from anything.
214 ;; `anything-call-source'
215 ;; Preconfigured `anything' to call anything source.
216 ;; `anything-call-source-from-anything'
217 ;; Call anything source within `anything' session.
218 ;; `anything-execute-anything-command'
219 ;; Preconfigured `anything' to execute preconfigured `anything'.
221 ;; Preconfigured Anything for Occur source.
222 ;; `anything-create-from-anything'
223 ;; Run `anything-create' from `anything' as a fallback.
225 ;; Preconfigured `anything' to do many create actions from STRING.
227 ;; Preconfigured `anything' for top command.
228 ;; `anything-select-xfont'
229 ;; Preconfigured `anything' to select Xfont.
231 ;; Preconfigured `anything' : frontend of APT package manager.
232 ;; `anything-c-shell-command-if-needed'
234 ;; `anything-c-run-external-command'
235 ;; Run External PROGRAM asyncronously from Emacs.
236 ;; `anything-ratpoison-commands'
237 ;; Preconfigured `anything' to execute ratpoison commands.
238 ;; `anything-c-set-variable'
239 ;; Set value to VAR interactively.
240 ;; `anything-c-adaptive-save-history'
241 ;; Save history information to file given by `anything-c-adaptive-history-file'.
243 ;; * User variables defined here:
244 ;; [EVAL] (autodoc-document-lisp-buffer :type 'user-variable :prefix "anything-" :var-value t)
245 ;; `anything-c-use-standard-keys'
246 ;; Default Value: nil
247 ;; `anything-c-adaptive-history-file'
248 ;; Default Value: "~/.emacs.d/anything-c-adaptive-history"
249 ;; `anything-c-adaptive-history-length'
251 ;; `anything-c-google-suggest-url'
252 ;; Default Value: "http://google.com/complete/search?output=toolbar&q="
253 ;; `anything-c-google-suggest-search-url'
254 ;; Default Value: "http://www.google.com/search?ie=utf-8&oe=utf-8&q="
255 ;; `anything-google-suggest-use-curl-p'
256 ;; Default Value: nil
257 ;; `anything-c-yahoo-suggest-url'
258 ;; Default Value: "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=G [...]
259 ;; `anything-c-yahoo-suggest-search-url'
260 ;; Default Value: "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p="
261 ;; `anything-c-boring-buffer-regexp'
262 ;; Default Value: "\\ (\\` \\)\\|\\*anything\\| \\*Echo Area\\| \\*Minibuf"
263 ;; `anything-c-boring-file-regexp'
264 ;; Default Value: "/\\ (?:\\(?:\\.\\(?:git\\|hg\\|svn\\)\\|CVS\\|_darcs\\)\\)\\(?:/\\|$\\)\\| [...]
265 ;; `anything-kill-ring-threshold'
267 ;; `anything-su-or-sudo'
268 ;; Default Value: "su"
269 ;; `anything-for-files-prefered-list'
270 ;; Default Value: (anything-c-source-ffap-line anything-c-source-ffap-guesser anything-c-sou [...]
271 ;; `anything-create--actions-private'
272 ;; Default Value: nil
273 ;; `anything-allow-skipping-current-buffer'
275 ;; `anything-c-enable-eval-defun-hack'
277 ;; `anything-tramp-verbose'
279 ;; `anything-raise-command'
280 ;; Default Value: nil
281 ;; `anything-command-map-prefix-key'
282 ;; Default Value: "<f5> a"
284 ;; * Anything sources defined here:
285 ;; [EVAL] (autodoc-document-lisp-buffer :type 'anything-source :prefix "anything-" :any-sname t)
286 ;; `anything-c-source-buffers' (Buffers)
287 ;; `anything-c-source-buffer-not-found' (Create buffer)
288 ;; `anything-c-source-buffers+' (Buffers)
289 ;; `anything-c-source-file-name-history' (File Name History)
290 ;; `anything-c-source-files-in-current-dir' (Files from Current Directory)
291 ;; `anything-c-source-files-in-current-dir+' (Files from Current Directory)
292 ;; `anything-c-source-find-files' (Find Files (`C-.':Go to precedent level))
293 ;; `anything-c-source-write-file' (Write File (`C-.':Go to precedent level))
294 ;; `anything-c-source-insert-file' (Insert File (`C-.':Go to precedent level))
295 ;; `anything-c-source-copy-files' (Copy Files (`C-.':Go to precedent level))
296 ;; `anything-c-source-symlink-files' (Symlink Files (`C-.':Go to precedent level))
297 ;; `anything-c-source-hardlink-files' (Hardlink Files (`C-.':Go to precedent level))
298 ;; `anything-c-source-file-cache-initialized' ()
299 ;; `anything-c-source-file-cache' (File Cache)
300 ;; `anything-c-source-locate' (Locate)
301 ;; `anything-c-source-recentf' (Recentf)
302 ;; `anything-c-source-ffap-guesser' (File at point)
303 ;; `anything-c-source-ffap-line' (File/Lineno at point)
304 ;; `anything-c-source-files-in-all-dired' (Files in all dired buffer.)
305 ;; `anything-c-source-info-pages' (Info Pages)
306 ;; `anything-c-source-info-elisp' (Info index: elisp)
307 ;; `anything-c-source-info-cl' (Info index: cl)
308 ;; `anything-c-source-info-org' (Info index: org)
309 ;; `anything-c-source-info-ratpoison' (Info index: ratpoison)
310 ;; `anything-c-source-info-zsh' (Info index: zsh)
311 ;; `anything-c-source-info-bash' (Info index: bash)
312 ;; `anything-c-source-info-coreutils' (Info index: coreutils)
313 ;; `anything-c-source-info-fileutils' (Info index: fileutils)
314 ;; `anything-c-source-info-find' (Info index: find)
315 ;; `anything-c-source-info-sh-utils' (Info index: sh-utils)
316 ;; `anything-c-source-info-textutils' (Info index: textutils)
317 ;; `anything-c-source-info-libc' (Info index: libc)
318 ;; `anything-c-source-info-make' (Info index: make)
319 ;; `anything-c-source-info-automake' (Info index: automake)
320 ;; `anything-c-source-info-autoconf' (Info index: autoconf)
321 ;; `anything-c-source-info-emacs-lisp-intro' (Info index: emacs-lisp-intro)
322 ;; `anything-c-source-info-emacs' (Info index: emacs)
323 ;; `anything-c-source-info-elib' (Info index: elib)
324 ;; `anything-c-source-info-eieio' (Info index: eieio)
325 ;; `anything-c-source-info-gauche-refe' (Info index: gauche)
326 ;; `anything-c-source-info-guile' (Info index: guile)
327 ;; `anything-c-source-info-guile-tut' (Info index: guile-tut)
328 ;; `anything-c-source-info-goops' (Info index: goops)
329 ;; `anything-c-source-info-screen' (Info index: screen)
330 ;; `anything-c-source-info-latex' (Info index: latex)
331 ;; `anything-c-source-info-gawk' (Info index: gawk)
332 ;; `anything-c-source-info-sed' (Info index: sed)
333 ;; `anything-c-source-info-m4' (Info index: m4)
334 ;; `anything-c-source-info-wget' (Info index: wget)
335 ;; `anything-c-source-info-binutils' (Info index: binutils)
336 ;; `anything-c-source-info-as' (Info index: as)
337 ;; `anything-c-source-info-bfd' (Info index: bfd)
338 ;; `anything-c-source-info-gprof' (Info index: gprof)
339 ;; `anything-c-source-info-ld' (Info index: ld)
340 ;; `anything-c-source-info-diff' (Info index: diff)
341 ;; `anything-c-source-info-flex' (Info index: flex)
342 ;; `anything-c-source-info-grep' (Info index: grep)
343 ;; `anything-c-source-info-gzip' (Info index: gzip)
344 ;; `anything-c-source-info-libtool' (Info index: libtool)
345 ;; `anything-c-source-info-texinfo' (Info index: texinfo)
346 ;; `anything-c-source-info-info' (Info index: info)
347 ;; `anything-c-source-info-gdb' (Info index: gdb)
348 ;; `anything-c-source-info-stabs' (Info index: stabs)
349 ;; `anything-c-source-info-cvsbook' (Info index: cvsbook)
350 ;; `anything-c-source-info-cvs' (Info index: cvs)
351 ;; `anything-c-source-info-bison' (Info index: bison)
352 ;; `anything-c-source-info-id-utils' (Info index: id-utils)
353 ;; `anything-c-source-info-global' (Info index: global)
354 ;; `anything-c-source-man-pages' (Manual Pages)
355 ;; `anything-c-source-complex-command-history' (Complex Command History)
356 ;; `anything-c-source-extended-command-history' (Emacs Commands History)
357 ;; `anything-c-source-emacs-commands' (Emacs Commands)
358 ;; `anything-c-source-lacarte' (Lacarte)
359 ;; `anything-c-source-emacs-functions' (Emacs Functions)
360 ;; `anything-c-source-emacs-functions-with-abbrevs' (Emacs Functions)
361 ;; `anything-c-source-advice' (Function Advice)
362 ;; `anything-c-source-emacs-variables' (Emacs Variables)
363 ;; `anything-c-source-bookmarks' (Bookmarks)
364 ;; `anything-c-source-bookmark-set' (Set Bookmark)
365 ;; `anything-c-source-bm' (Visible Bookmarks)
366 ;; `anything-c-source-bookmarks-ssh' (Bookmarks-ssh)
367 ;; `anything-c-source-bookmarks-su' (Bookmarks-root)
368 ;; `anything-c-source-bookmarks-local' (Bookmarks-Local)
369 ;; `anything-c-source-bmkext-addressbook' (Bookmark Addressbook)
370 ;; `anything-c-source-bookmark-w3m' (Bookmark W3m)
371 ;; `anything-c-source-bookmark-images' (Bookmark Images)
372 ;; `anything-c-source-bookmark-man' (Bookmark Woman&Man)
373 ;; `anything-c-source-bookmark-gnus' (Bookmark Gnus)
374 ;; `anything-c-source-bookmark-info' (Bookmark Info)
375 ;; `anything-c-source-bookmark-files&dirs' (Bookmark Files&Directories)
376 ;; `anything-c-source-bookmark-su-files&dirs' (Bookmark Root-Files&Directories)
377 ;; `anything-c-source-bookmark-ssh-files&dirs' (Bookmark Ssh-Files&Directories)
378 ;; `anything-c-source-firefox-bookmarks' (Firefox Bookmarks)
379 ;; `anything-c-source-w3m-bookmarks' (W3m Bookmarks)
380 ;; `anything-c-source-elisp-library-scan' (Elisp libraries (Scan))
381 ;; `anything-c-source-imenu' (Imenu)
382 ;; `anything-c-source-ctags' (Exuberant ctags)
383 ;; `anything-c-source-semantic' (Semantic Tags)
384 ;; `anything-c-source-simple-call-tree-functions-callers' (Function is called by)
385 ;; `anything-c-source-simple-call-tree-callers-functions' (Function calls)
386 ;; `anything-c-source-commands-and-options-in-file' (Commands/Options in file)
387 ;; `anything-c-source-customize-face' (Customize Face)
388 ;; `anything-c-source-colors' (Colors)
389 ;; `anything-c-source-tracker-search' (Tracker Search)
390 ;; `anything-c-source-mac-spotlight' (mdfind)
391 ;; `anything-c-source-kill-ring' (Kill Ring)
392 ;; `anything-c-source-mark-ring' (mark-ring)
393 ;; `anything-c-source-global-mark-ring' (global-mark-ring)
394 ;; `anything-c-source-register' (Registers)
395 ;; `anything-c-source-fixme' (TODO/FIXME/DRY comments)
396 ;; `anything-c-source-rd-headline' (RD HeadLine)
397 ;; `anything-c-source-oddmuse-headline' (Oddmuse HeadLine)
398 ;; `anything-c-source-emacs-source-defun' (Emacs Source DEFUN)
399 ;; `anything-c-source-emacs-lisp-expectations' (Emacs Lisp Expectations)
400 ;; `anything-c-source-emacs-lisp-toplevels' (Emacs Lisp Toplevel / Level 4 Comment / Linkd Star)
401 ;; `anything-c-source-org-headline' (Org HeadLine)
402 ;; `anything-c-source-yaoddmuse-emacswiki-edit-or-view' (Yaoddmuse Edit or View (EmacsWiki))
403 ;; `anything-c-source-yaoddmuse-emacswiki-post-library' (Yaoddmuse Post library (EmacsWiki))
404 ;; `anything-c-source-eev-anchor' (Anchors)
405 ;; `anything-c-source-org-keywords' (Org Keywords)
406 ;; `anything-c-source-picklist' (Picklist)
407 ;; `anything-c-source-bbdb' (BBDB)
408 ;; `anything-c-source-evaluation-result' (Evaluation Result)
409 ;; `anything-c-source-calculation-result' (Calculation Result)
410 ;; `anything-c-source-google-suggest' (Google Suggest)
411 ;; `anything-c-source-yahoo-suggest' (Yahoo Suggest)
412 ;; `anything-c-source-emms-streams' (Emms Streams)
413 ;; `anything-c-source-emms-dired' (Music Directory)
414 ;; `anything-c-source-emms-files' (Emms files)
415 ;; `anything-c-source-jabber-contacts' (Jabber Contacts)
416 ;; `anything-c-source-call-source' (Call anything source)
417 ;; `anything-c-source-anything-commands' (Preconfigured Anything)
418 ;; `anything-c-source-occur' (Occur)
419 ;; `anything-c-source-create' (Create)
420 ;; `anything-c-source-minibuffer-history' (Minibuffer History)
421 ;; `anything-c-source-elscreen' (Elscreen)
422 ;; `anything-c-source-top' (Top (Press C-c C-u to refresh))
423 ;; `anything-c-source-absolute-time-timers' (Absolute Time Timers)
424 ;; `anything-c-source-idle-time-timers' (Idle Time Timers)
425 ;; `anything-c-source-xrandr-change-resolution' (Change Resolution)
426 ;; `anything-c-source-xfonts' (X Fonts)
427 ;; `anything-c-source-apt' (APT)
428 ;; `anything-c-source-gentoo' (Portage sources)
429 ;; `anything-c-source-use-flags' (Use Flags)
430 ;; `anything-c-source-emacs-process' (Emacs Process)
431 ;; `anything-c-source-ratpoison-commands' (Ratpoison Commands)
433 ;; *** END auto-documentation
438 ;; Change log of this file is found at
439 ;; http://repo.or.cz/w/anything-config.git/history/master:/anything-config.el
441 ;; Change log of this project is found at
442 ;; http://repo.or.cz/w/anything-config.git?a=shortlog
447 ;; Tassilo Horn <tassilo@member.fsf.org>
448 ;; Vagn Johansen <gonz808@hotmail.com>
449 ;; Mathias Dahl <mathias.dahl@gmail.com>
450 ;; Bill Clementson <billclem@gmail.com>
451 ;; Stefan Kamphausen (see http://www.skamphausen.de for more informations)
452 ;; Drew Adams <drew.adams@oracle.com>
453 ;; Jason McBrayer <jmcbray@carcosa.net>
454 ;; Andy Stewart <lazycat.manatee@gmail.com>
455 ;; Thierry Volpiatto <thierry.volpiatto@gmail.com>
456 ;; rubikitch <rubikitch@ruby-lang.org>
457 ;; Scott Vokes <vokes.s@gmail.com>
462 ;; Evaluate (autodoc-update-all) before commit. This function
463 ;; generates anything-c-source-* / functions / options list.
465 ;; Install also developer-tools/autodoc.el
466 ;; And eval it or run interactively.
468 ;; [EVAL IT] (autodoc-update-all)
470 ;; Please write details documentation about function, then others will
471 ;; read code more easier. -- Andy Stewart
477 ;; - Fix documentation, now many functions haven't documentations.
489 (let ((version "1.263"))
490 (when (and (string= "1." (substring version
0 2))
491 (string-match "1\.\\([0-9]+\\)" anything-version
)
492 (< (string-to-number (match-string 1 anything-version
))
493 (string-to-number (substring version
2))))
494 (error "Please update anything.el!!
496 http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
498 or M-x install-elisp-from-emacswiki anything.el")))
500 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Customize ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
501 (defgroup anything-config nil
502 "Predefined configurations for `anything.el'."
505 (defcustom anything-c-use-standard-keys nil
506 "Whether use standard keybindings. (no effect)
508 Key definitions in anything-config.el are removed because
509 anything.el uses Emacs-standard keys by default. e.g. M-p/M-n for
510 minibuffer history, C-s for isearch, etc.
512 If you use `iswitchb' with `anything',
513 evaluate (anything-iswitchb-setup) . Then some bindings that
514 conflict with `iswitchb', e.g. C-p/C-n for the minibuffer
515 history, are removed from `anything-map'. "
517 :group
'anything-config
)
519 (defcustom anything-c-adaptive-history-file
"~/.emacs.d/anything-c-adaptive-history"
520 "Path of file where history information is stored."
522 :group
'anything-config
)
524 (defcustom anything-c-adaptive-history-length
50
525 "Maximum number of candidates stored for a source."
527 :group
'anything-config
)
529 (defcustom anything-c-google-suggest-url
530 "http://google.com/complete/search?output=toolbar&q="
531 "URL used for looking up Google suggestions."
533 :group
'anything-config
)
535 (defcustom anything-c-google-suggest-search-url
536 "http://www.google.com/search?ie=utf-8&oe=utf-8&q="
537 "URL used for Google searching."
539 :group
'anything-config
)
541 (defcustom anything-google-suggest-use-curl-p nil
542 "*When non--nil use CURL to get info from `anything-c-google-suggest-url'.
543 Otherwise `url-retrieve-synchronously' is used."
545 :group
'anything-config
)
547 (defcustom anything-c-yahoo-suggest-url
548 "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=Generic&query="
549 "Url used for looking up Yahoo suggestions."
551 :group
'anything-config
)
553 (defcustom anything-c-yahoo-suggest-search-url
554 "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p="
555 "Url used for Yahoo searching."
557 :group
'anything-config
)
559 (defcustom anything-c-boring-buffer-regexp
565 " *Echo Area" " *Minibuf"))
566 "The regexp that match boring buffers.
567 Buffer candidates matching this regular expression will be
568 filtered from the list of candidates if the
569 `anything-c-skip-boring-buffers' candidate transformer is used, or
570 they will be displayed with face `file-name-shadow' if
571 `anything-c-shadow-boring-buffers' is used."
573 :group
'anything-config
)
574 ;; (string-match anything-c-boring-buffer-regexp "buf")
575 ;; (string-match anything-c-boring-buffer-regexp " hidden")
576 ;; (string-match anything-c-boring-buffer-regexp " *Minibuf-1*")
578 (defcustom anything-c-boring-file-regexp
580 ;; Boring directories
581 (and "/" (or ".svn" "CVS" "_darcs" ".git" ".hg") (or "/" eol
))
583 (and line-start
".#")
584 (and (or ".class" ".la" ".o" "~") eol
)))
585 "The regexp that match boring files.
586 File candidates matching this regular expression will be
587 filtered from the list of candidates if the
588 `anything-c-skip-boring-files' candidate transformer is used, or
589 they will be displayed with face `file-name-shadow' if
590 `anything-c-shadow-boring-files' is used."
592 :group
'anything-config
)
594 (defcustom anything-kill-ring-threshold
10
595 "*Minimum length to be listed by `anything-c-source-kill-ring'."
597 :group
'anything-config
)
599 (defcustom anything-su-or-sudo
"su"
600 "What command to use for root access."
602 :group
'anything-config
)
604 (defcustom anything-for-files-prefered-list
605 '(anything-c-source-ffap-line
606 anything-c-source-ffap-guesser
607 anything-c-source-buffers
+
608 anything-c-source-recentf
609 anything-c-source-bookmarks
610 anything-c-source-file-cache
611 anything-c-source-files-in-current-dir
+
612 anything-c-source-locate
)
613 "Your prefered sources to find files."
615 :group
'anything-config
)
617 (defcustom anything-create--actions-private nil
618 "User defined actions for `anything-create' / `anything-c-source-create'.
619 It is a list of (DISPLAY . FUNCTION) pairs like `action'
620 attribute of `anything-sources'.
622 It is prepended to predefined pairs."
624 :group
'anything-config
)
626 (defcustom anything-allow-skipping-current-buffer t
627 "Show current buffer or not in anything buffer"
629 :group
'anything-config
)
631 (defcustom anything-c-enable-eval-defun-hack t
632 "*If non-nil, execute `anything' using the source at point when C-M-x is pressed.
633 This hack is invoked when pressing C-M-x in the form \
634 (defvar anything-c-source-XXX ...) or (setq anything-c-source-XXX ...)."
636 :group
'anything-config
)
638 (defcustom anything-tramp-verbose
0
639 "*Just like `tramp-verbose' but specific to anything.
640 When set to 0 don't show tramp messages in anything.
641 If you want to have the default tramp messages set it to 3."
643 :group
'anything-config
)
645 (defcustom anything-raise-command nil
646 "*A shell command to jump to a window running specific program.
647 Stumpwm users could use:
648 \"stumpish eval \"\(stumpwm::%s\)\"\".
649 With others windows manager you could use:
651 Though wmctrl work also with stumpwm."
653 :group
'anything-config
)
655 (defun anything-set-anything-command-map-prefix-key (var key
)
656 (when (boundp 'anything-command-map-prefix-key
)
657 (global-unset-key (read-kbd-macro anything-command-map-prefix-key
)))
658 (setq anything-command-map-prefix-key key
)
659 (global-set-key (read-kbd-macro anything-command-map-prefix-key
)
660 'anything-command-map
))
662 (defcustom anything-command-map-prefix-key
"<f5> a"
663 "*The prefix key for all `anything-command-map' commands.
666 This default value is very likely to be changed,
667 because it is under discussion."
669 :set
'anything-set-anything-command-map-prefix-key
670 :group
'anything-config
)
673 (defun anything-configuration ()
674 "Customize `anything'."
676 (customize-group "anything-config"))
678 ;;; Anything-command-map
680 (defvar anything-command-map
)
681 (define-prefix-command 'anything-command-map
)
683 ;; rubikitch: Please change it freely because it is in discussion. I'll track from git.
684 (define-key anything-command-map
(kbd "<SPC>") 'anything-execute-anything-command
)
685 (define-key anything-command-map
(kbd "e") 'anything-etags-maybe-at-point
)
686 (define-key anything-command-map
(kbd "l") 'anything-locate
)
687 (define-key anything-command-map
(kbd "s") 'anything-surfraw
)
688 (define-key anything-command-map
(kbd "r") 'anything-regexp
)
689 (define-key anything-command-map
(kbd "w") 'anything-w3m-bookmarks
)
690 (define-key anything-command-map
(kbd "x") 'anything-firefox-bookmarks
)
691 (define-key anything-command-map
(kbd "#") 'anything-emms
)
692 (define-key anything-command-map
(kbd "m") 'anything-man-woman
)
693 (define-key anything-command-map
(kbd "t") 'anything-top
)
694 (define-key anything-command-map
(kbd "i") 'anything-imenu
)
695 (define-key anything-command-map
(kbd "C-x r b") 'anything-c-pp-bookmarks
)
696 (define-key anything-command-map
(kbd "M-y") 'anything-show-kill-ring
)
697 (define-key anything-command-map
(kbd "C-c <SPC>") 'anything-all-mark-rings
)
698 (define-key anything-command-map
(kbd "C-x C-f") 'anything-find-files
)
699 (define-key anything-command-map
(kbd "f") 'anything-for-files
)
700 (define-key anything-command-map
(kbd "C-:") 'anything-eval-expression-with-eldoc
)
701 (define-key anything-command-map
(kbd "C-,") 'anything-calcul-expression
)
702 (define-key anything-command-map
(kbd "M-x") 'anything-M-x
)
703 (define-key anything-command-map
(kbd "C-x C-w") 'anything-write-file
)
704 (define-key anything-command-map
(kbd "C-x i") 'anything-insert-file
)
705 (define-key anything-command-map
(kbd "M-s o") 'anything-occur
)
706 (define-key anything-command-map
(kbd "c") 'anything-colors
)
707 (define-key anything-command-map
(kbd "F") 'anything-select-xfont
)
708 (define-key anything-command-map
(kbd "C-c f") 'anything-recentf
)
709 (define-key anything-command-map
(kbd "C-c g") 'anything-google-suggest
)
710 (define-key anything-command-map
(kbd "h i") 'anything-info-at-point
)
711 (define-key anything-command-map
(kbd "C-x C-b") 'anything-buffers
+)
712 (define-key anything-command-map
(kbd "C-x r i") 'anything-register
)
713 (define-key anything-command-map
(kbd "C-c C-x") 'anything-c-run-external-command
)
716 (easy-menu-define nil global-map
719 ["All anything commands" anything-execute-anything-command t
]
720 ["Find any Files/Buffers" anything-for-files t
]
723 ["Find files" anything-find-files t
]
724 ["Recent Files" anything-recentf t
]
725 ["Locate" anything-locate t
]
726 ["Bookmarks" anything-c-pp-bookmarks t
])
728 ["Find buffers" anything-buffers
+ t
])
730 ["Emacs Commands" anything-M-x t
]
731 ["Externals Commands" anything-c-run-external-command t
])
733 ["Info at point" anything-info-at-point t
])
735 ["Occur" anything-occur t
]
736 ["Browse Kill ring" anything-show-kill-ring t
]
737 ["Browse register" anything-register t
]
738 ["Mark Ring" anything-all-mark-rings t
]
739 ["Colors & Faces" anything-colors t
]
740 ["Show xfonts" anything-select-xfont t
]
741 ["Imenu" anything-imenu t
]
742 ["Google Suggest" anything-google-suggest t
]
743 ["Eval expression" anything-eval-expression-with-eldoc t
]
744 ["Calcul expression" anything-calcul-expression t
]
745 ["Man pages" anything-man-woman t
]
746 ["Top externals process" anything-top t
])
748 ["Prefered Options" anything-configuration t
]))
751 ;; It is replaced by `anything-help'
752 (defun anything-c-describe-anything-bindings ()
753 "[OBSOLETE] Describe `anything' bindings."
755 (anything-run-after-quit
757 (with-current-buffer (get-buffer-create "*Anything Help*")
760 (substitute-command-keys
761 "The keys that are defined for `anything' are:
763 (pop-to-buffer "*Anything Help*")
764 (goto-char (point-min)))))
766 ;; Use `describe-mode' key in `global-map'
767 ;; (dolist (k (where-is-internal 'describe-mode global-map))
768 ;; (define-key anything-map k 'anything-c-describe-anything-bindings))
771 (defun anything-c-list-preconfigured-anything ()
774 for entry in
(cdr (assoc
775 (file-truename (locate-library "anything-config"))
777 if
(and (consp entry
)
778 (eq (car entry
) 'defun
)
779 (string-match "^Preconfigured.+$"
780 (setq doc
(or (documentation (setq sym
(cdr entry
)))
782 collect
(cons sym
(match-string 0 doc
))))
784 (defun anything-c-format-preconfigured-anything ()
785 (mapcar (lambda (x) (format "\\[%s] : %s\n" (car x
) (cdr x
)))
786 (anything-c-list-preconfigured-anything)))
788 (setq anything-help-message
792 "`anything' is QuickSilver-like candidate-selection framework.
794 Narrow the list by typing some pattern,
795 Multiple patterns are allowed by splitting by space.
796 Select with natural Emacs operations, choose with RET.
798 If you have any problems, press C-c C-x C-b!!
799 Feel free to send bug reports. I'll fix them.
800 The steps are described in the beginning of anything.el file.
802 == Basic Operations ==
803 C-p, Up: Previous Line
804 C-n, Down : Next Line
805 M-v, PageUp : Previous Page
806 C-v, PageDown : Next Page
807 Enter : Execute first (default) action / Select
810 M-PageUp, C-M-S-v, C-M-y : Previous Page (other-window)
811 M-PageDown, C-M-v : Next Page (other-window)
813 Tab, C-i : Show action list
814 Left : Previous Source
815 Right, C-o : Next Source
817 C-z : Persistent Action (Execute action with anything session kept)
818 C-c C-x C-b: Send a bug report
820 == Shortcuts For 2nd/3rd Action ==
821 \\[anything-select-2nd-action-or-end-of-line] : Execute 2nd Action (if the minibuffer cursor is at end of line)
822 \\[anything-select-3rd-action] : Execute 3rd Action
825 Visible marks store candidate. Some actions uses marked candidates.
827 \\[anything-toggle-visible-mark] : Toggle Visible Mark
828 \\[anything-prev-visible-mark] : Previous Mark
829 \\[anything-next-visible-mark] : Next Mark
831 == Miscellaneous Commands ==
832 \\[anything-toggle-resplit-window] : Toggle vertical/horizontal split anything window
833 \\[anything-quit-and-find-file] : Drop into `find-file'
834 \\[anything-delete-current-selection] : Delete Selected Item (visually)
835 \\[anything-kill-selection-and-quit] : Set Item Into the kill-ring And Quit
836 \\[anything-yank-selection] : Yank Selected Item Into Pattern
837 \\[anything-follow-mode] : Toggle Automatical Execution Of Persistent Action
838 \\[anything-force-update] : Recalculate And Redisplay Candidates
840 == Global Commands ==
841 \\<global-map>\\[anything-resume] revives last `anything' session.
842 It is very useful, so you should bind any key.
844 Single source is executed by \\[anything-call-source].
846 == Preconfigured `anything' ==
847 Preconfigured `anything' is commands that uses `anything' interface.
848 You can use them without configuration.
851 (apply 'concat
(anything-c-format-preconfigured-anything))
855 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Preconfigured Anything ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
857 (defun anything-mini ()
858 "Preconfigured `anything' lightweight version (buffer -> recentf)."
860 (anything-other-buffer '(anything-c-source-buffers+ anything-c-source-recentf
)
863 (defun anything-for-files ()
864 "Preconfigured `anything' for opening files.
865 ffap -> recentf -> buffer -> bookmark -> file-cache -> files-in-current-dir -> locate"
867 (anything-other-buffer anything-for-files-prefered-list
"*anything for files*"))
870 (defun anything-recentf ()
871 "Preconfigured `anything' for `recentf'."
873 (anything-other-buffer 'anything-c-source-recentf
"*anything recentf*"))
875 (defun anything-info-at-point ()
876 "Preconfigured `anything' for searching info at point."
878 (anything '(anything-c-source-info-elisp
879 anything-c-source-info-cl
880 anything-c-source-info-pages
)
881 (thing-at-point 'symbol
) nil nil nil
"*anything info*"))
884 (defun anything-show-kill-ring ()
885 "Preconfigured `anything' for `kill-ring'. It is drop-in replacement of `yank-pop'.
886 You may bind this command to M-y."
888 (anything-other-buffer 'anything-c-source-kill-ring
"*anything kill-ring*"))
891 (defun anything-minibuffer-history ()
892 "Preconfigured `anything' for `minibuffer-history'."
894 (let ((enable-recursive-minibuffers t
))
895 (anything-other-buffer 'anything-c-source-minibuffer-history
896 "*anything minibuffer-history*")))
898 ;; In Emacs 23.1.50, minibuffer-local-must-match-filename-map was renamed to
899 ;; minibuffer-local-filename-must-match-map.
900 (defvar minibuffer-local-filename-must-match-map
(make-sparse-keymap)) ;; Emacs 23.1.+
901 (defvar minibuffer-local-must-match-filename-map
(make-sparse-keymap)) ;; Older Emacsen
902 (dolist (map (list minibuffer-local-filename-completion-map
903 minibuffer-local-completion-map
904 minibuffer-local-must-match-filename-map
905 minibuffer-local-filename-must-match-map
907 minibuffer-local-isearch-map
908 minibuffer-local-must-match-map
909 minibuffer-local-ns-map
))
910 (define-key map
"\C-r" 'anything-minibuffer-history
))
913 (defun anything-gentoo ()
914 "Preconfigured `anything' for gentoo linux."
916 (anything-other-buffer '(anything-c-source-gentoo
917 anything-c-source-use-flags
)
918 "*anything gentoo*"))
921 (defun anything-imenu ()
922 "Preconfigured `anything' for `imenu'."
924 (anything 'anything-c-source-imenu nil nil nil nil
"*anything imenu*"))
927 (defun anything-google-suggest ()
928 "Preconfigured `anything' for google search with google suggest."
930 (anything-other-buffer 'anything-c-source-google-suggest
"*anything google*"))
933 (defun anything-yahoo-suggest ()
934 "Preconfigured `anything' for Yahoo searching with Yahoo suggest."
936 (anything-other-buffer 'anything-c-source-yahoo-suggest
"*anything yahoo*"))
938 ;;; Converted from anything-show-*-only
940 (defun anything-for-buffers ()
941 "Preconfigured `anything' for buffer."
943 (anything-other-buffer 'anything-c-source-buffers
"*anything for buffers*"))
946 (defun anything-buffers+ ()
947 "Enhanced preconfigured `anything' for buffer."
949 (anything-other-buffer 'anything-c-source-buffers
+ "*anything buffers*"))
952 (defun anything-bbdb ()
953 "Preconfigured `anything' for BBDB.
957 http://bbdb.sourceforge.net/"
959 (anything-other-buffer 'anything-c-source-bbdb
"*anything bbdb*"))
962 (defun anything-locate ()
963 "Preconfigured `anything' for Locate.
964 Note you can add locate command after entering pattern.
965 See man locate for more infos."
967 (anything-other-buffer 'anything-c-source-locate
"*anything locate*"))
970 (defun anything-w3m-bookmarks ()
971 "Preconfigured `anything' for w3m bookmark.
973 Needs w3m and emacs-w3m.
975 http://w3m.sourceforge.net/
976 http://emacs-w3m.namazu.org/"
978 (anything-other-buffer 'anything-c-source-w3m-bookmarks
979 "*anything w3m bookmarks*"))
982 (defun anything-firefox-bookmarks ()
983 "Preconfigured `anything' for firefox bookmark.
984 You will have to enable html bookmarks in firefox:
985 open about:config in firefox and double click on this line to enable value \
988 user_pref(\"browser.bookmarks.autoExportHTML\", false);
992 user_pref(\"browser.bookmarks.autoExportHTML\", true);
994 After closing firefox, you will be able to browse you bookmarks.
997 (anything-other-buffer 'anything-c-source-firefox-bookmarks
998 "*Anything Firefox*"))
1001 (defun anything-colors ()
1002 "Preconfigured `anything' for color."
1004 (anything-other-buffer '(anything-c-source-colors anything-c-source-customize-face
)
1005 "*anything colors*"))
1008 (defun anything-bookmarks ()
1009 "Preconfigured `anything' for bookmarks."
1011 (anything-other-buffer 'anything-c-source-bookmarks
"*anything bookmarks*"))
1014 (defun anything-c-pp-bookmarks ()
1015 "Preconfigured `anything' for bookmarks (pretty-printed)."
1017 (anything-other-buffer '(anything-c-source-bookmarks-local
1018 anything-c-source-bookmarks-su
1019 anything-c-source-bookmarks-ssh
)
1020 "*anything pp bookmarks*"))
1023 (defun anything-register ()
1024 "Preconfigured `anything' for Emacs registers."
1026 (anything-other-buffer 'anything-c-source-register
"*anything register*"))
1029 (defun anything-bm-list ()
1030 "Preconfigured `anything' for visible bookmarks.
1034 http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el"
1036 (let ((anything-outline-using t
))
1037 (anything-other-buffer 'anything-c-source-bm
"*anything bm list*")))
1040 (defun anything-timers ()
1041 "Preconfigured `anything' for timers."
1043 (anything-other-buffer '(anything-c-source-absolute-time-timers
1044 anything-c-source-idle-time-timers
)
1045 "*anything timers*"))
1047 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Applications ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1050 (defun anything-kill-buffers ()
1051 "Preconfigured `anything' to kill buffer you selected."
1054 '(((name .
"Kill Buffers")
1055 (candidates . anything-c-buffer-list
)
1057 ("Kill Buffer" .
(lambda (candidate)
1058 (kill-buffer candidate
)
1059 (anything-kill-buffers)
1065 (defun anything-query-replace-regexp (&rest args
)
1066 "Preconfigured `anything' : Drop-in replacement of `query-replace-regexp' with building regexp visually."
1069 (anything-c-regexp-base "Query Replace Regexp: "
1070 '((name .
"Lines matching Regexp")
1071 (mode-line .
"Set replace start line and type RET.")
1072 (action . anything-c-query-replace-args
)))))
1075 (list (car common
) (cadr common
) (caddr common
)
1076 ;; These are done separately here
1077 ;; so that command-history will record these expressions
1078 ;; rather than the values they had this time.
1080 ;; This idea is borrowed from original `query-replace-regexp'.
1081 (if (and transient-mark-mode mark-active
)
1083 (if (and transient-mark-mode mark-active
)
1085 (apply 'query-replace-regexp args
))
1088 (defun anything-regexp ()
1089 "Preconfigured `anything' : It is like `re-builder'. It helps buliding regexp and replacement."
1091 (anything-c-regexp-base
1093 '((name .
"Regexp Builder")
1094 (mode-line .
"Press TAB to select action.")
1096 ("Kill Regexp as sexp" .
1097 (lambda (x) (anything-c-regexp-kill-new (prin1-to-string (funcall (anything-attr 'regexp
))))))
1098 ("Query Replace Regexp" .
1099 (lambda (x) (apply 'query-replace-regexp
(anything-c-query-replace-args (point)))))
1101 (lambda (x) (anything-c-regexp-kill-new (funcall (anything-attr 'regexp
)))))))))
1103 (defun anything-c-query-replace-args (start-point)
1104 ;; create arguments of `query-replace-regexp'.
1105 (let ((region-only (and transient-mark-mode mark-active
))
1106 (regexp (funcall (anything-attr 'regexp
))))
1109 (query-replace-read-to regexp
1110 (format "Query replace regexp %s%s%s with: "
1111 (if region-only
"in region " "")
1113 (if current-prefix-arg
"(word) " ""))
1115 current-prefix-arg
)))
1117 (defun anything-c-regexp-get-line (s e
)
1121 (format "%5d: %s" (line-number-at-pos s
) (buffer-substring s e
))
1123 (loop for i from
0 to
(1- (/ (length (match-data)) 2))
1124 collect
(format "\n \\%s = %s"
1125 (if (zerop i
) "&" i
)
1128 ;; KLUDGE: point of anything-candidate-buffer is +1 than that of anything-current-buffer.
1129 ;; It is implementation problem of candidates-in-buffer.
1133 ;; Shut up byte compiler
1134 (defun anything-goto-line (numline)
1135 "Replacement of `goto-line'."
1136 (goto-char (point-min))
1137 (forward-line (1- numline
)))
1139 (defun anything-c-regexp-persistent-action (pt)
1141 (anything-persistent-highlight-point))
1143 (defun anything-c-regexp-base (prompt attributes
)
1145 (let ((anything-compile-source-functions
1146 ;; rule out anything-match-plugin because the input is one regexp.
1147 (delq 'anything-compile-source--match-plugin
1148 (copy-sequence anything-compile-source-functions
)))
1150 '((init .
(lambda () (anything-candidate-buffer anything-current-buffer
)))
1151 (candidates-in-buffer)
1152 (get-line . anything-c-regexp-get-line
)
1153 (persistent-action . anything-c-regexp-persistent-action
)
1154 (persistent-help .
"Show this line")
1157 (if (and transient-mark-mode mark-active
)
1158 (narrow-to-region (region-beginning) (region-end)))
1163 '((regexp .
(lambda () anything-pattern
)))
1167 `((name .
,(concat (assoc-default 'name attributes
) " (sexp)")))
1169 '((candidates-in-buffer
1170 .
(lambda () (let ((anything-pattern (eval (read anything-pattern
))))
1171 (anything-candidates-in-buffer))))
1172 (regexp .
(lambda () (eval (read anything-pattern
)))))
1174 nil prompt nil nil
"*anything regexp*"))))
1176 ;; (anything-c-regexp-base "Regexp: " '((name . "test")))
1177 ;; (anything-c-regexp-base "Regexp: " '((name . "test") (candidates-in-buffer . (lambda () (let ((anything-pattern (eval (read anything-pattern)))) (anything-candidates-in-buffer))))))
1179 (defun anything-c-regexp-kill-new (input)
1181 (message "Killed: %s" input
))
1183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1185 (defun anything-insert-buffer-name ()
1186 "Insert buffer name."
1188 (anything-insert-string
1189 (with-current-buffer anything-current-buffer
1190 (if buffer-file-name
(file-name-nondirectory buffer-file-name
)
1193 (defun anything-insert-symbol ()
1194 "Insert current symbol."
1196 (anything-insert-string
1197 (with-current-buffer anything-current-buffer
1199 (buffer-substring (beginning-of-thing 'symbol
)
1200 (end-of-thing 'symbol
))))))
1202 (defun anything-insert-selection ()
1203 "Insert current selection."
1205 (anything-insert-string
1206 (with-current-buffer anything-current-buffer
1207 (anything-get-selection))))
1209 (defun anything-show-buffer-only ()
1210 "[OBSOLETE] Only show sources about buffer.
1211 Use `anything-for-buffers' instead."
1213 (anything-set-source-filter '("Buffers")))
1215 (defun anything-show-bbdb-only ()
1216 "[OBSOLETE] Only show sources about BBDB.
1217 Use `anything-bbdb' instead."
1219 (anything-set-source-filter '("BBDB")))
1221 (defun anything-show-locate-only ()
1222 "[OBSOLETE] Only show sources about Locate.
1223 Use `anything-locate' instead."
1225 (anything-set-source-filter '("Locate")))
1227 (defun anything-show-info-only ()
1228 "[OBSOLETE] Only show sources about Info.
1229 Use `anything-info-at-point' instead."
1231 (anything-set-source-filter '("Info Pages"
1233 "Info Common-Lisp")))
1235 (defun anything-show-imenu-only ()
1236 "[OBSOLETE] Only show sources about Imenu.
1237 Use `anything-imenu' instead."
1239 (anything-set-source-filter '("Imenu")))
1241 (defun anything-show-files-only ()
1242 "[OBSOLETE] Only show sources about File.
1243 Use `anything-for-files' instead."
1245 (anything-set-source-filter '("File Name History"
1246 "Files from Current Directory"
1249 (defun anything-show-w3m-bookmarks-only ()
1250 "[OBSOLETE] Only show source about w3m bookmark.
1251 Use `anything-w3m-bookmarks' instead."
1253 (anything-set-source-filter '("W3m Bookmarks")))
1255 (defun anything-show-colors-only ()
1256 "[OBSOLETE] Only show source about color.
1257 Use `anything-colors' instead."
1259 (anything-set-source-filter '("Colors"
1260 "Customize Faces")))
1262 (defun anything-show-kill-ring-only ()
1263 "[OBSOLETE] Only show source about kill ring.
1264 Use `anything-show-kill-ring' instead."
1266 (anything-set-source-filter '("Kill Ring")))
1268 (defun anything-show-this-source-only ()
1269 "Only show this source."
1271 (setq anything-candidate-number-limit
9999)
1272 (anything-set-source-filter
1273 (list (assoc-default 'name
(anything-get-current-source)))))
1275 (defun anything-test-sources ()
1276 "List all anything sources for test.
1277 The output is sexps which are evaluated by \\[eval-last-sexp]."
1279 (with-output-to-temp-buffer "*Anything Test Sources*"
1280 (mapc (lambda (s) (princ (format ";; (anything '%s)\n" s
)))
1281 (apropos-internal "^anything-c-source" #'boundp
))
1282 (pop-to-buffer standard-output
)))
1284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utilities Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1285 ;;; For compatibility
1286 (unless (fboundp 'region-active-p
)
1287 (defun region-active-p ()
1288 "Return t if Transient Mark mode is enabled and the mark is active.
1290 Most commands that act on the region if it is active and
1291 Transient Mark mode is enabled, and on the text near point
1292 otherwise, should use `use-region-p' instead. That function
1293 checks the value of `use-empty-active-region' as well."
1294 (and transient-mark-mode mark-active
)))
1296 (defun anything-nest (&rest same-as-anything
)
1297 "Nested `anything'. If you use `anything' within `anything', use it."
1298 (with-selected-window (anything-window)
1299 (let (anything-current-position
1300 anything-current-buffer
1301 (orig-anything-buffer anything-buffer
)
1305 anything-compiled-sources
1306 anything-buffer-chars-modified-tick
1307 (anything-samewindow t
)
1308 (enable-recursive-minibuffers t
))
1310 (apply #'anything same-as-anything
)
1311 (anything-initialize-overlays orig-anything-buffer
)
1312 (add-hook 'post-command-hook
'anything-check-minibuffer-input
)))))
1314 (defun anything-displaying-source-names ()
1315 "Display sources name."
1316 (with-current-buffer anything-buffer
1317 (goto-char (point-min))
1319 while
(setq pos
(next-single-property-change (point) 'anything-header
))
1321 collect
(buffer-substring-no-properties (point-at-bol)(point-at-eol))
1322 do
(forward-line 1))))
1324 (defun anything-select-source ()
1327 (let ((default (assoc-default 'name
(anything-get-current-source)))
1328 (source-names (anything-displaying-source-names))
1329 (all-source-names (mapcar (lambda (s) (assoc-default 'name s
))
1330 (anything-get-sources))))
1331 (setq anything-candidate-number-limit
9999)
1333 (let (anything-source-filter)
1334 (anything-nest '(((name .
"Anything Source")
1335 (candidates . source-names
)
1336 (action . identity
))
1337 ((name .
"Anything Source (ALL)")
1338 (candidates . all-source-names
)
1339 (action . identity
)))
1341 default
"*anything select source*"))
1342 (anything-set-source-filter (list it
))
1343 (anything-set-source-filter nil
))))
1345 (defun anything-insert-string (str)
1347 (delete-minibuffer-contents)
1350 (defun anything-c-match-on-file-name (candidate)
1351 "Return non-nil if `anything-pattern' match the filename (without directory part) of CANDIDATE."
1352 (string-match anything-pattern
(file-name-nondirectory candidate
)))
1354 (defun anything-c-match-on-directory-name (candidate)
1355 "Return non-nil if `anything-pattern' match the directory part of CANDIDATE (a file)."
1356 (anything-aif (file-name-directory candidate
)
1357 (string-match anything-pattern it
)))
1359 (defun anything-c-string-match (candidate)
1360 "Return non-nil if `anything-pattern' match CANDIDATE.
1361 The match is done with `string-match'."
1362 (string-match anything-pattern candidate
))
1364 ;; `anything-c-compose' is no more needed, it is for compatibility.
1365 (defalias 'anything-c-compose
'anything-compose
)
1367 (defun anything-c-skip-entries (list regexp
)
1368 "Remove entries which matches REGEXP from LIST."
1369 (remove-if (lambda (x) (and (stringp x
) (string-match regexp x
)))
1372 (defun anything-c-shadow-entries (list regexp
)
1373 "Elements of LIST matching REGEXP will be displayed with the `file-name-shadow' face if available."
1374 (mapcar (lambda (file)
1375 ;; Add shadow face property to boring files.
1376 (let ((face (if (facep 'file-name-shadow
)
1378 ;; fall back to default on XEmacs
1380 (if (string-match regexp file
)
1381 (setq file
(propertize file
'face face
))))
1385 (defsubst anything-c-stringify
(str-or-sym)
1386 "Get string of STR-OR-SYM."
1387 (if (stringp str-or-sym
)
1389 (symbol-name str-or-sym
)))
1391 (defsubst anything-c-symbolify
(str-or-sym)
1392 "Get symbol of STR-OR-SYM."
1393 (if (symbolp str-or-sym
)
1395 (intern str-or-sym
)))
1397 (defun anything-c-describe-function (func)
1398 "FUNC is symbol or string."
1399 (describe-function (anything-c-symbolify func
)))
1401 (defun anything-c-describe-variable (var)
1402 "VAR is symbol or string."
1403 (describe-variable (anything-c-symbolify var
)))
1405 (defun anything-c-find-function (func)
1406 "FUNC is symbol or string."
1407 (find-function (anything-c-symbolify func
)))
1409 (defun anything-c-find-variable (var)
1410 "VAR is symbol or string."
1411 (find-variable (anything-c-symbolify var
)))
1413 (defun anything-c-kill-new (string &optional replace yank-handler
)
1414 "STRING is symbol or string."
1415 (kill-new (anything-c-stringify string
) replace yank-handler
))
1417 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Prefix argument in action ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1419 (defvar anything-current-prefix-arg nil
1420 "`current-prefix-arg' when selecting action.
1421 It is cleared after executing action.")
1423 (defadvice anything-exit-minibuffer
(before anything-current-prefix-arg activate
)
1424 (unless anything-current-prefix-arg
1425 (setq anything-current-prefix-arg current-prefix-arg
)))
1427 (add-hook 'anything-after-action-hook
1428 (lambda () (setq anything-current-prefix-arg nil
)))
1431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Hacks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1432 (defadvice eval-defun
(after anything-source-hack activate
)
1433 "See `anything-c-enable-eval-defun-hack'."
1434 (when anything-c-enable-eval-defun-hack
1435 (let ((varsym (save-excursion
1436 (beginning-of-defun)
1438 (when (memq (read (current-buffer)) '(defvar setq
))
1439 (read (current-buffer))))))
1440 (when (string-match "^anything-c-source-" (symbol-name varsym
))
1441 (anything varsym
)))))
1442 ;; (progn (ad-disable-advice 'eval-defun 'after 'anything-source-hack) (ad-update 'eval-defun))
1444 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Document Generator ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1445 (defun anything-c-create-summary ()
1446 "Create `anything' summary."
1448 (goto-char (point-min))
1449 (loop while
(re-search-forward "^;;;; <\\(.+?\\)>$\\|^;; (anything '\\(.+?\\))$\\|^ *;; (anything '\\(.+?\\))$" nil t
)
1450 collect
(cond ((match-beginning 1)
1451 (cons 'section
(match-string-no-properties 1)))
1452 ((match-beginning 2)
1454 (cons (match-string-no-properties 2)
1455 (assoc-default 'name
(symbol-value (intern (match-string-no-properties 2)))))))
1456 ((match-beginning 3)
1458 (cons (match-string-no-properties 3)
1459 (assoc-default 'name
(symbol-value (intern (match-string-no-properties 3)))))))))))
1461 ;; (find-epp (anything-c-create-summary))
1463 (defun anything-c-insert-summary ()
1464 "Insert `anything' summary."
1466 (goto-char (point-min))
1467 (search-forward ";; Below are complete source list you can setup in")
1469 (delete-region (point)
1470 (progn (search-forward ";;; Change log:" nil t
)
1471 (forward-line -
1) (point)))
1474 for
(kind . value
) in
(anything-c-create-summary)
1476 do
(cond ((eq kind
'section
)
1478 (align-regexp beg
(point) "\\(\\s-*\\)(" 1 1 nil
))
1479 (insert ";; " value
":\n")
1482 (insert ";; `" (car value
) "' (" (cdr value
) ")\n")))
1483 finally
(align-regexp beg
(point) "\\(\\s-*\\)(" 1 1 nil
))))
1484 ;; (anything-c-insert-summary)
1486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Sources ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1488 (defun anything-c-buffer-list ()
1489 "Return the list of names of buffers with boring buffers filtered out.
1490 Boring buffers is specified by `anything-c-boring-buffer-regexp'.
1491 The first buffer in the list will be the last recently used
1492 buffer that is not the current buffer."
1493 (let ((buffers (mapcar 'buffer-name
(buffer-list))))
1494 (append (cdr buffers
) (list (car buffers
)))))
1496 (defvar anything-c-source-buffers
1497 '((name .
"Buffers")
1498 (candidates . anything-c-buffer-list
)
1500 ;; (anything 'anything-c-source-buffers)
1502 (defvar anything-c-source-buffer-not-found
1503 '((name .
"Create buffer")
1506 ;; (anything 'anything-c-source-buffer-not-found)
1509 (defface anything-dir-heading
'((t (:foreground
"Blue" :background
"Pink")))
1510 "*Face used for directory headings in dired buffers."
1513 (defface anything-file-name
1514 '((t (:foreground
"Blue")))
1515 "*Face used for file names (without suffixes) in dired buffers."
1518 (defface anything-dir-priv
1519 '((t (:foreground
"DarkRed" :background
"LightGray")))
1520 "*Face used for directory privilege indicator (d) in dired buffers."
1523 (defvar anything-c-buffers-face1
'anything-dir-priv
)
1524 (defvar anything-c-buffers-face2
'font-lock-type-face
)
1525 (defvar anything-c-buffers-face3
'italic
)
1526 (eval-when-compile (require 'dired
))
1527 (defun anything-c-highlight-buffers (buffers)
1529 (loop for i in buffers
1530 if
(rassoc (get-buffer i
) dired-buffers
)
1531 collect
(propertize i
1532 'face anything-c-buffers-face1
1533 'help-echo
(car (rassoc (get-buffer i
) dired-buffers
)))
1534 if
(buffer-file-name (get-buffer i
))
1535 collect
(propertize i
1536 'face anything-c-buffers-face2
1537 'help-echo
(buffer-file-name (get-buffer i
)))
1538 if
(and (not (rassoc (get-buffer i
) dired-buffers
))
1539 (not (buffer-file-name (get-buffer i
))))
1540 collect
(propertize i
1541 'face anything-c-buffers-face3
)))
1543 (defvar anything-c-source-buffers
+
1544 '((name .
"Buffers")
1545 (candidates . anything-c-buffer-list
)
1547 (candidate-transformer anything-c-skip-current-buffer
1548 anything-c-highlight-buffers
1549 anything-c-skip-boring-buffers
)
1550 (persistent-action . anything-c-buffers
+-persistent-action
)
1551 (persistent-help .
"Show this buffer / C-u \\[anything-execute-persistent-action]: Kill this buffer")))
1553 (defun anything-c-buffers+-persistent-action
(name)
1555 (with-current-buffer item
1556 (if (and (buffer-modified-p)
1557 (buffer-file-name (current-buffer)))
1561 (kill-buffer item
))))
1563 (switch-to-buffer item
)))
1564 (if current-prefix-arg
1567 (anything-delete-current-selection))
1570 ;; (anything 'anything-c-source-buffers+)
1574 ;;; File name history
1575 (defvar anything-c-source-file-name-history
1576 '((name .
"File Name History")
1577 (candidates . file-name-history
)
1578 (match anything-c-match-on-file-name
1579 anything-c-match-on-directory-name
)
1581 ;; (anything 'anything-c-source-file-name-history)
1583 ;;; Files in current dir
1584 (defvar anything-c-source-files-in-current-dir
1585 '((name .
"Files from Current Directory")
1586 (candidates .
(lambda ()
1587 (with-current-buffer anything-current-buffer
1588 (directory-files (anything-c-current-directory)))))
1589 ;; volatile is not needed, I think.
1591 ;; (anything 'anything-c-source-files-in-current-dir)
1593 (defvar anything-c-files-face1
'anything-dir-priv
)
1594 (defvar anything-c-files-face2
'anything-file-name
)
1595 (defun anything-c-highlight-files (files)
1596 (loop for i in files
1597 if
(file-directory-p i
)
1598 collect
(propertize (file-name-nondirectory i
)
1599 'face anything-c-files-face1
1600 'help-echo
(expand-file-name i
))
1602 collect
(propertize (file-name-nondirectory i
)
1603 'face anything-c-files-face2
1604 'help-echo
(expand-file-name i
))))
1607 (defvar anything-c-source-files-in-current-dir
+
1608 '((name .
"Files from Current Directory")
1609 (candidates .
(lambda ()
1610 (with-current-buffer anything-current-buffer
1611 (directory-files (anything-c-current-directory) t
))))
1612 (candidate-transformer anything-c-highlight-files
)
1613 ;; volatile is not needed, I think.
1616 ;; (anything 'anything-c-source-files-in-current-dir+)
1618 ;;; Anything replacement of file name completion for `find-file' and friends.
1620 (defvar anything-c-find-files-doc-header
(format " (`%s':Go to precedent level)"
1621 (if window-system
"C-." "C-l"))
1622 "*The doc that is inserted in the Name header of a find-files or dired source.")
1624 (defvar anything-c-source-find-files
1625 `((name .
,(concat "Find Files" anything-c-find-files-doc-header
))
1626 ;; It is needed for filenames with capital letters
1629 (setq ffap-newfile-prompt t
)))
1630 (candidates . anything-find-files-get-candidates
)
1631 (candidate-transformer anything-c-highlight-ffiles
)
1632 (persistent-action . anything-find-files-persistent-action
)
1633 (persistent-help .
"Expand Candidate")
1638 `(("Find File" . anything-c-find-file-or-marked
)
1639 ("Find file in Dired" . anything-c-point-file-in-dired
)
1640 ,(and (locate-library "elscreen")
1641 '("Find file in Elscreen" . anything-elscreen-find-file
))
1642 ("Complete at point"
1643 . anything-c-insert-file-name-completion-at-point
)
1644 ("Delete File(s)" . anything-delete-marked-files
)
1645 ("Find file as root" . anything-find-file-as-root
)
1646 ("Open file externally (C-u to choose)"
1647 . anything-c-open-file-externally
)
1648 ;; ("Create dired buffer on marked"
1649 ;; . anything-c-create-dired-on-marked)
1650 ("Find file other window" . find-file-other-window
)
1651 ("Find file other frame" . find-file-other-frame
))))))
1653 ;; (anything 'anything-c-source-find-files)
1655 (defun* anything-reduce-file-name
(fname level
&key unix-close expand
)
1656 "Reduce FNAME by LEVEL from end or beginning depending LEVEL value.
1657 If LEVEL is positive reduce from end else from beginning.
1658 If UNIX-CLOSE is non--nil close filename with /.
1659 If EXPAND is non--nil expand-file-name."
1660 (let* ((exp-fname (expand-file-name fname
))
1661 (fname-list (split-string (if (or (string= fname
"~/") expand
)
1662 exp-fname fname
) "/" t
))
1663 (len (length fname-list
))
1664 (pop-list (if (< level
0)
1665 (subseq fname-list
(* level -
1))
1666 (subseq fname-list
0 (- len level
))))
1667 (result (mapconcat 'identity pop-list
"/"))
1668 (empty (string= result
"")))
1669 (when unix-close
(setq result
(concat result
"/")))
1670 (if (string-match "^~" result
)
1671 (if (string= result
"~/") "~/" result
)
1673 (if empty
"../" (concat "../" result
))
1674 (cond ((eq system-type
'windows-nt
)
1675 (if empty
"c:/" result
))
1678 (concat "/" result
)))))))
1680 (defun anything-file-completion-source-p ()
1681 "Test if current source is a dired or find-files source."
1682 (let ((ff-sources '("Find Files" "Copy Files"
1683 "Rename Files" "Symlink Files"
1684 "Hardlink Files" "Write File"
1685 "Insert File" "Read file name"))
1686 (cur-source (cdr (assoc 'name
(anything-get-current-source)))))
1688 (dolist (i ff-sources
)
1689 (when (equal cur-source
(concat i anything-c-find-files-doc-header
))
1690 (throw 'break t
))))))
1692 (defun anything-find-files-down-one-level (arg)
1693 "Go down one level like unix command `cd ..'.
1694 If prefix numeric arg is given go ARG level down."
1696 (when (anything-file-completion-source-p)
1697 (let ((new-pattern (anything-reduce-file-name anything-pattern arg
:unix-close t
:expand t
)))
1698 (with-selected-window (minibuffer-window)
1699 (delete-minibuffer-contents)
1700 (insert new-pattern
)))))
1702 ;; `C-.' doesn't work in terms use `C-l' instead.
1704 (define-key anything-map
(kbd "C-.") 'anything-find-files-down-one-level
)
1705 (define-key anything-map
(kbd "C-l") 'anything-find-files-down-one-level
))
1707 (defun anything-c-point-file-in-dired (file)
1708 "Put point on filename FILE in dired buffer."
1709 (dired (file-name-directory file
))
1710 (dired-goto-file file
))
1712 (defun anything-create-tramp-name (fname)
1713 "Build filename for `anything-pattern' like /su:: or /sudo::."
1714 (apply #'tramp-make-tramp-file-name
1716 with v
= (tramp-dissect-file-name fname
)
1717 for i across v collect i
)))
1719 (defun anything-find-files-get-candidates ()
1720 "Create candidate list for `anything-c-source-find-files'."
1721 (let* ( ; Don't try to tramp connect before entering the second ":".
1722 (tramp-file-name-regexp "\\`/\\([^[/:]+\\|[^/]+]\\):.*:?")
1723 (path (cond ((string-match "^~" anything-pattern
)
1724 (replace-match (getenv "HOME") nil t anything-pattern
))
1725 ((string-match tramp-file-name-regexp anything-pattern
)
1726 (let ((tramp-name (anything-create-tramp-name
1727 (match-string 0 anything-pattern
))))
1728 (replace-match tramp-name nil t anything-pattern
)))
1729 (t anything-pattern
)))
1730 (tramp-verbose anything-tramp-verbose
)) ; No tramp message when 0.
1731 ;; Inlined version (<2010-02-18 Jeu.>.) of `tramp-handle-directory-files'
1732 ;; to fix bug in tramp that doesn't show the dot file names(i.e "." "..")
1734 (flet ((tramp-handle-directory-files
1735 (directory &optional full match nosort files-only
)
1736 "Like `directory-files' for Tramp files."
1737 ;; FILES-ONLY is valid for XEmacs only.
1738 (when (file-directory-p directory
)
1739 (setq directory
(file-name-as-directory (expand-file-name directory
)))
1740 (let ((temp (nreverse (file-name-all-completions "" directory
)))
1744 (setq item
(directory-file-name (pop temp
)))
1745 (when (and (or (null match
) (string-match match item
))
1746 (or (null files-only
)
1748 (and (equal files-only t
) (file-regular-p item
))
1749 ;; Directories only.
1750 (file-directory-p item
)))
1751 (push (if full
(concat directory item
) item
)
1753 (if nosort result
(sort result
'string
<))))))
1755 (set-text-properties 0 (length path
) nil path
)
1756 (setq anything-pattern path
)
1757 (cond ((or (file-regular-p path
)
1758 (and ffap-url-regexp
(string-match ffap-url-regexp path
)))
1760 ((string= anything-pattern
"") (directory-files "/" t
))
1761 ((file-directory-p path
) (directory-files path t
))
1765 (directory-files (file-name-directory path
) t
)))))))
1767 (defface anything-dired-symlink-face
1768 '((t (:foreground
"DarkOrange")))
1769 "*Face used for symlinks in `anything-find-files'."
1772 (defun anything-c-highlight-ffiles (files)
1773 "Candidate transformer for `anything-c-source-find-files'."
1774 (loop for i in files
1775 if
(file-symlink-p i
)
1776 collect
(propertize i
'face
'anything-dired-symlink-face
1777 'help-echo
(file-truename i
)) into a
1778 if
(file-directory-p i
)
1779 collect
(propertize i
'face anything-c-files-face1
) into a
1781 collect
(propertize i
'face anything-c-files-face2
) into a
1785 (defun anything-find-files-persistent-action (candidate)
1786 "Open subtree CANDIDATE without quitting anything.
1787 If CANDIDATE is not a directory expand CANDIDATE filename.
1788 If CANDIDATE is alone, open file CANDIDATE filename."
1789 (flet ((insert-in-minibuffer (elm)
1790 (with-selected-window (minibuffer-window)
1791 (delete-minibuffer-contents)
1792 (set-text-properties 0 (length elm
) nil elm
)
1794 (cond ((and (file-directory-p candidate
) (file-symlink-p candidate
))
1795 (insert-in-minibuffer (file-name-as-directory
1797 (expand-file-name candidate
)))))
1798 ((file-directory-p candidate
)
1799 (insert-in-minibuffer (file-name-as-directory
1800 (expand-file-name candidate
))))
1801 ((file-symlink-p candidate
)
1802 (insert-in-minibuffer (file-truename candidate
)))
1803 (t ; First hit on C-z expand CANDIDATE second hit open file.
1804 (let ((new-pattern (anything-get-selection anything-last-buffer
))
1805 (num-lines-buf (with-current-buffer anything-last-buffer
1806 (count-lines (point-min) (point-max)))))
1807 (if (> num-lines-buf
3)
1808 (insert-in-minibuffer new-pattern
) (find-file candidate
)))))))
1810 (defun anything-c-insert-file-name-completion-at-point (candidate)
1811 "Insert file name completion at point."
1812 (if buffer-read-only
1813 (error "Error: Buffer `%s' is read-only" (buffer-name))
1814 (let* ((end (point))
1815 (guess (thing-at-point 'filename
))
1816 (full-path-p (or (string-match (concat "^" (getenv "HOME")) guess
)
1817 (string-match "^[^\~]" guess
))))
1818 (set-text-properties 0 (length candidate
) nil candidate
)
1819 (if (and guess
(not (string= guess
"")) (string-match "^~\\|/.*" guess
))
1821 (search-backward guess
(- (point) (length guess
)))
1822 (delete-region (point) end
)
1824 (insert (expand-file-name candidate
))
1825 (insert (abbreviate-file-name candidate
))))
1826 (error "Aborting completion: No valid file name at point")))))
1829 (defun anything-find-files ()
1830 "Preconfigured `anything' for anything implementation of `find-file'."
1832 (anything 'anything-c-source-find-files
1833 (anything-find-files-input (ffap-guesser)
1834 (thing-at-point 'filename
))
1835 "Find Files or Url: " nil nil
"*Anything Find Files*"))
1837 (defun anything-c-current-directory ()
1838 "Return current-directory name at point.
1839 Useful in dired buffers when there is inserted subdirs."
1840 (if (eq major-mode
'dired-mode
)
1841 (dired-current-directory)
1844 (defun anything-find-files-input (fap tap
)
1845 "Default input of `anything-find-files'."
1846 (let* ((def-dir (anything-c-current-directory))
1847 (file-p (and fap
(file-exists-p fap
)
1849 (file-name-directory (expand-file-name tap def-dir
)))))
1850 (input (if file-p
(expand-file-name tap def-dir
) fap
)))
1851 (or input
(expand-file-name def-dir
))))
1853 ;;; Anything completion for `write-file'.==> C-x C-w
1854 (defvar anything-c-source-write-file
1855 `((name .
,(concat "Write File" anything-c-find-files-doc-header
))
1856 ;; It is needed for filenames with capital letters
1858 (candidates . anything-find-files-get-candidates
)
1859 (candidate-transformer anything-c-highlight-ffiles
)
1860 (persistent-action . anything-find-files-persistent-action
)
1861 (persistent-help .
"Expand Candidate")
1864 (("Write File" .
(lambda (candidate)
1865 (write-file candidate
'confirm
)))))))
1868 (defun anything-write-file ()
1869 "Preconfigured `anything' providing completion for `write-file'."
1871 (anything 'anything-c-source-write-file
1872 (expand-file-name default-directory
)
1873 "Write buffer to file: " nil nil
"*Anything write file*"))
1875 ;;; Anything completion for `insert-file'.==> C-x i
1876 (defvar anything-c-source-insert-file
1877 `((name .
,(concat "Insert File" anything-c-find-files-doc-header
))
1878 ;; It is needed for filenames with capital letters
1880 (candidates . anything-find-files-get-candidates
)
1881 (candidate-transformer anything-c-highlight-ffiles
)
1882 (persistent-action . anything-find-files-persistent-action
)
1883 (persistent-help .
"Expand Candidate")
1886 (("Insert File" .
(lambda (candidate)
1887 (when (y-or-n-p (format "Really insert %s in %s "
1888 candidate anything-current-buffer
))
1889 (insert-file-contents candidate
))))))))
1892 (defun anything-insert-file ()
1893 "Preconfigured `anything' providing completion for `insert-file'."
1895 (anything 'anything-c-source-insert-file
1896 (expand-file-name default-directory
)
1897 "Insert file: " nil nil
"*Anything insert file*"))
1899 ;;; Anything completion for copy, rename and (rel)sym/hard/link files from dired.
1900 (defvar anything-c-source-copy-files
1901 `((name .
,(concat "Copy Files" anything-c-find-files-doc-header
))
1902 ;; It is needed for filenames with capital letters
1904 (candidates . anything-find-files-get-candidates
)
1905 (candidate-transformer anything-c-highlight-ffiles
)
1906 (persistent-action . anything-find-files-persistent-action
)
1907 (persistent-help .
"Expand Candidate")
1911 .
(lambda (candidate)
1912 (anything-dired-action candidate
:action
'copy
)))
1914 .
(lambda (candidate)
1915 (anything-dired-action candidate
:action
'copy
:follow t
)))))))
1918 (defvar anything-c-source-rename-files
1919 `((name .
,(concat "Rename Files" anything-c-find-files-doc-header
))
1920 ;; It is needed for filenames with capital letters
1922 (candidates . anything-find-files-get-candidates
)
1923 (candidate-transformer anything-c-highlight-ffiles
)
1924 (persistent-action . anything-find-files-persistent-action
)
1925 (persistent-help .
"Expand Candidate")
1929 .
(lambda (candidate)
1930 (anything-dired-action candidate
:action
'rename
)))
1931 ("Rename and Follow"
1932 .
(lambda (candidate)
1933 (anything-dired-action candidate
:action
'rename
:follow t
)))))))
1935 (defvar anything-c-source-symlink-files
1936 `((name .
,(concat "Symlink Files" anything-c-find-files-doc-header
))
1937 ;; It is needed for filenames with capital letters
1939 (candidates . anything-find-files-get-candidates
)
1940 (candidate-transformer anything-c-highlight-ffiles
)
1941 (persistent-action . anything-find-files-persistent-action
)
1942 (persistent-help .
"Expand Candidate")
1945 (("Symlink File" .
(lambda (candidate)
1946 (anything-dired-action candidate
:action
'symlink
)))
1947 ("RelSymlink File" .
(lambda (candidate)
1948 (anything-dired-action candidate
:action
'relsymlink
)))))))
1951 (defvar anything-c-source-hardlink-files
1952 `((name .
,(concat "Hardlink Files" anything-c-find-files-doc-header
))
1953 ;; It is needed for filenames with capital letters
1955 (candidates . anything-find-files-get-candidates
)
1956 (candidate-transformer anything-c-highlight-ffiles
)
1957 (persistent-action . anything-find-files-persistent-action
)
1958 (persistent-help .
"Expand Candidate")
1961 (("Hardlink File" .
(lambda (candidate)
1962 (anything-dired-action candidate
:action
'hardlink
)))))))
1964 (defun* anything-dired-action
(candidate &key action follow
)
1965 "Copy, rename or symlink file at point or marked files in dired to CANDIDATE.
1966 ACTION is a key that can be one of 'copy, 'rename, 'symlink, 'relsymlink."
1967 (let ((files (dired-get-marked-files))
1969 ('copy
'dired-copy-file
)
1970 ('rename
'dired-rename-file
)
1971 ('symlink
'make-symbolic-link
)
1972 ('relsymlink
'dired-make-relative-symlink
)
1973 ('hardlink
'dired-hardlink
)))
1974 (marker (case action
1975 ((copy rename
) dired-keep-marker-copy
)
1976 ('symlink dired-keep-marker-symlink
)
1977 ('relsymlink dired-keep-marker-relsymlink
)
1978 ('hardlink dired-keep-marker-hardlink
))))
1980 fn
(symbol-name action
) files
1981 (if (file-directory-p candidate
)
1982 ;; When CANDIDATE is a directory, build file-name in this directory.
1983 ;; Else we use CANDIDATE.
1985 (expand-file-name (file-name-nondirectory from
) candidate
))
1986 #'(lambda (from) candidate
))
1989 (let* ((src (car files
))
1990 (dest (expand-file-name candidate
))
1991 (basename-src (if (file-directory-p src
)
1993 (directory-file-name src
)
1994 (file-name-directory src
))
1995 (file-name-nondirectory src
)))
1996 (fname (if (file-directory-p dest
)
1997 (concat (file-name-as-directory dest
)
2000 (anything-c-point-file-in-dired fname
)))))
2003 (defun* anything-dired-do-action-on-file
(&key action
)
2004 (let* ((files (dired-get-marked-files))
2005 (len (length files
))
2006 (fname (if (> len
1)
2007 (format "* %d Files" len
)
2009 (source (case action
2010 ('copy
'anything-c-source-copy-files
)
2011 ('rename
'anything-c-source-rename-files
)
2012 ('symlink
'anything-c-source-symlink-files
)
2013 ('hardlink
'anything-c-source-hardlink-files
)))
2014 (prompt-fm (case action
2015 ('copy
"Copy %s to: ")
2016 ('rename
"Rename %s to: ")
2017 ('symlink
"Symlink %s to: ")
2018 ('hardlink
"Hardlink %s to: ")))
2019 (buffer (case action
2020 ('copy
"*Anything Copy Files*")
2021 ('rename
"*Anything Rename Files*")
2022 ('symlink
"*Anything Symlink Files*")
2023 ('hardlink
"*Anything Hardlink Files*"))))
2025 (or (dired-dwim-target-directory)
2026 (expand-file-name (anything-c-current-directory)))
2027 (format prompt-fm fname
) nil nil buffer
)))
2031 (defun anything-dired-rename-file ()
2032 "Preconfigured `anything' to rename files from dired."
2034 (anything-dired-do-action-on-file :action
'rename
))
2037 (defun anything-dired-copy-file ()
2038 "Preconfigured `anything' to copy files from dired."
2040 (anything-dired-do-action-on-file :action
'copy
))
2043 (defun anything-dired-symlink-file ()
2044 "Preconfigured `anything' to symlink files from dired."
2046 (anything-dired-do-action-on-file :action
'symlink
))
2049 (defun anything-dired-hardlink-file ()
2050 "Preconfigured `anything' to hardlink files from dired."
2052 (anything-dired-do-action-on-file :action
'hardlink
))
2054 (defvar anything-dired-bindings nil
)
2056 (defun anything-dired-bindings (&optional arg
)
2057 "Replace usual dired commands `C' and `R' by anything ones.
2058 When call interactively toggle dired bindings and anything bindings.
2059 When call non--interactively with arg > 0, enable anything bindings.
2060 You can put (anything-dired-binding 1) in init file to enable anything bindings."
2062 (if (or (when arg
(> arg
0)) (not anything-dired-bindings
))
2064 (define-key dired-mode-map
(kbd "C") 'anything-dired-copy-file
)
2065 (define-key dired-mode-map
(kbd "R") 'anything-dired-rename-file
)
2066 (define-key dired-mode-map
(kbd "S") 'anything-dired-symlink-file
)
2067 (define-key dired-mode-map
(kbd "H") 'anything-dired-hardlink-file
)
2068 (setq anything-dired-bindings t
))
2069 (define-key dired-mode-map
(kbd "C") 'dired-do-copy
)
2070 (define-key dired-mode-map
(kbd "R") 'dired-do-rename
)
2071 (define-key dired-mode-map
(kbd "S") 'dired-do-symlink
)
2072 (define-key dired-mode-map
(kbd "H") 'dired-do-hardlink
)
2073 (setq anything-dired-bindings nil
)))
2075 (defun* anything-c-read-file-name
(prompt &key
2076 (initial-input (expand-file-name default-directory
))
2077 (buffer "*Anything Completions*")
2079 "Anything `read-file-name' emulation.
2080 INITIAL-INPUT is a valid path, TEST is a predicate that take one arg."
2081 (when (get-buffer anything-action-buffer
)
2082 (kill-buffer anything-action-buffer
))
2084 `((name .
,(concat "Read file name" anything-c-find-files-doc-header
))
2085 ;; It is needed for filenames with capital letters
2087 (candidates .
(lambda ()
2089 (loop with seq
= (anything-find-files-get-candidates)
2090 for fname in seq when
(funcall test fname
)
2092 (anything-find-files-get-candidates))))
2093 (candidate-transformer anything-c-highlight-ffiles
)
2094 (persistent-action . anything-find-files-persistent-action
)
2095 (persistent-help .
"Expand Candidate")
2097 (action .
(("candidate" .
,'identity
))))
2098 initial-input prompt
'noresume nil buffer
)
2102 (defvar anything-c-source-file-cache-initialized nil
)
2104 (defvar anything-c-file-cache-files nil
)
2106 (defvar anything-c-source-file-cache
2107 '((name .
"File Cache")
2109 (require 'filecache nil t
)
2110 (unless anything-c-source-file-cache-initialized
2111 (setq anything-c-file-cache-files
2112 (loop for item in file-cache-alist append
2113 (destructuring-bind (base &rest dirs
) item
2114 (loop for dir in dirs collect
2115 (concat dir base
)))))
2116 (defadvice file-cache-add-file
(after file-cache-list activate
)
2117 (add-to-list 'anything-c-file-cache-files
(expand-file-name file
)))
2118 (setq anything-c-source-file-cache-initialized t
))))
2119 (candidates . anything-c-file-cache-files
)
2120 (match anything-c-match-on-file-name
2121 anything-c-match-on-directory-name
)
2123 ;; (anything 'anything-c-source-file-cache)
2126 ;; NOTE for WINDOZE users:
2127 ;; You have to install Everything with his command line interface here:
2128 ;; http://www.voidtools.com/download.php
2130 (defvar anything-c-locate-command
2132 ('gnu
/linux
"locate -i -r %s")
2133 ('berkeley-unix
"locate -i %s")
2134 ('windows-nt
"es -i -r %s")
2136 "A list of arguments for locate program.
2137 The \"-r\" option must be the last option.")
2139 (defun anything-c-locate-init ()
2140 "Initialize async locate process for `anything-c-source-locate'."
2141 (start-process-shell-command "locate-process" nil
2142 (format anything-c-locate-command
2145 (defvar anything-c-source-locate
2147 (candidates . anything-c-locate-init
)
2149 (requires-pattern .
3)
2151 "Find files matching the current input pattern with locate.")
2153 ;; (anything 'anything-c-source-locate)
2156 (defvar anything-c-source-recentf
2157 '((name .
"Recentf")
2160 (or recentf-mode
(recentf-mode 1))
2161 ;; Big value empowers anything/recentf
2162 (when (and (numberp recentf-max-saved-items
)
2163 (<= recentf-max-saved-items
20))
2164 (setq recentf-max-saved-items
500))))
2165 (candidates . recentf-list
)
2166 (match anything-c-match-on-file-name
2167 anything-c-match-on-directory-name
)
2169 "See (info \"(emacs)File Conveniences\").
2170 if `recentf-max-saved-items' is too small, set it to 500.")
2171 ;; (anything 'anything-c-source-recentf)
2174 (eval-when-compile (require 'ffap
))
2175 (defvar anything-c-source-ffap-guesser
2176 '((name .
"File at point")
2177 (init .
(lambda () (require 'ffap
)))
2178 (candidates .
(lambda ()
2180 (with-current-buffer anything-current-buffer
2184 ;; (anything 'anything-c-source-ffap-guesser)
2186 ;;; ffap with line number
2187 (defun anything-c-ffap-file-line-at-point ()
2188 "Get (FILENAME . LINENO) at point."
2189 (anything-aif (let (ffap-alist) (ffap-file-at-point))
2192 (when (and (search-forward it nil t
)
2193 (looking-at ":\\([0-9]+\\)"))
2194 (cons it
(string-to-number (match-string 1)))))))
2196 (defvar anything-c-ffap-line-location nil
2197 "(FILENAME . LINENO) used by `anything-c-source-ffap-line'.
2198 It is cleared after jumping line.")
2200 (defun anything-c-ffap-line-candidates ()
2201 (with-current-buffer anything-current-buffer
2202 (setq anything-c-ffap-line-location
(anything-c-ffap-file-line-at-point)))
2203 (when anything-c-ffap-line-location
2204 (destructuring-bind (file . line
) anything-c-ffap-line-location
2205 (list (cons (format "%s (line %d)" file line
) file
)))))
2207 ;;; Goto line after opening file by `anything-c-source-ffap-line'.
2208 (defun anything-c-ffap-line-goto-line ()
2209 (when (car anything-c-ffap-line-location
)
2212 (with-selected-window (get-buffer-window
2213 (get-file-buffer (car anything-c-ffap-line-location
)))
2214 (anything-goto-line (cdr anything-c-ffap-line-location
)))))))
2215 (add-hook 'anything-after-action-hook
'anything-c-ffap-line-goto-line
)
2216 (add-hook 'anything-after-persistent-action-hook
'anything-c-ffap-line-goto-line
)
2218 (defvar anything-c-source-ffap-line
2219 '((name .
"File/Lineno at point")
2220 (init .
(lambda () (require 'ffap
)))
2221 (candidates . anything-c-ffap-line-candidates
)
2223 ;; (anything 'anything-c-source-ffap-line)
2225 ;;; list of files gleaned from every dired buffer
2226 (defun anything-c-files-in-all-dired-candidates ()
2230 (cond ((listp dir
) ;filelist
2232 ((equal "" (file-name-nondirectory dir
)) ;dir
2233 (directory-files dir t
))
2235 (file-expand-wildcards dir t
))))
2237 (mapcar (lambda (buf)
2239 (when (eq major-mode
'dired-mode
)
2240 (if (consp dired-directory
)
2241 (cdr dired-directory
) ;filelist
2242 dired-directory
))) ;dir or wildcard
2244 ;; (dired '("~/" "~/.emacs-custom.el" "~/.emacs.bmk"))
2246 (defvar anything-c-source-files-in-all-dired
2247 '((name .
"Files in all dired buffer.")
2248 (candidates . anything-c-files-in-all-dired-candidates
)
2250 ;; (anything 'anything-c-source-files-in-all-dired)
2254 (defvar anything-c-info-pages nil
2255 "All info pages on system.
2256 Will be calculated the first time you invoke anything with this
2259 (defvar anything-c-source-info-pages
2260 `((name .
"Info Pages")
2261 (candidates .
(lambda ()
2262 (if anything-c-info-pages
2263 anything-c-info-pages
2264 (setq anything-c-info-pages
2265 (save-window-excursion
2268 (Info-find-node "dir" "top")
2269 (goto-char (point-min))
2270 (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
2272 (while (re-search-forward info-topic-regexp nil t
)
2273 (add-to-list 'topics
(match-string-no-properties 1)))
2274 (goto-char (point-min))
2277 (action .
(("Show with Info" .
(lambda (node-str)
2278 (info (replace-regexp-in-string "^[^:]+: "
2281 (requires-pattern .
2)))
2282 ;; (anything 'anything-c-source-info-pages)
2285 ;;; Use info-index plug-in. Note that `name' attribute is
2286 ;;; not needed but `anything-c-insert-summary' uses it.
2288 (defvar anything-c-source-info-elisp
2289 '((name .
"Info index: elisp")
2290 (info-index .
"elisp")))
2291 ;; (anything 'anything-c-source-info-elisp)
2294 (defvar anything-c-source-info-cl
2295 '((name .
"Info index: cl")
2296 (info-index .
"cl")))
2297 ;; (anything 'anything-c-source-info-cl)
2300 (defvar anything-c-source-info-org
2301 '((name .
"Info index: org")
2302 (info-index .
"org")))
2303 ;; (anything 'anything-c-source-info-org)
2305 ;; Info Index ratpoison
2306 (defvar anything-c-source-info-ratpoison
2307 '((name .
"Info index: ratpoison")
2308 (info-index .
"ratpoison")))
2309 ;; (anything 'anything-c-source-info-ratpoison)
2312 (defvar anything-c-source-info-zsh
2313 '((name .
"Info index: zsh")
2314 (info-index .
"zsh")))
2315 ;; (anything 'anything-c-source-info-zsh)
2318 (defvar anything-c-source-info-bash
2319 '((name .
"Info index: bash")
2320 (info-index .
"bash")))
2321 ;; (anything 'anything-c-source-info-bash)
2323 ;; Info Index coreutils
2324 (defvar anything-c-source-info-coreutils
2325 '((name .
"Info index: coreutils")
2326 (info-index .
"coreutils")))
2327 ;; (anything 'anything-c-source-info-coreutils)
2329 ;; Info Index fileutils
2330 (defvar anything-c-source-info-fileutils
2331 '((name .
"Info index: fileutils")
2332 (info-index .
"fileutils")))
2333 ;; (anything 'anything-c-source-info-fileutils)
2336 (defvar anything-c-source-info-find
2337 '((name .
"Info index: find")
2338 (info-index .
"find")))
2339 ;; (anything 'anything-c-source-info-find)
2341 ;; Info Index sh-utils
2342 (defvar anything-c-source-info-sh-utils
2343 '((name .
"Info index: sh-utils")
2344 (info-index .
"sh-utils")))
2345 ;; (anything 'anything-c-source-info-sh-utils)
2347 ;; Info Index textutils
2348 (defvar anything-c-source-info-textutils
2349 '((name .
"Info index: textutils")
2350 (info-index .
"textutils")))
2351 ;; (anything 'anything-c-source-info-textutils)
2354 (defvar anything-c-source-info-libc
2355 '((name .
"Info index: libc")
2356 (info-index .
"libc")))
2357 ;; (anything 'anything-c-source-info-libc)
2360 (defvar anything-c-source-info-make
2361 '((name .
"Info index: make")
2362 (info-index .
"make")))
2363 ;; (anything 'anything-c-source-info-make)
2365 ;; Info Index automake
2366 (defvar anything-c-source-info-automake
2367 '((name .
"Info index: automake")
2368 (info-index .
"automake")))
2369 ;; (anything 'anything-c-source-info-automake)
2371 ;; Info Index autoconf
2372 (defvar anything-c-source-info-autoconf
2373 '((name .
"Info index: autoconf")
2374 (info-index .
"autoconf")))
2375 ;; (anything 'anything-c-source-info-autoconf)
2377 ;; Info Index emacs-lisp-intro
2378 (defvar anything-c-source-info-emacs-lisp-intro
2379 '((name .
"Info index: emacs-lisp-intro")
2380 (info-index .
"emacs-lisp-intro")))
2381 ;; (anything 'anything-c-source-info-emacs-lisp-intro)
2384 (defvar anything-c-source-info-emacs
2385 '((name .
"Info index: emacs")
2386 (info-index .
"emacs")))
2387 ;; (anything 'anything-c-source-info-emacs)
2390 (defvar anything-c-source-info-elib
2391 '((name .
"Info index: elib")
2392 (info-index .
"elib")))
2393 ;; (anything 'anything-c-source-info-elib)
2396 (defvar anything-c-source-info-eieio
2397 '((name .
"Info index: eieio")
2398 (info-index .
"eieio")))
2399 ;; (anything 'anything-c-source-info-eieio)
2401 ;; Info Index gauche-refe
2402 (defvar anything-c-source-info-gauche-refe
2403 '((name .
"Info index: gauche")
2404 (info-index .
"gauche-refe")))
2405 ;; (anything 'anything-c-source-info-gauche-refe)
2408 (defvar anything-c-source-info-guile
2409 '((name .
"Info index: guile")
2410 (info-index .
"guile")))
2411 ;; (anything 'anything-c-source-info-guile)
2413 ;; Info Index guile-tut
2414 (defvar anything-c-source-info-guile-tut
2415 '((name .
"Info index: guile-tut")
2416 (info-index .
"guile-tut")))
2417 ;; (anything 'anything-c-source-info-guile-tut)
2420 (defvar anything-c-source-info-goops
2421 '((name .
"Info index: goops")
2422 (info-index .
"goops")))
2423 ;; (anything 'anything-c-source-info-goops)
2425 ;; Info Index screen
2426 (defvar anything-c-source-info-screen
2427 '((name .
"Info index: screen")
2428 (info-index .
"screen")
2429 (index-nodes "Concept Index" "Command Index" "Keystroke Index")))
2430 ;; (anything 'anything-c-source-info-screen)
2433 (defvar anything-c-source-info-latex
2434 '((name .
"Info index: latex")
2435 (info-index .
"latex")))
2436 ;; (anything 'anything-c-source-info-latex)
2439 (defvar anything-c-source-info-gawk
2440 '((name .
"Info index: gawk")
2441 (info-index .
"gawk")))
2442 ;; (anything 'anything-c-source-info-gawk)
2445 (defvar anything-c-source-info-sed
2446 '((name .
"Info index: sed")
2447 (info-index .
"sed")))
2448 ;; (anything 'anything-c-source-info-sed)
2451 (defvar anything-c-source-info-m4
2452 '((name .
"Info index: m4")
2453 (info-index .
"m4")))
2454 ;; (anything 'anything-c-source-info-m4)
2457 (defvar anything-c-source-info-wget
2458 '((name .
"Info index: wget")
2459 (info-index .
"wget")))
2460 ;; (anything 'anything-c-source-info-wget)
2462 ;; Info Index binutils
2463 (defvar anything-c-source-info-binutils
2464 '((name .
"Info index: binutils")
2465 (info-index .
"binutils")))
2466 ;; (anything 'anything-c-source-info-binutils)
2469 (defvar anything-c-source-info-as
2470 '((name .
"Info index: as")
2471 (info-index .
"as")))
2472 ;; (anything 'anything-c-source-info-as)
2475 (defvar anything-c-source-info-bfd
2476 '((name .
"Info index: bfd")
2477 (info-index .
"bfd")))
2478 ;; (anything 'anything-c-source-info-bfd)
2481 (defvar anything-c-source-info-gprof
2482 '((name .
"Info index: gprof")
2483 (info-index .
"gprof")))
2484 ;; (anything 'anything-c-source-info-gprof)
2487 (defvar anything-c-source-info-ld
2488 '((name .
"Info index: ld")
2489 (info-index .
"ld")))
2490 ;; (anything 'anything-c-source-info-ld)
2493 (defvar anything-c-source-info-diff
2494 '((name .
"Info index: diff")
2495 (info-index .
"diff")))
2496 ;; (anything 'anything-c-source-info-diff)
2499 (defvar anything-c-source-info-flex
2500 '((name .
"Info index: flex")
2501 (info-index .
"flex")))
2502 ;; (anything 'anything-c-source-info-flex)
2505 (defvar anything-c-source-info-grep
2506 '((name .
"Info index: grep")
2507 (info-index .
"grep")))
2508 ;; (anything 'anything-c-source-info-grep)
2511 (defvar anything-c-source-info-gzip
2512 '((name .
"Info index: gzip")
2513 (info-index .
"gzip")))
2514 ;; (anything 'anything-c-source-info-gzip)
2516 ;; Info Index libtool
2517 (defvar anything-c-source-info-libtool
2518 '((name .
"Info index: libtool")
2519 (info-index .
"libtool")))
2520 ;; (anything 'anything-c-source-info-libtool)
2522 ;; Info Index texinfo
2523 (defvar anything-c-source-info-texinfo
2524 '((name .
"Info index: texinfo")
2525 (info-index .
"texinfo")))
2526 ;; (anything 'anything-c-source-info-texinfo)
2529 (defvar anything-c-source-info-info
2530 '((name .
"Info index: info")
2531 (info-index .
"info")))
2532 ;; (anything 'anything-c-source-info-info)
2535 (defvar anything-c-source-info-gdb
2536 '((name .
"Info index: gdb")
2537 (info-index .
"gdb")))
2538 ;; (anything 'anything-c-source-info-gdb)
2541 (defvar anything-c-source-info-stabs
2542 '((name .
"Info index: stabs")
2543 (info-index .
"stabs")))
2544 ;; (anything 'anything-c-source-info-stabs)
2546 ;; Info Index cvsbook
2547 (defvar anything-c-source-info-cvsbook
2548 '((name .
"Info index: cvsbook")
2549 (info-index .
"cvsbook")))
2550 ;; (anything 'anything-c-source-info-cvsbook)
2553 (defvar anything-c-source-info-cvs
2554 '((name .
"Info index: cvs")
2555 (info-index .
"cvs")))
2556 ;; (anything 'anything-c-source-info-cvs)
2559 (defvar anything-c-source-info-bison
2560 '((name .
"Info index: bison")
2561 (info-index .
"bison")))
2562 ;; (anything 'anything-c-source-info-bison)
2564 ;; Info Index id-utils
2565 (defvar anything-c-source-info-id-utils
2566 '((name .
"Info index: id-utils")
2567 (info-index .
"id-utils")))
2568 ;; (anything 'anything-c-source-info-id-utils)
2570 ;; Info Index global
2571 (defvar anything-c-source-info-global
2572 '((name .
"Info index: global")
2573 (info-index .
"global")))
2574 ;; (anything 'anything-c-source-info-global)
2578 (defvar anything-c-man-pages nil
2579 "All man pages on system.
2580 Will be calculated the first time you invoke anything with this
2583 (defvar anything-c-source-man-pages
2584 `((name .
"Manual Pages")
2585 (candidates .
(lambda ()
2586 (if anything-c-man-pages
2587 anything-c-man-pages
2588 ;; XEmacs doesn't have a woman :)
2589 (setq anything-c-man-pages
2592 (woman-file-name "")
2593 (sort (mapcar 'car woman-topic-all-completions
)
2595 (action ("Show with Woman" .
(lambda (candidate)
2596 (let ((wfiles (woman-file-name-all-completions candidate
)))
2597 (if (> (length wfiles
) 1)
2598 (woman-find-file (anything-comp-read "ManFile: " wfiles
2600 (woman candidate
))))))
2601 ;; Woman does not work OS X
2602 ;; http://xahlee.org/emacs/modernization_man_page.html
2603 (action-transformer .
(lambda (actions candidate
)
2604 (if (eq system-type
'darwin
)
2605 '(("Show with Man" . man
))
2607 (requires-pattern .
2)))
2608 ;; (anything 'anything-c-source-man-pages)
2611 ;;; Complex command history
2612 (defvar anything-c-source-complex-command-history
2613 '((name .
"Complex Command History")
2614 (candidates .
(lambda () (mapcar 'prin1-to-string command-history
)))
2616 ;; (anything 'anything-c-source-complex-command-history)
2619 (defvar anything-c-source-extended-command-history
2620 '((name .
"Emacs Commands History")
2621 (candidates . extended-command-history
)
2623 ;; (anything 'anything-c-source-extended-command-history)
2626 (defvar anything-c-source-emacs-commands
2627 '((name .
"Emacs Commands")
2628 (candidates .
(lambda ()
2630 (mapatoms (lambda (a)
2632 (push (symbol-name a
)
2634 (sort commands
'string-lessp
))))
2636 (requires-pattern .
2))
2637 "Source for completing and invoking Emacs commands.
2638 A command is a function with interactive spec that can
2639 be invoked with `M-x'.
2641 To get non-interactive functions listed, use
2642 `anything-c-source-emacs-functions'.")
2643 ;; (anything 'anything-c-source-emacs-commands)
2645 ;; Another replacement of `M-x' that act exactly like the
2646 ;; vanilla Emacs one, no problem of windows configuration, prefix args
2647 ;; are passed before calling `M-x' (e.g C-u M-x..).
2649 (defun anything-M-x ()
2650 "Preconfigured `anything' for Emacs commands.
2651 It is `anything' replacement of regular `M-x' `execute-extended-command'."
2653 (let ((command (anything-comp-read "M-x " obarray
2656 :requires-pattern
2)))
2657 (call-interactively (intern command
))))
2660 (defvar anything-c-source-lacarte
2661 '((name .
"Lacarte")
2662 (init .
(lambda () (require 'lacarte
)))
2663 (candidates .
(lambda () (delete '(nil) (lacarte-get-overall-menu-item-alist))))
2664 (candidate-number-limit .
9999)
2665 (action . anything-c-call-interactively
))
2668 http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
2669 ;; (anything 'anything-c-source-lacarte)
2673 (defvar anything-c-source-emacs-functions
2674 '((name .
"Emacs Functions")
2675 (candidates .
(lambda ()
2677 (mapatoms (lambda (a) (if (functionp a
)
2678 (push (symbol-name a
) commands
))))
2679 (sort commands
'string-lessp
))))
2681 (requires-pattern .
2))
2682 "Source for completing Emacs functions.")
2683 ;; (anything 'anything-c-source-emacs-functions)
2685 ;;; With abbrev expansion
2686 ;;; Similar to my exec-abbrev-cmd.el
2687 ;;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el
2688 (defvar anything-c-function-abbrev-regexp nil
2689 "The regexp for `anything-c-source-emacs-functions-with-abbrevs'.
2690 Regexp built from the current `anything-pattern' interpreting it
2692 Only for internal use.")
2694 (defun anything-c-match-function-by-abbrev (candidate)
2695 "Return non-nil if `anything-pattern' is an abbreviation of the function CANDIDATE.
2697 Abbreviations are made by taking the first character from each
2698 word in the function's name, e.g. \"bb\" is an abbrev for
2699 `bury-buffer', \"stb\" is an abbrev for `switch-to-buffer'."
2700 (string-match anything-c-function-abbrev-regexp candidate
))
2702 (defvar anything-c-source-emacs-functions-with-abbrevs
2703 (append anything-c-source-emacs-functions
2704 '((match anything-c-match-function-by-abbrev
2705 anything-c-string-match
))
2706 '((init .
(lambda ()
2707 (defadvice anything-update
2708 (before anything-c-update-function-abbrev-regexp activate
)
2709 (let ((char-list (append anything-pattern nil
))
2711 (dolist (c char-list
)
2712 (setq str
(concat str
(list c
) "[^-]*-")))
2713 (setq str
(concat (substring str
0 (1- (length str
))) "$"))
2714 (setq anything-c-function-abbrev-regexp str
))))))))
2715 ;; (anything 'anything-c-source-emacs-functions-with-abbrevs)
2717 (defvar anything-c-source-advice
2718 '((name .
"Function Advice")
2719 (candidates . anything-c-advice-candidates
)
2720 (action ("Toggle Enable/Disable" . anything-c-advice-toggle
))
2721 ;; (real-to-display . anything-c-advice-real-to-display)
2724 (persistent-action . anything-c-advice-persistent-action
)
2725 (persistent-help .
"Describe function / C-u C-z: Toggle advice")))
2726 ;; (anything 'anything-c-source-advice)
2727 ;; (let ((debug-on-signal t))(anything 'anything-c-source-advice))
2730 (defun anything-c-advice-candidates ()
2732 (loop for
(fname) in ad-advised-functions
2733 for function
= (intern fname
)
2735 (loop for class in ad-advice-classes append
2736 (loop for advice in
(ad-get-advice-info-field function class
)
2737 for enabled
= (ad-advice-enabled advice
)
2739 (cons (format "%s %s %s"
2740 (if enabled
"Enabled " "Disabled")
2741 (propertize fname
'face
'font-lock-function-name-face
)
2742 (ad-make-single-advice-docstring advice class nil
))
2743 (list function class advice
))))))
2745 (defun anything-c-advice-persistent-action (func-class-advice)
2746 (if current-prefix-arg
2747 (anything-c-advice-toggle func-class-advice
)
2748 (describe-function (car func-class-advice
))))
2750 (defun anything-c-advice-toggle (func-class-advice)
2751 (destructuring-bind (function class advice
) func-class-advice
2752 (cond ((ad-advice-enabled advice
)
2753 (ad-advice-set-enabled advice nil
)
2754 (message "Disabled"))
2756 (ad-advice-set-enabled advice t
)
2757 (message "Enabled")))
2758 (ad-activate function
)
2759 (and anything-in-persistent-action
2760 (anything-c-advice-update-current-display-string))))
2762 (defun anything-c-advice-update-current-display-string ()
2763 (anything-edit-current-selection
2764 (let ((newword (cond ((looking-at "Disabled") "Enabled")
2765 ((looking-at "Enabled") "Disabled")))
2768 (delete-region (point) (progn (forward-word 1) (point)))
2769 (insert newword
)))))
2772 (defun anything-manage-advice ()
2773 "Preconfigured `anything' to disable/enable function advices."
2775 (anything-other-buffer 'anything-c-source-advice
"*anything advice*"))
2779 (defvar anything-c-source-emacs-variables
2780 '((name .
"Emacs Variables")
2781 (candidates .
(lambda ()
2782 (sort (all-completions "" obarray
'boundp
) 'string-lessp
)))
2784 (requires-pattern .
2))
2785 "Source for completing Emacs variables.")
2786 ;; (anything 'anything-c-source-emacs-variables)
2790 (eval-when-compile (require 'bookmark
))
2791 (defvar anything-c-source-bookmarks
2792 '((name .
"Bookmarks")
2794 (require 'bookmark
)))
2795 (candidates . bookmark-all-names
)
2797 "See (info \"(emacs)Bookmarks\").")
2798 ;; (anything 'anything-c-source-bookmarks)
2801 (defvar anything-c-source-bookmark-set
2802 '((name .
"Set Bookmark")
2804 (action . bookmark-set
))
2805 "See (info \"(emacs)Bookmarks\").")
2806 ;; (anything 'anything-c-source-bookmark-set)
2808 ;;; Visible Bookmarks
2809 ;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el")
2812 ;; http://d.hatena.ne.jp/grandVin/20080911/1221114327
2813 (defvar anything-c-source-bm
2814 '((name .
"Visible Bookmarks")
2815 (init . anything-c-bm-init
)
2816 (candidates-in-buffer)
2820 http://www.nongnu.org/bm/")
2822 (defun anything-c-bm-init ()
2823 "Init function for `anything-c-source-bm'."
2824 (when (require 'bm nil t
)
2826 (let ((bookmarks (bm-lists))
2827 (buf (anything-candidate-buffer 'global
)))
2828 (dolist (bm (sort* (append (car bookmarks
) (cdr bookmarks
))
2829 '< :key
'overlay-start
))
2830 (let ((start (overlay-start bm
))
2831 (end (overlay-end bm
))
2832 (annotation (or (overlay-get bm
'annotation
) "")))
2833 (unless (< (- end start
) 1) ; org => (if (< (- end start) 2)
2834 (let ((str (format "%5d: [%s]: %s\n"
2835 (line-number-at-pos start
)
2837 (buffer-substring start
(1- end
)))))
2838 (with-current-buffer buf
(insert str
))))))))))
2840 ;;; Special bookmarks
2841 (defvar anything-c-source-bookmarks-ssh
2842 '((name .
"Bookmarks-ssh")
2844 (require 'bookmark
)))
2845 (candidates .
(lambda () (anything-c-collect-bookmarks :ssh t
)))
2847 "See (info \"(emacs)Bookmarks\").")
2848 ;; (anything 'anything-c-source-bookmarks-ssh)
2850 (defvar anything-c-source-bookmarks-su
2851 '((name .
"Bookmarks-root")
2853 (require 'bookmark
)))
2854 (candidates .
(lambda () (anything-c-collect-bookmarks :su t
)))
2855 (filtered-candidate-transformer anything-c-highlight-bookmark-su
)
2858 "See (info \"(emacs)Bookmarks\").")
2859 ;; (anything 'anything-c-source-bookmarks-su)
2861 (defvar anything-c-source-bookmarks-local
2862 '((name .
"Bookmarks-Local")
2864 (require 'bookmark
)))
2865 (candidates .
(lambda () (anything-c-collect-bookmarks :local t
)))
2866 (filtered-candidate-transformer
2867 anything-c-adaptive-sort
2868 anything-c-highlight-bookmark
)
2870 "See (info \"(emacs)Bookmarks\").")
2871 ;; (anything 'anything-c-source-bookmarks-local)
2873 (defun* anything-c-collect-bookmarks
(&key local su sudo ssh
)
2874 (let* ((lis-all (bookmark-all-names))
2875 (lis-loc (cond (local (loop for i in lis-all
2876 unless
(string-match "^(ssh)\\|^(su)" i
)
2878 (su (loop for i in lis-all
2879 when
(string-match "^(su)" i
)
2881 (sudo (loop for i in lis-all
2882 when
(string-match "^(sudo)" i
)
2884 (ssh (loop for i in lis-all
2885 when
(string-match "^(ssh)" i
)
2887 (sort lis-loc
'string-lessp
)))
2889 (defun anything-c-bookmark-root-logged-p ()
2891 (dolist (i (mapcar #'buffer-name
(buffer-list)))
2892 (when (string-match (format "*tramp/%s ." anything-su-or-sudo
) i
)
2893 (throw 'break t
)))))
2895 (defun anything-c-highlight-bookmark-su (files source
)
2896 (if (anything-c-bookmark-root-logged-p)
2897 (anything-c-highlight-bookmark files source
)
2898 (anything-c-highlight-not-logged files source
)))
2900 (defun anything-c-highlight-not-logged (files source
)
2901 (loop for i in files
2902 collect
(propertize i
'face anything-c-bookmarks-face3
)))
2904 (defun anything-c-highlight-bookmark (bookmarks source
)
2905 "Used as `candidate-transformer' to colorize bookmarks.
2906 Work both with standard Emacs bookmarks and bookmark-extensions.el."
2907 (loop for i in bookmarks
2908 for pred
= (bookmark-get-filename i
)
2909 for bufp
= (and (fboundp 'bmkext-get-buffer-name
)
2910 (bmkext-get-buffer-name i
))
2911 for handlerp
= (and (fboundp 'bookmark-get-handler
)
2912 (bookmark-get-handler i
))
2913 for isw3m
= (and (fboundp 'bmkext-w3m-bookmark-p
)
2914 (bmkext-w3m-bookmark-p i
))
2915 for isgnus
= (and (fboundp 'bmkext-gnus-bookmark-p
)
2916 (bmkext-gnus-bookmark-p i
))
2917 for isman
= (and (fboundp 'bmkext-man-bookmark-p
) ; Man
2918 (bmkext-man-bookmark-p i
))
2919 for iswoman
= (and (fboundp 'bmkext-woman-bookmark-p
) ; Woman
2920 (bmkext-woman-bookmark-p i
))
2921 for handlerp
= (bookmark-get-handler i
)
2922 for isannotation
= (bookmark-get-annotation i
)
2923 for isabook
= (string= (bookmark-prop-get i
'type
) "addressbook")
2924 ;; Add a * if bookmark have annotation
2925 if
(and isannotation
(not (string-equal isannotation
"")))
2926 do
(setq i
(concat "*" i
))
2928 if
(eq handlerp
'Info-bookmark-jump
)
2929 collect
(propertize i
'face
'anything-bmkext-info
'help-echo pred
)
2932 collect
(propertize i
'face
'anything-bmkext-w3m
'help-echo pred
)
2935 collect
(propertize i
'face
'anything-bmkext-gnus
'help-echo pred
)
2937 if
(or iswoman isman
)
2938 collect
(propertize i
'face
'anything-bmkext-man
'help-echo pred
)
2940 if
(and (not pred
) isabook
)
2941 collect
(propertize i
'face
'((:foreground
"Tomato")))
2943 if
(and pred
(file-directory-p pred
))
2944 collect
(propertize i
'face anything-c-bookmarks-face1
'help-echo pred
)
2946 if
(and pred
(not (file-directory-p pred
)) (file-exists-p pred
)
2947 (not (or iswoman isman
)))
2948 collect
(propertize i
'face
'anything-bmkext-file
'help-echo pred
)))
2951 ;;; Faces for bookmarks
2952 (defface anything-bmkext-info
2953 '((t (:foreground
"green")))
2954 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2957 (defface anything-bmkext-w3m
2958 '((t (:foreground
"yellow")))
2959 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2962 (defface anything-bmkext-gnus
2963 '((t (:foreground
"magenta")))
2964 "*Face used for Gnus bookmarks."
2967 (defface anything-bmkext-man
2968 '((t (:foreground
"Orange4")))
2969 "*Face used for Woman/man bookmarks."
2972 (defface anything-bmkext-no--file
2973 '((t (:foreground
"grey")))
2974 "*Face used for non--file bookmarks."
2977 (defface anything-bmkext-file
2978 '((t (:foreground
"Deepskyblue2")))
2979 "*Face used for non--file bookmarks."
2982 (defface anything-bookmarks-su-face
'((t (:foreground
"red")))
2983 "Face for su/sudo bookmarks."
2986 (defvar anything-c-bookmarks-face1
'anything-dir-heading
)
2987 (defvar anything-c-bookmarks-face2
'anything-file-name
)
2988 (defvar anything-c-bookmarks-face3
'anything-bookmarks-su-face
)
2991 ;;; Sources to filter bookmark-extensions bookmarks.
2992 ;; Dependency: http://mercurial.intuxication.org/hg/emacs-bookmark-extension
2993 ;; If you want to enable google-maps in addressbook you will need
2994 ;; Julien Danjou google-maps-el package available here:
2995 ;; http://julien.danjou.info/google-maps-el.html
2997 (defun anything-c-bmkext-filter-setup-alist (fn &rest args
)
2998 "Return a filtered `bookmark-alist' sorted alphabetically."
3000 with alist
= (if args
3001 (apply #'(lambda (x) (funcall fn x
)) args
)
3006 finally return
(sort sa
'string-lessp
)))
3009 (defvar anything-c-source-bmkext-addressbook
3010 '((name .
"Bookmark Addressbook")
3012 (require 'bookmark-extensions
)
3013 (bookmark-maybe-load-default-file)))
3014 (candidates . anything-c-bmkext-addressbook-setup-alist
)
3016 .
(lambda (candidate)
3017 (let ((bmk (anything-bookmark-get-bookmark-from-name
3019 (bookmark--jump-via bmk
'pop-to-buffer
))))
3020 (persistent-help .
"Show contact - Prefix with C-u to append")
3021 (filtered-candidate-transformer
3022 anything-c-adaptive-sort
3023 anything-c-highlight-bookmark
)
3024 (action .
(("Show person's data"
3025 .
(lambda (candidate)
3026 (let ((bmk (anything-bookmark-get-bookmark-from-name
3028 (current-prefix-arg anything-current-prefix-arg
))
3029 (bookmark-jump bmk
))))
3031 .
(lambda (candidate)
3032 (let ((bmk (anything-bookmark-get-bookmark-from-name
3034 (if anything-current-prefix-arg
3035 (addressbook-set-mail-buffer1 bmk
'append
)
3036 (addressbook-set-mail-buffer1 bmk
)))))
3038 .
(lambda (candidate)
3039 (let ((bmk (anything-bookmark-get-bookmark-from-name
3041 (addressbook-bookmark-edit
3042 (assoc bmk bookmark-alist
)))))
3043 ("Insert Email at point"
3044 .
(lambda (candidate)
3045 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3047 (mlist (split-string
3049 'email
(assoc bmk bookmark-alist
))
3052 (if (> (length mlist
) 1)
3054 "Insert Mail Address: " mlist
:must-match t
)
3057 .
(lambda (candidate)
3058 (let ((bmk (anything-bookmark-get-bookmark-from-name
3060 (bookmark-show-annotation bmk
))))
3062 .
(lambda (candidate)
3063 (let ((bmk (anything-bookmark-get-bookmark-from-name
3065 (bookmark-edit-annotation bmk
))))
3066 ("Show Google map" .
(lambda (candidate)
3067 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3069 (full-bmk (assoc bmk bookmark-alist
)))
3070 (addressbook-google-map full-bmk
))))))))
3073 (defun anything-c-bmkext-addressbook-setup-alist ()
3074 "Specialized filter function for bookmarks w3m."
3075 (anything-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only
))
3078 (defvar anything-c-source-bookmark-w3m
3079 '((name .
"Bookmark W3m")
3081 (require 'bookmark-extensions
)
3082 (bookmark-maybe-load-default-file)))
3083 (candidates . anything-c-bookmark-w3m-setup-alist
)
3084 (filtered-candidate-transformer
3085 anything-c-adaptive-sort
3086 anything-c-highlight-bookmark
)
3088 ;; (anything 'anything-c-source-bookmark-w3m)
3090 (defun anything-c-bookmark-w3m-setup-alist ()
3091 "Specialized filter function for bookmarks w3m."
3092 (anything-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only
))
3095 (defvar anything-c-source-bookmark-images
3096 '((name .
"Bookmark Images")
3098 (require 'bookmark-extensions
)
3099 (bookmark-maybe-load-default-file)))
3100 (candidates . anything-c-bookmark-images-setup-alist
)
3101 (filtered-candidate-transformer
3102 anything-c-adaptive-sort
3103 anything-c-highlight-bookmark
)
3105 ;; (anything 'anything-c-source-bookmark-images)
3107 (defun anything-c-bookmark-images-setup-alist ()
3108 "Specialized filter function for images bookmarks."
3109 (anything-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only
))
3112 (defvar anything-c-source-bookmark-man
3113 '((name .
"Bookmark Woman&Man")
3115 (require 'bookmark-extensions
)
3116 (bookmark-maybe-load-default-file)))
3117 (candidates . anything-c-bookmark-man-setup-alist
)
3118 (filtered-candidate-transformer
3119 anything-c-adaptive-sort
3120 anything-c-highlight-bookmark
)
3122 ;; (anything 'anything-c-source-bookmark-man)
3124 (defun anything-c-bookmark-man-setup-alist ()
3125 "Specialized filter function for bookmarks w3m."
3126 (append (anything-c-bmkext-filter-setup-alist 'bmkext-man-alist-only
)
3127 (anything-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only
)))
3130 (defvar anything-c-source-bookmark-gnus
3131 '((name .
"Bookmark Gnus")
3133 (require 'bookmark-extensions
)
3134 (bookmark-maybe-load-default-file)))
3135 (candidates . anything-c-bookmark-gnus-setup-alist
)
3136 (filtered-candidate-transformer
3137 anything-c-adaptive-sort
3138 anything-c-highlight-bookmark
)
3140 ;; (anything 'anything-c-source-bookmark-gnus)
3142 (defun anything-c-bookmark-gnus-setup-alist ()
3143 "Specialized filter function for bookmarks gnus."
3144 (anything-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only
))
3147 (defvar anything-c-source-bookmark-info
3148 '((name .
"Bookmark Info")
3150 (require 'bookmark-extensions
)
3151 (bookmark-maybe-load-default-file)))
3152 (candidates . anything-c-bookmark-info-setup-alist
)
3153 (filtered-candidate-transformer
3154 anything-c-adaptive-sort
3155 anything-c-highlight-bookmark
)
3157 ;; (anything 'anything-c-source-bookmark-info)
3159 (defun anything-c-bookmark-info-setup-alist ()
3160 "Specialized filter function for bookmarks info."
3161 (anything-c-bmkext-filter-setup-alist 'bmkext-info-alist-only
))
3163 ;; Local Files&directories
3164 (defvar anything-c-source-bookmark-files
&dirs
3165 '((name .
"Bookmark Files&Directories")
3167 (require 'bookmark-extensions
)
3168 (bookmark-maybe-load-default-file)))
3169 (candidates . anything-c-bookmark-local-files-setup-alist
)
3170 (filtered-candidate-transformer
3171 anything-c-adaptive-sort
3172 anything-c-highlight-bookmark
)
3174 ;; (anything 'anything-c-source-bookmark-files&dirs)
3176 (defun anything-c-bookmark-local-files-setup-alist ()
3177 "Specialized filter function for bookmarks locals files."
3178 (anything-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only
))
3180 ;; Su Files&directories
3181 (defvar anything-c-source-bookmark-su-files
&dirs
3182 '((name .
"Bookmark Root-Files&Directories")
3184 (require 'bookmark-extensions
)
3185 (bookmark-maybe-load-default-file)))
3186 (candidates . anything-c-bookmark-su-files-setup-alist
)
3187 (filtered-candidate-transformer
3188 anything-c-adaptive-sort
3189 anything-c-highlight-bookmark-su
)
3191 ;; (anything 'anything-c-source-bookmark-su-files&dirs)
3193 (defun anything-c-bookmark-su-files-setup-alist ()
3194 "Specialized filter function for bookmarks su/sudo files."
3196 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3198 for isfile
= (bookmark-get-filename i
)
3199 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3201 (string-match tramp-file-name-regexp isfile
)))
3202 for issu
= (and istramp
3203 (string-match bmkext-su-or-sudo-regexp isfile
))
3207 ;; Ssh Files&directories
3208 (defvar anything-c-source-bookmark-ssh-files
&dirs
3209 '((name .
"Bookmark Ssh-Files&Directories")
3211 (require 'bookmark-extensions
)
3212 (bookmark-maybe-load-default-file)))
3213 (candidates . anything-c-bookmark-ssh-files-setup-alist
)
3214 (filtered-candidate-transformer . anything-c-adaptive-sort
)
3216 ;; (anything 'anything-c-source-bookmark-ssh-files&dirs)
3218 (defun anything-c-bookmark-ssh-files-setup-alist ()
3219 "Specialized filter function for bookmarks ssh files."
3221 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3223 for isfile
= (bookmark-get-filename i
)
3224 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3226 (string-match tramp-file-name-regexp isfile
)))
3227 for isssh
= (and istramp
3228 (string-match "/ssh:" isfile
))
3233 ;; All bookmark-extensions sources.
3235 (defun anything-bookmark-ext ()
3236 "Preconfigured `anything' for bookmark-extensions sources.
3237 Needs bookmark-ext.el
3239 http://mercurial.intuxication.org/hg/emacs-bookmark-extension"
3241 (anything '(anything-c-source-bookmark-files&dirs
3242 anything-c-source-bookmark-w3m
3243 anything-c-source-bmkext-addressbook
3244 anything-c-source-bookmark-gnus
3245 anything-c-source-bookmark-info
3246 anything-c-source-bookmark-man
3247 anything-c-source-bookmark-images
3248 anything-c-source-bookmark-su-files
&dirs
3249 anything-c-source-bookmark-ssh-files
&dirs
)
3250 nil
"SearchBookmark: " nil nil
"*anything bmkext*"))
3253 ;; Firefox bookmarks
3254 ;; You will have to set firefox to import bookmarks in his html file bookmarks.html.
3255 ;; (only for firefox versions >=3)
3256 ;; To achieve that, open about:config in firefox and double click on this line to enable value
3258 ;; user_pref("browser.bookmarks.autoExportHTML", false);
3259 ;; You should have now:
3260 ;; user_pref("browser.bookmarks.autoExportHTML", true);
3262 (defvar anything-firefox-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|about\\|file\\)://[^ ]*")
3263 (defvar anything-firefox-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3265 (defun anything-get-firefox-user-init-dir ()
3266 "Guess the default Firefox user directory name."
3267 (let* ((moz-dir (concat (getenv "HOME") "/.mozilla/firefox/"))
3268 (moz-user-dir (with-current-buffer (find-file-noselect (concat moz-dir
"profiles.ini"))
3269 (goto-char (point-min))
3270 (when (search-forward "Path=" nil t
)
3271 (buffer-substring-no-properties (point) (point-at-eol))))))
3272 (file-name-as-directory (concat moz-dir moz-user-dir
))))
3274 (defun anything-guess-firefox-bookmark-file ()
3275 "Return the path of the Firefox bookmarks file."
3276 (concat (anything-get-firefox-user-init-dir) "bookmarks.html"))
3278 (defun anything-html-bookmarks-to-alist (file url-regexp bmk-regexp
)
3279 "Parse html bookmark FILE and return an alist with (title . url) as elements."
3280 (let (bookmarks-alist url title
)
3282 (insert-file-contents file
)
3283 (goto-char (point-min))
3286 (when (re-search-forward "href=\\|^ *<DT><A HREF=" nil t
)
3288 (when (re-search-forward url-regexp nil t
)
3289 (setq url
(concat "\"" (match-string 0))))
3291 (when (re-search-forward bmk-regexp nil t
)
3292 (setq title
(match-string 1)))
3293 (push (cons title url
) bookmarks-alist
))))
3294 (nreverse bookmarks-alist
)))
3297 (defvar anything-c-firefox-bookmarks-alist nil
)
3298 (defvar anything-c-source-firefox-bookmarks
3299 '((name .
"Firefox Bookmarks")
3301 (setq anything-c-firefox-bookmarks-alist
3302 (anything-html-bookmarks-to-alist
3303 (anything-guess-firefox-bookmark-file)
3304 anything-firefox-bookmark-url-regexp
3305 anything-firefox-bookmarks-regexp
))))
3306 (candidates .
(lambda ()
3308 anything-c-firefox-bookmarks-alist
)))
3309 (filtered-candidate-transformer
3310 anything-c-adaptive-sort
3311 anything-c-highlight-firefox-bookmarks
)
3312 (action .
(("Browse Url Firefox" .
(lambda (candidate)
3314 (anything-c-firefox-bookmarks-get-value candidate
))))
3315 ("Browse Url w3m" .
(lambda (candidate)
3317 (anything-c-firefox-bookmarks-get-value candidate
))))
3318 ("Copy Url" .
(lambda (elm)
3319 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))))))
3321 ;; (anything 'anything-c-source-firefox-bookmarks)
3323 (defun anything-c-firefox-bookmarks-get-value (elm)
3324 (replace-regexp-in-string "\"" ""
3326 anything-c-firefox-bookmarks-alist
))))
3329 (defun anything-c-highlight-firefox-bookmarks (bookmarks source
)
3330 (loop for i in bookmarks
3331 collect
(propertize i
3332 'face
'((:foreground
"YellowGreen"))
3333 'help-echo
(anything-c-firefox-bookmarks-get-value i
))))
3336 (eval-when-compile (require 'w3m-bookmark nil t
))
3337 (unless (and (require 'w3m nil t
)
3338 (require 'w3m-bookmark nil t
))
3339 (defvar w3m-bookmark-file
"~/.w3m/bookmark.html"))
3342 (defface anything-w3m-bookmarks-face
'((t (:foreground
"cyan1" :underline t
)))
3343 "Face for w3m bookmarks" :group
'anything
)
3345 (defvar anything-w3m-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3346 (defvar anything-w3m-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|file\\)://[^>]*")
3347 (defvar anything-c-w3m-bookmarks-alist nil
)
3348 (defvar anything-c-source-w3m-bookmarks
3349 '((name .
"W3m Bookmarks")
3351 (setq anything-c-w3m-bookmarks-alist
3352 (anything-html-bookmarks-to-alist
3354 anything-w3m-bookmark-url-regexp
3355 anything-w3m-bookmarks-regexp
))))
3356 (candidates .
(lambda ()
3357 (mapcar #'car anything-c-w3m-bookmarks-alist
)))
3358 (filtered-candidate-transformer
3359 anything-c-adaptive-sort
3360 anything-c-highlight-w3m-bookmarks
)
3361 (action .
(("Browse Url" .
(lambda (candidate)
3362 (anything-c-w3m-browse-bookmark candidate
)))
3363 ("Copy Url" .
(lambda (elm)
3364 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))
3365 ("Browse Url Firefox" .
(lambda (candidate)
3366 (anything-c-w3m-browse-bookmark candidate t
)))
3367 ("Delete Bookmark" .
(lambda (candidate)
3368 (anything-c-w3m-delete-bookmark candidate
)))
3369 ("Rename Bookmark" .
(lambda (candidate)
3370 (anything-c-w3m-rename-bookmark candidate
)))))
3371 (persistent-action .
(lambda (candidate)
3372 (if current-prefix-arg
3373 (anything-c-w3m-browse-bookmark candidate t
)
3374 (anything-c-w3m-browse-bookmark candidate nil t
))))
3375 (persistent-help .
"Open URL with emacs-w3m in new tab / \
3376 C-u \\[anything-execute-persistent-action]: Open URL with Firefox"))
3377 "Needs w3m and emacs-w3m.
3379 http://w3m.sourceforge.net/
3380 http://emacs-w3m.namazu.org/")
3382 ;; (anything 'anything-c-source-w3m-bookmarks)
3384 (defun anything-c-w3m-bookmarks-get-value (elm)
3385 (replace-regexp-in-string
3386 "\"" "" (cdr (assoc elm anything-c-w3m-bookmarks-alist
))))
3388 (defun anything-c-w3m-browse-bookmark (elm &optional use-firefox new-tab
)
3389 (let* ((fn (if use-firefox
'browse-url-firefox
'w3m-browse-url
))
3390 (arg (and (eq fn
'w3m-browse-url
) new-tab
)))
3391 (funcall fn
(anything-c-w3m-bookmarks-get-value elm
) arg
)))
3393 (defun anything-c-highlight-w3m-bookmarks (bookmarks source
)
3394 (loop for i in bookmarks
3396 i
'face
'anything-w3m-bookmarks-face
3397 'help-echo
(anything-c-w3m-bookmarks-get-value i
))))
3400 (defun anything-c-w3m-delete-bookmark (elm)
3402 (find-file-literally w3m-bookmark-file
)
3403 (goto-char (point-min))
3404 (when (re-search-forward elm nil t
)
3406 (delete-region (point)
3407 (line-end-position))
3408 (delete-blank-lines))
3409 (save-buffer (current-buffer))
3410 (kill-buffer (current-buffer))))
3412 (defun anything-c-w3m-rename-bookmark (elm)
3413 (let* ((old-title (replace-regexp-in-string ">" "" elm
))
3414 (new-title (read-string "NewTitle: " old-title
)))
3416 (find-file-literally w3m-bookmark-file
)
3417 (goto-char (point-min))
3418 (when (re-search-forward (concat elm
"<") nil t
)
3419 (goto-char (1- (point)))
3420 (delete-char (- (length old-title
)))
3422 (save-buffer (current-buffer))
3423 (kill-buffer (current-buffer)))))
3426 ;;; Elisp library scan
3427 (defvar anything-c-source-elisp-library-scan
3428 '((name .
"Elisp libraries (Scan)")
3429 (init .
(anything-c-elisp-library-scan-init))
3430 (candidates-in-buffer)
3431 (action ("Find library" .
(lambda (candidate)
3432 (find-file (find-library-name candidate
))))
3433 ("Find library other window" .
(lambda (candidate)
3434 (find-file-other-window (find-library-name candidate
))))
3435 ("Load library" .
(lambda (candidate)
3436 (load-library candidate
))))))
3437 ;; (anything 'anything-c-source-elisp-library-scan)
3439 (defun anything-c-elisp-library-scan-init ()
3440 "Init anything buffer status."
3441 (let ((anything-buffer (anything-candidate-buffer 'global
))
3442 (library-list (anything-c-elisp-library-scan-list)))
3443 (with-current-buffer anything-buffer
3444 (dolist (library library-list
)
3445 (insert (format "%s\n" library
))))))
3447 (defun anything-c-elisp-library-scan-list (&optional dirs string
)
3448 "Do completion for file names passed to `locate-file'.
3449 DIRS is directory to search path.
3450 STRING is string to match."
3451 ;; Use `load-path' as path when ignore `dirs'.
3452 (or dirs
(setq dirs load-path
))
3453 ;; Init with blank when ignore `string'.
3454 (or string
(setq string
""))
3455 ;; Get library list.
3456 (let ((string-dir (file-name-directory string
))
3457 ;; File regexp that suffix match `load-file-rep-suffixes'.
3458 (match-regexp (format "^.*\\.el%s$" (regexp-opt load-file-rep-suffixes
)))
3463 (setq dir default-directory
))
3465 (setq dir
(expand-file-name string-dir dir
)))
3466 (when (file-directory-p dir
)
3467 (dolist (file (file-name-all-completions
3468 (file-name-nondirectory string
) dir
))
3469 ;; Suffixes match `load-file-rep-suffixes'.
3470 (setq name
(if string-dir
(concat string-dir file
) file
))
3471 (if (string-match match-regexp name
)
3472 (add-to-list 'names name
)))))
3477 (defvar anything-c-imenu-delimiter
" / ")
3479 (defvar anything-c-imenu-index-filter nil
)
3480 (make-variable-buffer-local 'anything-c-imenu-index-filter
)
3482 (defvar anything-c-cached-imenu-alist nil
)
3483 (make-variable-buffer-local 'anything-c-cached-imenu-alist
)
3485 (defvar anything-c-cached-imenu-candidates nil
)
3486 (make-variable-buffer-local 'anything-c-cached-imenu-candidates
)
3488 (defvar anything-c-cached-imenu-tick nil
)
3489 (make-variable-buffer-local 'anything-c-cached-imenu-tick
)
3491 (eval-when-compile (require 'imenu
))
3492 (setq imenu-auto-rescan t
)
3494 (defun anything-imenu-create-candidates (entry)
3495 "Create candidates with ENTRY."
3496 (if (listp (cdr entry
))
3497 (mapcan (lambda (sub)
3498 (if (consp (cdr sub
))
3501 (concat (car entry
) anything-c-imenu-delimiter subentry
))
3502 (anything-imenu-create-candidates sub
))
3503 (list (concat (car entry
) anything-c-imenu-delimiter
(car sub
)))))
3507 (defvar anything-c-source-imenu
3509 (init .
(lambda () (require 'imenu
)))
3510 (candidates . anything-c-imenu-candidates
)
3511 (persistent-action .
(lambda (elm)
3512 (anything-c-imenu-default-action elm
)
3513 (unless (fboundp 'semantic-imenu-tag-overlay
)
3514 (anything-match-line-color-current-line))))
3515 (persistent-help .
"Show this entry")
3516 (action . anything-c-imenu-default-action
))
3517 "See (info \"(emacs)Imenu\")")
3519 ;; (anything 'anything-c-source-imenu)
3521 (defun anything-c-imenu-candidates ()
3522 (with-current-buffer anything-current-buffer
3523 (let ((tick (buffer-modified-tick)))
3524 (if (eq anything-c-cached-imenu-tick tick
)
3525 anything-c-cached-imenu-candidates
3526 (setq imenu--index-alist nil
)
3527 (setq anything-c-cached-imenu-tick tick
3528 anything-c-cached-imenu-candidates
3531 'anything-imenu-create-candidates
3532 (setq anything-c-cached-imenu-alist
3533 (let ((index (imenu--make-index-alist)))
3534 (if anything-c-imenu-index-filter
3535 (funcall anything-c-imenu-index-filter index
)
3537 (setq anything-c-cached-imenu-candidates
3538 (mapcar #'(lambda (x)
3542 anything-c-cached-imenu-candidates
))))))
3544 (setq imenu-default-goto-function
'imenu-default-goto-function
)
3545 (defun anything-c-imenu-default-action (elm)
3546 "The default action for `anything-c-source-imenu'."
3547 (let ((path (split-string elm anything-c-imenu-delimiter
))
3548 (alist anything-c-cached-imenu-alist
))
3549 (if (> (length path
) 1)
3551 (setq alist
(assoc (car path
) alist
))
3552 (setq elm
(cadr path
))
3553 (imenu (assoc elm alist
)))
3554 (imenu (assoc elm alist
)))))
3557 (defvar anything-c-ctags-modes
3558 '( c-mode c
++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode
3559 makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode
3560 scheme-mode sh-mode slang-mode sql-mode tcl-mode
))
3562 (defun anything-c-source-ctags-init ()
3563 (when (and buffer-file-name
3564 (memq major-mode anything-c-ctags-modes
)
3565 (anything-current-buffer-is-modified))
3566 (with-current-buffer (anything-candidate-buffer 'local
)
3567 (call-process-shell-command
3568 (if (string-match "\\.el\\.gz$" anything-buffer-file-name
)
3569 (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) " anything-buffer-file-name
)
3570 (format "ctags -e -u -f- --fields=n %s " anything-buffer-file-name
))
3571 nil
(current-buffer))
3572 (goto-char (point-min))
3574 (delete-region (point-min) (point))
3575 (loop while
(and (not (eobp)) (search-forward "\001" (point-at-eol) t
))
3576 for lineno-start
= (point)
3577 for lineno
= (buffer-substring lineno-start
(1- (search-forward "," (point-at-eol) t
)))
3580 (insert (format "%5s:" lineno
))
3581 (search-forward "\177" (point-at-eol) t
)
3582 (delete-region (1- (point)) (point-at-eol))
3583 (forward-line 1)))))
3585 (defvar anything-c-source-ctags
3586 '((name .
"Exuberant ctags")
3587 (init . anything-c-source-ctags-init
)
3588 (candidates-in-buffer)
3591 "Needs Exuberant Ctags.
3593 http://ctags.sourceforge.net/")
3594 ;; (anything 'anything-c-source-ctags)
3597 (eval-when-compile (require 'semantic nil t
))
3598 (declare-function semantic-format-tag-summarize
"ext:format.el" (tag &optional parent color
) t
)
3599 (declare-function semantic-tag-components
"ext:tag.el" (tag) t
)
3600 (declare-function semantic-go-to-tag
"ext:tag-file.el" (tag) t
)
3601 (defvar anything-semantic-candidates nil
)
3603 (defun anything-semantic-construct-candidates (tags depth
)
3604 (when (require 'semantic nil t
)
3606 (mapcar (lambda (tag)
3608 (let ((type (semantic-tag-type tag
))
3609 (class (semantic-tag-class tag
)))
3610 (if (or (and (stringp type
)
3611 (or (string= type
"class")
3612 (string= type
"namespace")))
3613 (eq class
'function
)
3614 (eq class
'variable
))
3615 (cons (cons (concat (make-string (* depth
2) ?\s
)
3616 (semantic-format-tag-summarize tag nil t
)) tag
)
3617 (anything-semantic-construct-candidates (semantic-tag-components tag
)
3621 (defun anything-semantic-default-action (candidate)
3622 (let ((tag (cdr (assoc candidate anything-semantic-candidates
))))
3623 (semantic-go-to-tag tag
)))
3625 (defvar anything-c-source-semantic
3626 '((name .
"Semantic Tags")
3628 (setq anything-semantic-candidates
3629 (ignore-errors (anything-semantic-construct-candidates (semantic-fetch-tags) 0)))))
3630 (candidates .
(lambda ()
3631 (if anything-semantic-candidates
3632 (mapcar 'car anything-semantic-candidates
))))
3633 (persistent-action .
(lambda (elm)
3634 (anything-semantic-default-action elm
)
3635 (anything-match-line-color-current-line)))
3636 (persistent-help .
"Show this entry")
3637 (action . anything-semantic-default-action
)
3638 "Needs semantic in CEDET.
3640 http://cedet.sourceforge.net/semantic.shtml
3641 http://cedet.sourceforge.net/"))
3643 ;; (anything 'anything-c-source-semantic)
3645 ;;; Function is called by
3647 (defun anything-simple-call-tree ()
3648 "Preconfigured `anything' for simple-call-tree. List function relationships.
3650 Needs simple-call-tree.el.
3651 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el"
3653 (anything-other-buffer
3654 '(anything-c-source-simple-call-tree-functions-callers
3655 anything-c-source-simple-call-tree-callers-functions
)
3656 "*anything simple-call-tree*"))
3658 (defvar anything-c-source-simple-call-tree-functions-callers
3659 '((name .
"Function is called by")
3660 (init . anything-c-simple-call-tree-functions-callers-init
)
3662 (candidates . anything-c-simple-call-tree-candidates
)
3663 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3664 (persistent-help .
"Show function definitions by rotation")
3665 (action ("Find definition selected by persistent-action" .
3666 anything-c-simple-call-tree-find-definition
)))
3667 "Needs simple-call-tree.el.
3668 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3670 (defvar anything-c-simple-call-tree-tick nil
)
3671 (make-variable-buffer-local 'anything-c-simple-call-tree-tick
)
3672 (defun anything-c-simple-call-tree-analyze-maybe ()
3673 (unless (eq (buffer-chars-modified-tick) anything-c-simple-call-tree-tick
)
3674 (simple-call-tree-analyze)
3675 (setq anything-c-simple-call-tree-tick
(buffer-chars-modified-tick))))
3677 (defun anything-c-simple-call-tree-init-base (function message
)
3678 (require 'simple-call-tree
)
3680 (when (anything-current-buffer-is-modified)
3681 (anything-c-simple-call-tree-analyze-maybe)
3682 (let ((list (funcall function simple-call-tree-alist
)))
3683 (with-current-buffer (anything-candidate-buffer 'local
)
3684 (dolist (entry list
)
3685 (let ((funcs (concat " " (mapconcat #'identity
(cdr entry
) "\n "))))
3686 (insert (car entry
) message
3687 (if (string= funcs
" ")
3692 (defun anything-c-simple-call-tree-functions-callers-init ()
3693 (anything-c-simple-call-tree-init-base 'simple-call-tree-invert
" is called by\n"))
3695 (defun anything-c-simple-call-tree-candidates ()
3696 (with-current-buffer (anything-candidate-buffer)
3697 (split-string (buffer-string) "\n\n")))
3699 (defvar anything-c-simple-call-tree-related-functions nil
)
3700 (defvar anything-c-simple-call-tree-function-index
0)
3701 (defun anything-c-simple-call-tree-persistent-action (candidate)
3702 (unless (eq last-command
'anything-execute-persistent-action
)
3703 (setq anything-c-simple-call-tree-related-functions
3704 (delete "no functions."
3706 (replace-regexp-in-string " \\| is called by\\| calls " "" candidate
)
3708 (setq anything-c-simple-call-tree-function-index -
1))
3709 (incf anything-c-simple-call-tree-function-index
)
3710 (anything-c-simple-call-tree-find-definition candidate
))
3712 (defun anything-c-simple-call-tree-find-definition (candidate)
3713 (find-function (intern
3714 (nth (mod anything-c-simple-call-tree-function-index
3715 (length anything-c-simple-call-tree-related-functions
))
3716 anything-c-simple-call-tree-related-functions
))))
3718 ;; (anything 'anything-c-source-simple-call-tree-functions-callers)
3721 (defvar anything-c-source-simple-call-tree-callers-functions
3722 '((name .
"Function calls")
3723 (init . anything-c-simple-call-tree-callers-functions-init
)
3725 (candidates . anything-c-simple-call-tree-candidates
)
3726 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3727 (persistent-help .
"Show function definitions by rotation")
3728 (action ("Find definition selected by persistent-action" .
3729 anything-c-simple-call-tree-find-definition
)))
3730 "Needs simple-call-tree.el.
3731 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3733 (defun anything-c-simple-call-tree-callers-functions-init ()
3734 (anything-c-simple-call-tree-init-base 'identity
" calls \n"))
3736 ;; (anything 'anything-c-source-simple-call-tree-callers-functions)
3738 ;;; Commands/Options with doc
3739 (defvar anything-c-auto-document-data nil
)
3740 (make-variable-buffer-local 'anything-c-auto-document-data
)
3741 (defvar anything-c-source-commands-and-options-in-file
3742 '((name .
"Commands/Options in file")
3744 .
(lambda (x) (format "Commands/Options in %s"
3745 (buffer-local-value 'buffer-file-name anything-current-buffer
))))
3746 (candidates . anything-command-and-options-candidates
)
3749 "List Commands and Options with doc. It needs auto-document.el .
3751 http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el")
3753 (eval-when-compile (require 'auto-document nil t
))
3754 (defun anything-command-and-options-candidates ()
3755 (with-current-buffer anything-current-buffer
3756 (when (and (require 'auto-document nil t
)
3757 (eq major-mode
'emacs-lisp-mode
)
3758 (or (anything-current-buffer-is-modified)
3759 (not anything-c-auto-document-data
)))
3760 (or imenu--index-alist
(imenu--make-index-alist t
))
3761 (setq anything-c-auto-document-data
3762 (destructuring-bind (commands options
)
3763 (adoc-construct anything-current-buffer
)
3765 (loop for
(command . doc
) in commands
3766 for cmdname
= (symbol-name command
)
3768 (cons (format "Command: %s\n %s"
3769 (propertize cmdname
'face font-lock-function-name-face
)
3770 (adoc-first-line doc
))
3771 (assoc cmdname imenu--index-alist
)))
3772 (loop with var-alist
= (cdr (assoc "Variables" imenu--index-alist
))
3773 for
(option doc default
) in options
3774 for optname
= (symbol-name option
)
3776 (cons (format "Option: %s\n %s\n default = %s"
3777 (propertize optname
'face font-lock-variable-name-face
)
3778 (adoc-first-line doc
)
3779 (adoc-prin1-to-string default
))
3782 anything-c-auto-document-data
))
3784 ;; (anything 'anything-c-source-commands-and-options-in-file)
3786 ;;;; <Color and Face>
3788 (defvar anything-c-source-customize-face
3789 '((name .
"Customize Face")
3791 (unless (anything-candidate-buffer)
3792 (save-window-excursion (list-faces-display))
3793 (anything-candidate-buffer (get-buffer "*Faces*")))))
3794 (candidates-in-buffer)
3795 (get-line . buffer-substring
)
3796 (action .
(lambda (line)
3797 (customize-face (intern (car (split-string line
))))))
3798 (requires-pattern .
3))
3799 "See (info \"(emacs)Faces\")")
3800 ;; (anything 'anything-c-source-customize-face)
3803 (defvar anything-c-source-colors
3805 (init .
(lambda () (unless (anything-candidate-buffer)
3806 (save-window-excursion (list-colors-display))
3807 (anything-candidate-buffer (get-buffer "*Colors*")))))
3808 (candidates-in-buffer)
3809 (get-line . buffer-substring
)
3810 (action ("Copy Name" .
(lambda (candidate)
3811 (kill-new (anything-c-colors-get-name candidate
))))
3812 ("Copy RGB" .
(lambda (candidate)
3813 (kill-new (anything-c-colors-get-rgb candidate
))))
3814 ("Insert Name" .
(lambda (candidate)
3815 (with-current-buffer anything-current-buffer
3816 (insert (anything-c-colors-get-name candidate
)))))
3817 ("Insert RGB" .
(lambda (candidate)
3818 (with-current-buffer anything-current-buffer
3819 (insert (anything-c-colors-get-rgb candidate
))))))))
3820 ;; (anything 'anything-c-source-colors)
3822 (defun anything-c-colors-get-name (candidate)
3824 (replace-regexp-in-string
3827 (insert (capitalize candidate
))
3828 (goto-char (point-min))
3829 (search-forward-regexp "\\s-\\{2,\\}")
3830 (delete-region (point) (point-max))
3833 (defun anything-c-colors-get-rgb (candidate)
3835 (replace-regexp-in-string
3838 (insert (capitalize candidate
))
3839 (goto-char (point-max))
3840 (search-backward-regexp "\\s-\\{2,\\}")
3841 (delete-region (point) (point-min))
3844 ;;;; <Search Engine>
3845 ;;; Tracker desktop search
3846 (defvar anything-c-source-tracker-search
3847 '((name .
"Tracker Search")
3848 (candidates .
(lambda ()
3849 (start-process "tracker-search-process" nil
3853 (requires-pattern .
3)
3855 "Source for retrieving files matching the current input pattern
3856 with the tracker desktop search.")
3857 ;; (anything 'anything-c-source-tracker-search)
3859 ;;; Spotlight (MacOS X desktop search)
3860 (defvar anything-c-source-mac-spotlight
3862 (candidates .
(lambda ()
3863 (start-process "mdfind-process" nil
"mdfind" anything-pattern
)))
3865 (requires-pattern .
3)
3867 "Source for retrieving files via Spotlight's command line
3869 ;; (anything 'anything-c-source-mac-spotlight)
3874 (defvar anything-c-source-kill-ring
3875 '((name .
"Kill Ring")
3876 (init .
(lambda () (anything-attrset 'last-command last-command
)))
3877 (candidates . anything-c-kill-ring-candidates
)
3878 (action . anything-c-kill-ring-action
)
3882 "Source for browse and insert contents of kill-ring.")
3884 (defun anything-c-kill-ring-candidates ()
3885 (loop for kill in kill-ring
3886 unless
(or (< (length kill
) anything-kill-ring-threshold
)
3887 (string-match "^[\\s\\t]+$" kill
))
3890 (defun anything-c-kill-ring-action (str)
3891 "Insert STR in `kill-ring' and set STR to the head.
3892 If this action is executed just after `yank', replace with STR as yanked string."
3893 (setq kill-ring
(delete str kill-ring
))
3894 (if (not (eq (anything-attr 'last-command
) 'yank
))
3895 (insert-for-yank str
)
3897 (let ((inhibit-read-only t
)
3898 (before (< (point) (mark t
))))
3900 (funcall (or yank-undo-function
'delete-region
) (point) (mark t
))
3901 (funcall (or yank-undo-function
'delete-region
) (mark t
) (point)))
3902 (setq yank-undo-function nil
)
3903 (set-marker (mark-marker) (point) (current-buffer))
3904 (insert-for-yank str
)
3905 ;; Set the window start back where it was in the yank command,
3907 (set-window-start (selected-window) yank-window-start t
)
3909 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
3910 ;; It is cleaner to avoid activation, even though the command
3911 ;; loop would deactivate the mark because we inserted text.
3912 (goto-char (prog1 (mark t
)
3913 (set-marker (mark-marker) (point) (current-buffer)))))))
3916 ;; (anything 'anything-c-source-kill-ring)
3919 ;; DO NOT include these sources in `anything-sources' use
3920 ;; the commands `anything-mark-ring', `anything-global-mark-ring' or
3921 ;; `anything-all-mark-rings' instead.
3923 (defun anything-c-source-mark-ring-candidates ()
3924 (flet ((get-marks (pos)
3928 (let ((line (car (split-string (thing-at-point 'line
) "[\n\r]"))))
3929 (when (string= "" line
)
3930 (setq line
"<EMPTY LINE>"))
3931 (format "%7d: %s" (line-number-at-pos) line
)))))
3932 (with-current-buffer anything-current-buffer
3934 with marks
= (cons (mark-marker) mark-ring
)
3937 for m
= (get-marks i
)
3938 unless
(member m recip
)
3939 collect m into recip
3940 finally return recip
))))
3942 (defvar anything-mark-ring-cache nil
)
3943 (defvar anything-c-source-mark-ring
3944 '((name .
"mark-ring")
3946 (setq anything-mark-ring-cache
3947 (ignore-errors (anything-c-source-mark-ring-candidates)))))
3948 (candidates .
(lambda ()
3949 (anything-aif anything-mark-ring-cache
3951 (action .
(("Goto line" .
(lambda (candidate)
3952 (anything-goto-line (string-to-number candidate
))))))
3953 (persistent-action .
(lambda (candidate)
3954 (anything-goto-line (string-to-number candidate
))
3955 (anything-match-line-color-current-line)))
3956 (persistent-help .
"Show this line")))
3958 ;; (anything 'anything-c-source-mark-ring)
3961 (defun anything-mark-ring ()
3962 "Preconfigured `anything' for `anything-c-source-mark-ring'."
3964 (anything 'anything-c-source-mark-ring
))
3966 ;;; Global-mark-ring
3967 (defvar anything-c-source-global-mark-ring
3968 '((name .
"global-mark-ring")
3969 (candidates . anything-c-source-global-mark-ring-candidates
)
3970 (action .
(("Goto line" .
(lambda (candidate)
3971 (let ((items (split-string candidate
":")))
3972 (switch-to-buffer (second items
))
3973 (anything-goto-line (string-to-number (car items
))))))))
3974 (persistent-action .
(lambda (candidate)
3975 (let ((items (split-string candidate
":")))
3976 (switch-to-buffer (second items
))
3977 (anything-goto-line (string-to-number (car items
)))
3978 (anything-match-line-color-current-line))))
3979 (persistent-help .
"Show this line")))
3981 (defun anything-c-source-global-mark-ring-candidates ()
3983 (with-current-buffer (marker-buffer m
)
3987 (if (string= "" line
)
3988 (setq line
"<EMPTY LINE>")
3989 (setq line
(car (split-string (thing-at-point 'line
) "[\n\r]"))))
3990 (format "%7d:%s: %s" (line-number-at-pos) (marker-buffer m
) line
)))))
3992 with marks
= global-mark-ring
3995 for gm
= (unless (or (string-match
3996 "^ " (format "%s" (marker-buffer i
)))
3997 (null (marker-buffer i
)))
3999 when
(and gm
(not (member gm recip
)))
4000 collect gm into recip
4001 finally return recip
)))
4003 ;; (anything 'anything-c-source-global-mark-ring)
4006 (defun anything-global-mark-ring ()
4007 "Preconfigured `anything' for `anything-c-source-global-mark-ring'."
4009 (anything 'anything-c-source-global-mark-ring
))
4012 (defun anything-all-mark-rings ()
4013 "Preconfigured `anything' for `anything-c-source-global-mark-ring' and \
4014 `anything-c-source-mark-ring'."
4016 (anything '(anything-c-source-global-mark-ring
4017 anything-c-source-mark-ring
)))
4020 ;;; Insert from register
4021 (defvar anything-c-source-register
4022 '((name .
"Registers")
4023 (candidates . anything-c-register-candidates
)
4024 (action-transformer . anything-c-register-action-transformer
)
4027 "See (info \"(emacs)Registers\")")
4029 (defun anything-c-register-candidates ()
4030 "Collecting register contents and appropriate commands."
4031 (loop for
(char . val
) in register-alist
4032 for key
= (single-key-description char
)
4033 for string-actions
= (cond
4035 (list (int-to-string val
)
4037 'increment-register
))
4039 (let ((buf (marker-buffer val
)))
4041 (list "a marker in no buffer")
4043 "a buffer position:"
4046 (int-to-string (marker-position val
)))
4048 'insert-register
))))
4049 ((and (consp val
) (window-configuration-p (car val
)))
4050 (list "window configuration."
4052 ((and (consp val
) (frame-configuration-p (car val
)))
4053 (list "frame configuration."
4055 ((and (consp val
) (eq (car val
) 'file
))
4056 (list (concat "file:"
4057 (prin1-to-string (cdr val
))
4060 ((and (consp val
) (eq (car val
) 'file-query
))
4061 (list (concat "file:a file-query reference: file "
4064 (int-to-string (car (cdr (cdr val
))))
4068 (let ((lines (format "%4d" (length val
))))
4069 (list (format "%s: %s\n" lines
4070 (truncate-string-to-width
4071 (mapconcat 'identity
(list (car val
))
4072 ;; (mapconcat (lambda (y) y) val
4073 "^J") (- (window-width) 15)))
4076 (list ;; without properties
4077 (substring-no-properties val
)
4080 'prepend-to-register
))
4083 collect
(cons (format "register %3s: %s" key
(car string-actions
))
4084 (cons char
(cdr string-actions
)))))
4086 (defun anything-c-register-action-transformer (actions register-and-functions
)
4087 "Decide actions by the contents of register."
4088 (loop with func-actions
=
4091 (lambda (c) (insert-register (car c
))))
4093 "Jump to Register" .
4094 (lambda (c) (jump-to-register (car c
))))
4096 "Append Region to Register" .
4097 (lambda (c) (append-to-register (car c
) (region-beginning) (region-end))))
4098 (prepend-to-register
4099 "Prepend Region to Register" .
4100 (lambda (c) (prepend-to-register (car c
) (region-beginning) (region-end))))
4102 "Increment Prefix Arg to Register" .
4103 (lambda (c) (increment-register anything-current-prefix-arg
(car c
)))))
4104 for func in
(cdr register-and-functions
)
4105 for cell
= (assq func func-actions
)
4107 collect
(cdr cell
)))
4109 ;; (anything 'anything-c-source-register)
4111 ;;;; <Headline Extraction>
4112 (defvar anything-c-source-fixme
4113 '((name .
"TODO/FIXME/DRY comments")
4114 (headline .
"^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$")
4117 "Show TODO/FIXME/DRY comments in current file.")
4118 ;; (anything 'anything-c-source-fixme)
4120 (defvar anything-c-source-rd-headline
4121 '((name .
"RD HeadLine")
4122 (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$")
4123 (condition .
(memq major-mode
'(rdgrep-mode rd-mode
)))
4129 http://en.wikipedia.org/wiki/Ruby_Document_format")
4130 ;; (anything 'anything-c-source-rd-headline)
4132 (defvar anything-c-source-oddmuse-headline
4133 '((name .
"Oddmuse HeadLine")
4134 (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$"
4135 "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$")
4136 (condition .
(memq major-mode
'(oddmuse-mode yaoddmuse-mode
)))
4139 "Show Oddmuse headlines, such as EmacsWiki.")
4140 ;; (anything 'anything-c-source-oddmuse-headline)
4142 (defvar anything-c-source-emacs-source-defun
4143 '((name .
"Emacs Source DEFUN")
4144 (headline .
"DEFUN\\|DEFVAR")
4145 (condition .
(string-match "/emacs2[0-9].+/src/.+c$" (or buffer-file-name
""))))
4146 "Show DEFUN/DEFVAR in Emacs C source file.")
4147 ;; (anything 'anything-c-source-emacs-source-defun)
4149 (defvar anything-c-source-emacs-lisp-expectations
4150 '((name .
"Emacs Lisp Expectations")
4151 (headline .
"(desc[ ]\\|(expectations")
4152 (condition .
(eq major-mode
'emacs-lisp-mode
)))
4153 "Show descriptions (desc) in Emacs Lisp Expectations.
4155 http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
4156 ;; (anything 'anything-c-source-emacs-lisp-expectations)
4158 (defvar anything-c-source-emacs-lisp-toplevels
4159 '((name .
"Emacs Lisp Toplevel / Level 4 Comment / Linkd Star")
4160 (headline .
"^(\\|(@\\*\\|^;;;;")
4161 (get-line . buffer-substring
)
4162 (condition .
(eq major-mode
'emacs-lisp-mode
))
4164 "Show top-level forms, level 4 comments and linkd stars (optional) in Emacs Lisp.
4165 linkd.el is optional because linkd stars are extracted by regexp.
4166 http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el")
4167 ;; (anything 'anything-c-source-emacs-lisp-toplevels)
4169 (defvar anything-c-source-org-headline
4170 '((name .
"Org HeadLine")
4172 "^\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4173 "^\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4174 "^\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4175 "^\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4176 "^\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4177 "^\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4178 "^\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4179 "^\\*\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$")
4180 (condition .
(eq major-mode
'org-mode
))
4183 (persistent-action .
(lambda (elm)
4184 (anything-c-action-line-goto elm
)
4187 .
(lambda (actions candidate
)
4188 '(("Go to Line" . anything-c-action-line-goto
)
4189 ("Insert Link to This Headline" . anything-c-org-headline-insert-link-to-headline
)))))
4190 "Show Org headlines.
4191 org-mode is very very much extended text-mode/outline-mode.
4193 See (find-library \"org.el\")
4194 See http://orgmode.org for the latest version.")
4196 (defun anything-c-org-headline-insert-link-to-headline (lineno-and-content)
4199 (anything-goto-line (car lineno-and-content
))
4200 (and (looking-at org-complex-heading-regexp
)
4201 (org-make-link-string (concat "*" (match-string 4)))))))
4203 ;; (anything 'anything-c-source-org-headline)
4205 ;;; Anything yaoddmuse
4206 ;; Be sure to have yaoddmuse.el installed
4207 ;; install-elisp may be required if you want to install elisp file from here.
4208 (defvar anything-yaoddmuse-use-cache-file nil
)
4209 (defvar anything-c-yaoddmuse-cache-file
"~/.emacs.d/yaoddmuse-cache.el")
4210 (defvar anything-c-yaoddmuse-ew-cache nil
)
4211 (defvar anything-c-source-yaoddmuse-emacswiki-edit-or-view
4212 '((name .
"Yaoddmuse Edit or View (EmacsWiki)")
4213 (candidates .
(lambda ()
4214 (if anything-yaoddmuse-use-cache-file
4216 (unless anything-c-yaoddmuse-ew-cache
4217 (load anything-c-yaoddmuse-cache-file
)
4218 (setq anything-c-yaoddmuse-ew-cache
4219 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4220 anything-c-yaoddmuse-ew-cache
)
4221 (yaoddmuse-update-pagename t
)
4222 (gethash "EmacsWiki" yaoddmuse-pages-hash
))))
4223 (action .
(("Edit page" .
(lambda (candidate)
4224 (yaoddmuse-edit "EmacsWiki" candidate
)))
4225 ("Browse page" .
(lambda (candidate)
4226 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4227 ("Browse page other window" .
(lambda (candidate)
4229 (split-window-vertically))
4230 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4231 ("Browse diff" .
(lambda (candidate)
4232 (yaoddmuse-browse-page-diff "EmacsWiki" candidate
)))
4233 ("Copy URL" .
(lambda (candidate)
4234 (kill-new (yaoddmuse-url "EmacsWiki" candidate
))
4235 (message "Have copy page %s's URL to yank." candidate
)))
4236 ("Create page" .
(lambda (candidate)
4237 (yaoddmuse-edit "EmacsWiki" anything-input
)))
4238 ("Update cache" .
(lambda (candidate)
4239 (if anything-yaoddmuse-use-cache-file
4241 (anything-yaoddmuse-cache-pages t
)
4242 (setq anything-c-yaoddmuse-ew-cache
4243 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4244 (yaoddmuse-update-pagename))))))
4245 (action-transformer anything-c-yaoddmuse-action-transformer
))
4246 "Needs yaoddmuse.el.
4248 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4250 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view)
4252 (defvar anything-c-source-yaoddmuse-emacswiki-post-library
4253 '((name .
"Yaoddmuse Post library (EmacsWiki)")
4254 (init .
(anything-yaoddmuse-init))
4255 (candidates-in-buffer)
4256 (action .
(("Post library and Browse" .
(lambda (candidate)
4257 (yaoddmuse-post-file (find-library-name candidate
)
4259 (file-name-nondirectory (find-library-name candidate
))
4261 ("Post library" .
(lambda (candidate)
4262 (yaoddmuse-post-file (find-library-name candidate
)
4264 (file-name-nondirectory (find-library-name candidate
))))))))
4265 "Needs yaoddmuse.el.
4267 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4269 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-post-library)
4271 (defun anything-c-yaoddmuse-action-transformer (actions candidate
)
4272 "Allow the use of `install-elisp' only on elisp files."
4273 (if (string-match "\.el$" candidate
)
4274 (append actions
'(("Install Elisp" .
(lambda (elm)
4275 (install-elisp-from-emacswiki elm
)))))
4279 (defun anything-yaoddmuse-cache-pages (&optional load
)
4280 "Fetch the list of files on emacswiki and create cache file.
4281 If load is non--nil load the file and feed `yaoddmuse-pages-hash'."
4283 (yaoddmuse-update-pagename)
4285 (find-file anything-c-yaoddmuse-cache-file
)
4287 (insert "(puthash \"EmacsWiki\" '(")
4288 (loop for i in
(gethash "EmacsWiki" yaoddmuse-pages-hash
)
4290 (insert (concat "(\"" (car i
) "\") ")))
4291 (insert ") yaoddmuse-pages-hash)\n")
4293 (kill-buffer (current-buffer))
4294 (when (or current-prefix-arg
4296 (load anything-c-yaoddmuse-cache-file
))))
4299 (defun anything-yaoddmuse-emacswiki-edit-or-view ()
4300 "Preconfigured `anything' to edit or view EmacsWiki page.
4304 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4306 (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view
))
4309 (defun anything-yaoddmuse-emacswiki-post-library ()
4310 "Preconfigured `anything' to post library to EmacsWiki.
4314 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4316 (anything 'anything-c-source-yaoddmuse-emacswiki-post-library
))
4318 (defun anything-yaoddmuse-init ()
4319 "Init anything buffer status."
4320 (let ((anything-buffer (anything-candidate-buffer 'global
))
4321 (library-list (yaoddmuse-get-library-list)))
4322 (with-current-buffer anything-buffer
4323 ;; Insert library name.
4324 (dolist (library library-list
)
4325 (insert (format "%s\n" library
)))
4327 (sort-lines nil
(point-min) (point-max)))))
4330 (defvar anything-c-source-eev-anchor
4331 '((name .
"Anchors")
4335 (with-current-buffer anything-current-buffer
4336 (loop initially
(goto-char (point-min))
4337 while
(re-search-forward (format ee-anchor-format
"\\([^\.].+\\)") nil t
)
4338 for anchor
= (match-string-no-properties 1)
4339 collect
(cons (format "%5d:%s"
4340 (line-number-at-pos (match-beginning 0))
4341 (format ee-anchor-format anchor
)) anchor
))))))
4342 (persistent-action .
(lambda (item)
4344 (anything-match-line-color-current-line)))
4345 (persistent-help .
"Show this entry")
4346 (action .
(("Goto link" . ee-to
)))))
4347 ;; (anything 'anything-c-source-eev-anchor)
4351 (defvar anything-c-source-org-keywords
4352 '((name .
"Org Keywords")
4353 (init . anything-c-org-keywords-init
)
4354 (candidates . anything-c-org-keywords-candidates
)
4355 (action . anything-c-org-keywords-insert
)
4356 (persistent-action . anything-c-org-keywords-show-help
)
4357 (persistent-help .
"Show an example and info page to describe this keyword.")
4360 ;; (anything 'anything-c-source-org-keywords)
4361 (defvar anything-c-org-keywords-info-location
4362 '(("#+TITLE:" .
"(org)Export options")
4363 ("#+AUTHOR:" .
"(org)Export options")
4364 ("#+DATE:" .
"(org)Export options")
4365 ("#+EMAIL:" .
"(org)Export options")
4366 ("#+DESCRIPTION:" .
"(org)Export options")
4367 ("#+KEYWORDS:" .
"(org)Export options")
4368 ("#+LANGUAGE:" .
"(org)Export options")
4369 ("#+TEXT:" .
"(org)Export options")
4370 ("#+TEXT:" .
"(org)Export options")
4371 ("#+OPTIONS:" .
"(org)Export options")
4372 ("#+BIND:" .
"(org)Export options")
4373 ("#+LINK_UP:" .
"(org)Export options")
4374 ("#+LINK_HOME:" .
"(org)Export options")
4375 ("#+LATEX_HEADER:" .
"(org)Export options")
4376 ("#+EXPORT_SELECT_TAGS:" .
"(org)Export options")
4377 ("#+EXPORT_EXCLUDE_TAGS:" .
"(org)Export options")
4378 ("#+INFOJS_OPT" .
"(org)Javascript support")
4379 ("#+BEGIN_HTML" .
"(org)Quoting HTML tags")
4380 ("#+BEGIN_LaTeX" .
"(org)Quoting LaTeX code")
4381 ("#+ORGTBL" .
"(org)Radio tables")
4382 ("#+HTML:" .
"(org)Quoting HTML tags")
4383 ("#+LaTeX:" .
"(org)Quoting LaTeX code")
4384 ("#+BEGIN:" .
"(org)Dynamic blocks") ;clocktable columnview
4385 ("#+BEGIN_EXAMPLE" .
"(org)Literal examples")
4386 ("#+BEGIN_QUOTE" .
"(org)Paragraphs")
4387 ("#+BEGIN_VERSE" .
"(org)Paragraphs")
4388 ("#+BEGIN_SRC" .
"(org)Literal examples")
4389 ("#+CAPTION" .
"(org)Tables in HTML export")
4390 ("#+LABEL" .
"(org)Tables in LaTeX export")
4391 ("#+ATTR_HTML" .
"(org)Links")
4392 ("#+ATTR_LaTeX" .
"(org)Images in LaTeX export")))
4394 (defun anything-c-org-keywords-init ()
4395 (unless (anything-attr 'keywords-examples
)
4397 (anything-attrset 'keywords-examples
4401 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x
)
4402 (cons (match-string 2 x
) (match-string 1 x
)))
4403 (org-split-string (org-get-current-options) "\n"))
4404 (mapcar 'list org-additional-option-like-keywords
)))
4405 (anything-attrset 'keywords
(mapcar 'car
(anything-attr 'keywords-examples
)))))
4407 (defun anything-c-org-keywords-candidates ()
4408 (and (eq (buffer-local-value 'major-mode anything-current-buffer
) 'org-mode
)
4409 (anything-attr 'keywords
)))
4411 (defun anything-c-org-keywords-insert (keyword)
4412 (cond ((string-match "BEGIN" keyword
)
4413 (insert "#+" keyword
" ")
4415 (insert "\n" (replace-regexp-in-string "BEGIN" "END" keyword
) "\n")))
4417 (insert "#+" keyword
" "))))
4419 (defun anything-c-org-keywords-show-help (keyword)
4420 (info (or (assoc-default (concat "#+" keyword
) anything-c-org-keywords-info-location
)
4421 "(org)In-buffer settings"))
4422 (search-forward (concat "#+" keyword
) nil t
)
4423 (anything-persistent-highlight-point)
4424 (message "%s" (or (cdr (assoc keyword
(anything-attr 'keywords-examples
))) "")))
4428 (defvar anything-c-source-picklist
4429 '((name .
"Picklist")
4430 (candidates .
(lambda () (mapcar 'car picklist-list
)))
4432 ;; (anything 'anything-c-source-picklist)
4435 (defvar bbdb-records
)
4436 (defvar bbdb-buffer-name
)
4437 (declare-function bbdb
"ext:bbdb-com")
4438 (declare-function bbdb-current-record
"ext:bbdb-com")
4439 (declare-function bbdb-redisplay-one-record
"ext:bbdb-com")
4440 (declare-function bbdb-record-net
"ext:bbdb-com" (string) t
)
4441 (declare-function bbdb-current-record
"ext:bbdb-com")
4442 (declare-function bbdb-dwim-net-address
"ext:bbdb-com")
4443 (declare-function bbdb-records
"ext:bbdb-com"
4444 (&optional dont-check-disk already-in-db-buffer
))
4446 (defun anything-c-bbdb-candidates ()
4447 "Return a list of all names in the bbdb database. The format
4448 is \"Firstname Lastname\"."
4449 (mapcar (lambda (bbdb-record)
4450 (replace-regexp-in-string
4452 (concat (aref bbdb-record
0) " " (aref bbdb-record
1))))
4455 (defun anything-c-bbdb-create-contact (actions candidate
)
4456 "Action transformer that returns only an entry to add the
4457 current `anything-pattern' as new contact. All other actions are
4459 (if (string= candidate
"*Add to contacts*")
4460 '(("Add to contacts" .
(lambda (actions)
4461 (bbdb-create-internal
4462 (read-from-minibuffer "Name: " anything-c-bbdb-name
)
4463 (read-from-minibuffer "Company: ")
4464 (read-from-minibuffer "Email: ")
4467 (read-from-minibuffer "Note: ")))))
4470 (defun anything-c-bbdb-get-record (candidate)
4471 "Return record that match CANDIDATE."
4472 (bbdb candidate nil
)
4473 (set-buffer "*BBDB*")
4474 (bbdb-current-record))
4476 (defvar anything-c-bbdb-name nil
4477 "Only for internal use.")
4479 (defvar anything-c-source-bbdb
4481 (candidates . anything-c-bbdb-candidates
)
4482 (action ("Send a mail" . anything-c-bbdb-compose-mail
)
4483 ("View person's data" . anything-c-bbdb-view-person-action
))
4484 (filtered-candidate-transformer .
(lambda (candidates source
)
4485 (setq anything-c-bbdb-name anything-pattern
)
4486 (if (not candidates
)
4487 (list "*Add to contacts*")
4489 (action-transformer .
(lambda (actions candidate
)
4490 (anything-c-bbdb-create-contact actions candidate
))))
4493 http://bbdb.sourceforge.net/")
4494 ;; (anything 'anything-c-source-bbdb)
4496 (defun anything-c-bbdb-view-person-action (candidate)
4497 "View BBDB data of single CANDIDATE or marked candidates."
4498 (anything-aif (anything-marked-candidates)
4499 (let ((bbdb-append-records (length it
)))
4501 (bbdb-redisplay-one-record (anything-c-bbdb-get-record i
))))
4502 (bbdb-redisplay-one-record (anything-c-bbdb-get-record candidate
))))
4504 (defun anything-c-bbdb-collect-mail-addresses ()
4505 "Return a list of all mail addresses of records in bbdb buffer."
4506 (with-current-buffer bbdb-buffer-name
4507 (loop for i in bbdb-records
4508 if
(bbdb-record-net (car i
))
4509 collect
(bbdb-dwim-net-address (car i
)))))
4511 (defun anything-c-bbdb-compose-mail (candidate)
4512 "Compose a mail with all records of bbdb buffer."
4513 (anything-c-bbdb-view-person-action candidate
)
4514 (let* ((address-list (anything-c-bbdb-collect-mail-addresses))
4515 (address-str (mapconcat 'identity address-list
",\n ")))
4516 (compose-mail address-str
)))
4518 ;;; Evaluation Result
4519 (defvar anything-c-source-evaluation-result
4520 '((name .
"Evaluation Result")
4523 (filtered-candidate-transformer .
(lambda (candidates source
)
4526 (with-current-buffer anything-current-buffer
4528 (eval (read anything-pattern
))))
4530 (action ("Copy result to kill-ring" .
(lambda (candidate)
4531 (with-current-buffer anything-buffer
4532 (let ((end (save-excursion
4533 (goto-char (point-max))
4534 (search-backward "\n")
4536 (kill-region (point) end
))))))))
4537 ;; (anything 'anything-c-source-evaluation-result)
4540 (defun anything-eval-expression (arg)
4541 "Preconfigured anything for `anything-c-source-evaluation-result'."
4543 (anything 'anything-c-source-evaluation-result
(when arg
(thing-at-point 'sexp
))
4544 nil nil nil
"*anything eval*"))
4547 (defun anything-eval-expression-with-eldoc ()
4548 "Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. "
4551 (let ((timer (run-with-idle-timer eldoc-idle-delay
4552 'repeat
'anything-eldoc-show-in-eval
)))
4554 (call-interactively 'anything-eval-expression
)
4555 (cancel-timer timer
)))
4556 (call-interactively 'anything-eval-expression
)))
4558 (defun anything-eldoc-show-in-eval ()
4559 "Return eldoc in a tooltip for current minibuffer input."
4560 (let* ((str-all (minibuffer-completion-contents))
4564 (goto-char (point-max))
4565 (unless (looking-back ")\\|\"") (forward-char -
1))
4566 (eldoc-current-symbol))))
4567 (doc (or (eldoc-get-var-docstring sym
)
4568 (eldoc-get-fnsym-args-string
4569 (car (eldoc-fnsym-in-current-sexp))))))
4570 (when doc
(tooltip-show doc
))))
4572 ;;; Calculation Result
4573 (defvar anything-c-source-calculation-result
4574 '((name .
"Calculation Result")
4576 (filtered-candidate-transformer .
(lambda (candidates source
)
4579 (calc-eval anything-pattern
)
4581 (action ("Copy result to kill-ring" . kill-new
))))
4582 ;; (anything 'anything-c-source-calculation-result)
4584 ;;; Google Suggestions
4585 (defvar anything-gg-sug-lgh-flag
0)
4586 (defun anything-c-google-suggest-fetch (input)
4587 "Fetch suggestions for INPUT from XML buffer.
4588 Return an alist with elements like (data . number_results)."
4589 (let ((request (concat anything-c-google-suggest-url
4590 (url-hexify-string input
))))
4593 with result-alist
= (xml-get-children
4594 (car (xml-parse-region (point-min) (point-max)))
4595 'CompleteSuggestion
)
4596 for i in result-alist
4597 for data
= (cdr (caadr (assoc 'suggestion i
)))
4598 for nqueries
= (cdr (caadr (assoc 'num_queries i
)))
4599 for ldata
= (length data
)
4601 (when (> ldata anything-gg-sug-lgh-flag
)
4602 (setq anything-gg-sug-lgh-flag ldata
))
4603 collect
(cons data nqueries
) into cont
4604 finally return cont
)))
4605 (if anything-google-suggest-use-curl-p
4607 (call-process "curl" nil t nil request
)
4609 (with-current-buffer
4610 (url-retrieve-synchronously request
)
4614 (defun anything-c-google-suggest-set-candidates ()
4615 "Set candidates with result and number of google results found."
4616 (let ((suggestions (anything-c-google-suggest-fetch anything-input
)))
4617 (setq suggestions
(loop for i in suggestions
4618 for interval
= (- anything-gg-sug-lgh-flag
(length (car i
)))
4619 for elm
= (concat (car i
)
4620 (make-string (+ 2 interval
) ?
)
4621 "(" (cdr i
) " results)")
4622 collect
(cons elm
(car i
))))
4623 (if (some (lambda (data) (equal (cdr data
) anything-input
)) suggestions
)
4625 ;; if there is no suggestion exactly matching the input then
4626 ;; prepend a Search on Google item to the list
4629 (list (cons (concat "Search for " "'" anything-input
"'" " on Google")
4630 anything-input
))))))
4633 (defun anything-c-google-suggest-action (candidate)
4634 "Default action to jump to a google suggested candidate."
4635 (anything-c-browse-url (concat anything-c-google-suggest-search-url
4636 (url-hexify-string candidate
))))
4639 (defvar anything-c-source-google-suggest
4640 '((name .
"Google Suggest")
4641 (candidates . anything-c-google-suggest-set-candidates
)
4642 (action .
(("Google Search" . anything-c-google-suggest-action
)))
4644 (requires-pattern .
3)
4647 ;; (anything 'anything-c-source-google-suggest)
4649 ;;; Yahoo suggestions
4651 (defun anything-c-yahoo-suggest-fetch (input)
4652 "Fetch Yahoo suggestions for INPUT from XML buffer.
4653 Return an alist with elements like (data . number_results)."
4654 (let ((request (concat anything-c-yahoo-suggest-url
4655 (url-hexify-string input
))))
4658 with result-alist
= (xml-get-children
4659 (car (xml-parse-region (point-min) (point-max)))
4661 for i in result-alist
4662 collect
(caddr i
))))
4663 (with-current-buffer
4664 (url-retrieve-synchronously request
)
4667 (defun anything-c-yahoo-suggest-set-candidates ()
4668 "Set candidates with Yahoo results found."
4669 (let ((suggestions (anything-c-yahoo-suggest-fetch anything-input
)))
4673 (list (cons (concat "Search for " "'" anything-input
"'" " on Yahoo")
4674 anything-input
))))))
4676 (defun anything-c-yahoo-suggest-action (candidate)
4677 "Default action to jump to a Yahoo suggested candidate."
4678 (anything-c-browse-url (concat anything-c-yahoo-suggest-search-url
4679 (url-hexify-string candidate
))))
4681 (defvar anything-c-source-yahoo-suggest
4682 '((name .
"Yahoo Suggest")
4683 (candidates . anything-c-yahoo-suggest-set-candidates
)
4684 (action .
(("Yahoo Search" . anything-c-yahoo-suggest-action
)))
4686 (requires-pattern .
3)
4689 ;; (anything 'anything-c-source-yahoo-suggest)
4692 ;;; Need external program surfraw.
4693 ;;; http://surfraw.alioth.debian.org/
4695 (require 'browse-url
)
4696 (defvar w3m-command nil
)
4697 (defvar anything-c-home-url
"http://www.google.fr"
4698 "*Default url to use as home url.")
4700 (defvar anything-browse-url-default-browser-alist
4701 `((,w3m-command . w3m-browse-url
)
4702 (,browse-url-firefox-program . browse-url-firefox
)
4703 (,browse-url-kde-program . browse-url-kde
)
4704 (,browse-url-gnome-moz-program . browse-url-gnome-moz
)
4705 (,browse-url-mozilla-program . browse-url-mozilla
)
4706 (,browse-url-galeon-program . browse-url-galeon
)
4707 (,browse-url-netscape-program . browse-url-netscape
)
4708 (,browse-url-mosaic-program . browse-url-mosaic
)
4709 (,browse-url-xterm-program . browse-url-text-xterm
))
4710 "*Alist of (executable . function) to try to find a suitable url browser.")
4712 (defun anything-browse-url-default-browser (url &rest args
)
4713 "Find a suitable browser and ask it to load URL."
4714 (let ((default-browser (loop
4715 for i in anything-browse-url-default-browser-alist
4716 when
(and (car i
) (executable-find (car i
))) return
(cdr i
))))
4718 (apply default-browser url args
)
4719 (error "No usable browser found"))))
4721 (defun* anything-c-browse-url
(&optional
(url anything-c-home-url
))
4722 "Default command to browse URL."
4723 (if browse-url-browser-function
4725 (anything-browse-url-default-browser url
)))
4727 (defun anything-c-build-elvi-list ()
4728 "Return list of all engines and descriptions handled by surfraw."
4731 (call-process "surfraw" nil t nil
4733 (split-string (buffer-string) "\n"))))
4736 (defun anything-surfraw (pattern engine
)
4737 "Preconfigured `anything' to search PATTERN with search ENGINE."
4738 (interactive (list (read-string "SearchFor: ")
4741 (anything-c-build-elvi-list)
4743 (let* ((engine-nodesc (car (split-string engine
)))
4744 (url (with-temp-buffer
4745 (apply 'call-process
"surfraw" nil t nil
4746 (list engine-nodesc
"-p" pattern
))
4747 (replace-regexp-in-string
4748 "\n" "" (buffer-string)))))
4749 (if (string= engine-nodesc
"W")
4750 (anything-c-browse-url)
4751 (anything-c-browse-url url
))))
4756 (defun anything-emms-stream-edit-bookmark (elm)
4757 "Change the information of current emms-stream bookmark from anything."
4759 (let* ((cur-buf anything-current-buffer
)
4760 (bookmark (assoc elm emms-stream-list
))
4761 (name (read-from-minibuffer "Description: "
4763 (url (read-from-minibuffer "URL: "
4765 (fd (read-from-minibuffer "Feed Descriptor: "
4766 (int-to-string (nth 2 bookmark
))))
4767 (type (read-from-minibuffer "Type (url, streamlist, or lastfm): "
4768 (format "%s" (car (last bookmark
))))))
4771 (when (re-search-forward (concat "^" name
) nil t
)
4773 (emms-stream-delete-bookmark)
4774 (emms-stream-add-bookmark name url
(string-to-number fd
) type
)
4775 (emms-stream-save-bookmarks-file)
4777 (switch-to-buffer cur-buf
)))))
4779 (defun anything-emms-stream-delete-bookmark (elm)
4780 "Delete an emms-stream bookmark from anything."
4782 (let* ((cur-buf anything-current-buffer
)
4783 (bookmark (assoc elm emms-stream-list
))
4784 (name (nth 0 bookmark
)))
4787 (when (re-search-forward (concat "^" name
) nil t
)
4789 (emms-stream-delete-bookmark)
4790 (emms-stream-save-bookmarks-file)
4792 (switch-to-buffer cur-buf
)))))
4794 (defvar anything-c-source-emms-streams
4795 '((name .
"Emms Streams")
4797 (emms-stream-init)))
4798 (candidates .
(lambda ()
4799 (mapcar 'car emms-stream-list
)))
4800 (action .
(("Play" .
(lambda (elm)
4801 (let* ((stream (assoc elm emms-stream-list
))
4802 (fn (intern (concat "emms-play-" (symbol-name (car (last stream
))))))
4803 (url (second stream
)))
4805 ("Delete" . anything-emms-stream-delete-bookmark
)
4806 ("Edit" . anything-emms-stream-edit-bookmark
)))
4807 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4808 ;; (anything 'anything-c-source-emms-streams)
4810 ;; Don't forget to set `emms-source-file-default-directory'
4811 (defvar anything-c-source-emms-dired
4812 '((name .
"Music Directory")
4813 (candidates .
(lambda ()
4814 (cddr (directory-files emms-source-file-default-directory
))))
4816 (("Play Directory" .
(lambda (item)
4817 (emms-play-directory
4820 emms-source-file-default-directory
))))
4821 ("Open dired in file's directory" .
(lambda (item)
4822 (anything-c-open-dired
4825 emms-source-file-default-directory
))))))
4826 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4827 ;; (anything 'anything-c-source-emms-dired)
4829 (defface anything-emms-playlist
4830 '((t (:foreground
"Springgreen4" :underline t
)))
4831 "*Face used for tracks in current emms playlist."
4834 (defun anything-c-emms-files-modifier (candidates)
4835 (let ((current-playlist (with-current-emms-playlist
4837 with cur-list
= (emms-playlist-tracks-in-region
4838 (point-min) (point-max))
4840 collect
(assoc-default 'info-file i
)))))
4841 (loop for i in candidates
4842 if
(member i current-playlist
)
4843 collect
(propertize i
'face
'anything-emms-playlist
) into lis
4844 else collect i into lis finally return lis
)))
4846 (defun anything-c-emms-play-current-playlist ()
4847 "Play current playlist."
4848 (with-current-emms-playlist
4849 (emms-playlist-first)
4850 (emms-playlist-mode-play-smart)))
4852 (defvar anything-c-source-emms-files
4853 '((name .
"Emms files")
4854 (candidates .
(lambda ()
4855 (loop for v being the hash-values in emms-cache-db
4856 for name
= (assoc-default 'name v
)
4857 unless
(string-match "^http:" name
) collect name
)))
4858 (candidate-transformer . anything-c-emms-files-modifier
)
4859 (action .
(("Play file" . emms-play-file
)
4860 ("Add to Playlist and play"
4861 .
(lambda (candidate)
4863 (dolist (i (anything-marked-candidates))
4864 (emms-add-playlist-file i
))
4865 (unless emms-player-playing-p
4866 (anything-c-emms-play-current-playlist))))))))
4868 ;; (anything 'anything-c-source-emms-files)
4870 ;;; Jabber Contacts (jabber.el)
4871 (defun anything-c-jabber-online-contacts ()
4872 "List online Jabber contacts."
4875 (dolist (item (jabber-concat-rosters) jids
)
4876 (when (get item
'connected
)
4877 (push (if (get item
'name
)
4878 (cons (get item
'name
) item
)
4879 (cons (symbol-name item
) item
)) jids
))))))
4881 (defvar anything-c-source-jabber-contacts
4882 '((name .
"Jabber Contacts")
4883 (init .
(lambda () (require 'jabber
)))
4884 (candidates .
(lambda () (mapcar 'car
(anything-c-jabber-online-contacts))))
4885 (action .
(lambda (x)
4887 (jabber-read-account)
4889 (cdr (assoc x
(anything-c-jabber-online-contacts)))))))))
4890 ;; (anything 'anything-c-source-jabber-contacts)
4894 (defvar anything-source-select-buffer
"*anything source select*")
4895 (defvar anything-c-source-call-source
4896 `((name .
"Call anything source")
4897 (candidate-number-limit)
4898 (candidates .
(lambda ()
4899 (loop for vname in
(all-completions "anything-c-source-" obarray
)
4900 for var
= (intern vname
)
4901 for name
= (ignore-errors (assoc-default 'name
(symbol-value var
)))
4902 if name collect
(cons (format "%s `%s'"
4903 name
(propertize vname
'face
'font-lock-variable-name-face
))
4905 (action .
(("Invoke anything with selected source" .
4907 (setq anything-candidate-number-limit
9999)
4908 (anything candidate nil nil nil nil
4909 anything-source-select-buffer
)))
4910 ("Describe variable" . describe-variable
)
4911 ("Find variable" . find-variable
)))
4912 (persistent-action . describe-variable
)
4913 (persistent-help .
"Show description of this source")))
4914 ;; (anything 'anything-c-source-call-source)
4917 (defun anything-call-source ()
4918 "Preconfigured `anything' to call anything source."
4920 (anything 'anything-c-source-call-source nil nil nil nil
4921 anything-source-select-buffer
))
4923 (defun anything-call-source-from-anything ()
4924 "Call anything source within `anything' session."
4926 (setq anything-input-idle-delay
0)
4927 (anything-set-sources '(anything-c-source-call-source)))
4929 ;;; Execute Preconfigured anything.
4930 (defvar anything-c-source-anything-commands
4931 '((name .
"Preconfigured Anything")
4932 (candidates . anything-c-anything-commands-candidates
)
4934 (candidate-number-limit)))
4935 ;; (anything 'anything-c-source-anything-commands)
4937 (defun anything-c-anything-commands-candidates ()
4938 (loop for
(cmd . desc
) in
(anything-c-list-preconfigured-anything)
4939 collect
(cons (if (where-is-internal cmd nil t
)
4940 (substitute-command-keys (format "M-x %s (\\[%s]) : %s" cmd cmd desc
))
4941 (substitute-command-keys (format "\\[%s] : %s" cmd desc
)))
4945 (defun anything-execute-anything-command ()
4946 "Preconfigured `anything' to execute preconfigured `anything'."
4948 (anything-other-buffer 'anything-c-source-anything-commands
4949 "*anything commands*"))
4953 (defun anything-c-occur-goto-line (candidate)
4954 "Goto line action for anything-c-source-occur."
4955 (anything-goto-line (string-to-number candidate
)))
4957 (defun anything-c-occur-persistent-action (candidate)
4958 "Persistent action for anything occur source."
4959 (anything-c-occur-goto-line candidate
)
4960 (anything-match-line-color-current-line))
4962 (defun anything-c-get-occur-candidates ()
4963 "Get `anything-c-source-occur' candidates."
4965 (let ((count (occur-engine
4967 (list anything-current-buffer
) (current-buffer)
4968 list-matching-lines-default-context-lines nil
4969 list-matching-lines-buffer-name-face
4970 nil list-matching-lines-face
4971 (not (eq occur-excluded-properties t
)))))
4973 (cdr (split-string (buffer-string) "\n" t
))))))
4975 (defvar anything-c-source-occur
4977 (candidates . anything-c-get-occur-candidates
)
4978 (persistent-action . anything-c-occur-persistent-action
)
4979 (persistent-help .
"Goto Line")
4980 (action . anything-c-occur-goto-line
)
4981 (requires-pattern .
1)
4984 ;; (anything 'anything-c-source-occur)
4987 (defun anything-occur ()
4988 "Preconfigured Anything for Occur source."
4990 (anything-other-buffer 'anything-c-source-occur
"*Anything Occur*"))
4992 ;; Do many actions for input
4993 (defvar anything-c-source-create
4997 (action-transformer . anything-create--actions
))
4998 "Do many create actions from `anything-pattern'.
4999 See also `anything-create--actions'.")
5000 ;; (anything 'anything-c-source-create)
5002 (defun anything-create-from-anything ()
5003 "Run `anything-create' from `anything' as a fallback."
5005 (anything-run-after-quit 'anything-create nil anything-pattern
))
5008 (defun anything-create (&optional string initial-input
)
5009 "Preconfigured `anything' to do many create actions from STRING.
5010 See also `anything-create--actions'."
5012 (setq string
(or string
(read-string "Create Anything: " initial-input
)))
5013 (anything '(((name .
"Anything Create")
5014 (header-name .
(lambda (_) (format "Action for \"%s\"" string
)))
5015 (candidates . anything-create--actions
)
5016 (candidate-number-limit)
5017 (action .
(lambda (func) (funcall func string
)))))))
5019 (defun anything-create--actions (&rest ignored
)
5020 "Default actions for `anything-create' / `anything-c-source-create'."
5022 (lambda (pair) (and (consp pair
) (functionp (cdr pair
))))
5023 (append anything-create--actions-private
5024 '(("find-file" . find-file
)
5025 ("find-file other window" . find-file-other-window
)
5026 ("New buffer" . switch-to-buffer
)
5027 ("New buffer other window" . switch-to-buffer-other-window
)
5028 ("Bookmark Set" . bookmark-set
)
5030 (lambda (x) (set-register (read-char "Register: ") x
)))
5031 ("Insert Linkd star" . linkd-insert-star
)
5032 ("Insert Linkd Tag" . linkd-insert-tag
)
5033 ("Insert Linkd Link" . linkd-insert-link
)
5034 ("Insert Linkd Lisp" . linkd-insert-lisp
)
5035 ("Insert Linkd Wiki" . linkd-insert-wiki
)
5036 ("Google Search" . google
)))))
5038 ;; Minibuffer History
5039 (defvar anything-c-source-minibuffer-history
5040 '((name .
"Minibuffer History")
5041 (header-name .
(lambda (name) (format "%s (%s)" name minibuffer-history-variable
)))
5042 (candidates .
(lambda () (let ((history (symbol-value minibuffer-history-variable
)))
5043 (if (consp (car history
))
5044 (mapcar 'prin1-to-string history
)
5048 ;; (anything 'anything-c-source-minibuffer-history)
5051 (defvar anything-c-source-elscreen
5052 '((name .
"Elscreen")
5053 (candidates .
(lambda ()
5054 (if (cdr (elscreen-get-screen-to-name-alist))
5056 (loop for sname in
(elscreen-get-screen-to-name-alist)
5057 append
(list (format "[%d] %s" (car sname
) (cdr sname
))) into lst
5058 finally
(return lst
))
5059 #'(lambda (a b
) (compare-strings a nil nil b nil nil
))))))
5060 (action .
(("Change Screen".
5062 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))))
5065 (dolist (i (anything-marked-candidates))
5066 (elscreen-goto (- (aref i
1) (aref "0" 0)))
5070 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))
5071 (elscreen-kill-others)))))))
5072 ;; (anything 'anything-c-source-elscreen)
5077 (defvar anything-c-top-command
"COLUMNS=%s top -b -n 1"
5078 "Top command (batch mode). %s is replaced with `frame-width'.")
5079 (defvar anything-c-source-top
5080 '((name .
"Top (Press C-c C-u to refresh)")
5081 (init . anything-c-top-init
)
5082 (candidates-in-buffer)
5083 (display-to-real . anything-c-top-display-to-real
)
5084 (update . anything-c-top-update
)
5086 ("kill (TERM)" .
(lambda (pid) (anything-c-top-sh (format "kill -TERM %s" pid
))))
5087 ("kill (KILL)" .
(lambda (pid) (anything-c-top-sh (format "kill -KILL %s" pid
))))
5088 ("Copy PID" .
(lambda (pid) (kill-new pid
))))))
5089 ;; (anything 'anything-c-source-top)
5091 (defun anything-c-top-sh (cmd)
5092 (message "Executed %s\n%s" cmd
(shell-command-to-string cmd
)))
5094 (defun anything-c-top-init ()
5095 (with-current-buffer (anything-candidate-buffer 'global
)
5096 (call-process-shell-command
5097 (format anything-c-top-command
5098 (- (frame-width) (if anything-enable-digit-shortcuts
4 0)))
5099 nil
(current-buffer))))
5101 (defun anything-c-top-display-to-real (line)
5102 (car (split-string line
)))
5104 (defun anything-c-top-update ()
5105 (let ((anything-source-name (assoc-default 'name anything-c-source-top
))) ;UGLY HACK
5106 (anything-c-top-init)))
5109 (defun anything-top ()
5110 "Preconfigured `anything' for top command."
5112 (let ((anything-samewindow t
)
5113 (anything-enable-shortcuts)
5114 (anything-display-function 'anything-default-display-buffer
)
5115 (anything-candidate-number-limit 9999))
5116 (save-window-excursion
5117 (delete-other-windows)
5118 (anything-other-buffer 'anything-c-source-top
"*anything top*"))))
5121 (defvar anything-c-source-absolute-time-timers
5122 '((name .
"Absolute Time Timers")
5123 (candidates . timer-list
)
5125 ;; (anything 'anything-c-source-absolute-time-timers)
5127 (defvar anything-c-source-idle-time-timers
5128 '((name .
"Idle Time Timers")
5129 (candidates . timer-idle-list
)
5131 ;; (anything 'anything-c-source-idle-time-timers)
5133 (defun anything-c-timer-real-to-display (timer)
5134 (destructuring-bind (triggered t1 t2 t3 repeat-delay func args idle-delay
)
5135 (append timer nil
) ;use `append' to convert vector->list
5136 (format "%s repeat=%5S %s(%s)"
5137 (let ((time (list t1 t2 t3
)))
5139 (format-time-string "idle-for=%5s" time
)
5140 (format-time-string "%m/%d %T" time
)))
5143 (mapconcat 'prin1-to-string args
" "))))
5145 ;;; X RandR resolution change
5146 ;;; FIXME I do not care multi-display.
5147 (defvar anything-c-xrandr-output
"VGA")
5148 (defvar anything-c-xrandr-screen
"0")
5149 (defvar anything-c-source-xrandr-change-resolution
5150 '((name .
"Change Resolution")
5154 (call-process "xrandr" nil
(current-buffer) nil
5155 "--screen" anything-c-xrandr-screen
"-q")
5157 (loop while
(re-search-forward " \\([0-9]+x[0-9]+\\)" nil t
)
5158 collect
(match-string 1)))))
5160 ("Change Resolution" .
(lambda (mode)
5161 (call-process "xrandr" nil nil nil
5162 "--screen" anything-c-xrandr-screen
5163 "--output" anything-c-xrandr-output
5165 ;; (anything 'anything-c-source-xrandr-change-resolution)
5168 (defun anything-c-persistent-xfont-action (elm)
5169 "Show current font temporarily"
5170 (let ((current-font (cdr (assoc 'font
(frame-parameters))))
5173 (progn (set-frame-font default-font
'keep-size
) (sit-for 2))
5174 (set-frame-font current-font
))))
5176 (defvar anything-c-xfonts-cache nil
)
5177 (defvar anything-c-source-xfonts
5178 '((name .
"X Fonts")
5180 (unless anything-c-xfonts-cache
5181 (setq anything-c-xfonts-cache
5182 (x-list-fonts "*")))))
5183 (candidates . anything-c-xfonts-cache
)
5184 (action .
(("Copy to kill ring" .
(lambda (elm)
5186 ("Set Font" .
(lambda (elm)
5188 (set-frame-font elm
'keep-size
)
5189 (message "New font have been copied to kill ring")))))
5190 (persistent-action . anything-c-persistent-xfont-action
)
5191 (persistent-help .
"Switch to this font temporarily")))
5194 (defun anything-select-xfont ()
5195 "Preconfigured `anything' to select Xfont."
5197 (anything-other-buffer 'anything-c-source-xfonts
"*anything select* xfont"))
5199 ;; (anything 'anything-c-source-xfonts)
5201 ;;; Source for Debian/Ubuntu users
5202 (defvar anything-c-source-apt
5204 (init . anything-c-apt-init
)
5205 (candidates-in-buffer)
5206 (candidate-transformer anything-c-apt-candidate-transformer
)
5207 (display-to-real . anything-c-apt-display-to-real
)
5208 (candidate-number-limit .
9999)
5210 ("Show package description" . anything-c-apt-cache-show
)
5211 ("Install package" . anything-c-apt-install
)
5212 ("Remove package" . anything-c-apt-uninstall
)
5213 ("Purge package" . anything-c-apt-purge
))
5214 (persistent-action . anything-c-apt-persistent-action
)
5215 (persistent-help .
"Show - C-u Refresh")))
5216 ;; (anything 'anything-c-source-apt)
5218 (defvar anything-c-apt-query
"emacs")
5219 (defvar anything-c-apt-search-command
"apt-cache search '%s'")
5220 (defvar anything-c-apt-show-command
"apt-cache show '%s'")
5221 (defvar anything-c-apt-installed-packages nil
)
5223 (defface anything-apt-installed
5224 '((t (:foreground
"green")))
5225 "*Face used for apt installed candidates."
5228 (defun anything-c-apt-refresh ()
5229 "Refresh installed candidates list."
5230 (setq anything-c-apt-installed-packages nil
)
5231 (anything-force-update))
5233 (defun anything-c-apt-persistent-action (candidate)
5234 "Persistent action for APT source."
5235 (if current-prefix-arg
5236 (anything-c-apt-refresh)
5237 (anything-c-apt-cache-show candidate
)))
5240 (defun anything-apt (query)
5241 "Preconfigured `anything' : frontend of APT package manager."
5242 (interactive "sAPT search: ")
5243 (let ((anything-c-apt-query query
))
5244 (anything 'anything-c-source-apt
)))
5246 (defun anything-c-apt-candidate-transformer (candidates)
5247 "Show installed candidates in a different color."
5250 for cand in candidates
5251 for name
= (anything-c-apt-display-to-real cand
)
5252 if
(member name anything-c-apt-installed-packages
)
5253 collect
(propertize cand
'face
'anything-apt-installed
) into all
5254 else collect cand into all finally return all
))
5256 (defun anything-c-apt-init ()
5257 "Initialize list of debian packages."
5258 (unless anything-c-apt-installed-packages
5259 (message "Updating installed candidate list...")
5260 (setq anything-c-apt-installed-packages
5262 (call-process-shell-command "dpkg --get-selections"
5263 nil
(current-buffer))
5264 (loop for i in
(split-string (buffer-string) "\n" t
)
5265 collect
(car (split-string i
))))))
5266 (with-current-buffer
5267 (anything-candidate-buffer
5268 (get-buffer-create (format "*anything-apt:%s*" anything-c-apt-query
)))
5270 (call-process-shell-command
5271 (format anything-c-apt-search-command anything-c-apt-query
)
5272 nil
(current-buffer)))
5273 (message "Updating installed candidate list...done"))
5275 (defun anything-c-apt-display-to-real (line)
5276 "Return only name of a debian package.
5277 LINE is displayed like:
5278 package name - description."
5279 (car (split-string line
" - ")))
5282 (defun anything-c-shell-command-if-needed (command)
5283 (interactive "sShell command: ")
5284 (if (get-buffer command
) ; if the buffer already exists
5285 (switch-to-buffer command
) ; then just switch to it
5286 (switch-to-buffer command
) ; otherwise create it
5287 (insert (shell-command-to-string command
))))
5289 (defun anything-c-apt-cache-show (package)
5290 (anything-c-shell-command-if-needed (format anything-c-apt-show-command package
)))
5292 (defun anything-c-apt-install (package)
5293 (anything-c-apt-install1 package
:action
'install
))
5295 (defun anything-c-apt-uninstall (package)
5296 (anything-c-apt-install1 package
:action
'uninstall
))
5298 (defun anything-c-apt-purge (package)
5299 (anything-c-apt-install1 package
:action
'purge
))
5301 (defun* anything-c-apt-install1
(candidate &key action
)
5302 (ansi-term (getenv "SHELL") "anything apt")
5304 (let ((command (case action
5305 ('install
"sudo apt-get install '%s'")
5306 ('uninstall
"sudo apt-get remove '%s'")
5307 ('purge
"sudo apt-get purge '%s'")
5308 (t (error "Unknow action"))))
5310 (goto-char (point-max))
5311 (insert (format command candidate
))
5313 (if (y-or-n-p (format "%s package" (symbol-name action
)))
5315 (setq anything-c-external-commands-list nil
)
5316 (setq anything-c-apt-installed-packages nil
)
5317 (term-char-mode) (term-send-input))
5318 (delete-region beg end
) (term-send-eof) (kill-buffer))))
5320 ;; (anything-c-apt-install "jed")
5322 ;;; Sources for gentoo users
5323 (defvar anything-c-gentoo-use-flags nil
)
5324 (defvar anything-c-gentoo-buffer
"*anything-gentoo-output*")
5325 (defvar anything-c-cache-gentoo nil
)
5326 (defvar anything-c-cache-world nil
)
5327 (defvar anything-c-source-gentoo
5328 '((name .
"Portage sources")
5330 (get-buffer-create anything-c-gentoo-buffer
)
5331 (unless anything-c-cache-gentoo
5332 (anything-c-gentoo-setup-cache))
5333 (unless anything-c-cache-world
5334 (setq anything-c-cache-world
(anything-c-gentoo-get-world)))
5335 (anything-c-gentoo-init-list)))
5336 (candidates-in-buffer)
5338 (candidate-transformer anything-c-highlight-world
)
5339 (action .
(("Show package" .
(lambda (elm)
5340 (anything-c-gentoo-eshell-action elm
"eix")))
5341 ("Show history" .
(lambda (elm)
5342 (if (member elm anything-c-cache-world
)
5343 (anything-c-gentoo-eshell-action elm
"genlop -qe")
5344 (message "No infos on packages not yet installed"))))
5345 ("Copy in kill-ring" . kill-new
)
5346 ("insert at point" . insert
)
5347 ("Browse HomePage" .
(lambda (elm)
5348 (let ((urls (anything-c-gentoo-get-url elm
)))
5349 (browse-url (anything-comp-read "Url: " urls
:must-match t
)))))
5350 ("Show extra infos" .
(lambda (elm)
5351 (if (member elm anything-c-cache-world
)
5352 (anything-c-gentoo-eshell-action elm
"genlop -qi")
5353 (message "No infos on packages not yet installed"))))
5354 ("Show use flags" .
(lambda (elm)
5355 (anything-c-gentoo-default-action elm
"equery" "-C" "u")
5356 (font-lock-add-keywords nil
'(("^\+.*" . font-lock-variable-name-face
)))
5357 (font-lock-mode 1)))
5358 ("Run emerge pretend" .
(lambda (elm)
5359 (anything-c-gentoo-eshell-action elm
"emerge -p")))
5360 ("Emerge" .
(lambda (elm)
5361 (anything-gentoo-install elm
:action
'install
)))
5362 ("Unmerge" .
(lambda (elm)
5363 (anything-gentoo-install elm
:action
'uninstall
)))
5364 ("Show dependencies" .
(lambda (elm)
5365 (anything-c-gentoo-default-action elm
"equery" "-C" "d")))
5366 ("Show related files" .
(lambda (elm)
5367 (anything-c-gentoo-default-action elm
"equery" "files")))
5368 ("Refresh" .
(lambda (elm)
5369 (anything-c-gentoo-setup-cache)
5370 (setq anything-c-cache-world
(anything-c-gentoo-get-world))))))))
5372 ;; (anything 'anything-c-source-gentoo)
5374 (defun* anything-gentoo-install
(candidate &key action
)
5375 (setq anything-c-external-commands-list nil
)
5376 (ansi-term (getenv "SHELL") "anything gentoo")
5378 (let ((command (case action
5379 ('install
"sudo emerge -av ")
5380 ('uninstall
"sudo emerge -avC ")
5381 (t (error "Unknow action"))))
5382 (elms (mapconcat 'identity
(anything-marked-candidates) " "))
5384 (goto-char (point-max))
5385 (insert (concat command elms
))
5387 (term-char-mode) (term-send-input)))
5389 (defun anything-c-gentoo-default-action (elm command
&rest args
)
5390 "Gentoo default action that use `anything-c-gentoo-buffer'."
5391 (if (member elm anything-c-cache-world
)
5393 (switch-to-buffer anything-c-gentoo-buffer
)
5395 (let ((com-list (append args
(list elm
))))
5396 (apply #'call-process command nil t nil
5398 (message "No infos on packages not yet installed")))
5400 (defvar anything-c-source-use-flags
5401 '((name .
"Use Flags")
5403 (unless anything-c-gentoo-use-flags
5404 (anything-c-gentoo-setup-use-flags-cache))
5405 (anything-c-gentoo-get-use)))
5406 (candidates-in-buffer)
5408 (candidate-transformer anything-c-highlight-local-use
)
5409 (action .
(("Description"
5411 (switch-to-buffer anything-c-gentoo-buffer
)
5413 (apply #'call-process
"euse" nil t nil
5416 (font-lock-add-keywords nil
`((,elm . font-lock-variable-name-face
)))
5417 (font-lock-mode 1)))
5420 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -E")))
5423 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -D")))
5426 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -P")))
5427 ("Show which dep use this flag"
5429 (switch-to-buffer anything-c-gentoo-buffer
)
5431 (apply #'call-process
"equery" nil t nil
5437 ;; (anything 'anything-c-source-use-flags)
5439 (defun anything-c-gentoo-init-list ()
5440 "Initialize buffer with all packages in Portage."
5441 (let* ((portage-buf (get-buffer-create "*anything-gentoo*"))
5442 (buf (anything-candidate-buffer 'portage-buf
)))
5443 (with-current-buffer buf
5444 (dolist (i anything-c-cache-gentoo
)
5445 (insert (concat i
"\n"))))))
5447 (defun anything-c-gentoo-setup-cache ()
5448 "Set up `anything-c-cache-gentoo'"
5449 (setq anything-c-cache-gentoo
5450 (split-string (with-temp-buffer
5451 (call-process "eix" nil t nil
5455 (defun anything-c-gentoo-eshell-action (elm command
)
5456 (when (get-buffer "*EShell Command Output*")
5457 (kill-buffer "*EShell Command Output*"))
5458 (message "Wait searching...")
5459 (let ((buf-fname (buffer-file-name anything-current-buffer
)))
5460 (if (and buf-fname
(string-match tramp-file-name-regexp buf-fname
))
5462 (save-window-excursion
5463 (pop-to-buffer "*scratch*")
5464 (eshell-command (format "%s %s" command elm
)))
5465 (pop-to-buffer "*EShell Command Output*"))
5466 (eshell-command (format "%s %s" command elm
)))))
5468 (defun anything-c-gentoo-get-use ()
5469 "Initialize buffer with all use flags."
5470 (let* ((use-buf (get-buffer-create "*anything-gentoo-use*"))
5471 (buf (anything-candidate-buffer 'use-buf
)))
5472 (with-current-buffer buf
5473 (dolist (i anything-c-gentoo-use-flags
)
5474 (insert (concat i
"\n"))))))
5477 (defun anything-c-gentoo-setup-use-flags-cache ()
5478 "Setup `anything-c-gentoo-use-flags'"
5479 (setq anything-c-gentoo-use-flags
5480 (split-string (with-temp-buffer
5481 (call-process "eix" nil t nil
5482 "--print-all-useflags")
5485 (defun anything-c-gentoo-get-url (elm)
5486 "Return a list of urls from eix output."
5488 with url-list
= (split-string
5490 (call-process "eix" nil t nil
5491 elm
"--format" "<homepage>\n")
5495 when
(and (string-match "^http://.*" i
)
5496 (not (member i all
)))
5498 finally return all
))
5500 (defun anything-c-gentoo-get-world ()
5501 "Return list of all installed package on your system."
5502 (split-string (with-temp-buffer
5503 (call-process "qlist" nil t nil
5507 (defun anything-c-gentoo-get-local-use ()
5508 (split-string (with-temp-buffer
5509 (call-process "portageq" nil t nil
5514 (defface anything-gentoo-match-face
'((t (:foreground
"red")))
5515 "Face for anything-gentoo installed packages."
5516 :group
'traverse-faces
)
5518 (defun anything-c-highlight-world (eix)
5519 "Highlight all installed package."
5521 if
(member i anything-c-cache-world
)
5522 collect
(propertize i
'face
'anything-gentoo-match-face
)
5526 (defun anything-c-highlight-local-use (use-flags)
5527 (let ((local-uses (anything-c-gentoo-get-local-use)))
5528 (loop for i in use-flags
5529 if
(member i local-uses
)
5530 collect
(propertize i
'face
'anything-gentoo-match-face
)
5534 (defvar anything-c-source-emacs-process
5535 '((name .
"Emacs Process")
5536 (candidates .
(lambda () (mapcar #'process-name
(process-list))))
5537 (action ("Kill Process" .
(lambda (elm) (delete-process (get-process elm
)))))))
5539 ;; (anything 'anything-c-source-emacs-process)
5541 ;; Run Externals commands within Emacs
5542 (defmacro* anything-comp-hash-get-items
(hash-table &key test
)
5543 "Get the list of all keys/values of hash-table."
5544 `(let ((li-items ()))
5545 (maphash #'(lambda (x y
)
5547 (when (funcall ,test y
)
5548 (push (list x y
) li-items
))
5549 (push (list x y
) li-items
)))
5553 (defun anything-comp-read-get-candidates (collection &optional test
)
5554 "Convert collection to list.
5555 If collection is an `obarray', a test is maybe needed, otherwise
5556 the list would be incomplete.
5558 (cond ((and (listp collection
) test
)
5559 (loop for i in collection when
(funcall test i
) collect i
))
5560 ((and (eq collection obarray
) test
)
5561 (loop for s being the symbols of collection
5562 when
(funcall test s
) collect s
))
5563 ((and (vectorp collection
) test
)
5564 (loop for i across collection when
(funcall test i
) collect i
))
5565 ((vectorp collection
)
5566 (loop for i across collection collect i
))
5567 ((and (hash-table-p collection
) test
)
5568 (anything-comp-hash-get-items collection
:test test
))
5569 ((hash-table-p collection
)
5570 (anything-comp-hash-get-items collection
))
5573 (defun* anything-comp-read
(prompt collection
&key test initial-input
5574 (buffer "*Anything Completions*") must-match
5575 (requires-pattern 0))
5576 "Anything `completing-read' emulation.
5577 Collection can be a list, vector, obarray or hash-table."
5578 (when (get-buffer anything-action-buffer
)
5579 (kill-buffer anything-action-buffer
))
5581 `((name .
"Completions")
5584 (let ((cands (anything-comp-read-get-candidates collection test
)))
5585 (if (or must-match
(string= anything-pattern
""))
5586 cands
(append (list anything-pattern
) cands
)))))
5587 (requires-pattern .
,requires-pattern
)
5589 (action .
(("candidate" .
,'identity
))))
5590 initial-input prompt
'noresume nil buffer
)
5593 (defun anything-c-get-pid-from-process-name (process-name)
5594 "Get pid from running process PROCESS-NAME."
5595 (loop with process-list
= (list-system-processes)
5596 for pid in process-list
5597 for process
= (assoc-default 'comm
(process-attributes pid
))
5598 when
(and process
(string-match process-name process
))
5602 (defun anything-run-or-raise (exe &optional file
)
5603 "Generic command that run asynchronously EXE.
5604 If EXE is already running just jump to his window if `anything-raise-command'
5606 When FILE argument is provided run EXE with FILE.
5607 In this case EXE must be provided as \"EXE %s\"."
5608 (let ((real-com (car (split-string (replace-regexp-in-string " %s" "" exe
)))))
5609 (if (or (get-process real-com
)
5610 (anything-c-get-pid-from-process-name real-com
))
5611 (if anything-raise-command
5612 (shell-command (format anything-raise-command real-com
))
5613 (error "Error: %s is already running" real-com
))
5614 (when (member real-com anything-c-external-commands-list
)
5615 (message "Starting %s..." real-com
)
5617 (start-process-shell-command real-com nil
(format exe file
))
5618 (start-process-shell-command real-com nil real-com
))
5619 (set-process-sentinel
5620 (get-process real-com
)
5621 #'(lambda (process event
)
5622 (when (string= event
"finished\n")
5623 (when anything-raise-command
5624 (shell-command (format anything-raise-command
"emacs")))
5625 (message "%s process...Finished." process
))))
5626 (setq anything-c-external-commands-list
5627 (push (pop (nthcdr (anything-c-position
5628 real-com anything-c-external-commands-list
5630 anything-c-external-commands-list
))
5631 anything-c-external-commands-list
))))))
5634 (defun anything-c-run-external-command (program)
5635 "Preconfigured `anything' to run External PROGRAM asyncronously from Emacs.
5636 If program is already running exit with error.
5637 You can set your own list of commands with
5638 `anything-c-external-commands-list'."
5642 (anything-c-external-commands-list-1 'sort
)
5644 (anything-run-or-raise program
))
5646 (defsubst* anything-c-position
(item seq
&key
(test 'eq
))
5647 "A simple and faster replacement of CL `position'."
5648 (loop for i in seq for index from
0
5649 when
(funcall test i item
) return index
))
5651 (defvar anything-c-source-ratpoison-commands
5652 '((name .
"Ratpoison Commands")
5653 (init . anything-c-ratpoison-commands-init
)
5654 (candidates-in-buffer)
5655 (action ("Execute the command" . anything-c-ratpoison-commands-execute
))
5656 (display-to-real . anything-c-ratpoison-commands-display-to-real
)
5657 (candidate-number-limit)))
5658 ;; (anything 'anything-c-source-ratpoison-commands)
5660 (defun anything-c-ratpoison-commands-init ()
5661 (unless (anything-candidate-buffer)
5662 (with-current-buffer (anything-candidate-buffer 'global
)
5663 ;; with ratpoison prefix key
5665 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help"))
5666 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5667 (replace-match "<ratpoison> \\1: \\2"))
5668 (goto-char (point-max))
5671 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help top"))
5672 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5673 (replace-match "\\1: \\2")))))
5675 (defun anything-c-ratpoison-commands-display-to-real (display)
5676 (and (string-match ": " display
)
5677 (substring display
(match-end 0))))
5679 (defun anything-c-ratpoison-commands-execute (candidate)
5680 (call-process "ratpoison" nil nil nil
"-ic" candidate
))
5683 (defun anything-ratpoison-commands ()
5684 "Preconfigured `anything' to execute ratpoison commands."
5686 (anything-other-buffer 'anything-c-source-ratpoison-commands
5687 "*anything ratpoison commands*"))
5689 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5691 (defvar anything-c-external-commands-list nil
5692 "A list of all external commands the user can execute. If this
5693 variable is not set by the user, it will be calculated
5696 (defun anything-c-external-commands-list-1 (&optional sort
)
5697 "Returns a list of all external commands the user can execute.
5699 If `anything-c-external-commands-list' is non-nil it will
5700 return its contents. Else it calculates all external commands
5701 and sets `anything-c-external-commands-list'.
5703 The code is ripped out of `eshell-complete-commands-list'."
5704 (if anything-c-external-commands-list
5705 anything-c-external-commands-list
5706 (setq anything-c-external-commands-list
5707 (let* ((paths (split-string (getenv "PATH") path-separator
))
5708 (cwd (file-name-as-directory
5709 (expand-file-name default-directory
)))
5710 (path "") (comps-in-path ())
5711 (file "") (filepath "") (completions ()))
5712 ;; Go thru each path in the search path, finding completions.
5714 (setq path
(file-name-as-directory
5715 (expand-file-name (or (car paths
) ".")))
5717 (and (file-accessible-directory-p path
)
5718 (file-name-all-completions "" path
)))
5719 ;; Go thru each completion found, to see whether it should be
5720 ;; used, e.g. see if it's executable.
5721 (while comps-in-path
5722 (setq file
(car comps-in-path
)
5723 filepath
(concat path file
))
5724 (if (and (not (member file completions
))
5725 (or (string-equal path cwd
)
5726 (not (file-directory-p filepath
)))
5727 (file-executable-p filepath
))
5728 (setq completions
(cons file completions
)))
5729 (setq comps-in-path
(cdr comps-in-path
)))
5730 (setq paths
(cdr paths
)))
5732 (sort completions
#'(lambda (x y
) (string< x y
)))
5735 (defun anything-c-file-buffers (filename)
5736 "Returns a list of buffer names corresponding to FILENAME."
5737 (let ((name (expand-file-name filename
))
5739 (dolist (buf (buffer-list) buf-list
)
5740 (let ((bfn (buffer-file-name buf
)))
5741 (when (and bfn
(string= name bfn
))
5742 (push (buffer-name buf
) buf-list
))))))
5744 (defun anything-c-delete-file (file)
5745 "Delete the given file after querying the user.
5746 Ask to kill buffers associated with that file, too."
5747 (let ((buffers (anything-c-file-buffers file
)))
5748 (dired-delete-file file
'dired-recursive-deletes
)
5750 (dolist (buf buffers
)
5751 (when (y-or-n-p (format "Kill buffer %s, too? " buf
))
5752 (kill-buffer buf
))))))
5754 (defun anything-get-mailcap-for-file (filename)
5755 "Get the command to use for FILENAME from mailcap files.
5756 The command is like <command %s> and is meant to use with `format'."
5757 (mailcap-parse-mailcaps)
5758 (let* ((ext (file-name-extension filename
))
5759 (mime (when ext
(mailcap-extension-to-mime ext
))))
5760 (when mime
(mailcap-mime-info mime
))))
5762 (defun anything-c-open-file-externally (file)
5763 "Open FILE with an external tool found in .mailcap file.
5764 If not found or a prefix arg is given query the user which tool to use."
5765 (let* ((fname (expand-file-name file
))
5766 (collection (anything-c-external-commands-list-1 'sort
))
5767 (def-prog (anything-get-mailcap-for-file fname
))
5768 (program (or (unless (or anything-current-prefix-arg
5774 collection
:must-match t
)
5776 (anything-run-or-raise program file
)))
5779 (defun w32-shell-execute-open-file (file)
5780 (interactive "fOpen file:")
5782 (w32-shell-execute "open" (replace-regexp-in-string ;for UNC paths
5784 (replace-regexp-in-string ; strip cygdrive paths
5785 "/cygdrive/\\(.\\)" "\\1:"
5786 file nil nil
) nil t
))))
5788 (defun anything-c-open-file-with-default-tool (file)
5789 "Open FILE with the default tool on this platform."
5790 (if (eq system-type
'windows-nt
)
5791 (w32-shell-execute-open-file file
)
5792 (start-process "anything-c-open-file-with-default-tool"
5794 (cond ((eq system-type
'gnu
/linux
)
5796 ((or (eq system-type
'darwin
) ;; Mac OS X
5797 (eq system-type
'macos
)) ;; Mac OS 9
5801 (defun anything-c-open-dired (file)
5802 "Opens a dired buffer in FILE's directory. If FILE is a
5803 directory, open this directory."
5804 (if (file-directory-p file
)
5806 (dired (file-name-directory file
))
5807 (dired-goto-file file
)))
5809 (defun anything-c-display-to-real-line (candidate)
5810 (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate
)
5811 (list (string-to-number (match-string 1 candidate
)) (match-string 2 candidate
))
5812 (error "Line number not found")))
5814 (defun anything-c-action-line-goto (lineno-and-content)
5815 (apply #'anything-goto-file-line
(anything-interpret-value (anything-attr 'target-file
))
5816 (append lineno-and-content
5817 (list (if (and (anything-attr-defined 'target-file
)
5818 (not anything-in-persistent-action
))
5819 'find-file-other-window
5822 (defun* anything-c-action-file-line-goto
(file-line-content &optional
(find-file-function #'find-file
))
5823 (apply #'anything-goto-file-line
5824 (if (stringp file-line-content
)
5825 ;; Case: filtered-candidate-transformer is skipped
5826 (cdr (anything-c-filtered-candidate-transformer-file-line-1 file-line-content
))
5827 file-line-content
)))
5830 (defun anything-c-filtered-candidate-transformer-file-line (candidates source
)
5831 (delq nil
(mapcar 'anything-c-filtered-candidate-transformer-file-line-1 candidates
)))
5833 (defun anything-c-filtered-candidate-transformer-file-line-1 (candidate)
5834 (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate
)
5835 (let ((filename (match-string 1 candidate
))
5836 (lineno (match-string 2 candidate
))
5837 (content (match-string 3 candidate
)))
5838 (cons (format "%s:%s\n %s"
5839 (propertize filename
'face compilation-info-face
)
5840 (propertize lineno
'face compilation-line-face
)
5842 (list (expand-file-name
5844 (or (anything-interpret-value (anything-attr 'default-directory
))
5845 (and (anything-candidate-buffer)
5847 'default-directory
(anything-candidate-buffer)))))
5848 (string-to-number lineno
) content
)))))
5850 (defun* anything-goto-file-line
(file lineno content
&optional
(find-file-function #'find-file
))
5851 (anything-aif (anything-attr 'before-jump-hook
)
5853 (when file
(funcall find-file-function file
))
5854 (if (anything-attr-defined 'adjust
)
5855 (anything-c-goto-line-with-adjustment lineno content
)
5856 (anything-goto-line lineno
))
5857 (unless (anything-attr-defined 'recenter
)
5858 (set-window-start (get-buffer-window anything-current-buffer
) (point)))
5859 (anything-aif (anything-attr 'after-jump-hook
)
5861 (when anything-in-persistent-action
5862 (anything-match-line-color-current-line)))
5864 (defun anything-find-file-as-root (candidate)
5865 (find-file (concat "/" anything-su-or-sudo
"::" (expand-file-name candidate
))))
5867 (defun anything-find-many-files (ignore)
5868 (mapc 'find-file
(anything-marked-candidates)))
5870 ;; borrowed from etags.el
5871 ;; (anything-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el")
5872 (defun anything-c-goto-line-with-adjustment (line line-content
)
5875 ;; This constant is 1/2 the initial search window.
5876 ;; There is no sense in making it too small,
5877 ;; since just going around the loop once probably
5878 ;; costs about as much as searching 2000 chars.
5881 pat
(concat (if (eq selective-display t
)
5882 "\\(^\\|\^m\\) *" "^ *") ;allow indent
5883 (regexp-quote line-content
)))
5884 ;; If no char pos was given, try the given line number.
5885 (setq startpos
(progn (anything-goto-line line
) (point)))
5886 (or startpos
(setq startpos
(point-min)))
5887 ;; First see if the tag is right at the specified location.
5888 (goto-char startpos
)
5889 (setq found
(looking-at pat
))
5890 (while (and (not found
)
5892 (goto-char (- startpos offset
))
5895 (re-search-forward pat
(+ startpos offset
) t
)
5896 offset
(* 3 offset
))) ; expand search window
5898 (re-search-forward pat nil t
)
5899 (error "not found")))
5900 ;; Position point at the right place
5901 ;; if the search string matched an extra Ctrl-m at the beginning.
5902 (and (eq selective-display t
)
5905 (beginning-of-line))
5907 (anything-document-attribute 'default-directory
"type . file-line"
5908 "`default-directory' to interpret file.")
5909 (anything-document-attribute 'before-jump-hook
"type . file-line / line"
5910 "Function to call before jumping to the target location.")
5911 (anything-document-attribute 'after-jump-hook
"type . file-line / line"
5912 "Function to call after jumping to the target location.")
5913 (anything-document-attribute 'adjust
"type . file-line"
5914 "Search around line matching line contents.")
5915 (anything-document-attribute 'recenter
"type . file-line / line"
5916 "`recenter' after jumping.")
5917 (anything-document-attribute 'target-file
"type . line"
5918 "Goto line of target-file.")
5921 (defun anything-c-call-interactively (cmd-or-name)
5922 "Execute CMD-OR-NAME as Emacs command.
5923 It is added to `extended-command-history'.
5924 `anything-current-prefix-arg' is used as the command's prefix argument."
5925 (setq extended-command-history
5926 (cons (anything-c-stringify cmd-or-name
)
5927 (delete (anything-c-stringify cmd-or-name
) extended-command-history
)))
5928 (let ((current-prefix-arg anything-current-prefix-arg
)
5929 (cmd (anything-c-symbolify cmd-or-name
)))
5930 (if (stringp (symbol-function cmd
))
5931 (execute-kbd-macro (symbol-function cmd
))
5932 (setq this-command cmd
)
5933 (call-interactively cmd
))))
5936 (defun anything-c-set-variable (var)
5937 "Set value to VAR interactively."
5939 (let ((sym (anything-c-symbolify var
)))
5940 (set sym
(eval-minibuffer (format "Set %s: " var
)
5941 (prin1-to-string (symbol-value sym
))))))
5943 ;; (anything-c-set-variable 'hh)
5945 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Persistent Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5946 (defvar anything-match-line-overlay-face nil
)
5947 (defvar anything-match-line-overlay nil
)
5949 (defun anything-match-line-color-current-line (&optional start end buf face rec
)
5950 "Highlight and underline current position"
5951 (let ((args (list (or start
(line-beginning-position))
5952 (or end
(1+ (line-end-position)))
5954 (if (not anything-match-line-overlay
)
5955 (setq anything-match-line-overlay
(apply 'make-overlay args
))
5956 (apply 'move-overlay anything-match-line-overlay args
)))
5957 (overlay-put anything-match-line-overlay
5958 'face
(or face anything-match-line-overlay-face
))
5963 (defalias 'anything-persistent-highlight-point
'anything-match-line-color-current-line
)
5965 (defface anything-overlay-line-face
'((t (:background
"IndianRed4" :underline t
)))
5966 "Face for source header in the anything buffer." :group
'anything
)
5968 (setq anything-match-line-overlay-face
'anything-overlay-line-face
)
5970 (defun anything-match-line-cleanup ()
5971 (when anything-match-line-overlay
5972 (delete-overlay anything-match-line-overlay
)
5973 (setq anything-match-line-overlay nil
)))
5975 (defun anything-match-line-update ()
5976 (when anything-match-line-overlay
5977 (delete-overlay anything-match-line-overlay
)
5978 (anything-match-line-color-current-line)))
5980 (add-hook 'anything-cleanup-hook
'anything-match-line-cleanup
)
5981 (add-hook 'anything-after-persistent-action-hook
'anything-match-line-update
)
5983 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Actions Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5985 (defun anything-c-transform-file-load-el (actions candidate
)
5986 "Add action to load the file CANDIDATE if it is an emacs lisp
5987 file. Else return ACTIONS unmodified."
5988 (if (member (file-name-extension candidate
) '("el" "elc"))
5989 (append actions
'(("Load Emacs Lisp File" . load-file
)))
5992 (defun anything-c-transform-file-browse-url (actions candidate
)
5993 "Add an action to browse the file CANDIDATE if it in a html
5994 file or URL. Else return ACTIONS unmodified."
5995 (let ((browse-action '("Browse with Browser" . browse-url
)))
5996 (cond ((string-match "^http\\|^ftp" candidate
)
5997 (cons browse-action actions
))
5998 ((string-match "\\.html?$" candidate
)
5999 (append actions
(list browse-action
)))
6003 (defun anything-c-transform-function-call-interactively (actions candidate
)
6004 "Add an action to call the function CANDIDATE interactively if
6005 it is a command. Else return ACTIONS unmodified."
6006 (if (commandp (intern-soft candidate
))
6007 (append actions
'(("Call Interactively"
6009 anything-c-call-interactively
)))
6013 (defun anything-c-transform-sexp-eval-command-sexp (actions candidate
)
6014 "If CANDIDATE's `car' is a command, then add an action to
6015 evaluate it and put it onto the `command-history'."
6016 (if (commandp (car (read candidate
)))
6017 ;; Make it first entry
6018 (cons '("Eval and put onto command-history" .
6020 (let ((sym (read sexp
)))
6022 (setq command-history
6023 (cons sym command-history
)))))
6027 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Candidate Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6029 (defun anything-c-skip-boring-buffers (buffers)
6030 (anything-c-skip-entries buffers anything-c-boring-buffer-regexp
))
6032 (defun anything-c-skip-current-buffer (buffers)
6033 (if anything-allow-skipping-current-buffer
6034 (remove (buffer-name anything-current-buffer
) buffers
)
6037 (defun anything-c-shadow-boring-buffers (buffers)
6038 "Buffers matching `anything-c-boring-buffer-regexp' will be
6039 displayed with the `file-name-shadow' face if available."
6040 (anything-c-shadow-entries buffers anything-c-boring-buffer-regexp
))
6043 (defun anything-c-shadow-boring-files (files)
6044 "Files matching `anything-c-boring-file-regexp' will be
6045 displayed with the `file-name-shadow' face if available."
6046 (anything-c-shadow-entries files anything-c-boring-file-regexp
))
6048 (defun anything-c-skip-boring-files (files)
6049 "Files matching `anything-c-boring-file-regexp' will be skipped."
6050 (anything-c-skip-entries files anything-c-boring-file-regexp
))
6051 ;; (anything-c-skip-boring-files '("README" "/src/.svn/hoge"))
6053 (defun anything-c-skip-current-file (files)
6054 "Current file will be skipped."
6055 (remove (buffer-file-name anything-current-buffer
) files
))
6057 (defun anything-c-w32-pathname-transformer (args)
6058 "Change undesirable features of windows pathnames to ones more acceptable to
6059 other candidate transformers."
6060 (if (eq system-type
'windows-nt
)
6062 (replace-regexp-in-string "/cygdrive/\\(.\\)" "\\1:" x
))
6064 (replace-regexp-in-string "\\\\" "/" y
)) args
))
6067 (defun anything-c-shorten-home-path (files)
6068 "Replaces /home/user with ~."
6069 (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows...
6071 (mapcar (lambda (file)
6072 (if (and (stringp file
) (string-match home file
))
6073 (cons (replace-match "~" nil nil file
) file
)
6078 (defun anything-c-mark-interactive-functions (functions)
6079 "Mark interactive functions (commands) with (i) after the function name."
6081 (loop for function in functions
6082 do
(push (cons (concat function
6083 (when (commandp (intern-soft function
)) " (i)"))
6086 finally
(return (nreverse list
)))))
6088 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Adaptive Sorting of Candidates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6089 (defvar anything-c-adaptive-done nil
6090 "nil if history information is not yet stored for the current
6093 (defvar anything-c-adaptive-history nil
6094 "Contains the stored history information.
6095 Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")
6097 (defadvice anything-initialize
(before anything-c-adaptive-initialize activate
)
6098 "Advise `anything-initialize' to reset `anything-c-adaptive-done'
6099 when anything is started."
6100 (setq anything-c-adaptive-done nil
))
6102 (defadvice anything-exit-minibuffer
(before anything-c-adaptive-exit-minibuffer activate
)
6103 "Advise `anything-exit-minibuffer' to store history information
6104 when a candidate is selected with RET."
6105 (anything-c-adaptive-store-selection))
6107 (defadvice anything-select-action
(before anything-c-adaptive-select-action activate
)
6108 "Advise `anything-select-action' to store history information
6109 when the user goes to the action list with TAB."
6110 (anything-c-adaptive-store-selection))
6112 (defun anything-c-source-use-adaptative-p (&optional source-name
)
6113 "Return current source only if it use adaptative history, nil otherwise."
6114 (let* ((source (or source-name
(anything-get-current-source)))
6115 (adapt-source (or (assoc-default 'filtered-candidate-transformer
6116 (assoc (assoc-default 'type source
)
6117 anything-type-attributes
))
6118 (assoc-default 'candidate-transformer
6119 (assoc (assoc-default 'type source
)
6120 anything-type-attributes
))
6121 (assoc-default 'filtered-candidate-transformer source
)
6122 (assoc-default 'candidate-transformer source
))))
6123 (if (listp adapt-source
)
6124 (when (member 'anything-c-adaptive-sort adapt-source
) source
)
6125 (when (eq adapt-source
'anything-c-adaptive-sort
) source
))))
6127 (defun anything-c-adaptive-store-selection ()
6128 "Store history information for the selected candidate."
6129 (unless anything-c-adaptive-done
6130 (setq anything-c-adaptive-done t
)
6131 (let ((source (anything-c-source-use-adaptative-p)))
6133 (let* ((source-name (or (assoc-default 'type source
)
6134 (assoc-default 'name source
)))
6135 (source-info (or (assoc source-name anything-c-adaptive-history
)
6137 (push (list source-name
) anything-c-adaptive-history
)
6138 (car anything-c-adaptive-history
))))
6139 (selection (anything-get-selection))
6140 (selection-info (progn
6143 (let ((found (assoc selection
(cdr source-info
))))
6148 ;; move entry to the beginning of the
6149 ;; list, so that it doesn't get
6150 ;; trimmed when the history is
6153 (delete found
(cdr source-info
)))
6156 (cadr source-info
)))
6157 (pattern-info (progn
6158 (setcdr selection-info
6160 (let ((found (assoc anything-pattern
(cdr selection-info
))))
6163 (cons anything-pattern
0)
6165 ;; move entry to the beginning of the
6166 ;; list, so if two patterns used the
6167 ;; same number of times then the one
6168 ;; used last appears first in the list
6169 (setcdr selection-info
6170 (delete found
(cdr selection-info
)))
6172 (cdr selection-info
)))
6173 (cadr selection-info
))))
6175 ;; increase usage count
6176 (setcdr pattern-info
(1+ (cdr pattern-info
)))
6178 ;; truncate history if needed
6179 (if (> (length (cdr selection-info
)) anything-c-adaptive-history-length
)
6180 (setcdr selection-info
6181 (subseq (cdr selection-info
) 0 anything-c-adaptive-history-length
))))))))
6183 (if (file-readable-p anything-c-adaptive-history-file
)
6184 (load-file anything-c-adaptive-history-file
))
6185 (add-hook 'kill-emacs-hook
'anything-c-adaptive-save-history
)
6187 (defun anything-c-adaptive-save-history ()
6188 "Save history information to file given by `anything-c-adaptive-history-file'."
6192 ";; -*- mode: emacs-lisp -*-\n"
6193 ";; History entries used for anything adaptive display.\n")
6194 (prin1 `(setq anything-c-adaptive-history
',anything-c-adaptive-history
)
6197 (write-region (point-min) (point-max) anything-c-adaptive-history-file nil
6198 (unless (interactive-p) 'quiet
))))
6200 (defun anything-c-adaptive-sort (candidates source
)
6201 "Sort the CANDIDATES for SOURCE by usage frequency.
6202 This is a filtered candidate transformer you can use for the
6203 attribute `filtered-candidate-transformer' of a source in
6204 `anything-sources' or a type in `anything-type-attributes'."
6205 (let* ((source-name (or (assoc-default 'type source
)
6206 (assoc-default 'name source
)))
6207 (source-info (assoc source-name anything-c-adaptive-history
)))
6208 (if (not source-info
)
6209 ;; if there is no information stored for this source then do nothing
6213 ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT)
6215 (mapcar (lambda (candidate-info)
6217 (dolist (pattern-info (cdr candidate-info
))
6218 (if (not (equal (car pattern-info
)
6220 (incf count
(cdr pattern-info
))
6222 ;; if current pattern is equal to the previously
6223 ;; used one then this candidate has priority
6224 ;; (that's why its count is boosted by 10000) and
6225 ;; it only has to compete with other candidates
6226 ;; which were also selected with the same pattern
6227 (setq count
(+ 10000 (cdr pattern-info
)))
6229 (cons (car candidate-info
) count
)))
6233 ;; sort the list in descending order, so candidates with highest
6234 ;; priorty come first
6235 (setq usage
(sort usage
(lambda (first second
)
6236 (> (cdr first
) (cdr second
)))))
6238 ;; put those candidates first which have the highest usage count
6239 (dolist (info usage
)
6240 (when (member* (car info
) candidates
6241 :test
'anything-c-adaptive-compare
)
6242 (push (car info
) sorted
)
6243 (setq candidates
(remove* (car info
) candidates
6244 :test
'anything-c-adaptive-compare
))))
6246 ;; and append the rest
6247 (append (reverse sorted
) candidates nil
)))))
6249 (defun anything-c-adaptive-compare (x y
)
6250 "Compare candidates X and Y taking into account that the
6251 candidate can be in (DISPLAY . REAL) format."
6252 (equal (if (listp x
)
6259 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Outliner ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6260 (defvar anything-outline-goto-near-line-flag t
)
6261 (defvar anything-outline-using nil
)
6262 (defun anything-after-update-hook--outline ()
6263 (if (and (eq anything-outline-using t
)
6264 (eq anything-outline-goto-near-line-flag t
))
6265 (anything-outline-goto-near-line)))
6266 (add-hook 'anything-after-update-hook
'anything-after-update-hook--outline
)
6268 (defun anything-outline-goto-near-line ()
6269 (with-anything-window
6270 ;; TODO need consideration whether to update position by every input.
6271 (when t
; (equal anything-pattern "")
6272 (anything-goto-line 2)
6273 (let ((lineno (with-current-buffer anything-current-buffer
6274 (line-number-at-pos (car anything-current-position
)))))
6276 (while (<= (progn (skip-chars-forward " ")
6277 (or (number-at-point) lineno
))
6282 (return-from exit
))))
6284 (and (bobp) (forward-line 1))
6285 (and (anything-pos-header-line-p) (forward-line -
2))
6286 (anything-mark-current-line)))))
6288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Plug-in ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6289 ;; Plug-in: info-index
6290 (defun* anything-c-info-init
(&optional
(file (anything-attr 'info-file
)))
6292 (unless (anything-candidate-buffer)
6293 (save-window-excursion
6296 (tobuf (anything-candidate-buffer 'global
))
6297 (infobuf (current-buffer))
6299 (dolist (node (or (anything-attr 'index-nodes
) (Info-index-nodes)))
6300 (Info-goto-node node
)
6301 (goto-char (point-min))
6302 (while (search-forward "\n* " nil t
)
6303 (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t
)
6304 '(save-current-buffer (buffer-substring-no-properties (point-at-bol) (point-at-eol)) result
)
6305 (setq s
(point-at-bol)
6307 (with-current-buffer tobuf
6308 (insert-buffer-substring infobuf s e
)
6309 (insert "\n"))))))))))
6311 (defun anything-c-info-goto (node-line)
6312 (Info-goto-node (car node-line
))
6313 (anything-goto-line (cdr node-line
)))
6315 (defun anything-c-info-display-to-real (line)
6317 "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line
)
6318 (cons (format "(%s)%s" (anything-attr 'info-file
) (match-string 2 line
))
6319 (string-to-number (or (match-string 3 line
) "1")))))
6321 (defun anything-c-make-info-source (file)
6322 `((name .
,(concat "Info Index: " file
))
6324 (init . anything-c-info-init
)
6325 (display-to-real . anything-c-info-display-to-real
)
6326 (get-line . buffer-substring
)
6327 (candidates-in-buffer)
6328 (action ("Goto node" . anything-c-info-goto
))))
6330 (defun anything-compile-source--info-index (source)
6331 (anything-aif (anything-interpret-value (assoc-default 'info-index source
))
6332 (anything-c-make-info-source it
)
6334 (add-to-list 'anything-compile-source-functions
'anything-compile-source--info-index
)
6336 (anything-document-attribute 'info-index
"info-index plugin"
6337 "Create a source of info index very easily.
6339 ex. (defvar anything-c-source-info-wget '((info-index . \"wget\"))")
6341 (anything-document-attribute 'index-nodes
"info-index plugin (optional)"
6342 "Index nodes of info file.
6344 If it is omitted, `Info-index-nodes' is used to collect index nodes.
6345 Some info files are missing index specification.
6347 ex. See `anything-c-source-info-screen'.")
6349 ;; Plug-in: candidates-file
6350 (defun anything-compile-source--candidates-file (source)
6351 (if (assoc-default 'candidates-file source
)
6352 `((init anything-p-candidats-file-init
6353 ,@(let ((orig-init (assoc-default 'init source
)))
6354 (cond ((null orig-init
) nil
)
6355 ((functionp orig-init
) (list orig-init
))
6357 (candidates-in-buffer)
6360 (add-to-list 'anything-compile-source-functions
'anything-compile-source--candidates-file
)
6362 (defun anything-p-candidats-file-init ()
6363 (destructuring-bind (file &optional updating
)
6364 (anything-mklist (anything-attr 'candidates-file
))
6365 (setq file
(anything-interpret-value file
))
6366 (with-current-buffer (anything-candidate-buffer (find-file-noselect file
))
6368 (buffer-disable-undo)
6370 (auto-revert-mode 1)))))
6372 (anything-document-attribute 'candidates-file
"candidates-file plugin"
6373 "Use a file as the candidates buffer.
6375 1st argument is a filename, string or function name or variable name.
6376 If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.")
6378 ;; Plug-in: headline
6379 (defun anything-compile-source--anything-headline (source)
6380 (if (assoc-default 'headline source
)
6381 (append '((init . anything-headline-init
)
6382 (get-line . buffer-substring
)
6385 '((candidates-in-buffer)
6386 (persistent-help .
"Show this line")))
6388 (add-to-list 'anything-compile-source-functions
'anything-compile-source--anything-headline
)
6390 (defun anything-headline-init ()
6391 (when (and (anything-current-buffer-is-modified)
6392 (with-current-buffer anything-current-buffer
6393 (eval (or (anything-attr 'condition
) t
))))
6394 (anything-headline-make-candidate-buffer
6395 (anything-interpret-value (anything-attr 'headline
))
6396 (anything-interpret-value (anything-attr 'subexp
)))))
6398 (anything-document-attribute 'headline
"Headline plug-in"
6399 "Regexp string for anything-headline to scan.")
6400 (anything-document-attribute 'condition
"Headline plug-in"
6401 "A sexp representing the condition to use anything-headline.")
6402 (anything-document-attribute 'subexp
"Headline plug-in"
6403 "Display (match-string-no-properties subexp).")
6406 (defun anything-headline-get-candidates (regexp subexp
)
6407 (with-current-buffer anything-current-buffer
6409 (goto-char (point-min))
6410 (if (functionp regexp
) (setq regexp
(funcall regexp
)))
6411 (let (hierarchy curhead
)
6413 (if (numberp subexp
)
6414 (cons (match-string-no-properties subexp
) (match-beginning subexp
))
6415 (cons (buffer-substring (point-at-bol) (point-at-eol))
6417 (hierarchies (headlines)
6418 (1+ (loop for
(_ . hierarchy
) in headlines
6419 maximize hierarchy
)))
6421 (loop for i from
0 to hierarchy
6422 collecting
(aref curhead i
)))
6423 (arrange (headlines)
6424 (unless (null headlines
) ; FIX headlines empty bug!
6425 (loop with curhead
= (make-vector (hierarchies headlines
) "")
6426 for
((str . pt
) . hierarchy
) in headlines
6427 do
(aset curhead hierarchy str
)
6430 (format "H%d:%s" (1+ hierarchy
)
6431 (mapconcat 'identity
(vector-0-n curhead hierarchy
) " / "))
6436 (loop for re in regexp
6437 for hierarchy from
0
6438 do
(goto-char (point-min))
6441 while
(re-search-forward re nil t
)
6442 collect
(cons (matched) hierarchy
)))
6443 (lambda (a b
) (> (cdar b
) (cdar a
)))))
6444 (loop while
(re-search-forward regexp nil t
)
6445 collect
(matched))))))))
6448 (defun anything-headline-make-candidate-buffer (regexp subexp
)
6449 (with-current-buffer (anything-candidate-buffer 'local
)
6450 (loop for
(content . pos
) in
(anything-headline-get-candidates regexp subexp
)
6453 (with-current-buffer anything-current-buffer
6454 (line-number-at-pos pos
))
6457 (defun anything-headline-goto-position (pos recenter
)
6460 (set-window-start (get-buffer-window anything-current-buffer
) (point))))
6462 (defun anything-revert-buffer (candidate)
6463 (with-current-buffer candidate
6464 (when (buffer-modified-p)
6465 (revert-buffer t t
))))
6467 (defun anything-revert-marked-buffers (candidate)
6468 (dolist (i (anything-marked-candidates))
6469 (anything-revert-buffer i
)))
6471 (defun anything-kill-marked-buffers (candidate)
6472 (dolist (i (anything-marked-candidates))
6475 ;; Plug-in: persistent-help
6476 (defun anything-compile-source--persistent-help (source)
6477 (append source
'((header-line . anything-persistent-help-string
))))
6478 (add-to-list 'anything-compile-source-functions
'anything-compile-source--persistent-help
)
6480 (defun anything-persistent-help-string ()
6481 (substitute-command-keys
6482 (concat "\\<anything-map>\\[anything-execute-persistent-action]: "
6483 (or (anything-interpret-value (anything-attr 'persistent-help
))
6484 (anything-aif (or (assoc-default 'persistent-action
6485 (anything-get-current-source))
6486 (assoc-default 'action
6487 (anything-get-current-source)))
6488 (cond ((symbolp it
) (symbol-name it
))
6489 ((listp it
) (or (ignore-errors (caar it
)) ""))))
6491 " (keeping session)")))
6493 (anything-document-attribute 'persistent-help
"persistent-help plug-in"
6494 "A string to explain persistent-action of this source.
6495 It also accepts a function or a variable name.")
6497 ;;; (anything '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST"))))
6499 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6501 (defun anything-c-find-file-or-marked (candidate)
6502 "Open file CANDIDATE or open anything marked files in background."
6503 (let ((marked (anything-marked-candidates)))
6504 (if (> (length marked
) 1)
6505 (dolist (i marked
) (find-file-noselect i
))
6506 (find-file-at-point candidate
))))
6508 ;; FIXME there is a bug in dired that confuse all dired commands
6509 ;; when using this feature, so i suspend it until bug is fixed in emacs.
6511 ;; (defun anything-c-create-dired-on-marked (candidate)
6512 ;; "Create a new dired buffer with only marked candidates."
6513 ;; (let ((marked (anything-marked-candidates))
6514 ;; (buffer-name (read-string "New Dired Buffer: ")))
6515 ;; (dired (cons buffer-name marked))))
6517 (defun anything-delete-marked-files (ignore)
6518 (let* ((files (anything-marked-candidates))
6519 (len (length files
)))
6521 (format "Delete *%s File(s):\n%s"
6523 (mapconcat (lambda (f) (format "- %s\n" f
)) files
""))))
6524 (message "(No deletions performed)")
6526 (set-text-properties 0 (length i
) nil i
)
6527 (anything-c-delete-file i
))
6528 (message "%s File(s) deleted" len
))))
6530 (defun anything-ediff-marked-buffers (candidate &optional merge
)
6531 "Ediff 2 marked buffers or 1 marked buffer and current-buffer.
6532 With optional arg `merge' call `ediff-merge-buffers'."
6533 (let ((lg-lst (length (anything-marked-candidates)))
6537 (error "Error:You have to mark at least 1 buffer"))
6539 (setq buf1 anything-current-buffer
6540 buf2
(first (anything-marked-candidates))))
6542 (setq buf1
(first (anything-marked-candidates))
6543 buf2
(second (anything-marked-candidates))))
6545 (error "Error:To much buffers marked!")))
6547 (ediff-merge-buffers buf1 buf2
)
6548 (ediff-buffers buf1 buf2
))))
6550 (defun anything-bookmark-get-bookmark-from-name (bmk)
6551 "Return bookmark name even if it is a bookmark with annotation.
6552 e.g prepended with *.
6553 Return nil if bmk is not a valid bookmark."
6554 (let ((bookmark (replace-regexp-in-string "\*" "" bmk
)))
6555 (if (assoc bookmark bookmark-alist
)
6557 (when (assoc bmk bookmark-alist
)
6560 (defun anything-delete-marked-bookmarks (elm)
6561 "Delete this bookmark or all marked bookmarks."
6562 (let ((bookmark (anything-bookmark-get-bookmark-from-name elm
)))
6563 (anything-aif (anything-marked-candidates)
6565 (let ((bmk (anything-bookmark-get-bookmark-from-name i
)))
6566 (bookmark-delete bmk
'batch
)))
6567 (bookmark-delete bookmark
'batch
))))
6569 (defun anything-require-or-error (feature function
)
6570 (or (require feature nil t
)
6571 (error "Need %s to use `%s'." feature function
)))
6573 (defun anything-find-buffer-on-elscreen (candidate)
6574 "Open buffer in new screen, if marked buffers open all in elscreens."
6575 (anything-require-or-error 'elscreen
'anything-find-buffer-on-elscreen
)
6576 (anything-aif (anything-marked-candidates)
6578 (let ((target-screen (elscreen-find-screen-by-buffer
6579 (get-buffer i
) 'create
)))
6580 (elscreen-goto target-screen
)))
6581 (let ((target-screen (elscreen-find-screen-by-buffer
6582 (get-buffer candidate
) 'create
)))
6583 (elscreen-goto target-screen
))))
6585 (defun anything-elscreen-find-file (file)
6586 (anything-require-or-error 'elscreen
'anything-elscreen-find-file
)
6587 (elscreen-find-file file
))
6589 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6591 ;;;; Type Attributes
6592 (define-anything-type-attribute 'buffer
6595 '(("Switch to buffer other window" . switch-to-buffer-other-window
)
6596 ("Switch to buffer" . switch-to-buffer
))
6597 '(("Switch to buffer" . switch-to-buffer
)
6598 ("Switch to buffer other window" . switch-to-buffer-other-window
)
6599 ("Switch to buffer other frame" . switch-to-buffer-other-frame
)))
6600 ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . anything-find-buffer-on-elscreen
))
6601 ("Display buffer" . display-buffer
)
6602 ("Revert buffer" . anything-revert-buffer
)
6603 ("Revert Marked buffers" . anything-revert-marked-buffers
)
6604 ("Kill buffer" . kill-buffer
)
6605 ("Kill Marked buffers" . anything-kill-marked-buffers
)
6606 ("Ediff Marked buffers" . anything-ediff-marked-buffers
)
6607 ("Ediff Merge marked buffers" .
(lambda (candidate)
6608 (anything-ediff-marked-buffers candidate t
))))
6609 (persistent-help .
"Show this buffer")
6610 (candidate-transformer anything-c-skip-current-buffer anything-c-skip-boring-buffers
))
6611 "Buffer or buffer name.")
6613 (define-anything-type-attribute 'file
6616 '(("Find file other window" . find-file-other-window
)
6617 ("Find file(s)" . anything-find-many-files
)
6618 ("Find file as root" . anything-find-file-as-root
))
6619 '(("Find file" . anything-find-many-files
)
6620 ("Find file as root" . anything-find-file-as-root
)
6621 ("Find file other window" . find-file-other-window
)
6622 ("Find file other frame" . find-file-other-frame
)))
6623 ("Open dired in file's directory" . anything-c-open-dired
)
6624 ("Delete file(s)" . anything-delete-marked-files
)
6625 ("Open file externally" . anything-c-open-file-externally
)
6626 ("Open file with default tool" . anything-c-open-file-with-default-tool
))
6627 (persistent-help .
"Show this file")
6628 (action-transformer anything-c-transform-file-load-el
6629 anything-c-transform-file-browse-url
)
6630 (candidate-transformer anything-c-w32-pathname-transformer
6631 anything-c-skip-current-file
6632 anything-c-skip-boring-files
6633 anything-c-shorten-home-path
))
6636 (define-anything-type-attribute 'command
6637 `((action ("Call interactively" . anything-c-call-interactively
)
6638 ("Describe command" . anything-c-describe-function
)
6639 ("Add command to kill ring" . anything-c-kill-new
)
6640 ("Go to command's definition" . anything-c-find-function
))
6641 ;; Sort commands according to their usage count.
6642 (filtered-candidate-transformer . anything-c-adaptive-sort
)
6643 (persistent-action . anything-c-describe-function
))
6644 "Command. (string or symbol)")
6646 (define-anything-type-attribute 'function
6647 '((action ("Describe function" . anything-c-describe-function
)
6648 ("Add function to kill ring" . anything-c-kill-new
)
6649 ("Go to function's definition" . anything-c-find-function
))
6650 (action-transformer anything-c-transform-function-call-interactively
)
6651 (candidate-transformer anything-c-mark-interactive-functions
))
6652 "Function. (string or symbol)")
6654 (define-anything-type-attribute 'variable
6655 '((action ("Describe variable" . anything-c-describe-variable
)
6656 ("Add variable to kill ring" . anything-c-kill-new
)
6657 ("Go to variable's definition" . anything-c-find-variable
)
6658 ("Set variable" . anything-c-set-variable
)))
6661 (define-anything-type-attribute 'sexp
6662 '((action ("Eval s-expression" .
(lambda (c) (eval (read c
))))
6663 ("Add s-expression to kill ring" . kill-new
))
6664 (action-transformer anything-c-transform-sexp-eval-command-sexp
))
6665 "String representing S-Expressions.")
6667 (define-anything-type-attribute 'bookmark
6669 ("Jump to bookmark" .
(lambda (candidate)
6670 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
))
6671 (current-prefix-arg anything-current-prefix-arg
))
6672 (bookmark-jump bookmark
))
6674 ("Jump to BM other window" .
(lambda (candidate)
6675 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6676 (bookmark-jump-other-window bookmark
))
6678 ("Bookmark edit annotation" .
(lambda (candidate)
6679 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6680 (bookmark-edit-annotation bookmark
))))
6681 ("Bookmark show annotation" .
(lambda (candidate)
6682 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6683 (bookmark-show-annotation bookmark
))))
6684 ("Delete bookmark(s)" . anything-delete-marked-bookmarks
)
6685 ,@(when (fboundp 'bmkext-edit-bookmark
)
6686 '(("Edit Bookmark" .
(lambda (candidate)
6687 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6688 (bmkext-edit-bookmark bookmark
))))))
6689 ("Rename bookmark" .
(lambda (candidate)
6690 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6691 (bookmark-rename bookmark
))))
6692 ("Relocate bookmark" .
(lambda (candidate)
6693 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6694 (bookmark-relocate bookmark
))))))
6697 (define-anything-type-attribute 'line
6698 '((display-to-real . anything-c-display-to-real-line
)
6699 (action ("Go to Line" . anything-c-action-line-goto
)))
6700 "LINENO:CONTENT string, eg. \" 16:foo\".
6702 Optional `target-file' attribute is a name of target file.
6704 Optional `before-jump-hook' attribute is a function with no
6705 arguments which is called before jumping to position.
6707 Optional `after-jump-hook' attribute is a function with no
6708 arguments which is called after jumping to position.
6710 If `adjust' attribute is specified, searches the line whose
6711 content is CONTENT near the LINENO.
6713 If `recenter' attribute is specified, the line is displayed at
6714 the center of window, otherwise at the top of window.
6717 (define-anything-type-attribute 'file-line
6718 `((filtered-candidate-transformer anything-c-filtered-candidate-transformer-file-line
)
6720 (action ("Go to" . anything-c-action-file-line-goto
)))
6721 "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\".
6723 Optional `default-directory' attribute is a default-directory
6724 FILENAME is interpreted.
6726 Optional `before-jump-hook' attribute is a function with no
6727 arguments which is called before jumping to position.
6729 Optional `after-jump-hook' attribute is a function with no
6730 arguments which is called after jumping to position.
6732 If `adjust' attribute is specified, searches the line whose
6733 content is CONTENT near the LINENO.
6735 If `recenter' attribute is specified, the line is displayed at
6736 the center of window, otherwise at the top of window.
6739 (define-anything-type-attribute 'timer
6740 '((real-to-display . anything-c-timer-real-to-display
)
6741 (action ("Cancel Timer" . cancel-timer
)
6742 ("Describe Function" .
(lambda (tm) (describe-function (timer--function tm
))))
6743 ("Find Function" .
(lambda (tm) (find-function (timer--function tm
)))))
6744 (persistent-action .
(lambda (tm) (describe-function (timer--function tm
))))
6745 (persistent-help .
"Describe Function"))
6748 ;;;; Default `anything-sources'
6749 ;; Setting `anything-sources' is DEPRECATED, but it seems that newbies
6750 ;; tend to invoke M-x anything directly. So I offer default setting.
6751 (setq anything-sources
6752 '(anything-c-source-buffers+
6753 anything-c-source-recentf
6754 anything-c-source-files-in-current-dir
+))
6757 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
6758 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el")
6760 (when (fboundp 'expectations
)
6762 (desc "candidates-file plug-in")
6763 (expect '(anything-p-candidats-file-init)
6764 (assoc-default 'init
6765 (car (anything-compile-sources
6767 (candidates-file .
"test.txt")))
6768 '(anything-compile-source--candidates-file)))))
6769 (expect '(anything-p-candidats-file-init
6771 (assoc-default 'init
6772 (car (anything-compile-sources
6774 (candidates-file .
"test.txt")
6775 (init .
(lambda () 1))))
6776 '(anything-compile-source--candidates-file)))))
6777 (expect '(anything-p-candidats-file-init
6779 (assoc-default 'init
6780 (car (anything-compile-sources
6782 (candidates-file .
"test.txt")
6783 (init (lambda () 1))))
6784 '(anything-compile-source--candidates-file)))))
6785 (desc "anything-c-source-buffers")
6786 (expect '(("Buffers" ("foo" "curbuf")))
6787 (stub buffer-list
=> '("curbuf" " hidden" "foo" "*anything*"))
6788 (let ((anything-c-boring-buffer-regexp
6793 " *Echo Area" " *Minibuf"))))
6794 (flet ((buffer-name (x) x
))
6795 (anything-test-candidates 'anything-c-source-buffers
))))
6796 (desc "anything-c-stringify")
6798 (anything-c-stringify "str1"))
6800 (anything-c-stringify 'str2
))
6801 (desc "anything-c-symbolify")
6803 (anything-c-symbolify "sym1"))
6805 (anything-c-symbolify 'sym2
)))))
6807 (provide 'anything-config
)
6809 ;;; Local Variables:
6810 ;;; time-stamp-format: "%:y-%02m-%02d %02H:%02M:%02S (%Z) %u"
6813 ;; How to save (DO NOT REMOVE!!)
6814 ;; (progn (magit-push) (emacswiki-post "anything-config.el"))
6815 ;;; anything-config.el ends here
6817 ;;; LocalWords: Tassilo Patrovics Vagn Johansen Dahl Clementson infos
6818 ;;; LocalWords: Kamphausen informations McBrayer Volpiatto bbdb bb
6819 ;;; LocalWords: iswitchb imenu Recentf sym samewindow pos bol eol
6820 ;;; LocalWords: aif str lst func attrib recentf lessp prin mapatoms commandp
6821 ;;; LocalWords: cmd stb Picklist picklist mapcan subentry destructuring dirs
6822 ;;; LocalWords: darwin locat MacOS mdfind Firstname Lastname calc prepend jids
6823 ;;; LocalWords: dotimes Thierry online vname
6824 ;;; LocalWords: csharp javascript lua makefile cperl zcat lineno buf
6825 ;;; LocalWords: multiline href fn cand NewTitle cwd filepath thru ret
6826 ;;; LocalWords: bfn fOpen UNC cygdrive nt xdg macos FILE's elc rx svn hg
6827 ;;; LocalWords: CANDIDATE's darcs facep pathname args pathnames subseq priorty
6828 ;;; LocalWords: Vokes rfind berkeley JST ffap lacarte bos
6829 ;;; LocalWords: Lacarte Minibuf epp LaCarte bm attrset migemo attr conf mklist
6830 ;;; LocalWords: startpos noselect dont desc