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
1005 '(anything-c-source-colors anything-c-source-customize-face
)
1006 "*anything colors*"))
1009 (defun anything-bookmarks ()
1010 "Preconfigured `anything' for bookmarks."
1012 (anything-other-buffer 'anything-c-source-bookmarks
"*anything bookmarks*"))
1015 (defun anything-c-pp-bookmarks ()
1016 "Preconfigured `anything' for bookmarks (pretty-printed)."
1018 (anything-other-buffer '(anything-c-source-bookmarks-local
1019 anything-c-source-bookmarks-su
1020 anything-c-source-bookmarks-ssh
)
1021 "*anything pp bookmarks*"))
1024 (defun anything-register ()
1025 "Preconfigured `anything' for Emacs registers."
1027 (anything-other-buffer 'anything-c-source-register
"*anything register*"))
1030 (defun anything-bm-list ()
1031 "Preconfigured `anything' for visible bookmarks.
1035 http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el"
1037 (let ((anything-outline-using t
))
1038 (anything-other-buffer 'anything-c-source-bm
"*anything bm list*")))
1041 (defun anything-timers ()
1042 "Preconfigured `anything' for timers."
1044 (anything-other-buffer '(anything-c-source-absolute-time-timers
1045 anything-c-source-idle-time-timers
)
1046 "*anything timers*"))
1048 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Applications ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1051 (defun anything-kill-buffers ()
1052 "Preconfigured `anything' to kill buffer you selected."
1055 '(((name .
"Kill Buffers")
1056 (candidates . anything-c-buffer-list
)
1058 ("Kill Buffer" .
(lambda (candidate)
1059 (kill-buffer candidate
)
1060 (anything-kill-buffers)
1066 (defun anything-query-replace-regexp (&rest args
)
1067 "Preconfigured `anything' : Drop-in replacement of `query-replace-regexp' with building regexp visually."
1070 (anything-c-regexp-base
1071 "Query Replace Regexp: "
1072 '((name .
"Lines matching Regexp")
1073 (mode-line .
"Set replace start line and type RET.")
1074 (action . anything-c-query-replace-args
)))))
1077 (list (car common
) (cadr common
) (caddr common
)
1078 ;; These are done separately here
1079 ;; so that command-history will record these expressions
1080 ;; rather than the values they had this time.
1082 ;; This idea is borrowed from original `query-replace-regexp'.
1083 (if (and transient-mark-mode mark-active
)
1085 (if (and transient-mark-mode mark-active
)
1087 (apply 'query-replace-regexp args
))
1090 (defun anything-regexp ()
1091 "Preconfigured `anything' : It is like `re-builder'. It helps buliding regexp and replacement."
1093 (anything-c-regexp-base
1095 '((name .
"Regexp Builder")
1096 (mode-line .
"Press TAB to select action.")
1098 ("Kill Regexp as sexp" .
1099 (lambda (x) (anything-c-regexp-kill-new
1100 (prin1-to-string (funcall (anything-attr 'regexp
))))))
1101 ("Query Replace Regexp" .
1102 (lambda (x) (apply 'query-replace-regexp
1103 (anything-c-query-replace-args (point)))))
1105 (lambda (x) (anything-c-regexp-kill-new
1106 (funcall (anything-attr 'regexp
)))))))))
1108 (defun anything-c-query-replace-args (start-point)
1109 ;; create arguments of `query-replace-regexp'.
1110 (let ((region-only (and transient-mark-mode mark-active
))
1111 (regexp (funcall (anything-attr 'regexp
))))
1114 (query-replace-read-to regexp
1115 (format "Query replace regexp %s%s%s with: "
1116 (if region-only
"in region " "")
1118 (if current-prefix-arg
"(word) " ""))
1120 current-prefix-arg
)))
1122 (defun anything-c-regexp-get-line (s e
)
1126 (format "%5d: %s" (line-number-at-pos s
) (buffer-substring s e
))
1128 (loop for i from
0 to
(1- (/ (length (match-data)) 2))
1129 collect
(format "\n \\%s = %s"
1130 (if (zerop i
) "&" i
)
1133 ;; KLUDGE: point of anything-candidate-buffer is +1 than that of anything-current-buffer.
1134 ;; It is implementation problem of candidates-in-buffer.
1138 ;; Shut up byte compiler
1139 (defun anything-goto-line (numline)
1140 "Replacement of `goto-line'."
1141 (goto-char (point-min))
1142 (forward-line (1- numline
)))
1144 (defun anything-c-regexp-persistent-action (pt)
1146 (anything-persistent-highlight-point))
1148 (defun anything-c-regexp-base (prompt attributes
)
1150 (let ((anything-compile-source-functions
1151 ;; rule out anything-match-plugin because the input is one regexp.
1152 (delq 'anything-compile-source--match-plugin
1153 (copy-sequence anything-compile-source-functions
)))
1155 '((init .
(lambda () (anything-candidate-buffer anything-current-buffer
)))
1156 (candidates-in-buffer)
1157 (get-line . anything-c-regexp-get-line
)
1158 (persistent-action . anything-c-regexp-persistent-action
)
1159 (persistent-help .
"Show this line")
1162 (if (and transient-mark-mode mark-active
)
1163 (narrow-to-region (region-beginning) (region-end)))
1168 '((regexp .
(lambda () anything-pattern
)))
1172 `((name .
,(concat (assoc-default 'name attributes
) " (sexp)")))
1174 '((candidates-in-buffer
1175 .
(lambda () (let ((anything-pattern (eval (read anything-pattern
))))
1176 (anything-candidates-in-buffer))))
1177 (regexp .
(lambda () (eval (read anything-pattern
)))))
1179 nil prompt nil nil
"*anything regexp*"))))
1181 ;; (anything-c-regexp-base "Regexp: " '((name . "test")))
1182 ;; (anything-c-regexp-base "Regexp: " '((name . "test") (candidates-in-buffer . (lambda () (let ((anything-pattern (eval (read anything-pattern)))) (anything-candidates-in-buffer))))))
1184 (defun anything-c-regexp-kill-new (input)
1186 (message "Killed: %s" input
))
1188 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1190 (defun anything-insert-buffer-name ()
1191 "Insert buffer name."
1193 (anything-insert-string
1194 (with-current-buffer anything-current-buffer
1195 (if buffer-file-name
(file-name-nondirectory buffer-file-name
)
1198 (defun anything-insert-symbol ()
1199 "Insert current symbol."
1201 (anything-insert-string
1202 (with-current-buffer anything-current-buffer
1204 (buffer-substring (beginning-of-thing 'symbol
)
1205 (end-of-thing 'symbol
))))))
1207 (defun anything-insert-selection ()
1208 "Insert current selection."
1210 (anything-insert-string
1211 (with-current-buffer anything-current-buffer
1212 (anything-get-selection))))
1214 (defun anything-show-buffer-only ()
1215 "[OBSOLETE] Only show sources about buffer.
1216 Use `anything-for-buffers' instead."
1218 (anything-set-source-filter '("Buffers")))
1220 (defun anything-show-bbdb-only ()
1221 "[OBSOLETE] Only show sources about BBDB.
1222 Use `anything-bbdb' instead."
1224 (anything-set-source-filter '("BBDB")))
1226 (defun anything-show-locate-only ()
1227 "[OBSOLETE] Only show sources about Locate.
1228 Use `anything-locate' instead."
1230 (anything-set-source-filter '("Locate")))
1232 (defun anything-show-info-only ()
1233 "[OBSOLETE] Only show sources about Info.
1234 Use `anything-info-at-point' instead."
1236 (anything-set-source-filter '("Info Pages"
1238 "Info Common-Lisp")))
1240 (defun anything-show-imenu-only ()
1241 "[OBSOLETE] Only show sources about Imenu.
1242 Use `anything-imenu' instead."
1244 (anything-set-source-filter '("Imenu")))
1246 (defun anything-show-files-only ()
1247 "[OBSOLETE] Only show sources about File.
1248 Use `anything-for-files' instead."
1250 (anything-set-source-filter '("File Name History"
1251 "Files from Current Directory"
1254 (defun anything-show-w3m-bookmarks-only ()
1255 "[OBSOLETE] Only show source about w3m bookmark.
1256 Use `anything-w3m-bookmarks' instead."
1258 (anything-set-source-filter '("W3m Bookmarks")))
1260 (defun anything-show-colors-only ()
1261 "[OBSOLETE] Only show source about color.
1262 Use `anything-colors' instead."
1264 (anything-set-source-filter '("Colors"
1265 "Customize Faces")))
1267 (defun anything-show-kill-ring-only ()
1268 "[OBSOLETE] Only show source about kill ring.
1269 Use `anything-show-kill-ring' instead."
1271 (anything-set-source-filter '("Kill Ring")))
1273 (defun anything-show-this-source-only ()
1274 "Only show this source."
1276 (setq anything-candidate-number-limit
9999)
1277 (anything-set-source-filter
1278 (list (assoc-default 'name
(anything-get-current-source)))))
1280 (defun anything-test-sources ()
1281 "List all anything sources for test.
1282 The output is sexps which are evaluated by \\[eval-last-sexp]."
1284 (with-output-to-temp-buffer "*Anything Test Sources*"
1285 (mapc (lambda (s) (princ (format ";; (anything '%s)\n" s
)))
1286 (apropos-internal "^anything-c-source" #'boundp
))
1287 (pop-to-buffer standard-output
)))
1289 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utilities Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1290 ;;; For compatibility
1291 (unless (fboundp 'region-active-p
)
1292 (defun region-active-p ()
1293 "Return t if Transient Mark mode is enabled and the mark is active.
1295 Most commands that act on the region if it is active and
1296 Transient Mark mode is enabled, and on the text near point
1297 otherwise, should use `use-region-p' instead. That function
1298 checks the value of `use-empty-active-region' as well."
1299 (and transient-mark-mode mark-active
)))
1301 (defun anything-nest (&rest same-as-anything
)
1302 "Nested `anything'. If you use `anything' within `anything', use it."
1303 (with-selected-window (anything-window)
1304 (let (anything-current-position
1305 anything-current-buffer
1306 (orig-anything-buffer anything-buffer
)
1310 anything-compiled-sources
1311 anything-buffer-chars-modified-tick
1312 (anything-samewindow t
)
1313 (enable-recursive-minibuffers t
))
1315 (apply #'anything same-as-anything
)
1316 (anything-initialize-overlays orig-anything-buffer
)
1317 (add-hook 'post-command-hook
'anything-check-minibuffer-input
)))))
1319 (defun anything-displaying-source-names ()
1320 "Display sources name."
1321 (with-current-buffer anything-buffer
1322 (goto-char (point-min))
1324 while
(setq pos
(next-single-property-change (point) 'anything-header
))
1326 collect
(buffer-substring-no-properties (point-at-bol)(point-at-eol))
1327 do
(forward-line 1))))
1329 (defun anything-select-source ()
1332 (let ((default (assoc-default 'name
(anything-get-current-source)))
1333 (source-names (anything-displaying-source-names))
1334 (all-source-names (mapcar (lambda (s) (assoc-default 'name s
))
1335 (anything-get-sources))))
1336 (setq anything-candidate-number-limit
9999)
1338 (let (anything-source-filter)
1339 (anything-nest '(((name .
"Anything Source")
1340 (candidates . source-names
)
1341 (action . identity
))
1342 ((name .
"Anything Source (ALL)")
1343 (candidates . all-source-names
)
1344 (action . identity
)))
1346 default
"*anything select source*"))
1347 (anything-set-source-filter (list it
))
1348 (anything-set-source-filter nil
))))
1350 (defun anything-insert-string (str)
1352 (delete-minibuffer-contents)
1355 (defun anything-c-match-on-file-name (candidate)
1356 "Return non-nil if `anything-pattern' match the filename (without directory part) of CANDIDATE."
1357 (string-match anything-pattern
(file-name-nondirectory candidate
)))
1359 (defun anything-c-match-on-directory-name (candidate)
1360 "Return non-nil if `anything-pattern' match the directory part of CANDIDATE (a file)."
1361 (anything-aif (file-name-directory candidate
)
1362 (string-match anything-pattern it
)))
1364 (defun anything-c-string-match (candidate)
1365 "Return non-nil if `anything-pattern' match CANDIDATE.
1366 The match is done with `string-match'."
1367 (string-match anything-pattern candidate
))
1369 ;; `anything-c-compose' is no more needed, it is for compatibility.
1370 (defalias 'anything-c-compose
'anything-compose
)
1372 (defun anything-c-skip-entries (list regexp
)
1373 "Remove entries which matches REGEXP from LIST."
1374 (remove-if (lambda (x) (and (stringp x
) (string-match regexp x
)))
1377 (defun anything-c-shadow-entries (list regexp
)
1378 "Elements of LIST matching REGEXP will be displayed with the `file-name-shadow' face if available."
1379 (mapcar (lambda (file)
1380 ;; Add shadow face property to boring files.
1381 (let ((face (if (facep 'file-name-shadow
)
1383 ;; fall back to default on XEmacs
1385 (if (string-match regexp file
)
1386 (setq file
(propertize file
'face face
))))
1390 (defsubst anything-c-stringify
(str-or-sym)
1391 "Get string of STR-OR-SYM."
1392 (if (stringp str-or-sym
)
1394 (symbol-name str-or-sym
)))
1396 (defsubst anything-c-symbolify
(str-or-sym)
1397 "Get symbol of STR-OR-SYM."
1398 (if (symbolp str-or-sym
)
1400 (intern str-or-sym
)))
1402 (defun anything-c-describe-function (func)
1403 "FUNC is symbol or string."
1404 (describe-function (anything-c-symbolify func
)))
1406 (defun anything-c-describe-variable (var)
1407 "VAR is symbol or string."
1408 (describe-variable (anything-c-symbolify var
)))
1410 (defun anything-c-find-function (func)
1411 "FUNC is symbol or string."
1412 (find-function (anything-c-symbolify func
)))
1414 (defun anything-c-find-variable (var)
1415 "VAR is symbol or string."
1416 (find-variable (anything-c-symbolify var
)))
1418 (defun anything-c-kill-new (string &optional replace yank-handler
)
1419 "STRING is symbol or string."
1420 (kill-new (anything-c-stringify string
) replace yank-handler
))
1422 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Prefix argument in action ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1424 (defvar anything-current-prefix-arg nil
1425 "`current-prefix-arg' when selecting action.
1426 It is cleared after executing action.")
1428 (defadvice anything-exit-minibuffer
(before anything-current-prefix-arg activate
)
1429 (unless anything-current-prefix-arg
1430 (setq anything-current-prefix-arg current-prefix-arg
)))
1432 (add-hook 'anything-after-action-hook
1433 (lambda () (setq anything-current-prefix-arg nil
)))
1436 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Hacks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1437 (defadvice eval-defun
(after anything-source-hack activate
)
1438 "See `anything-c-enable-eval-defun-hack'."
1439 (when anything-c-enable-eval-defun-hack
1440 (let ((varsym (save-excursion
1441 (beginning-of-defun)
1443 (when (memq (read (current-buffer)) '(defvar setq
))
1444 (read (current-buffer))))))
1445 (when (string-match "^anything-c-source-" (symbol-name varsym
))
1446 (anything varsym
)))))
1447 ;; (progn (ad-disable-advice 'eval-defun 'after 'anything-source-hack) (ad-update 'eval-defun))
1449 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Document Generator ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1450 (defun anything-c-create-summary ()
1451 "Create `anything' summary."
1453 (goto-char (point-min))
1454 (loop while
(re-search-forward "^;;;; <\\(.+?\\)>$\\|^;; (anything '\\(.+?\\))$\\|^ *;; (anything '\\(.+?\\))$" nil t
)
1455 collect
(cond ((match-beginning 1)
1456 (cons 'section
(match-string-no-properties 1)))
1457 ((match-beginning 2)
1459 (cons (match-string-no-properties 2)
1460 (assoc-default 'name
(symbol-value (intern (match-string-no-properties 2)))))))
1461 ((match-beginning 3)
1463 (cons (match-string-no-properties 3)
1464 (assoc-default 'name
(symbol-value (intern (match-string-no-properties 3)))))))))))
1466 ;; (find-epp (anything-c-create-summary))
1468 (defun anything-c-insert-summary ()
1469 "Insert `anything' summary."
1471 (goto-char (point-min))
1472 (search-forward ";; Below are complete source list you can setup in")
1474 (delete-region (point)
1475 (progn (search-forward ";;; Change log:" nil t
)
1476 (forward-line -
1) (point)))
1479 for
(kind . value
) in
(anything-c-create-summary)
1481 do
(cond ((eq kind
'section
)
1483 (align-regexp beg
(point) "\\(\\s-*\\)(" 1 1 nil
))
1484 (insert ";; " value
":\n")
1487 (insert ";; `" (car value
) "' (" (cdr value
) ")\n")))
1488 finally
(align-regexp beg
(point) "\\(\\s-*\\)(" 1 1 nil
))))
1489 ;; (anything-c-insert-summary)
1491 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Anything Sources ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1493 (defun anything-c-buffer-list ()
1494 "Return the list of names of buffers with boring buffers filtered out.
1495 Boring buffers is specified by `anything-c-boring-buffer-regexp'.
1496 The first buffer in the list will be the last recently used
1497 buffer that is not the current buffer."
1498 (let ((buffers (mapcar 'buffer-name
(buffer-list))))
1499 (append (cdr buffers
) (list (car buffers
)))))
1501 (defvar anything-c-source-buffers
1502 '((name .
"Buffers")
1503 (candidates . anything-c-buffer-list
)
1505 ;; (anything 'anything-c-source-buffers)
1507 (defvar anything-c-source-buffer-not-found
1508 '((name .
"Create buffer")
1511 ;; (anything 'anything-c-source-buffer-not-found)
1514 (defface anything-dir-heading
'((t (:foreground
"Blue" :background
"Pink")))
1515 "*Face used for directory headings in dired buffers."
1518 (defface anything-file-name
1519 '((t (:foreground
"Blue")))
1520 "*Face used for file names (without suffixes) in dired buffers."
1523 (defface anything-dir-priv
1524 '((t (:foreground
"DarkRed" :background
"LightGray")))
1525 "*Face used for directory privilege indicator (d) in dired buffers."
1528 (defvar anything-c-buffers-face1
'anything-dir-priv
)
1529 (defvar anything-c-buffers-face2
'font-lock-type-face
)
1530 (defvar anything-c-buffers-face3
'italic
)
1531 (eval-when-compile (require 'dired
))
1532 (defun anything-c-highlight-buffers (buffers)
1534 (loop for i in buffers
1535 if
(rassoc (get-buffer i
) dired-buffers
)
1536 collect
(propertize i
1537 'face anything-c-buffers-face1
1538 'help-echo
(car (rassoc (get-buffer i
) dired-buffers
)))
1539 if
(buffer-file-name (get-buffer i
))
1540 collect
(propertize i
1541 'face anything-c-buffers-face2
1542 'help-echo
(buffer-file-name (get-buffer i
)))
1543 if
(and (not (rassoc (get-buffer i
) dired-buffers
))
1544 (not (buffer-file-name (get-buffer i
))))
1545 collect
(propertize i
1546 'face anything-c-buffers-face3
)))
1548 (defvar anything-c-source-buffers
+
1549 '((name .
"Buffers")
1550 (candidates . anything-c-buffer-list
)
1552 (candidate-transformer anything-c-skip-current-buffer
1553 anything-c-highlight-buffers
1554 anything-c-skip-boring-buffers
)
1555 (persistent-action . anything-c-buffers
+-persistent-action
)
1556 (persistent-help .
"Show this buffer / C-u \\[anything-execute-persistent-action]: Kill this buffer")))
1558 (defun anything-c-buffers+-persistent-action
(name)
1560 (with-current-buffer item
1561 (if (and (buffer-modified-p)
1562 (buffer-file-name (current-buffer)))
1566 (kill-buffer item
))))
1568 (switch-to-buffer item
)))
1569 (if current-prefix-arg
1572 (anything-delete-current-selection))
1575 ;; (anything 'anything-c-source-buffers+)
1579 ;;; File name history
1580 (defvar anything-c-source-file-name-history
1581 '((name .
"File Name History")
1582 (candidates . file-name-history
)
1583 (match anything-c-match-on-file-name
1584 anything-c-match-on-directory-name
)
1586 ;; (anything 'anything-c-source-file-name-history)
1588 ;;; Files in current dir
1589 (defvar anything-c-source-files-in-current-dir
1590 '((name .
"Files from Current Directory")
1591 (candidates .
(lambda ()
1592 (with-current-buffer anything-current-buffer
1593 (directory-files (anything-c-current-directory)))))
1594 ;; volatile is not needed, I think.
1596 ;; (anything 'anything-c-source-files-in-current-dir)
1598 (defvar anything-c-files-face1
'anything-dir-priv
)
1599 (defvar anything-c-files-face2
'anything-file-name
)
1600 (defun anything-c-highlight-files (files)
1601 (loop for i in files
1602 if
(file-directory-p i
)
1603 collect
(propertize (file-name-nondirectory i
)
1604 'face anything-c-files-face1
1605 'help-echo
(expand-file-name i
))
1607 collect
(propertize (file-name-nondirectory i
)
1608 'face anything-c-files-face2
1609 'help-echo
(expand-file-name i
))))
1612 (defvar anything-c-source-files-in-current-dir
+
1613 '((name .
"Files from Current Directory")
1614 (candidates .
(lambda ()
1615 (with-current-buffer anything-current-buffer
1616 (directory-files (anything-c-current-directory) t
))))
1617 (candidate-transformer anything-c-highlight-files
)
1618 ;; volatile is not needed, I think.
1621 ;; (anything 'anything-c-source-files-in-current-dir+)
1623 ;;; Anything replacement of file name completion for `find-file' and friends.
1625 (defvar anything-c-find-files-doc-header
(format " (`%s':Go to precedent level)"
1626 (if window-system
"C-." "C-l"))
1627 "*The doc that is inserted in the Name header of a find-files or dired source.")
1629 (defvar anything-c-source-find-files
1630 `((name .
,(concat "Find Files" anything-c-find-files-doc-header
))
1631 ;; It is needed for filenames with capital letters
1634 (setq ffap-newfile-prompt t
)))
1635 (candidates . anything-find-files-get-candidates
)
1636 (candidate-transformer anything-c-highlight-ffiles
)
1637 (persistent-action . anything-find-files-persistent-action
)
1638 (persistent-help .
"Expand Candidate")
1643 `(("Find File" . anything-c-find-file-or-marked
)
1644 ("Find file in Dired" . anything-c-point-file-in-dired
)
1645 ,(and (locate-library "elscreen")
1646 '("Find file in Elscreen" . anything-elscreen-find-file
))
1647 ("Complete at point"
1648 . anything-c-insert-file-name-completion-at-point
)
1649 ("Delete File(s)" . anything-delete-marked-files
)
1650 ("Find file as root" . anything-find-file-as-root
)
1651 ("Open file externally (C-u to choose)"
1652 . anything-c-open-file-externally
)
1653 ;; ("Create dired buffer on marked"
1654 ;; . anything-c-create-dired-on-marked)
1655 ("Find file other window" . find-file-other-window
)
1656 ("Find file other frame" . find-file-other-frame
))))))
1658 ;; (anything 'anything-c-source-find-files)
1660 (defun* anything-reduce-file-name
(fname level
&key unix-close expand
)
1661 "Reduce FNAME by LEVEL from end or beginning depending LEVEL value.
1662 If LEVEL is positive reduce from end else from beginning.
1663 If UNIX-CLOSE is non--nil close filename with /.
1664 If EXPAND is non--nil expand-file-name."
1665 (let* ((exp-fname (expand-file-name fname
))
1666 (fname-list (split-string (if (or (string= fname
"~/") expand
)
1667 exp-fname fname
) "/" t
))
1668 (len (length fname-list
))
1669 (pop-list (if (< level
0)
1670 (subseq fname-list
(* level -
1))
1671 (subseq fname-list
0 (- len level
))))
1672 (result (mapconcat 'identity pop-list
"/"))
1673 (empty (string= result
"")))
1674 (when unix-close
(setq result
(concat result
"/")))
1675 (if (string-match "^~" result
)
1676 (if (string= result
"~/") "~/" result
)
1678 (if empty
"../" (concat "../" result
))
1679 (cond ((eq system-type
'windows-nt
)
1680 (if empty
"c:/" result
))
1683 (concat "/" result
)))))))
1685 (defun anything-file-completion-source-p ()
1686 "Test if current source is a dired or find-files source."
1687 (let ((ff-sources '("Find Files" "Copy Files"
1688 "Rename Files" "Symlink Files"
1689 "Hardlink Files" "Write File"
1690 "Insert File" "Read file name"))
1691 (cur-source (cdr (assoc 'name
(anything-get-current-source)))))
1693 (dolist (i ff-sources
)
1694 (when (equal cur-source
(concat i anything-c-find-files-doc-header
))
1695 (throw 'break t
))))))
1697 (defun anything-find-files-down-one-level (arg)
1698 "Go down one level like unix command `cd ..'.
1699 If prefix numeric arg is given go ARG level down."
1701 (when (anything-file-completion-source-p)
1702 (let ((new-pattern (anything-reduce-file-name anything-pattern arg
1703 :unix-close t
:expand t
)))
1704 (with-selected-window (minibuffer-window)
1705 (delete-minibuffer-contents)
1706 (insert new-pattern
)))))
1708 ;; `C-.' doesn't work in terms use `C-l' instead.
1710 (define-key anything-map
(kbd "C-.") 'anything-find-files-down-one-level
)
1711 (define-key anything-map
(kbd "C-l") 'anything-find-files-down-one-level
))
1713 (defun anything-c-point-file-in-dired (file)
1714 "Put point on filename FILE in dired buffer."
1715 (dired (file-name-directory file
))
1716 (dired-goto-file file
))
1718 (defun anything-create-tramp-name (fname)
1719 "Build filename for `anything-pattern' like /su:: or /sudo::."
1720 (apply #'tramp-make-tramp-file-name
1722 with v
= (tramp-dissect-file-name fname
)
1723 for i across v collect i
)))
1725 (defun anything-find-files-get-candidates ()
1726 "Create candidate list for `anything-c-source-find-files'."
1727 (let* ( ; Don't try to tramp connect before entering the second ":".
1728 (tramp-file-name-regexp "\\`/\\([^[/:]+\\|[^/]+]\\):.*:?")
1729 (path (cond ((string-match "^~" anything-pattern
)
1730 (replace-match (getenv "HOME") nil t anything-pattern
))
1731 ((string-match tramp-file-name-regexp anything-pattern
)
1732 (let ((tramp-name (anything-create-tramp-name
1733 (match-string 0 anything-pattern
))))
1734 (replace-match tramp-name nil t anything-pattern
)))
1735 (t anything-pattern
)))
1736 (tramp-verbose anything-tramp-verbose
)) ; No tramp message when 0.
1737 ;; Inlined version (<2010-02-18 Jeu.>.) of `tramp-handle-directory-files'
1738 ;; to fix bug in tramp that doesn't show the dot file names(i.e "." "..")
1740 (flet ((tramp-handle-directory-files
1741 (directory &optional full match nosort files-only
)
1742 "Like `directory-files' for Tramp files."
1743 ;; FILES-ONLY is valid for XEmacs only.
1744 (when (file-directory-p directory
)
1745 (setq directory
(file-name-as-directory (expand-file-name directory
)))
1746 (let ((temp (nreverse (file-name-all-completions "" directory
)))
1750 (setq item
(directory-file-name (pop temp
)))
1751 (when (and (or (null match
) (string-match match item
))
1752 (or (null files-only
)
1754 (and (equal files-only t
) (file-regular-p item
))
1755 ;; Directories only.
1756 (file-directory-p item
)))
1757 (push (if full
(concat directory item
) item
)
1759 (if nosort result
(sort result
'string
<))))))
1761 (set-text-properties 0 (length path
) nil path
)
1762 (setq anything-pattern path
)
1763 (cond ((or (file-regular-p path
)
1764 (and ffap-url-regexp
(string-match ffap-url-regexp path
)))
1766 ((string= anything-pattern
"") (directory-files "/" t
))
1767 ((file-directory-p path
) (directory-files path t
))
1771 (directory-files (file-name-directory path
) t
)))))))
1773 (defface anything-dired-symlink-face
1774 '((t (:foreground
"DarkOrange")))
1775 "*Face used for symlinks in `anything-find-files'."
1778 (defun anything-c-highlight-ffiles (files)
1779 "Candidate transformer for `anything-c-source-find-files'."
1780 (loop for i in files
1781 if
(file-symlink-p i
)
1782 collect
(propertize i
'face
'anything-dired-symlink-face
1783 'help-echo
(file-truename i
)) into a
1784 if
(file-directory-p i
)
1785 collect
(propertize i
'face anything-c-files-face1
) into a
1787 collect
(propertize i
'face anything-c-files-face2
) into a
1791 (defun anything-find-files-persistent-action (candidate)
1792 "Open subtree CANDIDATE without quitting anything.
1793 If CANDIDATE is not a directory expand CANDIDATE filename.
1794 If CANDIDATE is alone, open file CANDIDATE filename."
1795 (flet ((insert-in-minibuffer (elm)
1796 (with-selected-window (minibuffer-window)
1797 (delete-minibuffer-contents)
1798 (set-text-properties 0 (length elm
) nil elm
)
1800 (cond ((and (file-directory-p candidate
) (file-symlink-p candidate
))
1801 (insert-in-minibuffer (file-name-as-directory
1803 (expand-file-name candidate
)))))
1804 ((file-directory-p candidate
)
1805 (insert-in-minibuffer (file-name-as-directory
1806 (expand-file-name candidate
))))
1807 ((file-symlink-p candidate
)
1808 (insert-in-minibuffer (file-truename candidate
)))
1809 (t ; First hit on C-z expand CANDIDATE second hit open file.
1810 (let ((new-pattern (anything-get-selection anything-last-buffer
))
1811 (num-lines-buf (with-current-buffer anything-last-buffer
1812 (count-lines (point-min) (point-max)))))
1813 (if (> num-lines-buf
3)
1814 (insert-in-minibuffer new-pattern
) (find-file candidate
)))))))
1816 (defun anything-c-insert-file-name-completion-at-point (candidate)
1817 "Insert file name completion at point."
1818 (if buffer-read-only
1819 (error "Error: Buffer `%s' is read-only" (buffer-name))
1820 (let* ((end (point))
1821 (guess (thing-at-point 'filename
))
1822 (full-path-p (or (string-match (concat "^" (getenv "HOME")) guess
)
1823 (string-match "^[^\~]" guess
))))
1824 (set-text-properties 0 (length candidate
) nil candidate
)
1825 (if (and guess
(not (string= guess
"")) (string-match "^~\\|/.*" guess
))
1827 (search-backward guess
(- (point) (length guess
)))
1828 (delete-region (point) end
)
1830 (insert (expand-file-name candidate
))
1831 (insert (abbreviate-file-name candidate
))))
1832 (error "Aborting completion: No valid file name at point")))))
1835 (defun anything-find-files ()
1836 "Preconfigured `anything' for anything implementation of `find-file'."
1838 (anything 'anything-c-source-find-files
1839 (anything-find-files-input (ffap-guesser)
1840 (thing-at-point 'filename
))
1841 "Find Files or Url: " nil nil
"*Anything Find Files*"))
1843 (defun anything-c-current-directory ()
1844 "Return current-directory name at point.
1845 Useful in dired buffers when there is inserted subdirs."
1846 (if (eq major-mode
'dired-mode
)
1847 (dired-current-directory)
1850 (defun anything-find-files-input (fap tap
)
1851 "Default input of `anything-find-files'."
1852 (let* ((def-dir (anything-c-current-directory))
1853 (file-p (and fap
(file-exists-p fap
)
1855 (file-name-directory (expand-file-name tap def-dir
)))))
1856 (input (if file-p
(expand-file-name tap def-dir
) fap
)))
1857 (or input
(expand-file-name def-dir
))))
1859 ;;; Anything completion for `write-file'.==> C-x C-w
1860 (defvar anything-c-source-write-file
1861 `((name .
,(concat "Write File" anything-c-find-files-doc-header
))
1862 ;; It is needed for filenames with capital letters
1864 (candidates . anything-find-files-get-candidates
)
1865 (candidate-transformer anything-c-highlight-ffiles
)
1866 (persistent-action . anything-find-files-persistent-action
)
1867 (persistent-help .
"Expand Candidate")
1870 (("Write File" .
(lambda (candidate)
1871 (write-file candidate
'confirm
)))))))
1874 (defun anything-write-file ()
1875 "Preconfigured `anything' providing completion for `write-file'."
1877 (anything 'anything-c-source-write-file
1878 (expand-file-name default-directory
)
1879 "Write buffer to file: " nil nil
"*Anything write file*"))
1881 ;;; Anything completion for `insert-file'.==> C-x i
1882 (defvar anything-c-source-insert-file
1883 `((name .
,(concat "Insert File" anything-c-find-files-doc-header
))
1884 ;; It is needed for filenames with capital letters
1886 (candidates . anything-find-files-get-candidates
)
1887 (candidate-transformer anything-c-highlight-ffiles
)
1888 (persistent-action . anything-find-files-persistent-action
)
1889 (persistent-help .
"Expand Candidate")
1892 (("Insert File" .
(lambda (candidate)
1893 (when (y-or-n-p (format "Really insert %s in %s "
1894 candidate anything-current-buffer
))
1895 (insert-file-contents candidate
))))))))
1898 (defun anything-insert-file ()
1899 "Preconfigured `anything' providing completion for `insert-file'."
1901 (anything 'anything-c-source-insert-file
1902 (expand-file-name default-directory
)
1903 "Insert file: " nil nil
"*Anything insert file*"))
1905 ;;; Anything completion for copy, rename and (rel)sym/hard/link files from dired.
1906 (defvar anything-c-source-copy-files
1907 `((name .
,(concat "Copy Files" anything-c-find-files-doc-header
))
1908 ;; It is needed for filenames with capital letters
1910 (candidates . anything-find-files-get-candidates
)
1911 (candidate-transformer anything-c-highlight-ffiles
)
1912 (persistent-action . anything-find-files-persistent-action
)
1913 (persistent-help .
"Expand Candidate")
1917 .
(lambda (candidate)
1918 (anything-dired-action candidate
:action
'copy
)))
1920 .
(lambda (candidate)
1921 (anything-dired-action candidate
:action
'copy
:follow t
)))))))
1924 (defvar anything-c-source-rename-files
1925 `((name .
,(concat "Rename Files" anything-c-find-files-doc-header
))
1926 ;; It is needed for filenames with capital letters
1928 (candidates . anything-find-files-get-candidates
)
1929 (candidate-transformer anything-c-highlight-ffiles
)
1930 (persistent-action . anything-find-files-persistent-action
)
1931 (persistent-help .
"Expand Candidate")
1935 .
(lambda (candidate)
1936 (anything-dired-action candidate
:action
'rename
)))
1937 ("Rename and Follow"
1938 .
(lambda (candidate)
1939 (anything-dired-action candidate
:action
'rename
:follow t
)))))))
1941 (defvar anything-c-source-symlink-files
1942 `((name .
,(concat "Symlink Files" anything-c-find-files-doc-header
))
1943 ;; It is needed for filenames with capital letters
1945 (candidates . anything-find-files-get-candidates
)
1946 (candidate-transformer anything-c-highlight-ffiles
)
1947 (persistent-action . anything-find-files-persistent-action
)
1948 (persistent-help .
"Expand Candidate")
1952 .
(lambda (candidate)
1953 (anything-dired-action candidate
:action
'symlink
)))
1955 .
(lambda (candidate)
1956 (anything-dired-action candidate
:action
'relsymlink
)))))))
1959 (defvar anything-c-source-hardlink-files
1960 `((name .
,(concat "Hardlink Files" anything-c-find-files-doc-header
))
1961 ;; It is needed for filenames with capital letters
1963 (candidates . anything-find-files-get-candidates
)
1964 (candidate-transformer anything-c-highlight-ffiles
)
1965 (persistent-action . anything-find-files-persistent-action
)
1966 (persistent-help .
"Expand Candidate")
1970 .
(lambda (candidate)
1971 (anything-dired-action candidate
:action
'hardlink
)))))))
1973 (defun* anything-dired-action
(candidate &key action follow
)
1974 "Copy, rename or symlink file at point or marked files in dired to CANDIDATE.
1975 ACTION is a key that can be one of 'copy, 'rename, 'symlink, 'relsymlink."
1976 (let ((files (dired-get-marked-files))
1978 ('copy
'dired-copy-file
)
1979 ('rename
'dired-rename-file
)
1980 ('symlink
'make-symbolic-link
)
1981 ('relsymlink
'dired-make-relative-symlink
)
1982 ('hardlink
'dired-hardlink
)))
1983 (marker (case action
1984 ((copy rename
) dired-keep-marker-copy
)
1985 ('symlink dired-keep-marker-symlink
)
1986 ('relsymlink dired-keep-marker-relsymlink
)
1987 ('hardlink dired-keep-marker-hardlink
))))
1989 fn
(symbol-name action
) files
1990 (if (file-directory-p candidate
)
1991 ;; When CANDIDATE is a directory, build file-name in this directory.
1992 ;; Else we use CANDIDATE.
1994 (expand-file-name (file-name-nondirectory from
) candidate
))
1995 #'(lambda (from) candidate
))
1998 (let* ((src (car files
))
1999 (dest (expand-file-name candidate
))
2000 (basename-src (if (file-directory-p src
)
2002 (directory-file-name src
)
2003 (file-name-directory src
))
2004 (file-name-nondirectory src
)))
2005 (fname (if (file-directory-p dest
)
2006 (concat (file-name-as-directory dest
)
2009 (anything-c-point-file-in-dired fname
)))))
2012 (defun* anything-dired-do-action-on-file
(&key action
)
2013 (let* ((files (dired-get-marked-files))
2014 (len (length files
))
2015 (fname (if (> len
1)
2016 (format "* %d Files" len
)
2018 (source (case action
2019 ('copy
'anything-c-source-copy-files
)
2020 ('rename
'anything-c-source-rename-files
)
2021 ('symlink
'anything-c-source-symlink-files
)
2022 ('hardlink
'anything-c-source-hardlink-files
)))
2023 (prompt-fm (case action
2024 ('copy
"Copy %s to: ")
2025 ('rename
"Rename %s to: ")
2026 ('symlink
"Symlink %s to: ")
2027 ('hardlink
"Hardlink %s to: ")))
2028 (buffer (case action
2029 ('copy
"*Anything Copy Files*")
2030 ('rename
"*Anything Rename Files*")
2031 ('symlink
"*Anything Symlink Files*")
2032 ('hardlink
"*Anything Hardlink Files*"))))
2034 (or (dired-dwim-target-directory)
2035 (expand-file-name (anything-c-current-directory)))
2036 (format prompt-fm fname
) nil nil buffer
)))
2040 (defun anything-dired-rename-file ()
2041 "Preconfigured `anything' to rename files from dired."
2043 (anything-dired-do-action-on-file :action
'rename
))
2046 (defun anything-dired-copy-file ()
2047 "Preconfigured `anything' to copy files from dired."
2049 (anything-dired-do-action-on-file :action
'copy
))
2052 (defun anything-dired-symlink-file ()
2053 "Preconfigured `anything' to symlink files from dired."
2055 (anything-dired-do-action-on-file :action
'symlink
))
2058 (defun anything-dired-hardlink-file ()
2059 "Preconfigured `anything' to hardlink files from dired."
2061 (anything-dired-do-action-on-file :action
'hardlink
))
2063 (defvar anything-dired-bindings nil
)
2065 (defun anything-dired-bindings (&optional arg
)
2066 "Replace usual dired commands `C' and `R' by anything ones.
2067 When call interactively toggle dired bindings and anything bindings.
2068 When call non--interactively with arg > 0, enable anything bindings.
2069 You can put (anything-dired-binding 1) in init file to enable anything bindings."
2071 (if (or (when arg
(> arg
0)) (not anything-dired-bindings
))
2073 (define-key dired-mode-map
(kbd "C") 'anything-dired-copy-file
)
2074 (define-key dired-mode-map
(kbd "R") 'anything-dired-rename-file
)
2075 (define-key dired-mode-map
(kbd "S") 'anything-dired-symlink-file
)
2076 (define-key dired-mode-map
(kbd "H") 'anything-dired-hardlink-file
)
2077 (setq anything-dired-bindings t
))
2078 (define-key dired-mode-map
(kbd "C") 'dired-do-copy
)
2079 (define-key dired-mode-map
(kbd "R") 'dired-do-rename
)
2080 (define-key dired-mode-map
(kbd "S") 'dired-do-symlink
)
2081 (define-key dired-mode-map
(kbd "H") 'dired-do-hardlink
)
2082 (setq anything-dired-bindings nil
)))
2084 (defun* anything-c-read-file-name
(prompt &key
2085 (initial-input (expand-file-name default-directory
))
2086 (buffer "*Anything Completions*")
2088 "Anything `read-file-name' emulation.
2089 INITIAL-INPUT is a valid path, TEST is a predicate that take one arg."
2090 (when (get-buffer anything-action-buffer
)
2091 (kill-buffer anything-action-buffer
))
2093 `((name .
,(concat "Read file name" anything-c-find-files-doc-header
))
2094 ;; It is needed for filenames with capital letters
2096 (candidates .
(lambda ()
2098 (loop with seq
= (anything-find-files-get-candidates)
2099 for fname in seq when
(funcall test fname
)
2101 (anything-find-files-get-candidates))))
2102 (candidate-transformer anything-c-highlight-ffiles
)
2103 (persistent-action . anything-find-files-persistent-action
)
2104 (persistent-help .
"Expand Candidate")
2106 (action .
(("candidate" .
,'identity
))))
2107 initial-input prompt
'noresume nil buffer
)
2111 (defvar anything-c-source-file-cache-initialized nil
)
2113 (defvar anything-c-file-cache-files nil
)
2115 (defvar anything-c-source-file-cache
2116 '((name .
"File Cache")
2119 (require 'filecache nil t
)
2120 (unless anything-c-source-file-cache-initialized
2121 (setq anything-c-file-cache-files
2122 (loop for item in file-cache-alist append
2123 (destructuring-bind (base &rest dirs
) item
2124 (loop for dir in dirs collect
2125 (concat dir base
)))))
2126 (defadvice file-cache-add-file
(after file-cache-list activate
)
2127 (add-to-list 'anything-c-file-cache-files
(expand-file-name file
)))
2128 (setq anything-c-source-file-cache-initialized t
))))
2129 (candidates . anything-c-file-cache-files
)
2130 (match anything-c-match-on-file-name
2131 anything-c-match-on-directory-name
)
2133 ;; (anything 'anything-c-source-file-cache)
2136 ;; NOTE for WINDOZE users:
2137 ;; You have to install Everything with his command line interface here:
2138 ;; http://www.voidtools.com/download.php
2140 (defvar anything-c-locate-command
2142 ('gnu
/linux
"locate -i -r %s")
2143 ('berkeley-unix
"locate -i %s")
2144 ('windows-nt
"es -i -r %s")
2146 "A list of arguments for locate program.
2147 The \"-r\" option must be the last option.")
2149 (defun anything-c-locate-init ()
2150 "Initialize async locate process for `anything-c-source-locate'."
2151 (start-process-shell-command "locate-process" nil
2152 (format anything-c-locate-command
2155 (defvar anything-c-source-locate
2157 (candidates . anything-c-locate-init
)
2159 (requires-pattern .
3)
2161 "Find files matching the current input pattern with locate.")
2163 ;; (anything 'anything-c-source-locate)
2166 (defvar anything-c-source-recentf
2167 '((name .
"Recentf")
2170 (or recentf-mode
(recentf-mode 1))
2171 ;; Big value empowers anything/recentf
2172 (when (and (numberp recentf-max-saved-items
)
2173 (<= recentf-max-saved-items
20))
2174 (setq recentf-max-saved-items
500))))
2175 (candidates . recentf-list
)
2176 (match anything-c-match-on-file-name
2177 anything-c-match-on-directory-name
)
2179 "See (info \"(emacs)File Conveniences\").
2180 if `recentf-max-saved-items' is too small, set it to 500.")
2181 ;; (anything 'anything-c-source-recentf)
2184 (eval-when-compile (require 'ffap
))
2185 (defvar anything-c-source-ffap-guesser
2186 '((name .
"File at point")
2187 (init .
(lambda () (require 'ffap
)))
2188 (candidates .
(lambda ()
2190 (with-current-buffer anything-current-buffer
2194 ;; (anything 'anything-c-source-ffap-guesser)
2196 ;;; ffap with line number
2197 (defun anything-c-ffap-file-line-at-point ()
2198 "Get (FILENAME . LINENO) at point."
2199 (anything-aif (let (ffap-alist) (ffap-file-at-point))
2202 (when (and (search-forward it nil t
)
2203 (looking-at ":\\([0-9]+\\)"))
2204 (cons it
(string-to-number (match-string 1)))))))
2206 (defvar anything-c-ffap-line-location nil
2207 "(FILENAME . LINENO) used by `anything-c-source-ffap-line'.
2208 It is cleared after jumping line.")
2210 (defun anything-c-ffap-line-candidates ()
2211 (with-current-buffer anything-current-buffer
2212 (setq anything-c-ffap-line-location
(anything-c-ffap-file-line-at-point)))
2213 (when anything-c-ffap-line-location
2214 (destructuring-bind (file . line
) anything-c-ffap-line-location
2215 (list (cons (format "%s (line %d)" file line
) file
)))))
2217 ;;; Goto line after opening file by `anything-c-source-ffap-line'.
2218 (defun anything-c-ffap-line-goto-line ()
2219 (when (car anything-c-ffap-line-location
)
2222 (with-selected-window
2224 (get-file-buffer (car anything-c-ffap-line-location
)))
2225 (anything-goto-line (cdr anything-c-ffap-line-location
)))))))
2226 (add-hook 'anything-after-action-hook
'anything-c-ffap-line-goto-line
)
2227 (add-hook 'anything-after-persistent-action-hook
'anything-c-ffap-line-goto-line
)
2229 (defvar anything-c-source-ffap-line
2230 '((name .
"File/Lineno at point")
2231 (init .
(lambda () (require 'ffap
)))
2232 (candidates . anything-c-ffap-line-candidates
)
2234 ;; (anything 'anything-c-source-ffap-line)
2236 ;;; list of files gleaned from every dired buffer
2237 (defun anything-c-files-in-all-dired-candidates ()
2241 (cond ((listp dir
) ;filelist
2243 ((equal "" (file-name-nondirectory dir
)) ;dir
2244 (directory-files dir t
))
2246 (file-expand-wildcards dir t
))))
2248 (mapcar (lambda (buf)
2250 (when (eq major-mode
'dired-mode
)
2251 (if (consp dired-directory
)
2252 (cdr dired-directory
) ;filelist
2253 dired-directory
))) ;dir or wildcard
2255 ;; (dired '("~/" "~/.emacs-custom.el" "~/.emacs.bmk"))
2257 (defvar anything-c-source-files-in-all-dired
2258 '((name .
"Files in all dired buffer.")
2259 (candidates . anything-c-files-in-all-dired-candidates
)
2261 ;; (anything 'anything-c-source-files-in-all-dired)
2265 (defvar anything-c-info-pages nil
2266 "All info pages on system.
2267 Will be calculated the first time you invoke anything with this
2270 (defvar anything-c-source-info-pages
2271 `((name .
"Info Pages")
2272 (candidates .
(lambda ()
2273 (if anything-c-info-pages
2274 anything-c-info-pages
2275 (setq anything-c-info-pages
2276 (save-window-excursion
2279 (Info-find-node "dir" "top")
2280 (goto-char (point-min))
2281 (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
2283 (while (re-search-forward info-topic-regexp nil t
)
2284 (add-to-list 'topics
(match-string-no-properties 1)))
2285 (goto-char (point-min))
2288 (action .
(("Show with Info" .
(lambda (node-str)
2289 (info (replace-regexp-in-string "^[^:]+: "
2292 (requires-pattern .
2)))
2293 ;; (anything 'anything-c-source-info-pages)
2296 ;;; Use info-index plug-in. Note that `name' attribute is
2297 ;;; not needed but `anything-c-insert-summary' uses it.
2299 (defvar anything-c-source-info-elisp
2300 '((name .
"Info index: elisp")
2301 (info-index .
"elisp")))
2302 ;; (anything 'anything-c-source-info-elisp)
2305 (defvar anything-c-source-info-cl
2306 '((name .
"Info index: cl")
2307 (info-index .
"cl")))
2308 ;; (anything 'anything-c-source-info-cl)
2311 (defvar anything-c-source-info-org
2312 '((name .
"Info index: org")
2313 (info-index .
"org")))
2314 ;; (anything 'anything-c-source-info-org)
2316 ;; Info Index ratpoison
2317 (defvar anything-c-source-info-ratpoison
2318 '((name .
"Info index: ratpoison")
2319 (info-index .
"ratpoison")))
2320 ;; (anything 'anything-c-source-info-ratpoison)
2323 (defvar anything-c-source-info-zsh
2324 '((name .
"Info index: zsh")
2325 (info-index .
"zsh")))
2326 ;; (anything 'anything-c-source-info-zsh)
2329 (defvar anything-c-source-info-bash
2330 '((name .
"Info index: bash")
2331 (info-index .
"bash")))
2332 ;; (anything 'anything-c-source-info-bash)
2334 ;; Info Index coreutils
2335 (defvar anything-c-source-info-coreutils
2336 '((name .
"Info index: coreutils")
2337 (info-index .
"coreutils")))
2338 ;; (anything 'anything-c-source-info-coreutils)
2340 ;; Info Index fileutils
2341 (defvar anything-c-source-info-fileutils
2342 '((name .
"Info index: fileutils")
2343 (info-index .
"fileutils")))
2344 ;; (anything 'anything-c-source-info-fileutils)
2347 (defvar anything-c-source-info-find
2348 '((name .
"Info index: find")
2349 (info-index .
"find")))
2350 ;; (anything 'anything-c-source-info-find)
2352 ;; Info Index sh-utils
2353 (defvar anything-c-source-info-sh-utils
2354 '((name .
"Info index: sh-utils")
2355 (info-index .
"sh-utils")))
2356 ;; (anything 'anything-c-source-info-sh-utils)
2358 ;; Info Index textutils
2359 (defvar anything-c-source-info-textutils
2360 '((name .
"Info index: textutils")
2361 (info-index .
"textutils")))
2362 ;; (anything 'anything-c-source-info-textutils)
2365 (defvar anything-c-source-info-libc
2366 '((name .
"Info index: libc")
2367 (info-index .
"libc")))
2368 ;; (anything 'anything-c-source-info-libc)
2371 (defvar anything-c-source-info-make
2372 '((name .
"Info index: make")
2373 (info-index .
"make")))
2374 ;; (anything 'anything-c-source-info-make)
2376 ;; Info Index automake
2377 (defvar anything-c-source-info-automake
2378 '((name .
"Info index: automake")
2379 (info-index .
"automake")))
2380 ;; (anything 'anything-c-source-info-automake)
2382 ;; Info Index autoconf
2383 (defvar anything-c-source-info-autoconf
2384 '((name .
"Info index: autoconf")
2385 (info-index .
"autoconf")))
2386 ;; (anything 'anything-c-source-info-autoconf)
2388 ;; Info Index emacs-lisp-intro
2389 (defvar anything-c-source-info-emacs-lisp-intro
2390 '((name .
"Info index: emacs-lisp-intro")
2391 (info-index .
"emacs-lisp-intro")))
2392 ;; (anything 'anything-c-source-info-emacs-lisp-intro)
2395 (defvar anything-c-source-info-emacs
2396 '((name .
"Info index: emacs")
2397 (info-index .
"emacs")))
2398 ;; (anything 'anything-c-source-info-emacs)
2401 (defvar anything-c-source-info-elib
2402 '((name .
"Info index: elib")
2403 (info-index .
"elib")))
2404 ;; (anything 'anything-c-source-info-elib)
2407 (defvar anything-c-source-info-eieio
2408 '((name .
"Info index: eieio")
2409 (info-index .
"eieio")))
2410 ;; (anything 'anything-c-source-info-eieio)
2412 ;; Info Index gauche-refe
2413 (defvar anything-c-source-info-gauche-refe
2414 '((name .
"Info index: gauche")
2415 (info-index .
"gauche-refe")))
2416 ;; (anything 'anything-c-source-info-gauche-refe)
2419 (defvar anything-c-source-info-guile
2420 '((name .
"Info index: guile")
2421 (info-index .
"guile")))
2422 ;; (anything 'anything-c-source-info-guile)
2424 ;; Info Index guile-tut
2425 (defvar anything-c-source-info-guile-tut
2426 '((name .
"Info index: guile-tut")
2427 (info-index .
"guile-tut")))
2428 ;; (anything 'anything-c-source-info-guile-tut)
2431 (defvar anything-c-source-info-goops
2432 '((name .
"Info index: goops")
2433 (info-index .
"goops")))
2434 ;; (anything 'anything-c-source-info-goops)
2436 ;; Info Index screen
2437 (defvar anything-c-source-info-screen
2438 '((name .
"Info index: screen")
2439 (info-index .
"screen")
2440 (index-nodes "Concept Index" "Command Index" "Keystroke Index")))
2441 ;; (anything 'anything-c-source-info-screen)
2444 (defvar anything-c-source-info-latex
2445 '((name .
"Info index: latex")
2446 (info-index .
"latex")))
2447 ;; (anything 'anything-c-source-info-latex)
2450 (defvar anything-c-source-info-gawk
2451 '((name .
"Info index: gawk")
2452 (info-index .
"gawk")))
2453 ;; (anything 'anything-c-source-info-gawk)
2456 (defvar anything-c-source-info-sed
2457 '((name .
"Info index: sed")
2458 (info-index .
"sed")))
2459 ;; (anything 'anything-c-source-info-sed)
2462 (defvar anything-c-source-info-m4
2463 '((name .
"Info index: m4")
2464 (info-index .
"m4")))
2465 ;; (anything 'anything-c-source-info-m4)
2468 (defvar anything-c-source-info-wget
2469 '((name .
"Info index: wget")
2470 (info-index .
"wget")))
2471 ;; (anything 'anything-c-source-info-wget)
2473 ;; Info Index binutils
2474 (defvar anything-c-source-info-binutils
2475 '((name .
"Info index: binutils")
2476 (info-index .
"binutils")))
2477 ;; (anything 'anything-c-source-info-binutils)
2480 (defvar anything-c-source-info-as
2481 '((name .
"Info index: as")
2482 (info-index .
"as")))
2483 ;; (anything 'anything-c-source-info-as)
2486 (defvar anything-c-source-info-bfd
2487 '((name .
"Info index: bfd")
2488 (info-index .
"bfd")))
2489 ;; (anything 'anything-c-source-info-bfd)
2492 (defvar anything-c-source-info-gprof
2493 '((name .
"Info index: gprof")
2494 (info-index .
"gprof")))
2495 ;; (anything 'anything-c-source-info-gprof)
2498 (defvar anything-c-source-info-ld
2499 '((name .
"Info index: ld")
2500 (info-index .
"ld")))
2501 ;; (anything 'anything-c-source-info-ld)
2504 (defvar anything-c-source-info-diff
2505 '((name .
"Info index: diff")
2506 (info-index .
"diff")))
2507 ;; (anything 'anything-c-source-info-diff)
2510 (defvar anything-c-source-info-flex
2511 '((name .
"Info index: flex")
2512 (info-index .
"flex")))
2513 ;; (anything 'anything-c-source-info-flex)
2516 (defvar anything-c-source-info-grep
2517 '((name .
"Info index: grep")
2518 (info-index .
"grep")))
2519 ;; (anything 'anything-c-source-info-grep)
2522 (defvar anything-c-source-info-gzip
2523 '((name .
"Info index: gzip")
2524 (info-index .
"gzip")))
2525 ;; (anything 'anything-c-source-info-gzip)
2527 ;; Info Index libtool
2528 (defvar anything-c-source-info-libtool
2529 '((name .
"Info index: libtool")
2530 (info-index .
"libtool")))
2531 ;; (anything 'anything-c-source-info-libtool)
2533 ;; Info Index texinfo
2534 (defvar anything-c-source-info-texinfo
2535 '((name .
"Info index: texinfo")
2536 (info-index .
"texinfo")))
2537 ;; (anything 'anything-c-source-info-texinfo)
2540 (defvar anything-c-source-info-info
2541 '((name .
"Info index: info")
2542 (info-index .
"info")))
2543 ;; (anything 'anything-c-source-info-info)
2546 (defvar anything-c-source-info-gdb
2547 '((name .
"Info index: gdb")
2548 (info-index .
"gdb")))
2549 ;; (anything 'anything-c-source-info-gdb)
2552 (defvar anything-c-source-info-stabs
2553 '((name .
"Info index: stabs")
2554 (info-index .
"stabs")))
2555 ;; (anything 'anything-c-source-info-stabs)
2557 ;; Info Index cvsbook
2558 (defvar anything-c-source-info-cvsbook
2559 '((name .
"Info index: cvsbook")
2560 (info-index .
"cvsbook")))
2561 ;; (anything 'anything-c-source-info-cvsbook)
2564 (defvar anything-c-source-info-cvs
2565 '((name .
"Info index: cvs")
2566 (info-index .
"cvs")))
2567 ;; (anything 'anything-c-source-info-cvs)
2570 (defvar anything-c-source-info-bison
2571 '((name .
"Info index: bison")
2572 (info-index .
"bison")))
2573 ;; (anything 'anything-c-source-info-bison)
2575 ;; Info Index id-utils
2576 (defvar anything-c-source-info-id-utils
2577 '((name .
"Info index: id-utils")
2578 (info-index .
"id-utils")))
2579 ;; (anything 'anything-c-source-info-id-utils)
2581 ;; Info Index global
2582 (defvar anything-c-source-info-global
2583 '((name .
"Info index: global")
2584 (info-index .
"global")))
2585 ;; (anything 'anything-c-source-info-global)
2589 (defvar anything-c-man-pages nil
2590 "All man pages on system.
2591 Will be calculated the first time you invoke anything with this
2594 (defvar anything-c-source-man-pages
2595 `((name .
"Manual Pages")
2596 (candidates .
(lambda ()
2597 (if anything-c-man-pages
2598 anything-c-man-pages
2599 ;; XEmacs doesn't have a woman :)
2600 (setq anything-c-man-pages
2603 (woman-file-name "")
2604 (sort (mapcar 'car woman-topic-all-completions
)
2606 (action ("Show with Woman" .
(lambda (candidate)
2607 (let ((wfiles (woman-file-name-all-completions candidate
)))
2608 (if (> (length wfiles
) 1)
2609 (woman-find-file (anything-comp-read "ManFile: " wfiles
2611 (woman candidate
))))))
2612 ;; Woman does not work OS X
2613 ;; http://xahlee.org/emacs/modernization_man_page.html
2614 (action-transformer .
(lambda (actions candidate
)
2615 (if (eq system-type
'darwin
)
2616 '(("Show with Man" . man
))
2618 (requires-pattern .
2)))
2619 ;; (anything 'anything-c-source-man-pages)
2622 ;;; Complex command history
2623 (defvar anything-c-source-complex-command-history
2624 '((name .
"Complex Command History")
2625 (candidates .
(lambda () (mapcar 'prin1-to-string command-history
)))
2627 ;; (anything 'anything-c-source-complex-command-history)
2630 (defvar anything-c-source-extended-command-history
2631 '((name .
"Emacs Commands History")
2632 (candidates . extended-command-history
)
2634 ;; (anything 'anything-c-source-extended-command-history)
2637 (defvar anything-c-source-emacs-commands
2638 '((name .
"Emacs Commands")
2639 (candidates .
(lambda ()
2641 (mapatoms (lambda (a)
2643 (push (symbol-name a
)
2645 (sort commands
'string-lessp
))))
2647 (requires-pattern .
2))
2648 "Source for completing and invoking Emacs commands.
2649 A command is a function with interactive spec that can
2650 be invoked with `M-x'.
2652 To get non-interactive functions listed, use
2653 `anything-c-source-emacs-functions'.")
2654 ;; (anything 'anything-c-source-emacs-commands)
2656 ;; Another replacement of `M-x' that act exactly like the
2657 ;; vanilla Emacs one, no problem of windows configuration, prefix args
2658 ;; are passed before calling `M-x' (e.g C-u M-x..).
2660 (defun anything-M-x ()
2661 "Preconfigured `anything' for Emacs commands.
2662 It is `anything' replacement of regular `M-x' `execute-extended-command'."
2664 (let ((command (anything-comp-read "M-x " obarray
2667 :requires-pattern
2)))
2668 (call-interactively (intern command
))))
2671 (defvar anything-c-source-lacarte
2672 '((name .
"Lacarte")
2673 (init .
(lambda () (require 'lacarte
)))
2674 (candidates .
(lambda () (delete '(nil) (lacarte-get-overall-menu-item-alist))))
2675 (candidate-number-limit .
9999)
2676 (action . anything-c-call-interactively
))
2679 http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
2680 ;; (anything 'anything-c-source-lacarte)
2684 (defvar anything-c-source-emacs-functions
2685 '((name .
"Emacs Functions")
2686 (candidates .
(lambda ()
2688 (mapatoms (lambda (a) (if (functionp a
)
2689 (push (symbol-name a
) commands
))))
2690 (sort commands
'string-lessp
))))
2692 (requires-pattern .
2))
2693 "Source for completing Emacs functions.")
2694 ;; (anything 'anything-c-source-emacs-functions)
2696 ;;; With abbrev expansion
2697 ;;; Similar to my exec-abbrev-cmd.el
2698 ;;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el
2699 (defvar anything-c-function-abbrev-regexp nil
2700 "The regexp for `anything-c-source-emacs-functions-with-abbrevs'.
2701 Regexp built from the current `anything-pattern' interpreting it
2703 Only for internal use.")
2705 (defun anything-c-match-function-by-abbrev (candidate)
2706 "Return non-nil if `anything-pattern' is an abbreviation of the function CANDIDATE.
2708 Abbreviations are made by taking the first character from each
2709 word in the function's name, e.g. \"bb\" is an abbrev for
2710 `bury-buffer', \"stb\" is an abbrev for `switch-to-buffer'."
2711 (string-match anything-c-function-abbrev-regexp candidate
))
2713 (defvar anything-c-source-emacs-functions-with-abbrevs
2714 (append anything-c-source-emacs-functions
2715 '((match anything-c-match-function-by-abbrev
2716 anything-c-string-match
))
2717 '((init .
(lambda ()
2718 (defadvice anything-update
2719 (before anything-c-update-function-abbrev-regexp activate
)
2720 (let ((char-list (append anything-pattern nil
))
2722 (dolist (c char-list
)
2723 (setq str
(concat str
(list c
) "[^-]*-")))
2724 (setq str
(concat (substring str
0 (1- (length str
))) "$"))
2725 (setq anything-c-function-abbrev-regexp str
))))))))
2726 ;; (anything 'anything-c-source-emacs-functions-with-abbrevs)
2728 (defvar anything-c-source-advice
2729 '((name .
"Function Advice")
2730 (candidates . anything-c-advice-candidates
)
2731 (action ("Toggle Enable/Disable" . anything-c-advice-toggle
))
2732 ;; (real-to-display . anything-c-advice-real-to-display)
2735 (persistent-action . anything-c-advice-persistent-action
)
2736 (persistent-help .
"Describe function / C-u C-z: Toggle advice")))
2737 ;; (anything 'anything-c-source-advice)
2738 ;; (let ((debug-on-signal t))(anything 'anything-c-source-advice))
2741 (defun anything-c-advice-candidates ()
2743 (loop for
(fname) in ad-advised-functions
2744 for function
= (intern fname
)
2746 (loop for class in ad-advice-classes append
2747 (loop for advice in
(ad-get-advice-info-field function class
)
2748 for enabled
= (ad-advice-enabled advice
)
2750 (cons (format "%s %s %s"
2751 (if enabled
"Enabled " "Disabled")
2752 (propertize fname
'face
'font-lock-function-name-face
)
2753 (ad-make-single-advice-docstring advice class nil
))
2754 (list function class advice
))))))
2756 (defun anything-c-advice-persistent-action (func-class-advice)
2757 (if current-prefix-arg
2758 (anything-c-advice-toggle func-class-advice
)
2759 (describe-function (car func-class-advice
))))
2761 (defun anything-c-advice-toggle (func-class-advice)
2762 (destructuring-bind (function class advice
) func-class-advice
2763 (cond ((ad-advice-enabled advice
)
2764 (ad-advice-set-enabled advice nil
)
2765 (message "Disabled"))
2767 (ad-advice-set-enabled advice t
)
2768 (message "Enabled")))
2769 (ad-activate function
)
2770 (and anything-in-persistent-action
2771 (anything-c-advice-update-current-display-string))))
2773 (defun anything-c-advice-update-current-display-string ()
2774 (anything-edit-current-selection
2775 (let ((newword (cond ((looking-at "Disabled") "Enabled")
2776 ((looking-at "Enabled") "Disabled")))
2779 (delete-region (point) (progn (forward-word 1) (point)))
2780 (insert newword
)))))
2783 (defun anything-manage-advice ()
2784 "Preconfigured `anything' to disable/enable function advices."
2786 (anything-other-buffer 'anything-c-source-advice
"*anything advice*"))
2790 (defvar anything-c-source-emacs-variables
2791 '((name .
"Emacs Variables")
2792 (candidates .
(lambda ()
2793 (sort (all-completions "" obarray
'boundp
) 'string-lessp
)))
2795 (requires-pattern .
2))
2796 "Source for completing Emacs variables.")
2797 ;; (anything 'anything-c-source-emacs-variables)
2801 (eval-when-compile (require 'bookmark
))
2802 (defvar anything-c-source-bookmarks
2803 '((name .
"Bookmarks")
2805 (require 'bookmark
)))
2806 (candidates . bookmark-all-names
)
2808 "See (info \"(emacs)Bookmarks\").")
2809 ;; (anything 'anything-c-source-bookmarks)
2812 (defvar anything-c-source-bookmark-set
2813 '((name .
"Set Bookmark")
2815 (action . bookmark-set
))
2816 "See (info \"(emacs)Bookmarks\").")
2817 ;; (anything 'anything-c-source-bookmark-set)
2819 ;;; Visible Bookmarks
2820 ;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el")
2823 ;; http://d.hatena.ne.jp/grandVin/20080911/1221114327
2824 (defvar anything-c-source-bm
2825 '((name .
"Visible Bookmarks")
2826 (init . anything-c-bm-init
)
2827 (candidates-in-buffer)
2831 http://www.nongnu.org/bm/")
2833 (defun anything-c-bm-init ()
2834 "Init function for `anything-c-source-bm'."
2835 (when (require 'bm nil t
)
2837 (let ((bookmarks (bm-lists))
2838 (buf (anything-candidate-buffer 'global
)))
2839 (dolist (bm (sort* (append (car bookmarks
) (cdr bookmarks
))
2840 '< :key
'overlay-start
))
2841 (let ((start (overlay-start bm
))
2842 (end (overlay-end bm
))
2843 (annotation (or (overlay-get bm
'annotation
) "")))
2844 (unless (< (- end start
) 1) ; org => (if (< (- end start) 2)
2845 (let ((str (format "%5d: [%s]: %s\n"
2846 (line-number-at-pos start
)
2848 (buffer-substring start
(1- end
)))))
2849 (with-current-buffer buf
(insert str
))))))))))
2851 ;;; Special bookmarks
2852 (defvar anything-c-source-bookmarks-ssh
2853 '((name .
"Bookmarks-ssh")
2855 (require 'bookmark
)))
2856 (candidates .
(lambda () (anything-c-collect-bookmarks :ssh t
)))
2858 "See (info \"(emacs)Bookmarks\").")
2859 ;; (anything 'anything-c-source-bookmarks-ssh)
2861 (defvar anything-c-source-bookmarks-su
2862 '((name .
"Bookmarks-root")
2864 (require 'bookmark
)))
2865 (candidates .
(lambda () (anything-c-collect-bookmarks :su t
)))
2866 (filtered-candidate-transformer anything-c-highlight-bookmark-su
)
2869 "See (info \"(emacs)Bookmarks\").")
2870 ;; (anything 'anything-c-source-bookmarks-su)
2872 (defvar anything-c-source-bookmarks-local
2873 '((name .
"Bookmarks-Local")
2875 (require 'bookmark
)))
2876 (candidates .
(lambda () (anything-c-collect-bookmarks :local t
)))
2877 (filtered-candidate-transformer
2878 anything-c-adaptive-sort
2879 anything-c-highlight-bookmark
)
2881 "See (info \"(emacs)Bookmarks\").")
2882 ;; (anything 'anything-c-source-bookmarks-local)
2884 (defun* anything-c-collect-bookmarks
(&key local su sudo ssh
)
2885 (let* ((lis-all (bookmark-all-names))
2886 (lis-loc (cond (local (loop for i in lis-all
2887 unless
(string-match "^(ssh)\\|^(su)" i
)
2889 (su (loop for i in lis-all
2890 when
(string-match "^(su)" i
)
2892 (sudo (loop for i in lis-all
2893 when
(string-match "^(sudo)" i
)
2895 (ssh (loop for i in lis-all
2896 when
(string-match "^(ssh)" i
)
2898 (sort lis-loc
'string-lessp
)))
2900 (defun anything-c-bookmark-root-logged-p ()
2902 (dolist (i (mapcar #'buffer-name
(buffer-list)))
2903 (when (string-match (format "*tramp/%s ." anything-su-or-sudo
) i
)
2904 (throw 'break t
)))))
2906 (defun anything-c-highlight-bookmark-su (files source
)
2907 (if (anything-c-bookmark-root-logged-p)
2908 (anything-c-highlight-bookmark files source
)
2909 (anything-c-highlight-not-logged files source
)))
2911 (defun anything-c-highlight-not-logged (files source
)
2912 (loop for i in files
2913 collect
(propertize i
'face anything-c-bookmarks-face3
)))
2915 (defun anything-c-highlight-bookmark (bookmarks source
)
2916 "Used as `candidate-transformer' to colorize bookmarks.
2917 Work both with standard Emacs bookmarks and bookmark-extensions.el."
2918 (loop for i in bookmarks
2919 for pred
= (bookmark-get-filename i
)
2920 for bufp
= (and (fboundp 'bmkext-get-buffer-name
)
2921 (bmkext-get-buffer-name i
))
2922 for handlerp
= (and (fboundp 'bookmark-get-handler
)
2923 (bookmark-get-handler i
))
2924 for isw3m
= (and (fboundp 'bmkext-w3m-bookmark-p
)
2925 (bmkext-w3m-bookmark-p i
))
2926 for isgnus
= (and (fboundp 'bmkext-gnus-bookmark-p
)
2927 (bmkext-gnus-bookmark-p i
))
2928 for isman
= (and (fboundp 'bmkext-man-bookmark-p
) ; Man
2929 (bmkext-man-bookmark-p i
))
2930 for iswoman
= (and (fboundp 'bmkext-woman-bookmark-p
) ; Woman
2931 (bmkext-woman-bookmark-p i
))
2932 for handlerp
= (bookmark-get-handler i
)
2933 for isannotation
= (bookmark-get-annotation i
)
2934 for isabook
= (string= (bookmark-prop-get i
'type
) "addressbook")
2935 ;; Add a * if bookmark have annotation
2936 if
(and isannotation
(not (string-equal isannotation
"")))
2937 do
(setq i
(concat "*" i
))
2939 if
(eq handlerp
'Info-bookmark-jump
)
2940 collect
(propertize i
'face
'anything-bmkext-info
'help-echo pred
)
2943 collect
(propertize i
'face
'anything-bmkext-w3m
'help-echo pred
)
2946 collect
(propertize i
'face
'anything-bmkext-gnus
'help-echo pred
)
2948 if
(or iswoman isman
)
2949 collect
(propertize i
'face
'anything-bmkext-man
'help-echo pred
)
2951 if
(and (not pred
) isabook
)
2952 collect
(propertize i
'face
'((:foreground
"Tomato")))
2954 if
(and pred
(file-directory-p pred
))
2955 collect
(propertize i
'face anything-c-bookmarks-face1
'help-echo pred
)
2957 if
(and pred
(not (file-directory-p pred
)) (file-exists-p pred
)
2958 (not (or iswoman isman
)))
2959 collect
(propertize i
'face
'anything-bmkext-file
'help-echo pred
)))
2962 ;;; Faces for bookmarks
2963 (defface anything-bmkext-info
2964 '((t (:foreground
"green")))
2965 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2968 (defface anything-bmkext-w3m
2969 '((t (:foreground
"yellow")))
2970 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2973 (defface anything-bmkext-gnus
2974 '((t (:foreground
"magenta")))
2975 "*Face used for Gnus bookmarks."
2978 (defface anything-bmkext-man
2979 '((t (:foreground
"Orange4")))
2980 "*Face used for Woman/man bookmarks."
2983 (defface anything-bmkext-no--file
2984 '((t (:foreground
"grey")))
2985 "*Face used for non--file bookmarks."
2988 (defface anything-bmkext-file
2989 '((t (:foreground
"Deepskyblue2")))
2990 "*Face used for non--file bookmarks."
2993 (defface anything-bookmarks-su-face
'((t (:foreground
"red")))
2994 "Face for su/sudo bookmarks."
2997 (defvar anything-c-bookmarks-face1
'anything-dir-heading
)
2998 (defvar anything-c-bookmarks-face2
'anything-file-name
)
2999 (defvar anything-c-bookmarks-face3
'anything-bookmarks-su-face
)
3002 ;;; Sources to filter bookmark-extensions bookmarks.
3003 ;; Dependency: http://mercurial.intuxication.org/hg/emacs-bookmark-extension
3004 ;; If you want to enable google-maps in addressbook you will need
3005 ;; Julien Danjou google-maps-el package available here:
3006 ;; http://julien.danjou.info/google-maps-el.html
3008 (defun anything-c-bmkext-filter-setup-alist (fn &rest args
)
3009 "Return a filtered `bookmark-alist' sorted alphabetically."
3011 with alist
= (if args
3012 (apply #'(lambda (x) (funcall fn x
)) args
)
3017 finally return
(sort sa
'string-lessp
)))
3020 (defvar anything-c-source-bmkext-addressbook
3021 '((name .
"Bookmark Addressbook")
3023 (require 'bookmark-extensions
)
3024 (bookmark-maybe-load-default-file)))
3025 (candidates . anything-c-bmkext-addressbook-setup-alist
)
3027 .
(lambda (candidate)
3028 (let ((bmk (anything-bookmark-get-bookmark-from-name
3030 (bookmark--jump-via bmk
'pop-to-buffer
))))
3031 (persistent-help .
"Show contact - Prefix with C-u to append")
3032 (filtered-candidate-transformer
3033 anything-c-adaptive-sort
3034 anything-c-highlight-bookmark
)
3035 (action .
(("Show person's data"
3036 .
(lambda (candidate)
3037 (let ((bmk (anything-bookmark-get-bookmark-from-name
3039 (current-prefix-arg anything-current-prefix-arg
))
3040 (bookmark-jump bmk
))))
3042 .
(lambda (candidate)
3043 (let ((bmk (anything-bookmark-get-bookmark-from-name
3045 (if anything-current-prefix-arg
3046 (addressbook-set-mail-buffer1 bmk
'append
)
3047 (addressbook-set-mail-buffer1 bmk
)))))
3049 .
(lambda (candidate)
3050 (let ((bmk (anything-bookmark-get-bookmark-from-name
3052 (addressbook-bookmark-edit
3053 (assoc bmk bookmark-alist
)))))
3054 ("Insert Email at point"
3055 .
(lambda (candidate)
3056 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3058 (mlist (split-string
3060 'email
(assoc bmk bookmark-alist
))
3063 (if (> (length mlist
) 1)
3065 "Insert Mail Address: " mlist
:must-match t
)
3068 .
(lambda (candidate)
3069 (let ((bmk (anything-bookmark-get-bookmark-from-name
3071 (bookmark-show-annotation bmk
))))
3073 .
(lambda (candidate)
3074 (let ((bmk (anything-bookmark-get-bookmark-from-name
3076 (bookmark-edit-annotation bmk
))))
3077 ("Show Google map" .
(lambda (candidate)
3078 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3080 (full-bmk (assoc bmk bookmark-alist
)))
3081 (addressbook-google-map full-bmk
))))))))
3084 (defun anything-c-bmkext-addressbook-setup-alist ()
3085 "Specialized filter function for bookmarks w3m."
3086 (anything-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only
))
3089 (defvar anything-c-source-bookmark-w3m
3090 '((name .
"Bookmark W3m")
3092 (require 'bookmark-extensions
)
3093 (bookmark-maybe-load-default-file)))
3094 (candidates . anything-c-bookmark-w3m-setup-alist
)
3095 (filtered-candidate-transformer
3096 anything-c-adaptive-sort
3097 anything-c-highlight-bookmark
)
3099 ;; (anything 'anything-c-source-bookmark-w3m)
3101 (defun anything-c-bookmark-w3m-setup-alist ()
3102 "Specialized filter function for bookmarks w3m."
3103 (anything-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only
))
3106 (defvar anything-c-source-bookmark-images
3107 '((name .
"Bookmark Images")
3109 (require 'bookmark-extensions
)
3110 (bookmark-maybe-load-default-file)))
3111 (candidates . anything-c-bookmark-images-setup-alist
)
3112 (filtered-candidate-transformer
3113 anything-c-adaptive-sort
3114 anything-c-highlight-bookmark
)
3116 ;; (anything 'anything-c-source-bookmark-images)
3118 (defun anything-c-bookmark-images-setup-alist ()
3119 "Specialized filter function for images bookmarks."
3120 (anything-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only
))
3123 (defvar anything-c-source-bookmark-man
3124 '((name .
"Bookmark Woman&Man")
3126 (require 'bookmark-extensions
)
3127 (bookmark-maybe-load-default-file)))
3128 (candidates . anything-c-bookmark-man-setup-alist
)
3129 (filtered-candidate-transformer
3130 anything-c-adaptive-sort
3131 anything-c-highlight-bookmark
)
3133 ;; (anything 'anything-c-source-bookmark-man)
3135 (defun anything-c-bookmark-man-setup-alist ()
3136 "Specialized filter function for bookmarks w3m."
3137 (append (anything-c-bmkext-filter-setup-alist 'bmkext-man-alist-only
)
3138 (anything-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only
)))
3141 (defvar anything-c-source-bookmark-gnus
3142 '((name .
"Bookmark Gnus")
3144 (require 'bookmark-extensions
)
3145 (bookmark-maybe-load-default-file)))
3146 (candidates . anything-c-bookmark-gnus-setup-alist
)
3147 (filtered-candidate-transformer
3148 anything-c-adaptive-sort
3149 anything-c-highlight-bookmark
)
3151 ;; (anything 'anything-c-source-bookmark-gnus)
3153 (defun anything-c-bookmark-gnus-setup-alist ()
3154 "Specialized filter function for bookmarks gnus."
3155 (anything-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only
))
3158 (defvar anything-c-source-bookmark-info
3159 '((name .
"Bookmark Info")
3161 (require 'bookmark-extensions
)
3162 (bookmark-maybe-load-default-file)))
3163 (candidates . anything-c-bookmark-info-setup-alist
)
3164 (filtered-candidate-transformer
3165 anything-c-adaptive-sort
3166 anything-c-highlight-bookmark
)
3168 ;; (anything 'anything-c-source-bookmark-info)
3170 (defun anything-c-bookmark-info-setup-alist ()
3171 "Specialized filter function for bookmarks info."
3172 (anything-c-bmkext-filter-setup-alist 'bmkext-info-alist-only
))
3174 ;; Local Files&directories
3175 (defvar anything-c-source-bookmark-files
&dirs
3176 '((name .
"Bookmark Files&Directories")
3178 (require 'bookmark-extensions
)
3179 (bookmark-maybe-load-default-file)))
3180 (candidates . anything-c-bookmark-local-files-setup-alist
)
3181 (filtered-candidate-transformer
3182 anything-c-adaptive-sort
3183 anything-c-highlight-bookmark
)
3185 ;; (anything 'anything-c-source-bookmark-files&dirs)
3187 (defun anything-c-bookmark-local-files-setup-alist ()
3188 "Specialized filter function for bookmarks locals files."
3189 (anything-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only
))
3191 ;; Su Files&directories
3192 (defvar anything-c-source-bookmark-su-files
&dirs
3193 '((name .
"Bookmark Root-Files&Directories")
3195 (require 'bookmark-extensions
)
3196 (bookmark-maybe-load-default-file)))
3197 (candidates . anything-c-bookmark-su-files-setup-alist
)
3198 (filtered-candidate-transformer
3199 anything-c-adaptive-sort
3200 anything-c-highlight-bookmark-su
)
3202 ;; (anything 'anything-c-source-bookmark-su-files&dirs)
3204 (defun anything-c-bookmark-su-files-setup-alist ()
3205 "Specialized filter function for bookmarks su/sudo files."
3207 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3209 for isfile
= (bookmark-get-filename i
)
3210 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3212 (string-match tramp-file-name-regexp isfile
)))
3213 for issu
= (and istramp
3214 (string-match bmkext-su-or-sudo-regexp isfile
))
3218 ;; Ssh Files&directories
3219 (defvar anything-c-source-bookmark-ssh-files
&dirs
3220 '((name .
"Bookmark Ssh-Files&Directories")
3222 (require 'bookmark-extensions
)
3223 (bookmark-maybe-load-default-file)))
3224 (candidates . anything-c-bookmark-ssh-files-setup-alist
)
3225 (filtered-candidate-transformer . anything-c-adaptive-sort
)
3227 ;; (anything 'anything-c-source-bookmark-ssh-files&dirs)
3229 (defun anything-c-bookmark-ssh-files-setup-alist ()
3230 "Specialized filter function for bookmarks ssh files."
3232 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3234 for isfile
= (bookmark-get-filename i
)
3235 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3237 (string-match tramp-file-name-regexp isfile
)))
3238 for isssh
= (and istramp
3239 (string-match "/ssh:" isfile
))
3244 ;; All bookmark-extensions sources.
3246 (defun anything-bookmark-ext ()
3247 "Preconfigured `anything' for bookmark-extensions sources.
3248 Needs bookmark-ext.el
3250 http://mercurial.intuxication.org/hg/emacs-bookmark-extension"
3252 (anything '(anything-c-source-bookmark-files&dirs
3253 anything-c-source-bookmark-w3m
3254 anything-c-source-bmkext-addressbook
3255 anything-c-source-bookmark-gnus
3256 anything-c-source-bookmark-info
3257 anything-c-source-bookmark-man
3258 anything-c-source-bookmark-images
3259 anything-c-source-bookmark-su-files
&dirs
3260 anything-c-source-bookmark-ssh-files
&dirs
)
3261 nil
"SearchBookmark: " nil nil
"*anything bmkext*"))
3264 ;; Firefox bookmarks
3265 ;; You will have to set firefox to import bookmarks in his html file bookmarks.html.
3266 ;; (only for firefox versions >=3)
3267 ;; To achieve that, open about:config in firefox and double click on this line to enable value
3269 ;; user_pref("browser.bookmarks.autoExportHTML", false);
3270 ;; You should have now:
3271 ;; user_pref("browser.bookmarks.autoExportHTML", true);
3273 (defvar anything-firefox-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|about\\|file\\)://[^ ]*")
3274 (defvar anything-firefox-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3276 (defun anything-get-firefox-user-init-dir ()
3277 "Guess the default Firefox user directory name."
3278 (let* ((moz-dir (concat (getenv "HOME") "/.mozilla/firefox/"))
3279 (moz-user-dir (with-current-buffer (find-file-noselect (concat moz-dir
"profiles.ini"))
3280 (goto-char (point-min))
3281 (when (search-forward "Path=" nil t
)
3282 (buffer-substring-no-properties (point) (point-at-eol))))))
3283 (file-name-as-directory (concat moz-dir moz-user-dir
))))
3285 (defun anything-guess-firefox-bookmark-file ()
3286 "Return the path of the Firefox bookmarks file."
3287 (concat (anything-get-firefox-user-init-dir) "bookmarks.html"))
3289 (defun anything-html-bookmarks-to-alist (file url-regexp bmk-regexp
)
3290 "Parse html bookmark FILE and return an alist with (title . url) as elements."
3291 (let (bookmarks-alist url title
)
3293 (insert-file-contents file
)
3294 (goto-char (point-min))
3297 (when (re-search-forward "href=\\|^ *<DT><A HREF=" nil t
)
3299 (when (re-search-forward url-regexp nil t
)
3300 (setq url
(concat "\"" (match-string 0))))
3302 (when (re-search-forward bmk-regexp nil t
)
3303 (setq title
(match-string 1)))
3304 (push (cons title url
) bookmarks-alist
))))
3305 (nreverse bookmarks-alist
)))
3308 (defvar anything-c-firefox-bookmarks-alist nil
)
3309 (defvar anything-c-source-firefox-bookmarks
3310 '((name .
"Firefox Bookmarks")
3312 (setq anything-c-firefox-bookmarks-alist
3313 (anything-html-bookmarks-to-alist
3314 (anything-guess-firefox-bookmark-file)
3315 anything-firefox-bookmark-url-regexp
3316 anything-firefox-bookmarks-regexp
))))
3317 (candidates .
(lambda ()
3319 anything-c-firefox-bookmarks-alist
)))
3320 (filtered-candidate-transformer
3321 anything-c-adaptive-sort
3322 anything-c-highlight-firefox-bookmarks
)
3323 (action .
(("Browse Url Firefox" .
(lambda (candidate)
3325 (anything-c-firefox-bookmarks-get-value candidate
))))
3326 ("Browse Url w3m" .
(lambda (candidate)
3328 (anything-c-firefox-bookmarks-get-value candidate
))))
3329 ("Copy Url" .
(lambda (elm)
3330 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))))))
3332 ;; (anything 'anything-c-source-firefox-bookmarks)
3334 (defun anything-c-firefox-bookmarks-get-value (elm)
3335 (replace-regexp-in-string "\"" ""
3337 anything-c-firefox-bookmarks-alist
))))
3340 (defun anything-c-highlight-firefox-bookmarks (bookmarks source
)
3341 (loop for i in bookmarks
3342 collect
(propertize i
3343 'face
'((:foreground
"YellowGreen"))
3344 'help-echo
(anything-c-firefox-bookmarks-get-value i
))))
3347 (eval-when-compile (require 'w3m-bookmark nil t
))
3348 (unless (and (require 'w3m nil t
)
3349 (require 'w3m-bookmark nil t
))
3350 (defvar w3m-bookmark-file
"~/.w3m/bookmark.html"))
3353 (defface anything-w3m-bookmarks-face
'((t (:foreground
"cyan1" :underline t
)))
3354 "Face for w3m bookmarks" :group
'anything
)
3356 (defvar anything-w3m-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3357 (defvar anything-w3m-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|file\\)://[^>]*")
3358 (defvar anything-c-w3m-bookmarks-alist nil
)
3359 (defvar anything-c-source-w3m-bookmarks
3360 '((name .
"W3m Bookmarks")
3362 (setq anything-c-w3m-bookmarks-alist
3363 (anything-html-bookmarks-to-alist
3365 anything-w3m-bookmark-url-regexp
3366 anything-w3m-bookmarks-regexp
))))
3367 (candidates .
(lambda ()
3368 (mapcar #'car anything-c-w3m-bookmarks-alist
)))
3369 (filtered-candidate-transformer
3370 anything-c-adaptive-sort
3371 anything-c-highlight-w3m-bookmarks
)
3372 (action .
(("Browse Url" .
(lambda (candidate)
3373 (anything-c-w3m-browse-bookmark candidate
)))
3374 ("Copy Url" .
(lambda (elm)
3375 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))
3376 ("Browse Url Firefox" .
(lambda (candidate)
3377 (anything-c-w3m-browse-bookmark candidate t
)))
3378 ("Delete Bookmark" .
(lambda (candidate)
3379 (anything-c-w3m-delete-bookmark candidate
)))
3380 ("Rename Bookmark" .
(lambda (candidate)
3381 (anything-c-w3m-rename-bookmark candidate
)))))
3382 (persistent-action .
(lambda (candidate)
3383 (if current-prefix-arg
3384 (anything-c-w3m-browse-bookmark candidate t
)
3385 (anything-c-w3m-browse-bookmark candidate nil t
))))
3386 (persistent-help .
"Open URL with emacs-w3m in new tab / \
3387 C-u \\[anything-execute-persistent-action]: Open URL with Firefox"))
3388 "Needs w3m and emacs-w3m.
3390 http://w3m.sourceforge.net/
3391 http://emacs-w3m.namazu.org/")
3393 ;; (anything 'anything-c-source-w3m-bookmarks)
3395 (defun anything-c-w3m-bookmarks-get-value (elm)
3396 (replace-regexp-in-string
3397 "\"" "" (cdr (assoc elm anything-c-w3m-bookmarks-alist
))))
3399 (defun anything-c-w3m-browse-bookmark (elm &optional use-firefox new-tab
)
3400 (let* ((fn (if use-firefox
'browse-url-firefox
'w3m-browse-url
))
3401 (arg (and (eq fn
'w3m-browse-url
) new-tab
)))
3402 (funcall fn
(anything-c-w3m-bookmarks-get-value elm
) arg
)))
3404 (defun anything-c-highlight-w3m-bookmarks (bookmarks source
)
3405 (loop for i in bookmarks
3407 i
'face
'anything-w3m-bookmarks-face
3408 'help-echo
(anything-c-w3m-bookmarks-get-value i
))))
3411 (defun anything-c-w3m-delete-bookmark (elm)
3413 (find-file-literally w3m-bookmark-file
)
3414 (goto-char (point-min))
3415 (when (re-search-forward elm nil t
)
3417 (delete-region (point)
3418 (line-end-position))
3419 (delete-blank-lines))
3420 (save-buffer (current-buffer))
3421 (kill-buffer (current-buffer))))
3423 (defun anything-c-w3m-rename-bookmark (elm)
3424 (let* ((old-title (replace-regexp-in-string ">" "" elm
))
3425 (new-title (read-string "NewTitle: " old-title
)))
3427 (find-file-literally w3m-bookmark-file
)
3428 (goto-char (point-min))
3429 (when (re-search-forward (concat elm
"<") nil t
)
3430 (goto-char (1- (point)))
3431 (delete-char (- (length old-title
)))
3433 (save-buffer (current-buffer))
3434 (kill-buffer (current-buffer)))))
3437 ;;; Elisp library scan
3438 (defvar anything-c-source-elisp-library-scan
3439 '((name .
"Elisp libraries (Scan)")
3440 (init .
(anything-c-elisp-library-scan-init))
3441 (candidates-in-buffer)
3442 (action ("Find library" .
(lambda (candidate)
3443 (find-file (find-library-name candidate
))))
3444 ("Find library other window" .
(lambda (candidate)
3445 (find-file-other-window (find-library-name candidate
))))
3446 ("Load library" .
(lambda (candidate)
3447 (load-library candidate
))))))
3448 ;; (anything 'anything-c-source-elisp-library-scan)
3450 (defun anything-c-elisp-library-scan-init ()
3451 "Init anything buffer status."
3452 (let ((anything-buffer (anything-candidate-buffer 'global
))
3453 (library-list (anything-c-elisp-library-scan-list)))
3454 (with-current-buffer anything-buffer
3455 (dolist (library library-list
)
3456 (insert (format "%s\n" library
))))))
3458 (defun anything-c-elisp-library-scan-list (&optional dirs string
)
3459 "Do completion for file names passed to `locate-file'.
3460 DIRS is directory to search path.
3461 STRING is string to match."
3462 ;; Use `load-path' as path when ignore `dirs'.
3463 (or dirs
(setq dirs load-path
))
3464 ;; Init with blank when ignore `string'.
3465 (or string
(setq string
""))
3466 ;; Get library list.
3467 (let ((string-dir (file-name-directory string
))
3468 ;; File regexp that suffix match `load-file-rep-suffixes'.
3469 (match-regexp (format "^.*\\.el%s$" (regexp-opt load-file-rep-suffixes
)))
3474 (setq dir default-directory
))
3476 (setq dir
(expand-file-name string-dir dir
)))
3477 (when (file-directory-p dir
)
3478 (dolist (file (file-name-all-completions
3479 (file-name-nondirectory string
) dir
))
3480 ;; Suffixes match `load-file-rep-suffixes'.
3481 (setq name
(if string-dir
(concat string-dir file
) file
))
3482 (if (string-match match-regexp name
)
3483 (add-to-list 'names name
)))))
3488 (defvar anything-c-imenu-delimiter
" / ")
3490 (defvar anything-c-imenu-index-filter nil
)
3491 (make-variable-buffer-local 'anything-c-imenu-index-filter
)
3493 (defvar anything-c-cached-imenu-alist nil
)
3494 (make-variable-buffer-local 'anything-c-cached-imenu-alist
)
3496 (defvar anything-c-cached-imenu-candidates nil
)
3497 (make-variable-buffer-local 'anything-c-cached-imenu-candidates
)
3499 (defvar anything-c-cached-imenu-tick nil
)
3500 (make-variable-buffer-local 'anything-c-cached-imenu-tick
)
3502 (eval-when-compile (require 'imenu
))
3503 (setq imenu-auto-rescan t
)
3505 (defun anything-imenu-create-candidates (entry)
3506 "Create candidates with ENTRY."
3507 (if (listp (cdr entry
))
3508 (mapcan (lambda (sub)
3509 (if (consp (cdr sub
))
3512 (concat (car entry
) anything-c-imenu-delimiter subentry
))
3513 (anything-imenu-create-candidates sub
))
3514 (list (concat (car entry
) anything-c-imenu-delimiter
(car sub
)))))
3518 (defvar anything-c-source-imenu
3520 (init .
(lambda () (require 'imenu
)))
3521 (candidates . anything-c-imenu-candidates
)
3522 (persistent-action .
(lambda (elm)
3523 (anything-c-imenu-default-action elm
)
3524 (unless (fboundp 'semantic-imenu-tag-overlay
)
3525 (anything-match-line-color-current-line))))
3526 (persistent-help .
"Show this entry")
3527 (action . anything-c-imenu-default-action
))
3528 "See (info \"(emacs)Imenu\")")
3530 ;; (anything 'anything-c-source-imenu)
3532 (defun anything-c-imenu-candidates ()
3533 (with-current-buffer anything-current-buffer
3534 (let ((tick (buffer-modified-tick)))
3535 (if (eq anything-c-cached-imenu-tick tick
)
3536 anything-c-cached-imenu-candidates
3537 (setq imenu--index-alist nil
)
3538 (setq anything-c-cached-imenu-tick tick
3539 anything-c-cached-imenu-candidates
3542 'anything-imenu-create-candidates
3543 (setq anything-c-cached-imenu-alist
3544 (let ((index (imenu--make-index-alist)))
3545 (if anything-c-imenu-index-filter
3546 (funcall anything-c-imenu-index-filter index
)
3548 (setq anything-c-cached-imenu-candidates
3549 (mapcar #'(lambda (x)
3553 anything-c-cached-imenu-candidates
))))))
3555 (setq imenu-default-goto-function
'imenu-default-goto-function
)
3556 (defun anything-c-imenu-default-action (elm)
3557 "The default action for `anything-c-source-imenu'."
3558 (let ((path (split-string elm anything-c-imenu-delimiter
))
3559 (alist anything-c-cached-imenu-alist
))
3560 (if (> (length path
) 1)
3562 (setq alist
(assoc (car path
) alist
))
3563 (setq elm
(cadr path
))
3564 (imenu (assoc elm alist
)))
3565 (imenu (assoc elm alist
)))))
3568 (defvar anything-c-ctags-modes
3569 '( c-mode c
++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode
3570 makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode
3571 scheme-mode sh-mode slang-mode sql-mode tcl-mode
))
3573 (defun anything-c-source-ctags-init ()
3574 (when (and buffer-file-name
3575 (memq major-mode anything-c-ctags-modes
)
3576 (anything-current-buffer-is-modified))
3577 (with-current-buffer (anything-candidate-buffer 'local
)
3578 (call-process-shell-command
3579 (if (string-match "\\.el\\.gz$" anything-buffer-file-name
)
3580 (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) " anything-buffer-file-name
)
3581 (format "ctags -e -u -f- --fields=n %s " anything-buffer-file-name
))
3582 nil
(current-buffer))
3583 (goto-char (point-min))
3585 (delete-region (point-min) (point))
3586 (loop while
(and (not (eobp)) (search-forward "\001" (point-at-eol) t
))
3587 for lineno-start
= (point)
3588 for lineno
= (buffer-substring lineno-start
(1- (search-forward "," (point-at-eol) t
)))
3591 (insert (format "%5s:" lineno
))
3592 (search-forward "\177" (point-at-eol) t
)
3593 (delete-region (1- (point)) (point-at-eol))
3594 (forward-line 1)))))
3596 (defvar anything-c-source-ctags
3597 '((name .
"Exuberant ctags")
3598 (init . anything-c-source-ctags-init
)
3599 (candidates-in-buffer)
3602 "Needs Exuberant Ctags.
3604 http://ctags.sourceforge.net/")
3605 ;; (anything 'anything-c-source-ctags)
3608 (eval-when-compile (require 'semantic nil t
))
3609 (declare-function semantic-format-tag-summarize
"ext:format.el" (tag &optional parent color
) t
)
3610 (declare-function semantic-tag-components
"ext:tag.el" (tag) t
)
3611 (declare-function semantic-go-to-tag
"ext:tag-file.el" (tag) t
)
3612 (defvar anything-semantic-candidates nil
)
3614 (defun anything-semantic-construct-candidates (tags depth
)
3615 (when (require 'semantic nil t
)
3617 (mapcar (lambda (tag)
3619 (let ((type (semantic-tag-type tag
))
3620 (class (semantic-tag-class tag
)))
3621 (if (or (and (stringp type
)
3622 (or (string= type
"class")
3623 (string= type
"namespace")))
3624 (eq class
'function
)
3625 (eq class
'variable
))
3626 (cons (cons (concat (make-string (* depth
2) ?\s
)
3627 (semantic-format-tag-summarize tag nil t
)) tag
)
3628 (anything-semantic-construct-candidates (semantic-tag-components tag
)
3632 (defun anything-semantic-default-action (candidate)
3633 (let ((tag (cdr (assoc candidate anything-semantic-candidates
))))
3634 (semantic-go-to-tag tag
)))
3636 (defvar anything-c-source-semantic
3637 '((name .
"Semantic Tags")
3639 (setq anything-semantic-candidates
3640 (ignore-errors (anything-semantic-construct-candidates (semantic-fetch-tags) 0)))))
3641 (candidates .
(lambda ()
3642 (if anything-semantic-candidates
3643 (mapcar 'car anything-semantic-candidates
))))
3644 (persistent-action .
(lambda (elm)
3645 (anything-semantic-default-action elm
)
3646 (anything-match-line-color-current-line)))
3647 (persistent-help .
"Show this entry")
3648 (action . anything-semantic-default-action
)
3649 "Needs semantic in CEDET.
3651 http://cedet.sourceforge.net/semantic.shtml
3652 http://cedet.sourceforge.net/"))
3654 ;; (anything 'anything-c-source-semantic)
3656 ;;; Function is called by
3658 (defun anything-simple-call-tree ()
3659 "Preconfigured `anything' for simple-call-tree. List function relationships.
3661 Needs simple-call-tree.el.
3662 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el"
3664 (anything-other-buffer
3665 '(anything-c-source-simple-call-tree-functions-callers
3666 anything-c-source-simple-call-tree-callers-functions
)
3667 "*anything simple-call-tree*"))
3669 (defvar anything-c-source-simple-call-tree-functions-callers
3670 '((name .
"Function is called by")
3671 (init . anything-c-simple-call-tree-functions-callers-init
)
3673 (candidates . anything-c-simple-call-tree-candidates
)
3674 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3675 (persistent-help .
"Show function definitions by rotation")
3676 (action ("Find definition selected by persistent-action" .
3677 anything-c-simple-call-tree-find-definition
)))
3678 "Needs simple-call-tree.el.
3679 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3681 (defvar anything-c-simple-call-tree-tick nil
)
3682 (make-variable-buffer-local 'anything-c-simple-call-tree-tick
)
3683 (defun anything-c-simple-call-tree-analyze-maybe ()
3684 (unless (eq (buffer-chars-modified-tick) anything-c-simple-call-tree-tick
)
3685 (simple-call-tree-analyze)
3686 (setq anything-c-simple-call-tree-tick
(buffer-chars-modified-tick))))
3688 (defun anything-c-simple-call-tree-init-base (function message
)
3689 (require 'simple-call-tree
)
3691 (when (anything-current-buffer-is-modified)
3692 (anything-c-simple-call-tree-analyze-maybe)
3693 (let ((list (funcall function simple-call-tree-alist
)))
3694 (with-current-buffer (anything-candidate-buffer 'local
)
3695 (dolist (entry list
)
3696 (let ((funcs (concat " " (mapconcat #'identity
(cdr entry
) "\n "))))
3697 (insert (car entry
) message
3698 (if (string= funcs
" ")
3703 (defun anything-c-simple-call-tree-functions-callers-init ()
3704 (anything-c-simple-call-tree-init-base 'simple-call-tree-invert
" is called by\n"))
3706 (defun anything-c-simple-call-tree-candidates ()
3707 (with-current-buffer (anything-candidate-buffer)
3708 (split-string (buffer-string) "\n\n")))
3710 (defvar anything-c-simple-call-tree-related-functions nil
)
3711 (defvar anything-c-simple-call-tree-function-index
0)
3712 (defun anything-c-simple-call-tree-persistent-action (candidate)
3713 (unless (eq last-command
'anything-execute-persistent-action
)
3714 (setq anything-c-simple-call-tree-related-functions
3715 (delete "no functions."
3717 (replace-regexp-in-string " \\| is called by\\| calls " "" candidate
)
3719 (setq anything-c-simple-call-tree-function-index -
1))
3720 (incf anything-c-simple-call-tree-function-index
)
3721 (anything-c-simple-call-tree-find-definition candidate
))
3723 (defun anything-c-simple-call-tree-find-definition (candidate)
3724 (find-function (intern
3725 (nth (mod anything-c-simple-call-tree-function-index
3726 (length anything-c-simple-call-tree-related-functions
))
3727 anything-c-simple-call-tree-related-functions
))))
3729 ;; (anything 'anything-c-source-simple-call-tree-functions-callers)
3732 (defvar anything-c-source-simple-call-tree-callers-functions
3733 '((name .
"Function calls")
3734 (init . anything-c-simple-call-tree-callers-functions-init
)
3736 (candidates . anything-c-simple-call-tree-candidates
)
3737 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3738 (persistent-help .
"Show function definitions by rotation")
3739 (action ("Find definition selected by persistent-action" .
3740 anything-c-simple-call-tree-find-definition
)))
3741 "Needs simple-call-tree.el.
3742 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3744 (defun anything-c-simple-call-tree-callers-functions-init ()
3745 (anything-c-simple-call-tree-init-base 'identity
" calls \n"))
3747 ;; (anything 'anything-c-source-simple-call-tree-callers-functions)
3749 ;;; Commands/Options with doc
3750 (defvar anything-c-auto-document-data nil
)
3751 (make-variable-buffer-local 'anything-c-auto-document-data
)
3752 (defvar anything-c-source-commands-and-options-in-file
3753 '((name .
"Commands/Options in file")
3755 .
(lambda (x) (format "Commands/Options in %s"
3756 (buffer-local-value 'buffer-file-name anything-current-buffer
))))
3757 (candidates . anything-command-and-options-candidates
)
3760 "List Commands and Options with doc. It needs auto-document.el .
3762 http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el")
3764 (eval-when-compile (require 'auto-document nil t
))
3765 (defun anything-command-and-options-candidates ()
3766 (with-current-buffer anything-current-buffer
3767 (when (and (require 'auto-document nil t
)
3768 (eq major-mode
'emacs-lisp-mode
)
3769 (or (anything-current-buffer-is-modified)
3770 (not anything-c-auto-document-data
)))
3771 (or imenu--index-alist
(imenu--make-index-alist t
))
3772 (setq anything-c-auto-document-data
3773 (destructuring-bind (commands options
)
3774 (adoc-construct anything-current-buffer
)
3776 (loop for
(command . doc
) in commands
3777 for cmdname
= (symbol-name command
)
3779 (cons (format "Command: %s\n %s"
3780 (propertize cmdname
'face font-lock-function-name-face
)
3781 (adoc-first-line doc
))
3782 (assoc cmdname imenu--index-alist
)))
3783 (loop with var-alist
= (cdr (assoc "Variables" imenu--index-alist
))
3784 for
(option doc default
) in options
3785 for optname
= (symbol-name option
)
3787 (cons (format "Option: %s\n %s\n default = %s"
3788 (propertize optname
'face font-lock-variable-name-face
)
3789 (adoc-first-line doc
)
3790 (adoc-prin1-to-string default
))
3793 anything-c-auto-document-data
))
3795 ;; (anything 'anything-c-source-commands-and-options-in-file)
3797 ;;;; <Color and Face>
3799 (defvar anything-c-source-customize-face
3800 '((name .
"Customize Face")
3802 (unless (anything-candidate-buffer)
3803 (save-window-excursion (list-faces-display))
3804 (anything-candidate-buffer (get-buffer "*Faces*")))))
3805 (candidates-in-buffer)
3806 (get-line . buffer-substring
)
3807 (action .
(lambda (line)
3808 (customize-face (intern (car (split-string line
))))))
3809 (requires-pattern .
3))
3810 "See (info \"(emacs)Faces\")")
3811 ;; (anything 'anything-c-source-customize-face)
3814 (defvar anything-c-source-colors
3816 (init .
(lambda () (unless (anything-candidate-buffer)
3817 (save-window-excursion (list-colors-display))
3818 (anything-candidate-buffer (get-buffer "*Colors*")))))
3819 (candidates-in-buffer)
3820 (get-line . buffer-substring
)
3821 (action ("Copy Name" .
(lambda (candidate)
3822 (kill-new (anything-c-colors-get-name candidate
))))
3823 ("Copy RGB" .
(lambda (candidate)
3824 (kill-new (anything-c-colors-get-rgb candidate
))))
3825 ("Insert Name" .
(lambda (candidate)
3826 (with-current-buffer anything-current-buffer
3827 (insert (anything-c-colors-get-name candidate
)))))
3828 ("Insert RGB" .
(lambda (candidate)
3829 (with-current-buffer anything-current-buffer
3830 (insert (anything-c-colors-get-rgb candidate
))))))))
3831 ;; (anything 'anything-c-source-colors)
3833 (defun anything-c-colors-get-name (candidate)
3835 (replace-regexp-in-string
3838 (insert (capitalize candidate
))
3839 (goto-char (point-min))
3840 (search-forward-regexp "\\s-\\{2,\\}")
3841 (delete-region (point) (point-max))
3844 (defun anything-c-colors-get-rgb (candidate)
3846 (replace-regexp-in-string
3849 (insert (capitalize candidate
))
3850 (goto-char (point-max))
3851 (search-backward-regexp "\\s-\\{2,\\}")
3852 (delete-region (point) (point-min))
3855 ;;;; <Search Engine>
3856 ;;; Tracker desktop search
3857 (defvar anything-c-source-tracker-search
3858 '((name .
"Tracker Search")
3859 (candidates .
(lambda ()
3860 (start-process "tracker-search-process" nil
3864 (requires-pattern .
3)
3866 "Source for retrieving files matching the current input pattern
3867 with the tracker desktop search.")
3868 ;; (anything 'anything-c-source-tracker-search)
3870 ;;; Spotlight (MacOS X desktop search)
3871 (defvar anything-c-source-mac-spotlight
3873 (candidates .
(lambda ()
3874 (start-process "mdfind-process" nil
"mdfind" anything-pattern
)))
3876 (requires-pattern .
3)
3878 "Source for retrieving files via Spotlight's command line
3880 ;; (anything 'anything-c-source-mac-spotlight)
3885 (defvar anything-c-source-kill-ring
3886 '((name .
"Kill Ring")
3887 (init .
(lambda () (anything-attrset 'last-command last-command
)))
3888 (candidates . anything-c-kill-ring-candidates
)
3889 (action . anything-c-kill-ring-action
)
3893 "Source for browse and insert contents of kill-ring.")
3895 (defun anything-c-kill-ring-candidates ()
3896 (loop for kill in kill-ring
3897 unless
(or (< (length kill
) anything-kill-ring-threshold
)
3898 (string-match "^[\\s\\t]+$" kill
))
3901 (defun anything-c-kill-ring-action (str)
3902 "Insert STR in `kill-ring' and set STR to the head.
3903 If this action is executed just after `yank', replace with STR as yanked string."
3904 (setq kill-ring
(delete str kill-ring
))
3905 (if (not (eq (anything-attr 'last-command
) 'yank
))
3906 (insert-for-yank str
)
3908 (let ((inhibit-read-only t
)
3909 (before (< (point) (mark t
))))
3911 (funcall (or yank-undo-function
'delete-region
) (point) (mark t
))
3912 (funcall (or yank-undo-function
'delete-region
) (mark t
) (point)))
3913 (setq yank-undo-function nil
)
3914 (set-marker (mark-marker) (point) (current-buffer))
3915 (insert-for-yank str
)
3916 ;; Set the window start back where it was in the yank command,
3918 (set-window-start (selected-window) yank-window-start t
)
3920 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
3921 ;; It is cleaner to avoid activation, even though the command
3922 ;; loop would deactivate the mark because we inserted text.
3923 (goto-char (prog1 (mark t
)
3924 (set-marker (mark-marker) (point) (current-buffer)))))))
3927 ;; (anything 'anything-c-source-kill-ring)
3930 ;; DO NOT include these sources in `anything-sources' use
3931 ;; the commands `anything-mark-ring', `anything-global-mark-ring' or
3932 ;; `anything-all-mark-rings' instead.
3934 (defun anything-c-source-mark-ring-candidates ()
3935 (flet ((get-marks (pos)
3939 (let ((line (car (split-string (thing-at-point 'line
) "[\n\r]"))))
3940 (when (string= "" line
)
3941 (setq line
"<EMPTY LINE>"))
3942 (format "%7d: %s" (line-number-at-pos) line
)))))
3943 (with-current-buffer anything-current-buffer
3945 with marks
= (cons (mark-marker) mark-ring
)
3948 for m
= (get-marks i
)
3949 unless
(member m recip
)
3950 collect m into recip
3951 finally return recip
))))
3953 (defvar anything-mark-ring-cache nil
)
3954 (defvar anything-c-source-mark-ring
3955 '((name .
"mark-ring")
3957 (setq anything-mark-ring-cache
3958 (ignore-errors (anything-c-source-mark-ring-candidates)))))
3959 (candidates .
(lambda ()
3960 (anything-aif anything-mark-ring-cache
3962 (action .
(("Goto line" .
(lambda (candidate)
3963 (anything-goto-line (string-to-number candidate
))))))
3964 (persistent-action .
(lambda (candidate)
3965 (anything-goto-line (string-to-number candidate
))
3966 (anything-match-line-color-current-line)))
3967 (persistent-help .
"Show this line")))
3969 ;; (anything 'anything-c-source-mark-ring)
3972 (defun anything-mark-ring ()
3973 "Preconfigured `anything' for `anything-c-source-mark-ring'."
3975 (anything 'anything-c-source-mark-ring
))
3977 ;;; Global-mark-ring
3978 (defvar anything-c-source-global-mark-ring
3979 '((name .
"global-mark-ring")
3980 (candidates . anything-c-source-global-mark-ring-candidates
)
3981 (action .
(("Goto line" .
(lambda (candidate)
3982 (let ((items (split-string candidate
":")))
3983 (switch-to-buffer (second items
))
3984 (anything-goto-line (string-to-number (car items
))))))))
3985 (persistent-action .
(lambda (candidate)
3986 (let ((items (split-string candidate
":")))
3987 (switch-to-buffer (second items
))
3988 (anything-goto-line (string-to-number (car items
)))
3989 (anything-match-line-color-current-line))))
3990 (persistent-help .
"Show this line")))
3992 (defun anything-c-source-global-mark-ring-candidates ()
3994 (with-current-buffer (marker-buffer m
)
3998 (if (string= "" line
)
3999 (setq line
"<EMPTY LINE>")
4000 (setq line
(car (split-string (thing-at-point 'line
) "[\n\r]"))))
4001 (format "%7d:%s: %s" (line-number-at-pos) (marker-buffer m
) line
)))))
4003 with marks
= global-mark-ring
4006 for gm
= (unless (or (string-match
4007 "^ " (format "%s" (marker-buffer i
)))
4008 (null (marker-buffer i
)))
4010 when
(and gm
(not (member gm recip
)))
4011 collect gm into recip
4012 finally return recip
)))
4014 ;; (anything 'anything-c-source-global-mark-ring)
4017 (defun anything-global-mark-ring ()
4018 "Preconfigured `anything' for `anything-c-source-global-mark-ring'."
4020 (anything 'anything-c-source-global-mark-ring
))
4023 (defun anything-all-mark-rings ()
4024 "Preconfigured `anything' for `anything-c-source-global-mark-ring' and \
4025 `anything-c-source-mark-ring'."
4027 (anything '(anything-c-source-global-mark-ring
4028 anything-c-source-mark-ring
)))
4031 ;;; Insert from register
4032 (defvar anything-c-source-register
4033 '((name .
"Registers")
4034 (candidates . anything-c-register-candidates
)
4035 (action-transformer . anything-c-register-action-transformer
)
4038 "See (info \"(emacs)Registers\")")
4040 (defun anything-c-register-candidates ()
4041 "Collecting register contents and appropriate commands."
4042 (loop for
(char . val
) in register-alist
4043 for key
= (single-key-description char
)
4044 for string-actions
= (cond
4046 (list (int-to-string val
)
4048 'increment-register
))
4050 (let ((buf (marker-buffer val
)))
4052 (list "a marker in no buffer")
4054 "a buffer position:"
4057 (int-to-string (marker-position val
)))
4059 'insert-register
))))
4060 ((and (consp val
) (window-configuration-p (car val
)))
4061 (list "window configuration."
4063 ((and (consp val
) (frame-configuration-p (car val
)))
4064 (list "frame configuration."
4066 ((and (consp val
) (eq (car val
) 'file
))
4067 (list (concat "file:"
4068 (prin1-to-string (cdr val
))
4071 ((and (consp val
) (eq (car val
) 'file-query
))
4072 (list (concat "file:a file-query reference: file "
4075 (int-to-string (car (cdr (cdr val
))))
4079 (let ((lines (format "%4d" (length val
))))
4080 (list (format "%s: %s\n" lines
4081 (truncate-string-to-width
4082 (mapconcat 'identity
(list (car val
))
4083 ;; (mapconcat (lambda (y) y) val
4084 "^J") (- (window-width) 15)))
4087 (list ;; without properties
4088 (substring-no-properties val
)
4091 'prepend-to-register
))
4094 collect
(cons (format "register %3s: %s" key
(car string-actions
))
4095 (cons char
(cdr string-actions
)))))
4097 (defun anything-c-register-action-transformer (actions register-and-functions
)
4098 "Decide actions by the contents of register."
4099 (loop with func-actions
=
4102 (lambda (c) (insert-register (car c
))))
4104 "Jump to Register" .
4105 (lambda (c) (jump-to-register (car c
))))
4107 "Append Region to Register" .
4108 (lambda (c) (append-to-register (car c
) (region-beginning) (region-end))))
4109 (prepend-to-register
4110 "Prepend Region to Register" .
4111 (lambda (c) (prepend-to-register (car c
) (region-beginning) (region-end))))
4113 "Increment Prefix Arg to Register" .
4114 (lambda (c) (increment-register anything-current-prefix-arg
(car c
)))))
4115 for func in
(cdr register-and-functions
)
4116 for cell
= (assq func func-actions
)
4118 collect
(cdr cell
)))
4120 ;; (anything 'anything-c-source-register)
4122 ;;;; <Headline Extraction>
4123 (defvar anything-c-source-fixme
4124 '((name .
"TODO/FIXME/DRY comments")
4125 (headline .
"^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$")
4128 "Show TODO/FIXME/DRY comments in current file.")
4129 ;; (anything 'anything-c-source-fixme)
4131 (defvar anything-c-source-rd-headline
4132 '((name .
"RD HeadLine")
4133 (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$")
4134 (condition .
(memq major-mode
'(rdgrep-mode rd-mode
)))
4140 http://en.wikipedia.org/wiki/Ruby_Document_format")
4141 ;; (anything 'anything-c-source-rd-headline)
4143 (defvar anything-c-source-oddmuse-headline
4144 '((name .
"Oddmuse HeadLine")
4145 (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$"
4146 "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$")
4147 (condition .
(memq major-mode
'(oddmuse-mode yaoddmuse-mode
)))
4150 "Show Oddmuse headlines, such as EmacsWiki.")
4151 ;; (anything 'anything-c-source-oddmuse-headline)
4153 (defvar anything-c-source-emacs-source-defun
4154 '((name .
"Emacs Source DEFUN")
4155 (headline .
"DEFUN\\|DEFVAR")
4156 (condition .
(string-match "/emacs2[0-9].+/src/.+c$" (or buffer-file-name
""))))
4157 "Show DEFUN/DEFVAR in Emacs C source file.")
4158 ;; (anything 'anything-c-source-emacs-source-defun)
4160 (defvar anything-c-source-emacs-lisp-expectations
4161 '((name .
"Emacs Lisp Expectations")
4162 (headline .
"(desc[ ]\\|(expectations")
4163 (condition .
(eq major-mode
'emacs-lisp-mode
)))
4164 "Show descriptions (desc) in Emacs Lisp Expectations.
4166 http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
4167 ;; (anything 'anything-c-source-emacs-lisp-expectations)
4169 (defvar anything-c-source-emacs-lisp-toplevels
4170 '((name .
"Emacs Lisp Toplevel / Level 4 Comment / Linkd Star")
4171 (headline .
"^(\\|(@\\*\\|^;;;;")
4172 (get-line . buffer-substring
)
4173 (condition .
(eq major-mode
'emacs-lisp-mode
))
4175 "Show top-level forms, level 4 comments and linkd stars (optional) in Emacs Lisp.
4176 linkd.el is optional because linkd stars are extracted by regexp.
4177 http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el")
4178 ;; (anything 'anything-c-source-emacs-lisp-toplevels)
4180 (defvar anything-c-source-org-headline
4181 '((name .
"Org HeadLine")
4183 "^\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4184 "^\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4185 "^\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4186 "^\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4187 "^\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4188 "^\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4189 "^\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4190 "^\\*\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$")
4191 (condition .
(eq major-mode
'org-mode
))
4194 (persistent-action .
(lambda (elm)
4195 (anything-c-action-line-goto elm
)
4198 .
(lambda (actions candidate
)
4199 '(("Go to Line" . anything-c-action-line-goto
)
4200 ("Insert Link to This Headline" . anything-c-org-headline-insert-link-to-headline
)))))
4201 "Show Org headlines.
4202 org-mode is very very much extended text-mode/outline-mode.
4204 See (find-library \"org.el\")
4205 See http://orgmode.org for the latest version.")
4207 (defun anything-c-org-headline-insert-link-to-headline (lineno-and-content)
4210 (anything-goto-line (car lineno-and-content
))
4211 (and (looking-at org-complex-heading-regexp
)
4212 (org-make-link-string (concat "*" (match-string 4)))))))
4214 ;; (anything 'anything-c-source-org-headline)
4216 ;;; Anything yaoddmuse
4217 ;; Be sure to have yaoddmuse.el installed
4218 ;; install-elisp may be required if you want to install elisp file from here.
4219 (defvar anything-yaoddmuse-use-cache-file nil
)
4220 (defvar anything-c-yaoddmuse-cache-file
"~/.emacs.d/yaoddmuse-cache.el")
4221 (defvar anything-c-yaoddmuse-ew-cache nil
)
4222 (defvar anything-c-source-yaoddmuse-emacswiki-edit-or-view
4223 '((name .
"Yaoddmuse Edit or View (EmacsWiki)")
4224 (candidates .
(lambda ()
4225 (if anything-yaoddmuse-use-cache-file
4227 (unless anything-c-yaoddmuse-ew-cache
4228 (load anything-c-yaoddmuse-cache-file
)
4229 (setq anything-c-yaoddmuse-ew-cache
4230 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4231 anything-c-yaoddmuse-ew-cache
)
4232 (yaoddmuse-update-pagename t
)
4233 (gethash "EmacsWiki" yaoddmuse-pages-hash
))))
4234 (action .
(("Edit page" .
(lambda (candidate)
4235 (yaoddmuse-edit "EmacsWiki" candidate
)))
4236 ("Browse page" .
(lambda (candidate)
4237 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4238 ("Browse page other window" .
(lambda (candidate)
4240 (split-window-vertically))
4241 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4242 ("Browse diff" .
(lambda (candidate)
4243 (yaoddmuse-browse-page-diff "EmacsWiki" candidate
)))
4244 ("Copy URL" .
(lambda (candidate)
4245 (kill-new (yaoddmuse-url "EmacsWiki" candidate
))
4246 (message "Have copy page %s's URL to yank." candidate
)))
4247 ("Create page" .
(lambda (candidate)
4248 (yaoddmuse-edit "EmacsWiki" anything-input
)))
4249 ("Update cache" .
(lambda (candidate)
4250 (if anything-yaoddmuse-use-cache-file
4252 (anything-yaoddmuse-cache-pages t
)
4253 (setq anything-c-yaoddmuse-ew-cache
4254 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4255 (yaoddmuse-update-pagename))))))
4256 (action-transformer anything-c-yaoddmuse-action-transformer
))
4257 "Needs yaoddmuse.el.
4259 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4261 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view)
4263 (defvar anything-c-source-yaoddmuse-emacswiki-post-library
4264 '((name .
"Yaoddmuse Post library (EmacsWiki)")
4265 (init .
(anything-yaoddmuse-init))
4266 (candidates-in-buffer)
4267 (action .
(("Post library and Browse" .
(lambda (candidate)
4268 (yaoddmuse-post-file (find-library-name candidate
)
4270 (file-name-nondirectory (find-library-name candidate
))
4272 ("Post library" .
(lambda (candidate)
4273 (yaoddmuse-post-file (find-library-name candidate
)
4275 (file-name-nondirectory (find-library-name candidate
))))))))
4276 "Needs yaoddmuse.el.
4278 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4280 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-post-library)
4282 (defun anything-c-yaoddmuse-action-transformer (actions candidate
)
4283 "Allow the use of `install-elisp' only on elisp files."
4284 (if (string-match "\.el$" candidate
)
4285 (append actions
'(("Install Elisp" .
(lambda (elm)
4286 (install-elisp-from-emacswiki elm
)))))
4290 (defun anything-yaoddmuse-cache-pages (&optional load
)
4291 "Fetch the list of files on emacswiki and create cache file.
4292 If load is non--nil load the file and feed `yaoddmuse-pages-hash'."
4294 (yaoddmuse-update-pagename)
4296 (find-file anything-c-yaoddmuse-cache-file
)
4298 (insert "(puthash \"EmacsWiki\" '(")
4299 (loop for i in
(gethash "EmacsWiki" yaoddmuse-pages-hash
)
4301 (insert (concat "(\"" (car i
) "\") ")))
4302 (insert ") yaoddmuse-pages-hash)\n")
4304 (kill-buffer (current-buffer))
4305 (when (or current-prefix-arg
4307 (load anything-c-yaoddmuse-cache-file
))))
4310 (defun anything-yaoddmuse-emacswiki-edit-or-view ()
4311 "Preconfigured `anything' to edit or view EmacsWiki page.
4315 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4317 (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view
))
4320 (defun anything-yaoddmuse-emacswiki-post-library ()
4321 "Preconfigured `anything' to post library to EmacsWiki.
4325 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4327 (anything 'anything-c-source-yaoddmuse-emacswiki-post-library
))
4329 (defun anything-yaoddmuse-init ()
4330 "Init anything buffer status."
4331 (let ((anything-buffer (anything-candidate-buffer 'global
))
4332 (library-list (yaoddmuse-get-library-list)))
4333 (with-current-buffer anything-buffer
4334 ;; Insert library name.
4335 (dolist (library library-list
)
4336 (insert (format "%s\n" library
)))
4338 (sort-lines nil
(point-min) (point-max)))))
4341 (defvar anything-c-source-eev-anchor
4342 '((name .
"Anchors")
4346 (with-current-buffer anything-current-buffer
4347 (loop initially
(goto-char (point-min))
4348 while
(re-search-forward (format ee-anchor-format
"\\([^\.].+\\)") nil t
)
4349 for anchor
= (match-string-no-properties 1)
4350 collect
(cons (format "%5d:%s"
4351 (line-number-at-pos (match-beginning 0))
4352 (format ee-anchor-format anchor
)) anchor
))))))
4353 (persistent-action .
(lambda (item)
4355 (anything-match-line-color-current-line)))
4356 (persistent-help .
"Show this entry")
4357 (action .
(("Goto link" . ee-to
)))))
4358 ;; (anything 'anything-c-source-eev-anchor)
4362 (defvar anything-c-source-org-keywords
4363 '((name .
"Org Keywords")
4364 (init . anything-c-org-keywords-init
)
4365 (candidates . anything-c-org-keywords-candidates
)
4366 (action . anything-c-org-keywords-insert
)
4367 (persistent-action . anything-c-org-keywords-show-help
)
4368 (persistent-help .
"Show an example and info page to describe this keyword.")
4371 ;; (anything 'anything-c-source-org-keywords)
4372 (defvar anything-c-org-keywords-info-location
4373 '(("#+TITLE:" .
"(org)Export options")
4374 ("#+AUTHOR:" .
"(org)Export options")
4375 ("#+DATE:" .
"(org)Export options")
4376 ("#+EMAIL:" .
"(org)Export options")
4377 ("#+DESCRIPTION:" .
"(org)Export options")
4378 ("#+KEYWORDS:" .
"(org)Export options")
4379 ("#+LANGUAGE:" .
"(org)Export options")
4380 ("#+TEXT:" .
"(org)Export options")
4381 ("#+TEXT:" .
"(org)Export options")
4382 ("#+OPTIONS:" .
"(org)Export options")
4383 ("#+BIND:" .
"(org)Export options")
4384 ("#+LINK_UP:" .
"(org)Export options")
4385 ("#+LINK_HOME:" .
"(org)Export options")
4386 ("#+LATEX_HEADER:" .
"(org)Export options")
4387 ("#+EXPORT_SELECT_TAGS:" .
"(org)Export options")
4388 ("#+EXPORT_EXCLUDE_TAGS:" .
"(org)Export options")
4389 ("#+INFOJS_OPT" .
"(org)Javascript support")
4390 ("#+BEGIN_HTML" .
"(org)Quoting HTML tags")
4391 ("#+BEGIN_LaTeX" .
"(org)Quoting LaTeX code")
4392 ("#+ORGTBL" .
"(org)Radio tables")
4393 ("#+HTML:" .
"(org)Quoting HTML tags")
4394 ("#+LaTeX:" .
"(org)Quoting LaTeX code")
4395 ("#+BEGIN:" .
"(org)Dynamic blocks") ;clocktable columnview
4396 ("#+BEGIN_EXAMPLE" .
"(org)Literal examples")
4397 ("#+BEGIN_QUOTE" .
"(org)Paragraphs")
4398 ("#+BEGIN_VERSE" .
"(org)Paragraphs")
4399 ("#+BEGIN_SRC" .
"(org)Literal examples")
4400 ("#+CAPTION" .
"(org)Tables in HTML export")
4401 ("#+LABEL" .
"(org)Tables in LaTeX export")
4402 ("#+ATTR_HTML" .
"(org)Links")
4403 ("#+ATTR_LaTeX" .
"(org)Images in LaTeX export")))
4405 (defun anything-c-org-keywords-init ()
4406 (unless (anything-attr 'keywords-examples
)
4408 (anything-attrset 'keywords-examples
4412 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x
)
4413 (cons (match-string 2 x
) (match-string 1 x
)))
4414 (org-split-string (org-get-current-options) "\n"))
4415 (mapcar 'list org-additional-option-like-keywords
)))
4416 (anything-attrset 'keywords
(mapcar 'car
(anything-attr 'keywords-examples
)))))
4418 (defun anything-c-org-keywords-candidates ()
4419 (and (eq (buffer-local-value 'major-mode anything-current-buffer
) 'org-mode
)
4420 (anything-attr 'keywords
)))
4422 (defun anything-c-org-keywords-insert (keyword)
4423 (cond ((string-match "BEGIN" keyword
)
4424 (insert "#+" keyword
" ")
4426 (insert "\n" (replace-regexp-in-string "BEGIN" "END" keyword
) "\n")))
4428 (insert "#+" keyword
" "))))
4430 (defun anything-c-org-keywords-show-help (keyword)
4431 (info (or (assoc-default (concat "#+" keyword
) anything-c-org-keywords-info-location
)
4432 "(org)In-buffer settings"))
4433 (search-forward (concat "#+" keyword
) nil t
)
4434 (anything-persistent-highlight-point)
4435 (message "%s" (or (cdr (assoc keyword
(anything-attr 'keywords-examples
))) "")))
4439 (defvar anything-c-source-picklist
4440 '((name .
"Picklist")
4441 (candidates .
(lambda () (mapcar 'car picklist-list
)))
4443 ;; (anything 'anything-c-source-picklist)
4446 (defvar bbdb-records
)
4447 (defvar bbdb-buffer-name
)
4448 (declare-function bbdb
"ext:bbdb-com")
4449 (declare-function bbdb-current-record
"ext:bbdb-com")
4450 (declare-function bbdb-redisplay-one-record
"ext:bbdb-com")
4451 (declare-function bbdb-record-net
"ext:bbdb-com" (string) t
)
4452 (declare-function bbdb-current-record
"ext:bbdb-com")
4453 (declare-function bbdb-dwim-net-address
"ext:bbdb-com")
4454 (declare-function bbdb-records
"ext:bbdb-com"
4455 (&optional dont-check-disk already-in-db-buffer
))
4457 (defun anything-c-bbdb-candidates ()
4458 "Return a list of all names in the bbdb database. The format
4459 is \"Firstname Lastname\"."
4460 (mapcar (lambda (bbdb-record)
4461 (replace-regexp-in-string
4463 (concat (aref bbdb-record
0) " " (aref bbdb-record
1))))
4466 (defun anything-c-bbdb-create-contact (actions candidate
)
4467 "Action transformer that returns only an entry to add the
4468 current `anything-pattern' as new contact. All other actions are
4470 (if (string= candidate
"*Add to contacts*")
4471 '(("Add to contacts" .
(lambda (actions)
4472 (bbdb-create-internal
4473 (read-from-minibuffer "Name: " anything-c-bbdb-name
)
4474 (read-from-minibuffer "Company: ")
4475 (read-from-minibuffer "Email: ")
4478 (read-from-minibuffer "Note: ")))))
4481 (defun anything-c-bbdb-get-record (candidate)
4482 "Return record that match CANDIDATE."
4483 (bbdb candidate nil
)
4484 (set-buffer "*BBDB*")
4485 (bbdb-current-record))
4487 (defvar anything-c-bbdb-name nil
4488 "Only for internal use.")
4490 (defvar anything-c-source-bbdb
4492 (candidates . anything-c-bbdb-candidates
)
4493 (action ("Send a mail" . anything-c-bbdb-compose-mail
)
4494 ("View person's data" . anything-c-bbdb-view-person-action
))
4495 (filtered-candidate-transformer .
(lambda (candidates source
)
4496 (setq anything-c-bbdb-name anything-pattern
)
4497 (if (not candidates
)
4498 (list "*Add to contacts*")
4500 (action-transformer .
(lambda (actions candidate
)
4501 (anything-c-bbdb-create-contact actions candidate
))))
4504 http://bbdb.sourceforge.net/")
4505 ;; (anything 'anything-c-source-bbdb)
4507 (defun anything-c-bbdb-view-person-action (candidate)
4508 "View BBDB data of single CANDIDATE or marked candidates."
4509 (anything-aif (anything-marked-candidates)
4510 (let ((bbdb-append-records (length it
)))
4512 (bbdb-redisplay-one-record (anything-c-bbdb-get-record i
))))
4513 (bbdb-redisplay-one-record (anything-c-bbdb-get-record candidate
))))
4515 (defun anything-c-bbdb-collect-mail-addresses ()
4516 "Return a list of all mail addresses of records in bbdb buffer."
4517 (with-current-buffer bbdb-buffer-name
4518 (loop for i in bbdb-records
4519 if
(bbdb-record-net (car i
))
4520 collect
(bbdb-dwim-net-address (car i
)))))
4522 (defun anything-c-bbdb-compose-mail (candidate)
4523 "Compose a mail with all records of bbdb buffer."
4524 (anything-c-bbdb-view-person-action candidate
)
4525 (let* ((address-list (anything-c-bbdb-collect-mail-addresses))
4526 (address-str (mapconcat 'identity address-list
",\n ")))
4527 (compose-mail address-str
)))
4529 ;;; Evaluation Result
4530 (defvar anything-c-source-evaluation-result
4531 '((name .
"Evaluation Result")
4534 (filtered-candidate-transformer .
(lambda (candidates source
)
4537 (with-current-buffer anything-current-buffer
4539 (eval (read anything-pattern
))))
4541 (action ("Copy result to kill-ring" .
(lambda (candidate)
4542 (with-current-buffer anything-buffer
4543 (let ((end (save-excursion
4544 (goto-char (point-max))
4545 (search-backward "\n")
4547 (kill-region (point) end
))))))))
4548 ;; (anything 'anything-c-source-evaluation-result)
4551 (defun anything-eval-expression (arg)
4552 "Preconfigured anything for `anything-c-source-evaluation-result'."
4554 (anything 'anything-c-source-evaluation-result
(when arg
(thing-at-point 'sexp
))
4555 nil nil nil
"*anything eval*"))
4558 (defun anything-eval-expression-with-eldoc ()
4559 "Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. "
4562 (let ((timer (run-with-idle-timer eldoc-idle-delay
4563 'repeat
'anything-eldoc-show-in-eval
)))
4565 (call-interactively 'anything-eval-expression
)
4566 (cancel-timer timer
)))
4567 (call-interactively 'anything-eval-expression
)))
4569 (defun anything-eldoc-show-in-eval ()
4570 "Return eldoc in a tooltip for current minibuffer input."
4571 (let* ((str-all (minibuffer-completion-contents))
4575 (goto-char (point-max))
4576 (unless (looking-back ")\\|\"") (forward-char -
1))
4577 (eldoc-current-symbol))))
4578 (doc (or (eldoc-get-var-docstring sym
)
4579 (eldoc-get-fnsym-args-string
4580 (car (eldoc-fnsym-in-current-sexp))))))
4581 (when doc
(tooltip-show doc
))))
4583 ;;; Calculation Result
4584 (defvar anything-c-source-calculation-result
4585 '((name .
"Calculation Result")
4587 (filtered-candidate-transformer .
(lambda (candidates source
)
4590 (calc-eval anything-pattern
)
4592 (action ("Copy result to kill-ring" . kill-new
))))
4593 ;; (anything 'anything-c-source-calculation-result)
4595 ;;; Google Suggestions
4596 (defvar anything-gg-sug-lgh-flag
0)
4597 (defun anything-c-google-suggest-fetch (input)
4598 "Fetch suggestions for INPUT from XML buffer.
4599 Return an alist with elements like (data . number_results)."
4600 (let ((request (concat anything-c-google-suggest-url
4601 (url-hexify-string input
))))
4604 with result-alist
= (xml-get-children
4605 (car (xml-parse-region (point-min) (point-max)))
4606 'CompleteSuggestion
)
4607 for i in result-alist
4608 for data
= (cdr (caadr (assoc 'suggestion i
)))
4609 for nqueries
= (cdr (caadr (assoc 'num_queries i
)))
4610 for ldata
= (length data
)
4612 (when (> ldata anything-gg-sug-lgh-flag
)
4613 (setq anything-gg-sug-lgh-flag ldata
))
4614 collect
(cons data nqueries
) into cont
4615 finally return cont
)))
4616 (if anything-google-suggest-use-curl-p
4618 (call-process "curl" nil t nil request
)
4620 (with-current-buffer
4621 (url-retrieve-synchronously request
)
4625 (defun anything-c-google-suggest-set-candidates ()
4626 "Set candidates with result and number of google results found."
4627 (let ((suggestions (anything-c-google-suggest-fetch anything-input
)))
4628 (setq suggestions
(loop for i in suggestions
4629 for interval
= (- anything-gg-sug-lgh-flag
(length (car i
)))
4630 for elm
= (concat (car i
)
4631 (make-string (+ 2 interval
) ?
)
4632 "(" (cdr i
) " results)")
4633 collect
(cons elm
(car i
))))
4634 (if (some (lambda (data) (equal (cdr data
) anything-input
)) suggestions
)
4636 ;; if there is no suggestion exactly matching the input then
4637 ;; prepend a Search on Google item to the list
4640 (list (cons (concat "Search for " "'" anything-input
"'" " on Google")
4641 anything-input
))))))
4644 (defun anything-c-google-suggest-action (candidate)
4645 "Default action to jump to a google suggested candidate."
4646 (anything-c-browse-url (concat anything-c-google-suggest-search-url
4647 (url-hexify-string candidate
))))
4650 (defvar anything-c-source-google-suggest
4651 '((name .
"Google Suggest")
4652 (candidates . anything-c-google-suggest-set-candidates
)
4653 (action .
(("Google Search" . anything-c-google-suggest-action
)))
4655 (requires-pattern .
3)
4658 ;; (anything 'anything-c-source-google-suggest)
4660 ;;; Yahoo suggestions
4662 (defun anything-c-yahoo-suggest-fetch (input)
4663 "Fetch Yahoo suggestions for INPUT from XML buffer.
4664 Return an alist with elements like (data . number_results)."
4665 (let ((request (concat anything-c-yahoo-suggest-url
4666 (url-hexify-string input
))))
4669 with result-alist
= (xml-get-children
4670 (car (xml-parse-region (point-min) (point-max)))
4672 for i in result-alist
4673 collect
(caddr i
))))
4674 (with-current-buffer
4675 (url-retrieve-synchronously request
)
4678 (defun anything-c-yahoo-suggest-set-candidates ()
4679 "Set candidates with Yahoo results found."
4680 (let ((suggestions (anything-c-yahoo-suggest-fetch anything-input
)))
4684 (list (cons (concat "Search for " "'" anything-input
"'" " on Yahoo")
4685 anything-input
))))))
4687 (defun anything-c-yahoo-suggest-action (candidate)
4688 "Default action to jump to a Yahoo suggested candidate."
4689 (anything-c-browse-url (concat anything-c-yahoo-suggest-search-url
4690 (url-hexify-string candidate
))))
4692 (defvar anything-c-source-yahoo-suggest
4693 '((name .
"Yahoo Suggest")
4694 (candidates . anything-c-yahoo-suggest-set-candidates
)
4695 (action .
(("Yahoo Search" . anything-c-yahoo-suggest-action
)))
4697 (requires-pattern .
3)
4700 ;; (anything 'anything-c-source-yahoo-suggest)
4703 ;;; Need external program surfraw.
4704 ;;; http://surfraw.alioth.debian.org/
4706 (require 'browse-url
)
4707 (defvar w3m-command nil
)
4708 (defvar anything-c-home-url
"http://www.google.fr"
4709 "*Default url to use as home url.")
4711 (defvar anything-browse-url-default-browser-alist
4712 `((,w3m-command . w3m-browse-url
)
4713 (,browse-url-firefox-program . browse-url-firefox
)
4714 (,browse-url-kde-program . browse-url-kde
)
4715 (,browse-url-gnome-moz-program . browse-url-gnome-moz
)
4716 (,browse-url-mozilla-program . browse-url-mozilla
)
4717 (,browse-url-galeon-program . browse-url-galeon
)
4718 (,browse-url-netscape-program . browse-url-netscape
)
4719 (,browse-url-mosaic-program . browse-url-mosaic
)
4720 (,browse-url-xterm-program . browse-url-text-xterm
))
4721 "*Alist of (executable . function) to try to find a suitable url browser.")
4723 (defun anything-browse-url-default-browser (url &rest args
)
4724 "Find a suitable browser and ask it to load URL."
4725 (let ((default-browser (loop
4726 for i in anything-browse-url-default-browser-alist
4727 when
(and (car i
) (executable-find (car i
))) return
(cdr i
))))
4729 (apply default-browser url args
)
4730 (error "No usable browser found"))))
4732 (defun* anything-c-browse-url
(&optional
(url anything-c-home-url
))
4733 "Default command to browse URL."
4734 (if browse-url-browser-function
4736 (anything-browse-url-default-browser url
)))
4738 (defun anything-c-build-elvi-list ()
4739 "Return list of all engines and descriptions handled by surfraw."
4742 (call-process "surfraw" nil t nil
4744 (split-string (buffer-string) "\n"))))
4747 (defun anything-surfraw (pattern engine
)
4748 "Preconfigured `anything' to search PATTERN with search ENGINE."
4749 (interactive (list (read-string "SearchFor: ")
4752 (anything-c-build-elvi-list)
4754 (let* ((engine-nodesc (car (split-string engine
)))
4755 (url (with-temp-buffer
4756 (apply 'call-process
"surfraw" nil t nil
4757 (list engine-nodesc
"-p" pattern
))
4758 (replace-regexp-in-string
4759 "\n" "" (buffer-string)))))
4760 (if (string= engine-nodesc
"W")
4761 (anything-c-browse-url)
4762 (anything-c-browse-url url
))))
4767 (defun anything-emms-stream-edit-bookmark (elm)
4768 "Change the information of current emms-stream bookmark from anything."
4770 (let* ((cur-buf anything-current-buffer
)
4771 (bookmark (assoc elm emms-stream-list
))
4772 (name (read-from-minibuffer "Description: "
4774 (url (read-from-minibuffer "URL: "
4776 (fd (read-from-minibuffer "Feed Descriptor: "
4777 (int-to-string (nth 2 bookmark
))))
4778 (type (read-from-minibuffer "Type (url, streamlist, or lastfm): "
4779 (format "%s" (car (last bookmark
))))))
4782 (when (re-search-forward (concat "^" name
) nil t
)
4784 (emms-stream-delete-bookmark)
4785 (emms-stream-add-bookmark name url
(string-to-number fd
) type
)
4786 (emms-stream-save-bookmarks-file)
4788 (switch-to-buffer cur-buf
)))))
4790 (defun anything-emms-stream-delete-bookmark (elm)
4791 "Delete an emms-stream bookmark from anything."
4793 (let* ((cur-buf anything-current-buffer
)
4794 (bookmark (assoc elm emms-stream-list
))
4795 (name (nth 0 bookmark
)))
4798 (when (re-search-forward (concat "^" name
) nil t
)
4800 (emms-stream-delete-bookmark)
4801 (emms-stream-save-bookmarks-file)
4803 (switch-to-buffer cur-buf
)))))
4805 (defvar anything-c-source-emms-streams
4806 '((name .
"Emms Streams")
4808 (emms-stream-init)))
4809 (candidates .
(lambda ()
4810 (mapcar 'car emms-stream-list
)))
4811 (action .
(("Play" .
(lambda (elm)
4812 (let* ((stream (assoc elm emms-stream-list
))
4813 (fn (intern (concat "emms-play-" (symbol-name (car (last stream
))))))
4814 (url (second stream
)))
4816 ("Delete" . anything-emms-stream-delete-bookmark
)
4817 ("Edit" . anything-emms-stream-edit-bookmark
)))
4818 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4819 ;; (anything 'anything-c-source-emms-streams)
4821 ;; Don't forget to set `emms-source-file-default-directory'
4822 (defvar anything-c-source-emms-dired
4823 '((name .
"Music Directory")
4824 (candidates .
(lambda ()
4825 (cddr (directory-files emms-source-file-default-directory
))))
4827 (("Play Directory" .
(lambda (item)
4828 (emms-play-directory
4831 emms-source-file-default-directory
))))
4832 ("Open dired in file's directory" .
(lambda (item)
4833 (anything-c-open-dired
4836 emms-source-file-default-directory
))))))
4837 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4838 ;; (anything 'anything-c-source-emms-dired)
4840 (defface anything-emms-playlist
4841 '((t (:foreground
"Springgreen4" :underline t
)))
4842 "*Face used for tracks in current emms playlist."
4845 (defun anything-c-emms-files-modifier (candidates)
4846 (let ((current-playlist (with-current-emms-playlist
4848 with cur-list
= (emms-playlist-tracks-in-region
4849 (point-min) (point-max))
4851 collect
(assoc-default 'info-file i
)))))
4852 (loop for i in candidates
4853 if
(member i current-playlist
)
4854 collect
(propertize i
'face
'anything-emms-playlist
) into lis
4855 else collect i into lis finally return lis
)))
4857 (defun anything-c-emms-play-current-playlist ()
4858 "Play current playlist."
4859 (with-current-emms-playlist
4860 (emms-playlist-first)
4861 (emms-playlist-mode-play-smart)))
4863 (defvar anything-c-source-emms-files
4864 '((name .
"Emms files")
4865 (candidates .
(lambda ()
4866 (loop for v being the hash-values in emms-cache-db
4867 for name
= (assoc-default 'name v
)
4868 unless
(string-match "^http:" name
) collect name
)))
4869 (candidate-transformer . anything-c-emms-files-modifier
)
4870 (action .
(("Play file" . emms-play-file
)
4871 ("Add to Playlist and play"
4872 .
(lambda (candidate)
4874 (dolist (i (anything-marked-candidates))
4875 (emms-add-playlist-file i
))
4876 (unless emms-player-playing-p
4877 (anything-c-emms-play-current-playlist))))))))
4879 ;; (anything 'anything-c-source-emms-files)
4881 ;;; Jabber Contacts (jabber.el)
4882 (defun anything-c-jabber-online-contacts ()
4883 "List online Jabber contacts."
4886 (dolist (item (jabber-concat-rosters) jids
)
4887 (when (get item
'connected
)
4888 (push (if (get item
'name
)
4889 (cons (get item
'name
) item
)
4890 (cons (symbol-name item
) item
)) jids
))))))
4892 (defvar anything-c-source-jabber-contacts
4893 '((name .
"Jabber Contacts")
4894 (init .
(lambda () (require 'jabber
)))
4895 (candidates .
(lambda () (mapcar 'car
(anything-c-jabber-online-contacts))))
4896 (action .
(lambda (x)
4898 (jabber-read-account)
4900 (cdr (assoc x
(anything-c-jabber-online-contacts)))))))))
4901 ;; (anything 'anything-c-source-jabber-contacts)
4905 (defvar anything-source-select-buffer
"*anything source select*")
4906 (defvar anything-c-source-call-source
4907 `((name .
"Call anything source")
4908 (candidate-number-limit)
4909 (candidates .
(lambda ()
4910 (loop for vname in
(all-completions "anything-c-source-" obarray
)
4911 for var
= (intern vname
)
4912 for name
= (ignore-errors (assoc-default 'name
(symbol-value var
)))
4913 if name collect
(cons (format "%s `%s'"
4914 name
(propertize vname
'face
'font-lock-variable-name-face
))
4916 (action .
(("Invoke anything with selected source" .
4918 (setq anything-candidate-number-limit
9999)
4919 (anything candidate nil nil nil nil
4920 anything-source-select-buffer
)))
4921 ("Describe variable" . describe-variable
)
4922 ("Find variable" . find-variable
)))
4923 (persistent-action . describe-variable
)
4924 (persistent-help .
"Show description of this source")))
4925 ;; (anything 'anything-c-source-call-source)
4928 (defun anything-call-source ()
4929 "Preconfigured `anything' to call anything source."
4931 (anything 'anything-c-source-call-source nil nil nil nil
4932 anything-source-select-buffer
))
4934 (defun anything-call-source-from-anything ()
4935 "Call anything source within `anything' session."
4937 (setq anything-input-idle-delay
0)
4938 (anything-set-sources '(anything-c-source-call-source)))
4940 ;;; Execute Preconfigured anything.
4941 (defvar anything-c-source-anything-commands
4942 '((name .
"Preconfigured Anything")
4943 (candidates . anything-c-anything-commands-candidates
)
4945 (candidate-number-limit)))
4946 ;; (anything 'anything-c-source-anything-commands)
4948 (defun anything-c-anything-commands-candidates ()
4949 (loop for
(cmd . desc
) in
(anything-c-list-preconfigured-anything)
4950 collect
(cons (if (where-is-internal cmd nil t
)
4951 (substitute-command-keys (format "M-x %s (\\[%s]) : %s" cmd cmd desc
))
4952 (substitute-command-keys (format "\\[%s] : %s" cmd desc
)))
4956 (defun anything-execute-anything-command ()
4957 "Preconfigured `anything' to execute preconfigured `anything'."
4959 (anything-other-buffer 'anything-c-source-anything-commands
4960 "*anything commands*"))
4964 (defun anything-c-occur-goto-line (candidate)
4965 "Goto line action for anything-c-source-occur."
4966 (anything-goto-line (string-to-number candidate
)))
4968 (defun anything-c-occur-persistent-action (candidate)
4969 "Persistent action for anything occur source."
4970 (anything-c-occur-goto-line candidate
)
4971 (anything-match-line-color-current-line))
4973 (defun anything-c-get-occur-candidates ()
4974 "Get `anything-c-source-occur' candidates."
4976 (let ((count (occur-engine
4978 (list anything-current-buffer
) (current-buffer)
4979 list-matching-lines-default-context-lines nil
4980 list-matching-lines-buffer-name-face
4981 nil list-matching-lines-face
4982 (not (eq occur-excluded-properties t
)))))
4984 (cdr (split-string (buffer-string) "\n" t
))))))
4986 (defvar anything-c-source-occur
4988 (candidates . anything-c-get-occur-candidates
)
4989 (persistent-action . anything-c-occur-persistent-action
)
4990 (persistent-help .
"Goto Line")
4991 (action . anything-c-occur-goto-line
)
4992 (requires-pattern .
1)
4995 ;; (anything 'anything-c-source-occur)
4998 (defun anything-occur ()
4999 "Preconfigured Anything for Occur source."
5001 (anything-other-buffer 'anything-c-source-occur
"*Anything Occur*"))
5003 ;; Do many actions for input
5004 (defvar anything-c-source-create
5008 (action-transformer . anything-create--actions
))
5009 "Do many create actions from `anything-pattern'.
5010 See also `anything-create--actions'.")
5011 ;; (anything 'anything-c-source-create)
5013 (defun anything-create-from-anything ()
5014 "Run `anything-create' from `anything' as a fallback."
5016 (anything-run-after-quit 'anything-create nil anything-pattern
))
5019 (defun anything-create (&optional string initial-input
)
5020 "Preconfigured `anything' to do many create actions from STRING.
5021 See also `anything-create--actions'."
5023 (setq string
(or string
(read-string "Create Anything: " initial-input
)))
5024 (anything '(((name .
"Anything Create")
5025 (header-name .
(lambda (_) (format "Action for \"%s\"" string
)))
5026 (candidates . anything-create--actions
)
5027 (candidate-number-limit)
5028 (action .
(lambda (func) (funcall func string
)))))))
5030 (defun anything-create--actions (&rest ignored
)
5031 "Default actions for `anything-create' / `anything-c-source-create'."
5033 (lambda (pair) (and (consp pair
) (functionp (cdr pair
))))
5034 (append anything-create--actions-private
5035 '(("find-file" . find-file
)
5036 ("find-file other window" . find-file-other-window
)
5037 ("New buffer" . switch-to-buffer
)
5038 ("New buffer other window" . switch-to-buffer-other-window
)
5039 ("Bookmark Set" . bookmark-set
)
5041 (lambda (x) (set-register (read-char "Register: ") x
)))
5042 ("Insert Linkd star" . linkd-insert-star
)
5043 ("Insert Linkd Tag" . linkd-insert-tag
)
5044 ("Insert Linkd Link" . linkd-insert-link
)
5045 ("Insert Linkd Lisp" . linkd-insert-lisp
)
5046 ("Insert Linkd Wiki" . linkd-insert-wiki
)
5047 ("Google Search" . google
)))))
5049 ;; Minibuffer History
5050 (defvar anything-c-source-minibuffer-history
5051 '((name .
"Minibuffer History")
5052 (header-name .
(lambda (name) (format "%s (%s)" name minibuffer-history-variable
)))
5053 (candidates .
(lambda () (let ((history (symbol-value minibuffer-history-variable
)))
5054 (if (consp (car history
))
5055 (mapcar 'prin1-to-string history
)
5059 ;; (anything 'anything-c-source-minibuffer-history)
5062 (defvar anything-c-source-elscreen
5063 '((name .
"Elscreen")
5064 (candidates .
(lambda ()
5065 (if (cdr (elscreen-get-screen-to-name-alist))
5067 (loop for sname in
(elscreen-get-screen-to-name-alist)
5068 append
(list (format "[%d] %s" (car sname
) (cdr sname
))) into lst
5069 finally
(return lst
))
5070 #'(lambda (a b
) (compare-strings a nil nil b nil nil
))))))
5071 (action .
(("Change Screen".
5073 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))))
5076 (dolist (i (anything-marked-candidates))
5077 (elscreen-goto (- (aref i
1) (aref "0" 0)))
5081 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))
5082 (elscreen-kill-others)))))))
5083 ;; (anything 'anything-c-source-elscreen)
5088 (defvar anything-c-top-command
"COLUMNS=%s top -b -n 1"
5089 "Top command (batch mode). %s is replaced with `frame-width'.")
5090 (defvar anything-c-source-top
5091 '((name .
"Top (Press C-c C-u to refresh)")
5092 (init . anything-c-top-init
)
5093 (candidates-in-buffer)
5094 (display-to-real . anything-c-top-display-to-real
)
5095 (update . anything-c-top-update
)
5097 ("kill (TERM)" .
(lambda (pid) (anything-c-top-sh (format "kill -TERM %s" pid
))))
5098 ("kill (KILL)" .
(lambda (pid) (anything-c-top-sh (format "kill -KILL %s" pid
))))
5099 ("Copy PID" .
(lambda (pid) (kill-new pid
))))))
5100 ;; (anything 'anything-c-source-top)
5102 (defun anything-c-top-sh (cmd)
5103 (message "Executed %s\n%s" cmd
(shell-command-to-string cmd
)))
5105 (defun anything-c-top-init ()
5106 (with-current-buffer (anything-candidate-buffer 'global
)
5107 (call-process-shell-command
5108 (format anything-c-top-command
5109 (- (frame-width) (if anything-enable-digit-shortcuts
4 0)))
5110 nil
(current-buffer))))
5112 (defun anything-c-top-display-to-real (line)
5113 (car (split-string line
)))
5115 (defun anything-c-top-update ()
5116 (let ((anything-source-name (assoc-default 'name anything-c-source-top
))) ;UGLY HACK
5117 (anything-c-top-init)))
5120 (defun anything-top ()
5121 "Preconfigured `anything' for top command."
5123 (let ((anything-samewindow t
)
5124 (anything-enable-shortcuts)
5125 (anything-display-function 'anything-default-display-buffer
)
5126 (anything-candidate-number-limit 9999))
5127 (save-window-excursion
5128 (delete-other-windows)
5129 (anything-other-buffer 'anything-c-source-top
"*anything top*"))))
5132 (defvar anything-c-source-absolute-time-timers
5133 '((name .
"Absolute Time Timers")
5134 (candidates . timer-list
)
5136 ;; (anything 'anything-c-source-absolute-time-timers)
5138 (defvar anything-c-source-idle-time-timers
5139 '((name .
"Idle Time Timers")
5140 (candidates . timer-idle-list
)
5142 ;; (anything 'anything-c-source-idle-time-timers)
5144 (defun anything-c-timer-real-to-display (timer)
5145 (destructuring-bind (triggered t1 t2 t3 repeat-delay func args idle-delay
)
5146 (append timer nil
) ;use `append' to convert vector->list
5147 (format "%s repeat=%5S %s(%s)"
5148 (let ((time (list t1 t2 t3
)))
5150 (format-time-string "idle-for=%5s" time
)
5151 (format-time-string "%m/%d %T" time
)))
5154 (mapconcat 'prin1-to-string args
" "))))
5156 ;;; X RandR resolution change
5157 ;;; FIXME I do not care multi-display.
5158 (defvar anything-c-xrandr-output
"VGA")
5159 (defvar anything-c-xrandr-screen
"0")
5160 (defvar anything-c-source-xrandr-change-resolution
5161 '((name .
"Change Resolution")
5165 (call-process "xrandr" nil
(current-buffer) nil
5166 "--screen" anything-c-xrandr-screen
"-q")
5168 (loop while
(re-search-forward " \\([0-9]+x[0-9]+\\)" nil t
)
5169 collect
(match-string 1)))))
5171 ("Change Resolution" .
(lambda (mode)
5172 (call-process "xrandr" nil nil nil
5173 "--screen" anything-c-xrandr-screen
5174 "--output" anything-c-xrandr-output
5176 ;; (anything 'anything-c-source-xrandr-change-resolution)
5179 (defun anything-c-persistent-xfont-action (elm)
5180 "Show current font temporarily"
5181 (let ((current-font (cdr (assoc 'font
(frame-parameters))))
5184 (progn (set-frame-font default-font
'keep-size
) (sit-for 2))
5185 (set-frame-font current-font
))))
5187 (defvar anything-c-xfonts-cache nil
)
5188 (defvar anything-c-source-xfonts
5189 '((name .
"X Fonts")
5191 (unless anything-c-xfonts-cache
5192 (setq anything-c-xfonts-cache
5193 (x-list-fonts "*")))))
5194 (candidates . anything-c-xfonts-cache
)
5195 (action .
(("Copy to kill ring" .
(lambda (elm)
5197 ("Set Font" .
(lambda (elm)
5199 (set-frame-font elm
'keep-size
)
5200 (message "New font have been copied to kill ring")))))
5201 (persistent-action . anything-c-persistent-xfont-action
)
5202 (persistent-help .
"Switch to this font temporarily")))
5205 (defun anything-select-xfont ()
5206 "Preconfigured `anything' to select Xfont."
5208 (anything-other-buffer 'anything-c-source-xfonts
"*anything select* xfont"))
5210 ;; (anything 'anything-c-source-xfonts)
5212 ;;; Source for Debian/Ubuntu users
5213 (defvar anything-c-source-apt
5215 (init . anything-c-apt-init
)
5216 (candidates-in-buffer)
5217 (candidate-transformer anything-c-apt-candidate-transformer
)
5218 (display-to-real . anything-c-apt-display-to-real
)
5219 (candidate-number-limit .
9999)
5221 ("Show package description" . anything-c-apt-cache-show
)
5222 ("Install package" . anything-c-apt-install
)
5223 ("Remove package" . anything-c-apt-uninstall
)
5224 ("Purge package" . anything-c-apt-purge
))
5225 (persistent-action . anything-c-apt-persistent-action
)
5226 (persistent-help .
"Show - C-u Refresh")))
5227 ;; (anything 'anything-c-source-apt)
5229 (defvar anything-c-apt-query
"emacs")
5230 (defvar anything-c-apt-search-command
"apt-cache search '%s'")
5231 (defvar anything-c-apt-show-command
"apt-cache show '%s'")
5232 (defvar anything-c-apt-installed-packages nil
)
5234 (defface anything-apt-installed
5235 '((t (:foreground
"green")))
5236 "*Face used for apt installed candidates."
5239 (defun anything-c-apt-refresh ()
5240 "Refresh installed candidates list."
5241 (setq anything-c-apt-installed-packages nil
)
5242 (anything-force-update))
5244 (defun anything-c-apt-persistent-action (candidate)
5245 "Persistent action for APT source."
5246 (if current-prefix-arg
5247 (anything-c-apt-refresh)
5248 (anything-c-apt-cache-show candidate
)))
5251 (defun anything-apt (query)
5252 "Preconfigured `anything' : frontend of APT package manager."
5253 (interactive "sAPT search: ")
5254 (let ((anything-c-apt-query query
))
5255 (anything 'anything-c-source-apt
)))
5257 (defun anything-c-apt-candidate-transformer (candidates)
5258 "Show installed candidates in a different color."
5261 for cand in candidates
5262 for name
= (anything-c-apt-display-to-real cand
)
5263 if
(member name anything-c-apt-installed-packages
)
5264 collect
(propertize cand
'face
'anything-apt-installed
) into all
5265 else collect cand into all finally return all
))
5267 (defun anything-c-apt-init ()
5268 "Initialize list of debian packages."
5269 (unless anything-c-apt-installed-packages
5270 (message "Updating installed candidate list...")
5271 (setq anything-c-apt-installed-packages
5273 (call-process-shell-command "dpkg --get-selections"
5274 nil
(current-buffer))
5275 (loop for i in
(split-string (buffer-string) "\n" t
)
5276 collect
(car (split-string i
))))))
5277 (with-current-buffer
5278 (anything-candidate-buffer
5279 (get-buffer-create (format "*anything-apt:%s*" anything-c-apt-query
)))
5281 (call-process-shell-command
5282 (format anything-c-apt-search-command anything-c-apt-query
)
5283 nil
(current-buffer)))
5284 (message "Updating installed candidate list...done"))
5286 (defun anything-c-apt-display-to-real (line)
5287 "Return only name of a debian package.
5288 LINE is displayed like:
5289 package name - description."
5290 (car (split-string line
" - ")))
5293 (defun anything-c-shell-command-if-needed (command)
5294 (interactive "sShell command: ")
5295 (if (get-buffer command
) ; if the buffer already exists
5296 (switch-to-buffer command
) ; then just switch to it
5297 (switch-to-buffer command
) ; otherwise create it
5298 (insert (shell-command-to-string command
))))
5300 (defun anything-c-apt-cache-show (package)
5301 (anything-c-shell-command-if-needed (format anything-c-apt-show-command package
)))
5303 (defun anything-c-apt-install (package)
5304 (anything-c-apt-install1 package
:action
'install
))
5306 (defun anything-c-apt-uninstall (package)
5307 (anything-c-apt-install1 package
:action
'uninstall
))
5309 (defun anything-c-apt-purge (package)
5310 (anything-c-apt-install1 package
:action
'purge
))
5312 (defun* anything-c-apt-install1
(candidate &key action
)
5313 (ansi-term (getenv "SHELL") "anything apt")
5315 (let ((command (case action
5316 ('install
"sudo apt-get install '%s'")
5317 ('uninstall
"sudo apt-get remove '%s'")
5318 ('purge
"sudo apt-get purge '%s'")
5319 (t (error "Unknow action"))))
5321 (goto-char (point-max))
5322 (insert (format command candidate
))
5324 (if (y-or-n-p (format "%s package" (symbol-name action
)))
5326 (setq anything-c-external-commands-list nil
)
5327 (setq anything-c-apt-installed-packages nil
)
5328 (term-char-mode) (term-send-input))
5329 (delete-region beg end
) (term-send-eof) (kill-buffer))))
5331 ;; (anything-c-apt-install "jed")
5333 ;;; Sources for gentoo users
5334 (defvar anything-c-gentoo-use-flags nil
)
5335 (defvar anything-c-gentoo-buffer
"*anything-gentoo-output*")
5336 (defvar anything-c-cache-gentoo nil
)
5337 (defvar anything-c-cache-world nil
)
5338 (defvar anything-c-source-gentoo
5339 '((name .
"Portage sources")
5341 (get-buffer-create anything-c-gentoo-buffer
)
5342 (unless anything-c-cache-gentoo
5343 (anything-c-gentoo-setup-cache))
5344 (unless anything-c-cache-world
5345 (setq anything-c-cache-world
(anything-c-gentoo-get-world)))
5346 (anything-c-gentoo-init-list)))
5347 (candidates-in-buffer)
5349 (candidate-transformer anything-c-highlight-world
)
5350 (action .
(("Show package" .
(lambda (elm)
5351 (anything-c-gentoo-eshell-action elm
"eix")))
5352 ("Show history" .
(lambda (elm)
5353 (if (member elm anything-c-cache-world
)
5354 (anything-c-gentoo-eshell-action elm
"genlop -qe")
5355 (message "No infos on packages not yet installed"))))
5356 ("Copy in kill-ring" . kill-new
)
5357 ("insert at point" . insert
)
5358 ("Browse HomePage" .
(lambda (elm)
5359 (let ((urls (anything-c-gentoo-get-url elm
)))
5360 (browse-url (anything-comp-read "Url: " urls
:must-match t
)))))
5361 ("Show extra infos" .
(lambda (elm)
5362 (if (member elm anything-c-cache-world
)
5363 (anything-c-gentoo-eshell-action elm
"genlop -qi")
5364 (message "No infos on packages not yet installed"))))
5365 ("Show use flags" .
(lambda (elm)
5366 (anything-c-gentoo-default-action elm
"equery" "-C" "u")
5367 (font-lock-add-keywords nil
'(("^\+.*" . font-lock-variable-name-face
)))
5368 (font-lock-mode 1)))
5369 ("Run emerge pretend" .
(lambda (elm)
5370 (anything-c-gentoo-eshell-action elm
"emerge -p")))
5371 ("Emerge" .
(lambda (elm)
5372 (anything-gentoo-install elm
:action
'install
)))
5373 ("Unmerge" .
(lambda (elm)
5374 (anything-gentoo-install elm
:action
'uninstall
)))
5375 ("Show dependencies" .
(lambda (elm)
5376 (anything-c-gentoo-default-action elm
"equery" "-C" "d")))
5377 ("Show related files" .
(lambda (elm)
5378 (anything-c-gentoo-default-action elm
"equery" "files")))
5379 ("Refresh" .
(lambda (elm)
5380 (anything-c-gentoo-setup-cache)
5381 (setq anything-c-cache-world
(anything-c-gentoo-get-world))))))))
5383 ;; (anything 'anything-c-source-gentoo)
5385 (defun* anything-gentoo-install
(candidate &key action
)
5386 (setq anything-c-external-commands-list nil
)
5387 (ansi-term (getenv "SHELL") "anything gentoo")
5389 (let ((command (case action
5390 ('install
"sudo emerge -av ")
5391 ('uninstall
"sudo emerge -avC ")
5392 (t (error "Unknow action"))))
5393 (elms (mapconcat 'identity
(anything-marked-candidates) " "))
5395 (goto-char (point-max))
5396 (insert (concat command elms
))
5398 (term-char-mode) (term-send-input)))
5400 (defun anything-c-gentoo-default-action (elm command
&rest args
)
5401 "Gentoo default action that use `anything-c-gentoo-buffer'."
5402 (if (member elm anything-c-cache-world
)
5404 (switch-to-buffer anything-c-gentoo-buffer
)
5406 (let ((com-list (append args
(list elm
))))
5407 (apply #'call-process command nil t nil
5409 (message "No infos on packages not yet installed")))
5411 (defvar anything-c-source-use-flags
5412 '((name .
"Use Flags")
5414 (unless anything-c-gentoo-use-flags
5415 (anything-c-gentoo-setup-use-flags-cache))
5416 (anything-c-gentoo-get-use)))
5417 (candidates-in-buffer)
5419 (candidate-transformer anything-c-highlight-local-use
)
5420 (action .
(("Description"
5422 (switch-to-buffer anything-c-gentoo-buffer
)
5424 (apply #'call-process
"euse" nil t nil
5427 (font-lock-add-keywords nil
`((,elm . font-lock-variable-name-face
)))
5428 (font-lock-mode 1)))
5431 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -E")))
5434 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -D")))
5437 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -P")))
5438 ("Show which dep use this flag"
5440 (switch-to-buffer anything-c-gentoo-buffer
)
5442 (apply #'call-process
"equery" nil t nil
5448 ;; (anything 'anything-c-source-use-flags)
5450 (defun anything-c-gentoo-init-list ()
5451 "Initialize buffer with all packages in Portage."
5452 (let* ((portage-buf (get-buffer-create "*anything-gentoo*"))
5453 (buf (anything-candidate-buffer 'portage-buf
)))
5454 (with-current-buffer buf
5455 (dolist (i anything-c-cache-gentoo
)
5456 (insert (concat i
"\n"))))))
5458 (defun anything-c-gentoo-setup-cache ()
5459 "Set up `anything-c-cache-gentoo'"
5460 (setq anything-c-cache-gentoo
5461 (split-string (with-temp-buffer
5462 (call-process "eix" nil t nil
5466 (defun anything-c-gentoo-eshell-action (elm command
)
5467 (when (get-buffer "*EShell Command Output*")
5468 (kill-buffer "*EShell Command Output*"))
5469 (message "Wait searching...")
5470 (let ((buf-fname (buffer-file-name anything-current-buffer
)))
5471 (if (and buf-fname
(string-match tramp-file-name-regexp buf-fname
))
5473 (save-window-excursion
5474 (pop-to-buffer "*scratch*")
5475 (eshell-command (format "%s %s" command elm
)))
5476 (pop-to-buffer "*EShell Command Output*"))
5477 (eshell-command (format "%s %s" command elm
)))))
5479 (defun anything-c-gentoo-get-use ()
5480 "Initialize buffer with all use flags."
5481 (let* ((use-buf (get-buffer-create "*anything-gentoo-use*"))
5482 (buf (anything-candidate-buffer 'use-buf
)))
5483 (with-current-buffer buf
5484 (dolist (i anything-c-gentoo-use-flags
)
5485 (insert (concat i
"\n"))))))
5488 (defun anything-c-gentoo-setup-use-flags-cache ()
5489 "Setup `anything-c-gentoo-use-flags'"
5490 (setq anything-c-gentoo-use-flags
5491 (split-string (with-temp-buffer
5492 (call-process "eix" nil t nil
5493 "--print-all-useflags")
5496 (defun anything-c-gentoo-get-url (elm)
5497 "Return a list of urls from eix output."
5499 with url-list
= (split-string
5501 (call-process "eix" nil t nil
5502 elm
"--format" "<homepage>\n")
5506 when
(and (string-match "^http://.*" i
)
5507 (not (member i all
)))
5509 finally return all
))
5511 (defun anything-c-gentoo-get-world ()
5512 "Return list of all installed package on your system."
5513 (split-string (with-temp-buffer
5514 (call-process "qlist" nil t nil
5518 (defun anything-c-gentoo-get-local-use ()
5519 (split-string (with-temp-buffer
5520 (call-process "portageq" nil t nil
5525 (defface anything-gentoo-match-face
'((t (:foreground
"red")))
5526 "Face for anything-gentoo installed packages."
5527 :group
'traverse-faces
)
5529 (defun anything-c-highlight-world (eix)
5530 "Highlight all installed package."
5532 if
(member i anything-c-cache-world
)
5533 collect
(propertize i
'face
'anything-gentoo-match-face
)
5537 (defun anything-c-highlight-local-use (use-flags)
5538 (let ((local-uses (anything-c-gentoo-get-local-use)))
5539 (loop for i in use-flags
5540 if
(member i local-uses
)
5541 collect
(propertize i
'face
'anything-gentoo-match-face
)
5545 (defvar anything-c-source-emacs-process
5546 '((name .
"Emacs Process")
5547 (candidates .
(lambda () (mapcar #'process-name
(process-list))))
5548 (action ("Kill Process" .
(lambda (elm) (delete-process (get-process elm
)))))))
5550 ;; (anything 'anything-c-source-emacs-process)
5552 ;; Run Externals commands within Emacs
5553 (defmacro* anything-comp-hash-get-items
(hash-table &key test
)
5554 "Get the list of all keys/values of hash-table."
5555 `(let ((li-items ()))
5556 (maphash #'(lambda (x y
)
5558 (when (funcall ,test y
)
5559 (push (list x y
) li-items
))
5560 (push (list x y
) li-items
)))
5564 (defun anything-comp-read-get-candidates (collection &optional test
)
5565 "Convert collection to list.
5566 If collection is an `obarray', a test is maybe needed, otherwise
5567 the list would be incomplete.
5569 (cond ((and (listp collection
) test
)
5570 (loop for i in collection when
(funcall test i
) collect i
))
5571 ((and (eq collection obarray
) test
)
5572 (loop for s being the symbols of collection
5573 when
(funcall test s
) collect s
))
5574 ((and (vectorp collection
) test
)
5575 (loop for i across collection when
(funcall test i
) collect i
))
5576 ((vectorp collection
)
5577 (loop for i across collection collect i
))
5578 ((and (hash-table-p collection
) test
)
5579 (anything-comp-hash-get-items collection
:test test
))
5580 ((hash-table-p collection
)
5581 (anything-comp-hash-get-items collection
))
5584 (defun* anything-comp-read
(prompt collection
&key test initial-input
5585 (buffer "*Anything Completions*") must-match
5586 (requires-pattern 0))
5587 "Anything `completing-read' emulation.
5588 Collection can be a list, vector, obarray or hash-table."
5589 (when (get-buffer anything-action-buffer
)
5590 (kill-buffer anything-action-buffer
))
5592 `((name .
"Completions")
5595 (let ((cands (anything-comp-read-get-candidates collection test
)))
5596 (if (or must-match
(string= anything-pattern
""))
5597 cands
(append (list anything-pattern
) cands
)))))
5598 (requires-pattern .
,requires-pattern
)
5600 (action .
(("candidate" .
,'identity
))))
5601 initial-input prompt
'noresume nil buffer
)
5604 (defun anything-c-get-pid-from-process-name (process-name)
5605 "Get pid from running process PROCESS-NAME."
5606 (loop with process-list
= (list-system-processes)
5607 for pid in process-list
5608 for process
= (assoc-default 'comm
(process-attributes pid
))
5609 when
(and process
(string-match process-name process
))
5613 (defun anything-run-or-raise (exe &optional file
)
5614 "Generic command that run asynchronously EXE.
5615 If EXE is already running just jump to his window if `anything-raise-command'
5617 When FILE argument is provided run EXE with FILE.
5618 In this case EXE must be provided as \"EXE %s\"."
5619 (let ((real-com (car (split-string (replace-regexp-in-string " %s" "" exe
)))))
5620 (if (or (get-process real-com
)
5621 (anything-c-get-pid-from-process-name real-com
))
5622 (if anything-raise-command
5623 (shell-command (format anything-raise-command real-com
))
5624 (error "Error: %s is already running" real-com
))
5625 (when (member real-com anything-c-external-commands-list
)
5626 (message "Starting %s..." real-com
)
5628 (start-process-shell-command real-com nil
(format exe file
))
5629 (start-process-shell-command real-com nil real-com
))
5630 (set-process-sentinel
5631 (get-process real-com
)
5632 #'(lambda (process event
)
5633 (when (string= event
"finished\n")
5634 (when anything-raise-command
5635 (shell-command (format anything-raise-command
"emacs")))
5636 (message "%s process...Finished." process
))))
5637 (setq anything-c-external-commands-list
5638 (push (pop (nthcdr (anything-c-position
5639 real-com anything-c-external-commands-list
5641 anything-c-external-commands-list
))
5642 anything-c-external-commands-list
))))))
5645 (defun anything-c-run-external-command (program)
5646 "Preconfigured `anything' to run External PROGRAM asyncronously from Emacs.
5647 If program is already running exit with error.
5648 You can set your own list of commands with
5649 `anything-c-external-commands-list'."
5653 (anything-c-external-commands-list-1 'sort
)
5655 (anything-run-or-raise program
))
5657 (defsubst* anything-c-position
(item seq
&key
(test 'eq
))
5658 "A simple and faster replacement of CL `position'."
5659 (loop for i in seq for index from
0
5660 when
(funcall test i item
) return index
))
5662 (defvar anything-c-source-ratpoison-commands
5663 '((name .
"Ratpoison Commands")
5664 (init . anything-c-ratpoison-commands-init
)
5665 (candidates-in-buffer)
5666 (action ("Execute the command" . anything-c-ratpoison-commands-execute
))
5667 (display-to-real . anything-c-ratpoison-commands-display-to-real
)
5668 (candidate-number-limit)))
5669 ;; (anything 'anything-c-source-ratpoison-commands)
5671 (defun anything-c-ratpoison-commands-init ()
5672 (unless (anything-candidate-buffer)
5673 (with-current-buffer (anything-candidate-buffer 'global
)
5674 ;; with ratpoison prefix key
5676 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help"))
5677 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5678 (replace-match "<ratpoison> \\1: \\2"))
5679 (goto-char (point-max))
5682 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help top"))
5683 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5684 (replace-match "\\1: \\2")))))
5686 (defun anything-c-ratpoison-commands-display-to-real (display)
5687 (and (string-match ": " display
)
5688 (substring display
(match-end 0))))
5690 (defun anything-c-ratpoison-commands-execute (candidate)
5691 (call-process "ratpoison" nil nil nil
"-ic" candidate
))
5694 (defun anything-ratpoison-commands ()
5695 "Preconfigured `anything' to execute ratpoison commands."
5697 (anything-other-buffer 'anything-c-source-ratpoison-commands
5698 "*anything ratpoison commands*"))
5700 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5702 (defvar anything-c-external-commands-list nil
5703 "A list of all external commands the user can execute. If this
5704 variable is not set by the user, it will be calculated
5707 (defun anything-c-external-commands-list-1 (&optional sort
)
5708 "Returns a list of all external commands the user can execute.
5710 If `anything-c-external-commands-list' is non-nil it will
5711 return its contents. Else it calculates all external commands
5712 and sets `anything-c-external-commands-list'.
5714 The code is ripped out of `eshell-complete-commands-list'."
5715 (if anything-c-external-commands-list
5716 anything-c-external-commands-list
5717 (setq anything-c-external-commands-list
5718 (let* ((paths (split-string (getenv "PATH") path-separator
))
5719 (cwd (file-name-as-directory
5720 (expand-file-name default-directory
)))
5721 (path "") (comps-in-path ())
5722 (file "") (filepath "") (completions ()))
5723 ;; Go thru each path in the search path, finding completions.
5725 (setq path
(file-name-as-directory
5726 (expand-file-name (or (car paths
) ".")))
5728 (and (file-accessible-directory-p path
)
5729 (file-name-all-completions "" path
)))
5730 ;; Go thru each completion found, to see whether it should be
5731 ;; used, e.g. see if it's executable.
5732 (while comps-in-path
5733 (setq file
(car comps-in-path
)
5734 filepath
(concat path file
))
5735 (if (and (not (member file completions
))
5736 (or (string-equal path cwd
)
5737 (not (file-directory-p filepath
)))
5738 (file-executable-p filepath
))
5739 (setq completions
(cons file completions
)))
5740 (setq comps-in-path
(cdr comps-in-path
)))
5741 (setq paths
(cdr paths
)))
5743 (sort completions
#'(lambda (x y
) (string< x y
)))
5746 (defun anything-c-file-buffers (filename)
5747 "Returns a list of buffer names corresponding to FILENAME."
5748 (let ((name (expand-file-name filename
))
5750 (dolist (buf (buffer-list) buf-list
)
5751 (let ((bfn (buffer-file-name buf
)))
5752 (when (and bfn
(string= name bfn
))
5753 (push (buffer-name buf
) buf-list
))))))
5755 (defun anything-c-delete-file (file)
5756 "Delete the given file after querying the user.
5757 Ask to kill buffers associated with that file, too."
5758 (let ((buffers (anything-c-file-buffers file
)))
5759 (dired-delete-file file
'dired-recursive-deletes
)
5761 (dolist (buf buffers
)
5762 (when (y-or-n-p (format "Kill buffer %s, too? " buf
))
5763 (kill-buffer buf
))))))
5765 (defun anything-get-mailcap-for-file (filename)
5766 "Get the command to use for FILENAME from mailcap files.
5767 The command is like <command %s> and is meant to use with `format'."
5768 (mailcap-parse-mailcaps)
5769 (let* ((ext (file-name-extension filename
))
5770 (mime (when ext
(mailcap-extension-to-mime ext
))))
5771 (when mime
(mailcap-mime-info mime
))))
5773 (defun anything-c-open-file-externally (file)
5774 "Open FILE with an external tool found in .mailcap file.
5775 If not found or a prefix arg is given query the user which tool to use."
5776 (let* ((fname (expand-file-name file
))
5777 (collection (anything-c-external-commands-list-1 'sort
))
5778 (def-prog (anything-get-mailcap-for-file fname
))
5779 (program (or (unless (or anything-current-prefix-arg
5785 collection
:must-match t
)
5787 (anything-run-or-raise program file
)))
5790 (defun w32-shell-execute-open-file (file)
5791 (interactive "fOpen file:")
5793 (w32-shell-execute "open" (replace-regexp-in-string ;for UNC paths
5795 (replace-regexp-in-string ; strip cygdrive paths
5796 "/cygdrive/\\(.\\)" "\\1:"
5797 file nil nil
) nil t
))))
5799 (defun anything-c-open-file-with-default-tool (file)
5800 "Open FILE with the default tool on this platform."
5801 (if (eq system-type
'windows-nt
)
5802 (w32-shell-execute-open-file file
)
5803 (start-process "anything-c-open-file-with-default-tool"
5805 (cond ((eq system-type
'gnu
/linux
)
5807 ((or (eq system-type
'darwin
) ;; Mac OS X
5808 (eq system-type
'macos
)) ;; Mac OS 9
5812 (defun anything-c-open-dired (file)
5813 "Opens a dired buffer in FILE's directory. If FILE is a
5814 directory, open this directory."
5815 (if (file-directory-p file
)
5817 (dired (file-name-directory file
))
5818 (dired-goto-file file
)))
5820 (defun anything-c-display-to-real-line (candidate)
5821 (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate
)
5822 (list (string-to-number (match-string 1 candidate
)) (match-string 2 candidate
))
5823 (error "Line number not found")))
5825 (defun anything-c-action-line-goto (lineno-and-content)
5826 (apply #'anything-goto-file-line
(anything-interpret-value (anything-attr 'target-file
))
5827 (append lineno-and-content
5828 (list (if (and (anything-attr-defined 'target-file
)
5829 (not anything-in-persistent-action
))
5830 'find-file-other-window
5833 (defun* anything-c-action-file-line-goto
(file-line-content &optional
(find-file-function #'find-file
))
5834 (apply #'anything-goto-file-line
5835 (if (stringp file-line-content
)
5836 ;; Case: filtered-candidate-transformer is skipped
5837 (cdr (anything-c-filtered-candidate-transformer-file-line-1 file-line-content
))
5838 file-line-content
)))
5841 (defun anything-c-filtered-candidate-transformer-file-line (candidates source
)
5842 (delq nil
(mapcar 'anything-c-filtered-candidate-transformer-file-line-1 candidates
)))
5844 (defun anything-c-filtered-candidate-transformer-file-line-1 (candidate)
5845 (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate
)
5846 (let ((filename (match-string 1 candidate
))
5847 (lineno (match-string 2 candidate
))
5848 (content (match-string 3 candidate
)))
5849 (cons (format "%s:%s\n %s"
5850 (propertize filename
'face compilation-info-face
)
5851 (propertize lineno
'face compilation-line-face
)
5853 (list (expand-file-name
5855 (or (anything-interpret-value (anything-attr 'default-directory
))
5856 (and (anything-candidate-buffer)
5858 'default-directory
(anything-candidate-buffer)))))
5859 (string-to-number lineno
) content
)))))
5861 (defun* anything-goto-file-line
(file lineno content
&optional
(find-file-function #'find-file
))
5862 (anything-aif (anything-attr 'before-jump-hook
)
5864 (when file
(funcall find-file-function file
))
5865 (if (anything-attr-defined 'adjust
)
5866 (anything-c-goto-line-with-adjustment lineno content
)
5867 (anything-goto-line lineno
))
5868 (unless (anything-attr-defined 'recenter
)
5869 (set-window-start (get-buffer-window anything-current-buffer
) (point)))
5870 (anything-aif (anything-attr 'after-jump-hook
)
5872 (when anything-in-persistent-action
5873 (anything-match-line-color-current-line)))
5875 (defun anything-find-file-as-root (candidate)
5876 (find-file (concat "/" anything-su-or-sudo
"::" (expand-file-name candidate
))))
5878 (defun anything-find-many-files (ignore)
5879 (mapc 'find-file
(anything-marked-candidates)))
5881 ;; borrowed from etags.el
5882 ;; (anything-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el")
5883 (defun anything-c-goto-line-with-adjustment (line line-content
)
5886 ;; This constant is 1/2 the initial search window.
5887 ;; There is no sense in making it too small,
5888 ;; since just going around the loop once probably
5889 ;; costs about as much as searching 2000 chars.
5892 pat
(concat (if (eq selective-display t
)
5893 "\\(^\\|\^m\\) *" "^ *") ;allow indent
5894 (regexp-quote line-content
)))
5895 ;; If no char pos was given, try the given line number.
5896 (setq startpos
(progn (anything-goto-line line
) (point)))
5897 (or startpos
(setq startpos
(point-min)))
5898 ;; First see if the tag is right at the specified location.
5899 (goto-char startpos
)
5900 (setq found
(looking-at pat
))
5901 (while (and (not found
)
5903 (goto-char (- startpos offset
))
5906 (re-search-forward pat
(+ startpos offset
) t
)
5907 offset
(* 3 offset
))) ; expand search window
5909 (re-search-forward pat nil t
)
5910 (error "not found")))
5911 ;; Position point at the right place
5912 ;; if the search string matched an extra Ctrl-m at the beginning.
5913 (and (eq selective-display t
)
5916 (beginning-of-line))
5918 (anything-document-attribute 'default-directory
"type . file-line"
5919 "`default-directory' to interpret file.")
5920 (anything-document-attribute 'before-jump-hook
"type . file-line / line"
5921 "Function to call before jumping to the target location.")
5922 (anything-document-attribute 'after-jump-hook
"type . file-line / line"
5923 "Function to call after jumping to the target location.")
5924 (anything-document-attribute 'adjust
"type . file-line"
5925 "Search around line matching line contents.")
5926 (anything-document-attribute 'recenter
"type . file-line / line"
5927 "`recenter' after jumping.")
5928 (anything-document-attribute 'target-file
"type . line"
5929 "Goto line of target-file.")
5932 (defun anything-c-call-interactively (cmd-or-name)
5933 "Execute CMD-OR-NAME as Emacs command.
5934 It is added to `extended-command-history'.
5935 `anything-current-prefix-arg' is used as the command's prefix argument."
5936 (setq extended-command-history
5937 (cons (anything-c-stringify cmd-or-name
)
5938 (delete (anything-c-stringify cmd-or-name
) extended-command-history
)))
5939 (let ((current-prefix-arg anything-current-prefix-arg
)
5940 (cmd (anything-c-symbolify cmd-or-name
)))
5941 (if (stringp (symbol-function cmd
))
5942 (execute-kbd-macro (symbol-function cmd
))
5943 (setq this-command cmd
)
5944 (call-interactively cmd
))))
5947 (defun anything-c-set-variable (var)
5948 "Set value to VAR interactively."
5950 (let ((sym (anything-c-symbolify var
)))
5951 (set sym
(eval-minibuffer (format "Set %s: " var
)
5952 (prin1-to-string (symbol-value sym
))))))
5954 ;; (anything-c-set-variable 'hh)
5956 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Persistent Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5957 (defvar anything-match-line-overlay-face nil
)
5958 (defvar anything-match-line-overlay nil
)
5960 (defun anything-match-line-color-current-line (&optional start end buf face rec
)
5961 "Highlight and underline current position"
5962 (let ((args (list (or start
(line-beginning-position))
5963 (or end
(1+ (line-end-position)))
5965 (if (not anything-match-line-overlay
)
5966 (setq anything-match-line-overlay
(apply 'make-overlay args
))
5967 (apply 'move-overlay anything-match-line-overlay args
)))
5968 (overlay-put anything-match-line-overlay
5969 'face
(or face anything-match-line-overlay-face
))
5974 (defalias 'anything-persistent-highlight-point
'anything-match-line-color-current-line
)
5976 (defface anything-overlay-line-face
'((t (:background
"IndianRed4" :underline t
)))
5977 "Face for source header in the anything buffer." :group
'anything
)
5979 (setq anything-match-line-overlay-face
'anything-overlay-line-face
)
5981 (defun anything-match-line-cleanup ()
5982 (when anything-match-line-overlay
5983 (delete-overlay anything-match-line-overlay
)
5984 (setq anything-match-line-overlay nil
)))
5986 (defun anything-match-line-update ()
5987 (when anything-match-line-overlay
5988 (delete-overlay anything-match-line-overlay
)
5989 (anything-match-line-color-current-line)))
5991 (add-hook 'anything-cleanup-hook
'anything-match-line-cleanup
)
5992 (add-hook 'anything-after-persistent-action-hook
'anything-match-line-update
)
5994 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Actions Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5996 (defun anything-c-transform-file-load-el (actions candidate
)
5997 "Add action to load the file CANDIDATE if it is an emacs lisp
5998 file. Else return ACTIONS unmodified."
5999 (if (member (file-name-extension candidate
) '("el" "elc"))
6000 (append actions
'(("Load Emacs Lisp File" . load-file
)))
6003 (defun anything-c-transform-file-browse-url (actions candidate
)
6004 "Add an action to browse the file CANDIDATE if it in a html
6005 file or URL. Else return ACTIONS unmodified."
6006 (let ((browse-action '("Browse with Browser" . browse-url
)))
6007 (cond ((string-match "^http\\|^ftp" candidate
)
6008 (cons browse-action actions
))
6009 ((string-match "\\.html?$" candidate
)
6010 (append actions
(list browse-action
)))
6014 (defun anything-c-transform-function-call-interactively (actions candidate
)
6015 "Add an action to call the function CANDIDATE interactively if
6016 it is a command. Else return ACTIONS unmodified."
6017 (if (commandp (intern-soft candidate
))
6018 (append actions
'(("Call Interactively"
6020 anything-c-call-interactively
)))
6024 (defun anything-c-transform-sexp-eval-command-sexp (actions candidate
)
6025 "If CANDIDATE's `car' is a command, then add an action to
6026 evaluate it and put it onto the `command-history'."
6027 (if (commandp (car (read candidate
)))
6028 ;; Make it first entry
6029 (cons '("Eval and put onto command-history" .
6031 (let ((sym (read sexp
)))
6033 (setq command-history
6034 (cons sym command-history
)))))
6038 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Candidate Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6040 (defun anything-c-skip-boring-buffers (buffers)
6041 (anything-c-skip-entries buffers anything-c-boring-buffer-regexp
))
6043 (defun anything-c-skip-current-buffer (buffers)
6044 (if anything-allow-skipping-current-buffer
6045 (remove (buffer-name anything-current-buffer
) buffers
)
6048 (defun anything-c-shadow-boring-buffers (buffers)
6049 "Buffers matching `anything-c-boring-buffer-regexp' will be
6050 displayed with the `file-name-shadow' face if available."
6051 (anything-c-shadow-entries buffers anything-c-boring-buffer-regexp
))
6054 (defun anything-c-shadow-boring-files (files)
6055 "Files matching `anything-c-boring-file-regexp' will be
6056 displayed with the `file-name-shadow' face if available."
6057 (anything-c-shadow-entries files anything-c-boring-file-regexp
))
6059 (defun anything-c-skip-boring-files (files)
6060 "Files matching `anything-c-boring-file-regexp' will be skipped."
6061 (anything-c-skip-entries files anything-c-boring-file-regexp
))
6062 ;; (anything-c-skip-boring-files '("README" "/src/.svn/hoge"))
6064 (defun anything-c-skip-current-file (files)
6065 "Current file will be skipped."
6066 (remove (buffer-file-name anything-current-buffer
) files
))
6068 (defun anything-c-w32-pathname-transformer (args)
6069 "Change undesirable features of windows pathnames to ones more acceptable to
6070 other candidate transformers."
6071 (if (eq system-type
'windows-nt
)
6073 (replace-regexp-in-string "/cygdrive/\\(.\\)" "\\1:" x
))
6075 (replace-regexp-in-string "\\\\" "/" y
)) args
))
6078 (defun anything-c-shorten-home-path (files)
6079 "Replaces /home/user with ~."
6080 (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows...
6082 (mapcar (lambda (file)
6083 (if (and (stringp file
) (string-match home file
))
6084 (cons (replace-match "~" nil nil file
) file
)
6089 (defun anything-c-mark-interactive-functions (functions)
6090 "Mark interactive functions (commands) with (i) after the function name."
6092 (loop for function in functions
6093 do
(push (cons (concat function
6094 (when (commandp (intern-soft function
)) " (i)"))
6097 finally
(return (nreverse list
)))))
6099 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Adaptive Sorting of Candidates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6100 (defvar anything-c-adaptive-done nil
6101 "nil if history information is not yet stored for the current
6104 (defvar anything-c-adaptive-history nil
6105 "Contains the stored history information.
6106 Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")
6108 (defadvice anything-initialize
(before anything-c-adaptive-initialize activate
)
6109 "Advise `anything-initialize' to reset `anything-c-adaptive-done'
6110 when anything is started."
6111 (setq anything-c-adaptive-done nil
))
6113 (defadvice anything-exit-minibuffer
(before anything-c-adaptive-exit-minibuffer activate
)
6114 "Advise `anything-exit-minibuffer' to store history information
6115 when a candidate is selected with RET."
6116 (anything-c-adaptive-store-selection))
6118 (defadvice anything-select-action
(before anything-c-adaptive-select-action activate
)
6119 "Advise `anything-select-action' to store history information
6120 when the user goes to the action list with TAB."
6121 (anything-c-adaptive-store-selection))
6123 (defun anything-c-source-use-adaptative-p (&optional source-name
)
6124 "Return current source only if it use adaptative history, nil otherwise."
6125 (let* ((source (or source-name
(anything-get-current-source)))
6126 (adapt-source (or (assoc-default 'filtered-candidate-transformer
6127 (assoc (assoc-default 'type source
)
6128 anything-type-attributes
))
6129 (assoc-default 'candidate-transformer
6130 (assoc (assoc-default 'type source
)
6131 anything-type-attributes
))
6132 (assoc-default 'filtered-candidate-transformer source
)
6133 (assoc-default 'candidate-transformer source
))))
6134 (if (listp adapt-source
)
6135 (when (member 'anything-c-adaptive-sort adapt-source
) source
)
6136 (when (eq adapt-source
'anything-c-adaptive-sort
) source
))))
6138 (defun anything-c-adaptive-store-selection ()
6139 "Store history information for the selected candidate."
6140 (unless anything-c-adaptive-done
6141 (setq anything-c-adaptive-done t
)
6142 (let ((source (anything-c-source-use-adaptative-p)))
6144 (let* ((source-name (or (assoc-default 'type source
)
6145 (assoc-default 'name source
)))
6146 (source-info (or (assoc source-name anything-c-adaptive-history
)
6148 (push (list source-name
) anything-c-adaptive-history
)
6149 (car anything-c-adaptive-history
))))
6150 (selection (anything-get-selection))
6151 (selection-info (progn
6154 (let ((found (assoc selection
(cdr source-info
))))
6159 ;; move entry to the beginning of the
6160 ;; list, so that it doesn't get
6161 ;; trimmed when the history is
6164 (delete found
(cdr source-info
)))
6167 (cadr source-info
)))
6168 (pattern-info (progn
6169 (setcdr selection-info
6171 (let ((found (assoc anything-pattern
(cdr selection-info
))))
6174 (cons anything-pattern
0)
6176 ;; move entry to the beginning of the
6177 ;; list, so if two patterns used the
6178 ;; same number of times then the one
6179 ;; used last appears first in the list
6180 (setcdr selection-info
6181 (delete found
(cdr selection-info
)))
6183 (cdr selection-info
)))
6184 (cadr selection-info
))))
6186 ;; increase usage count
6187 (setcdr pattern-info
(1+ (cdr pattern-info
)))
6189 ;; truncate history if needed
6190 (if (> (length (cdr selection-info
)) anything-c-adaptive-history-length
)
6191 (setcdr selection-info
6192 (subseq (cdr selection-info
) 0 anything-c-adaptive-history-length
))))))))
6194 (if (file-readable-p anything-c-adaptive-history-file
)
6195 (load-file anything-c-adaptive-history-file
))
6196 (add-hook 'kill-emacs-hook
'anything-c-adaptive-save-history
)
6198 (defun anything-c-adaptive-save-history ()
6199 "Save history information to file given by `anything-c-adaptive-history-file'."
6203 ";; -*- mode: emacs-lisp -*-\n"
6204 ";; History entries used for anything adaptive display.\n")
6205 (prin1 `(setq anything-c-adaptive-history
',anything-c-adaptive-history
)
6208 (write-region (point-min) (point-max) anything-c-adaptive-history-file nil
6209 (unless (interactive-p) 'quiet
))))
6211 (defun anything-c-adaptive-sort (candidates source
)
6212 "Sort the CANDIDATES for SOURCE by usage frequency.
6213 This is a filtered candidate transformer you can use for the
6214 attribute `filtered-candidate-transformer' of a source in
6215 `anything-sources' or a type in `anything-type-attributes'."
6216 (let* ((source-name (or (assoc-default 'type source
)
6217 (assoc-default 'name source
)))
6218 (source-info (assoc source-name anything-c-adaptive-history
)))
6219 (if (not source-info
)
6220 ;; if there is no information stored for this source then do nothing
6224 ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT)
6226 (mapcar (lambda (candidate-info)
6228 (dolist (pattern-info (cdr candidate-info
))
6229 (if (not (equal (car pattern-info
)
6231 (incf count
(cdr pattern-info
))
6233 ;; if current pattern is equal to the previously
6234 ;; used one then this candidate has priority
6235 ;; (that's why its count is boosted by 10000) and
6236 ;; it only has to compete with other candidates
6237 ;; which were also selected with the same pattern
6238 (setq count
(+ 10000 (cdr pattern-info
)))
6240 (cons (car candidate-info
) count
)))
6244 ;; sort the list in descending order, so candidates with highest
6245 ;; priorty come first
6246 (setq usage
(sort usage
(lambda (first second
)
6247 (> (cdr first
) (cdr second
)))))
6249 ;; put those candidates first which have the highest usage count
6250 (dolist (info usage
)
6251 (when (member* (car info
) candidates
6252 :test
'anything-c-adaptive-compare
)
6253 (push (car info
) sorted
)
6254 (setq candidates
(remove* (car info
) candidates
6255 :test
'anything-c-adaptive-compare
))))
6257 ;; and append the rest
6258 (append (reverse sorted
) candidates nil
)))))
6260 (defun anything-c-adaptive-compare (x y
)
6261 "Compare candidates X and Y taking into account that the
6262 candidate can be in (DISPLAY . REAL) format."
6263 (equal (if (listp x
)
6270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Outliner ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6271 (defvar anything-outline-goto-near-line-flag t
)
6272 (defvar anything-outline-using nil
)
6273 (defun anything-after-update-hook--outline ()
6274 (if (and (eq anything-outline-using t
)
6275 (eq anything-outline-goto-near-line-flag t
))
6276 (anything-outline-goto-near-line)))
6277 (add-hook 'anything-after-update-hook
'anything-after-update-hook--outline
)
6279 (defun anything-outline-goto-near-line ()
6280 (with-anything-window
6281 ;; TODO need consideration whether to update position by every input.
6282 (when t
; (equal anything-pattern "")
6283 (anything-goto-line 2)
6284 (let ((lineno (with-current-buffer anything-current-buffer
6285 (line-number-at-pos (car anything-current-position
)))))
6287 (while (<= (progn (skip-chars-forward " ")
6288 (or (number-at-point) lineno
))
6293 (return-from exit
))))
6295 (and (bobp) (forward-line 1))
6296 (and (anything-pos-header-line-p) (forward-line -
2))
6297 (anything-mark-current-line)))))
6299 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Plug-in ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6300 ;; Plug-in: info-index
6301 (defun* anything-c-info-init
(&optional
(file (anything-attr 'info-file
)))
6303 (unless (anything-candidate-buffer)
6304 (save-window-excursion
6307 (tobuf (anything-candidate-buffer 'global
))
6308 (infobuf (current-buffer))
6310 (dolist (node (or (anything-attr 'index-nodes
) (Info-index-nodes)))
6311 (Info-goto-node node
)
6312 (goto-char (point-min))
6313 (while (search-forward "\n* " nil t
)
6314 (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t
)
6315 '(save-current-buffer (buffer-substring-no-properties (point-at-bol) (point-at-eol)) result
)
6316 (setq s
(point-at-bol)
6318 (with-current-buffer tobuf
6319 (insert-buffer-substring infobuf s e
)
6320 (insert "\n"))))))))))
6322 (defun anything-c-info-goto (node-line)
6323 (Info-goto-node (car node-line
))
6324 (anything-goto-line (cdr node-line
)))
6326 (defun anything-c-info-display-to-real (line)
6328 "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line
)
6329 (cons (format "(%s)%s" (anything-attr 'info-file
) (match-string 2 line
))
6330 (string-to-number (or (match-string 3 line
) "1")))))
6332 (defun anything-c-make-info-source (file)
6333 `((name .
,(concat "Info Index: " file
))
6335 (init . anything-c-info-init
)
6336 (display-to-real . anything-c-info-display-to-real
)
6337 (get-line . buffer-substring
)
6338 (candidates-in-buffer)
6339 (action ("Goto node" . anything-c-info-goto
))))
6341 (defun anything-compile-source--info-index (source)
6342 (anything-aif (anything-interpret-value (assoc-default 'info-index source
))
6343 (anything-c-make-info-source it
)
6345 (add-to-list 'anything-compile-source-functions
'anything-compile-source--info-index
)
6347 (anything-document-attribute 'info-index
"info-index plugin"
6348 "Create a source of info index very easily.
6350 ex. (defvar anything-c-source-info-wget '((info-index . \"wget\"))")
6352 (anything-document-attribute 'index-nodes
"info-index plugin (optional)"
6353 "Index nodes of info file.
6355 If it is omitted, `Info-index-nodes' is used to collect index nodes.
6356 Some info files are missing index specification.
6358 ex. See `anything-c-source-info-screen'.")
6360 ;; Plug-in: candidates-file
6361 (defun anything-compile-source--candidates-file (source)
6362 (if (assoc-default 'candidates-file source
)
6363 `((init anything-p-candidats-file-init
6364 ,@(let ((orig-init (assoc-default 'init source
)))
6365 (cond ((null orig-init
) nil
)
6366 ((functionp orig-init
) (list orig-init
))
6368 (candidates-in-buffer)
6371 (add-to-list 'anything-compile-source-functions
'anything-compile-source--candidates-file
)
6373 (defun anything-p-candidats-file-init ()
6374 (destructuring-bind (file &optional updating
)
6375 (anything-mklist (anything-attr 'candidates-file
))
6376 (setq file
(anything-interpret-value file
))
6377 (with-current-buffer (anything-candidate-buffer (find-file-noselect file
))
6379 (buffer-disable-undo)
6381 (auto-revert-mode 1)))))
6383 (anything-document-attribute 'candidates-file
"candidates-file plugin"
6384 "Use a file as the candidates buffer.
6386 1st argument is a filename, string or function name or variable name.
6387 If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.")
6389 ;; Plug-in: headline
6390 (defun anything-compile-source--anything-headline (source)
6391 (if (assoc-default 'headline source
)
6392 (append '((init . anything-headline-init
)
6393 (get-line . buffer-substring
)
6396 '((candidates-in-buffer)
6397 (persistent-help .
"Show this line")))
6399 (add-to-list 'anything-compile-source-functions
'anything-compile-source--anything-headline
)
6401 (defun anything-headline-init ()
6402 (when (and (anything-current-buffer-is-modified)
6403 (with-current-buffer anything-current-buffer
6404 (eval (or (anything-attr 'condition
) t
))))
6405 (anything-headline-make-candidate-buffer
6406 (anything-interpret-value (anything-attr 'headline
))
6407 (anything-interpret-value (anything-attr 'subexp
)))))
6409 (anything-document-attribute 'headline
"Headline plug-in"
6410 "Regexp string for anything-headline to scan.")
6411 (anything-document-attribute 'condition
"Headline plug-in"
6412 "A sexp representing the condition to use anything-headline.")
6413 (anything-document-attribute 'subexp
"Headline plug-in"
6414 "Display (match-string-no-properties subexp).")
6417 (defun anything-headline-get-candidates (regexp subexp
)
6418 (with-current-buffer anything-current-buffer
6420 (goto-char (point-min))
6421 (if (functionp regexp
) (setq regexp
(funcall regexp
)))
6422 (let (hierarchy curhead
)
6424 (if (numberp subexp
)
6425 (cons (match-string-no-properties subexp
) (match-beginning subexp
))
6426 (cons (buffer-substring (point-at-bol) (point-at-eol))
6428 (hierarchies (headlines)
6429 (1+ (loop for
(_ . hierarchy
) in headlines
6430 maximize hierarchy
)))
6432 (loop for i from
0 to hierarchy
6433 collecting
(aref curhead i
)))
6434 (arrange (headlines)
6435 (unless (null headlines
) ; FIX headlines empty bug!
6436 (loop with curhead
= (make-vector (hierarchies headlines
) "")
6437 for
((str . pt
) . hierarchy
) in headlines
6438 do
(aset curhead hierarchy str
)
6441 (format "H%d:%s" (1+ hierarchy
)
6442 (mapconcat 'identity
(vector-0-n curhead hierarchy
) " / "))
6447 (loop for re in regexp
6448 for hierarchy from
0
6449 do
(goto-char (point-min))
6452 while
(re-search-forward re nil t
)
6453 collect
(cons (matched) hierarchy
)))
6454 (lambda (a b
) (> (cdar b
) (cdar a
)))))
6455 (loop while
(re-search-forward regexp nil t
)
6456 collect
(matched))))))))
6459 (defun anything-headline-make-candidate-buffer (regexp subexp
)
6460 (with-current-buffer (anything-candidate-buffer 'local
)
6461 (loop for
(content . pos
) in
(anything-headline-get-candidates regexp subexp
)
6464 (with-current-buffer anything-current-buffer
6465 (line-number-at-pos pos
))
6468 (defun anything-headline-goto-position (pos recenter
)
6471 (set-window-start (get-buffer-window anything-current-buffer
) (point))))
6473 (defun anything-revert-buffer (candidate)
6474 (with-current-buffer candidate
6475 (when (buffer-modified-p)
6476 (revert-buffer t t
))))
6478 (defun anything-revert-marked-buffers (candidate)
6479 (dolist (i (anything-marked-candidates))
6480 (anything-revert-buffer i
)))
6482 (defun anything-kill-marked-buffers (candidate)
6483 (dolist (i (anything-marked-candidates))
6486 ;; Plug-in: persistent-help
6487 (defun anything-compile-source--persistent-help (source)
6488 (append source
'((header-line . anything-persistent-help-string
))))
6489 (add-to-list 'anything-compile-source-functions
'anything-compile-source--persistent-help
)
6491 (defun anything-persistent-help-string ()
6492 (substitute-command-keys
6493 (concat "\\<anything-map>\\[anything-execute-persistent-action]: "
6494 (or (anything-interpret-value (anything-attr 'persistent-help
))
6495 (anything-aif (or (assoc-default 'persistent-action
6496 (anything-get-current-source))
6497 (assoc-default 'action
6498 (anything-get-current-source)))
6499 (cond ((symbolp it
) (symbol-name it
))
6500 ((listp it
) (or (ignore-errors (caar it
)) ""))))
6502 " (keeping session)")))
6504 (anything-document-attribute 'persistent-help
"persistent-help plug-in"
6505 "A string to explain persistent-action of this source.
6506 It also accepts a function or a variable name.")
6508 ;;; (anything '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST"))))
6510 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6512 (defun anything-c-find-file-or-marked (candidate)
6513 "Open file CANDIDATE or open anything marked files in background."
6514 (let ((marked (anything-marked-candidates)))
6515 (if (> (length marked
) 1)
6516 (dolist (i marked
) (find-file-noselect i
))
6517 (find-file-at-point candidate
))))
6519 ;; FIXME there is a bug in dired that confuse all dired commands
6520 ;; when using this feature, so i suspend it until bug is fixed in emacs.
6522 ;; (defun anything-c-create-dired-on-marked (candidate)
6523 ;; "Create a new dired buffer with only marked candidates."
6524 ;; (let ((marked (anything-marked-candidates))
6525 ;; (buffer-name (read-string "New Dired Buffer: ")))
6526 ;; (dired (cons buffer-name marked))))
6528 (defun anything-delete-marked-files (ignore)
6529 (let* ((files (anything-marked-candidates))
6530 (len (length files
)))
6532 (format "Delete *%s File(s):\n%s"
6534 (mapconcat (lambda (f) (format "- %s\n" f
)) files
""))))
6535 (message "(No deletions performed)")
6537 (set-text-properties 0 (length i
) nil i
)
6538 (anything-c-delete-file i
))
6539 (message "%s File(s) deleted" len
))))
6541 (defun anything-ediff-marked-buffers (candidate &optional merge
)
6542 "Ediff 2 marked buffers or 1 marked buffer and current-buffer.
6543 With optional arg `merge' call `ediff-merge-buffers'."
6544 (let ((lg-lst (length (anything-marked-candidates)))
6548 (error "Error:You have to mark at least 1 buffer"))
6550 (setq buf1 anything-current-buffer
6551 buf2
(first (anything-marked-candidates))))
6553 (setq buf1
(first (anything-marked-candidates))
6554 buf2
(second (anything-marked-candidates))))
6556 (error "Error:To much buffers marked!")))
6558 (ediff-merge-buffers buf1 buf2
)
6559 (ediff-buffers buf1 buf2
))))
6561 (defun anything-bookmark-get-bookmark-from-name (bmk)
6562 "Return bookmark name even if it is a bookmark with annotation.
6563 e.g prepended with *.
6564 Return nil if bmk is not a valid bookmark."
6565 (let ((bookmark (replace-regexp-in-string "\*" "" bmk
)))
6566 (if (assoc bookmark bookmark-alist
)
6568 (when (assoc bmk bookmark-alist
)
6571 (defun anything-delete-marked-bookmarks (elm)
6572 "Delete this bookmark or all marked bookmarks."
6573 (let ((bookmark (anything-bookmark-get-bookmark-from-name elm
)))
6574 (anything-aif (anything-marked-candidates)
6576 (let ((bmk (anything-bookmark-get-bookmark-from-name i
)))
6577 (bookmark-delete bmk
'batch
)))
6578 (bookmark-delete bookmark
'batch
))))
6580 (defun anything-require-or-error (feature function
)
6581 (or (require feature nil t
)
6582 (error "Need %s to use `%s'." feature function
)))
6584 (defun anything-find-buffer-on-elscreen (candidate)
6585 "Open buffer in new screen, if marked buffers open all in elscreens."
6586 (anything-require-or-error 'elscreen
'anything-find-buffer-on-elscreen
)
6587 (anything-aif (anything-marked-candidates)
6589 (let ((target-screen (elscreen-find-screen-by-buffer
6590 (get-buffer i
) 'create
)))
6591 (elscreen-goto target-screen
)))
6592 (let ((target-screen (elscreen-find-screen-by-buffer
6593 (get-buffer candidate
) 'create
)))
6594 (elscreen-goto target-screen
))))
6596 (defun anything-elscreen-find-file (file)
6597 (anything-require-or-error 'elscreen
'anything-elscreen-find-file
)
6598 (elscreen-find-file file
))
6600 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6602 ;;;; Type Attributes
6603 (define-anything-type-attribute 'buffer
6606 '(("Switch to buffer other window" . switch-to-buffer-other-window
)
6607 ("Switch to buffer" . switch-to-buffer
))
6608 '(("Switch to buffer" . switch-to-buffer
)
6609 ("Switch to buffer other window" . switch-to-buffer-other-window
)
6610 ("Switch to buffer other frame" . switch-to-buffer-other-frame
)))
6611 ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . anything-find-buffer-on-elscreen
))
6612 ("Display buffer" . display-buffer
)
6613 ("Revert buffer" . anything-revert-buffer
)
6614 ("Revert Marked buffers" . anything-revert-marked-buffers
)
6615 ("Kill buffer" . kill-buffer
)
6616 ("Kill Marked buffers" . anything-kill-marked-buffers
)
6617 ("Ediff Marked buffers" . anything-ediff-marked-buffers
)
6618 ("Ediff Merge marked buffers" .
(lambda (candidate)
6619 (anything-ediff-marked-buffers candidate t
))))
6620 (persistent-help .
"Show this buffer")
6621 (candidate-transformer anything-c-skip-current-buffer anything-c-skip-boring-buffers
))
6622 "Buffer or buffer name.")
6624 (define-anything-type-attribute 'file
6627 '(("Find file other window" . find-file-other-window
)
6628 ("Find file(s)" . anything-find-many-files
)
6629 ("Find file as root" . anything-find-file-as-root
))
6630 '(("Find file" . anything-find-many-files
)
6631 ("Find file as root" . anything-find-file-as-root
)
6632 ("Find file other window" . find-file-other-window
)
6633 ("Find file other frame" . find-file-other-frame
)))
6634 ("Open dired in file's directory" . anything-c-open-dired
)
6635 ("Delete file(s)" . anything-delete-marked-files
)
6636 ("Open file externally" . anything-c-open-file-externally
)
6637 ("Open file with default tool" . anything-c-open-file-with-default-tool
))
6638 (persistent-help .
"Show this file")
6639 (action-transformer anything-c-transform-file-load-el
6640 anything-c-transform-file-browse-url
)
6641 (candidate-transformer anything-c-w32-pathname-transformer
6642 anything-c-skip-current-file
6643 anything-c-skip-boring-files
6644 anything-c-shorten-home-path
))
6647 (define-anything-type-attribute 'command
6648 `((action ("Call interactively" . anything-c-call-interactively
)
6649 ("Describe command" . anything-c-describe-function
)
6650 ("Add command to kill ring" . anything-c-kill-new
)
6651 ("Go to command's definition" . anything-c-find-function
))
6652 ;; Sort commands according to their usage count.
6653 (filtered-candidate-transformer . anything-c-adaptive-sort
)
6654 (persistent-action . anything-c-describe-function
))
6655 "Command. (string or symbol)")
6657 (define-anything-type-attribute 'function
6658 '((action ("Describe function" . anything-c-describe-function
)
6659 ("Add function to kill ring" . anything-c-kill-new
)
6660 ("Go to function's definition" . anything-c-find-function
))
6661 (action-transformer anything-c-transform-function-call-interactively
)
6662 (candidate-transformer anything-c-mark-interactive-functions
))
6663 "Function. (string or symbol)")
6665 (define-anything-type-attribute 'variable
6666 '((action ("Describe variable" . anything-c-describe-variable
)
6667 ("Add variable to kill ring" . anything-c-kill-new
)
6668 ("Go to variable's definition" . anything-c-find-variable
)
6669 ("Set variable" . anything-c-set-variable
)))
6672 (define-anything-type-attribute 'sexp
6673 '((action ("Eval s-expression" .
(lambda (c) (eval (read c
))))
6674 ("Add s-expression to kill ring" . kill-new
))
6675 (action-transformer anything-c-transform-sexp-eval-command-sexp
))
6676 "String representing S-Expressions.")
6678 (define-anything-type-attribute 'bookmark
6680 ("Jump to bookmark" .
(lambda (candidate)
6681 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
))
6682 (current-prefix-arg anything-current-prefix-arg
))
6683 (bookmark-jump bookmark
))
6685 ("Jump to BM other window" .
(lambda (candidate)
6686 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6687 (bookmark-jump-other-window bookmark
))
6689 ("Bookmark edit annotation" .
(lambda (candidate)
6690 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6691 (bookmark-edit-annotation bookmark
))))
6692 ("Bookmark show annotation" .
(lambda (candidate)
6693 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6694 (bookmark-show-annotation bookmark
))))
6695 ("Delete bookmark(s)" . anything-delete-marked-bookmarks
)
6696 ,@(when (fboundp 'bmkext-edit-bookmark
)
6697 '(("Edit Bookmark" .
(lambda (candidate)
6698 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6699 (bmkext-edit-bookmark bookmark
))))))
6700 ("Rename bookmark" .
(lambda (candidate)
6701 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6702 (bookmark-rename bookmark
))))
6703 ("Relocate bookmark" .
(lambda (candidate)
6704 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6705 (bookmark-relocate bookmark
))))))
6708 (define-anything-type-attribute 'line
6709 '((display-to-real . anything-c-display-to-real-line
)
6710 (action ("Go to Line" . anything-c-action-line-goto
)))
6711 "LINENO:CONTENT string, eg. \" 16:foo\".
6713 Optional `target-file' attribute is a name of target file.
6715 Optional `before-jump-hook' attribute is a function with no
6716 arguments which is called before jumping to position.
6718 Optional `after-jump-hook' attribute is a function with no
6719 arguments which is called after jumping to position.
6721 If `adjust' attribute is specified, searches the line whose
6722 content is CONTENT near the LINENO.
6724 If `recenter' attribute is specified, the line is displayed at
6725 the center of window, otherwise at the top of window.
6728 (define-anything-type-attribute 'file-line
6729 `((filtered-candidate-transformer anything-c-filtered-candidate-transformer-file-line
)
6731 (action ("Go to" . anything-c-action-file-line-goto
)))
6732 "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\".
6734 Optional `default-directory' attribute is a default-directory
6735 FILENAME is interpreted.
6737 Optional `before-jump-hook' attribute is a function with no
6738 arguments which is called before jumping to position.
6740 Optional `after-jump-hook' attribute is a function with no
6741 arguments which is called after jumping to position.
6743 If `adjust' attribute is specified, searches the line whose
6744 content is CONTENT near the LINENO.
6746 If `recenter' attribute is specified, the line is displayed at
6747 the center of window, otherwise at the top of window.
6750 (define-anything-type-attribute 'timer
6751 '((real-to-display . anything-c-timer-real-to-display
)
6752 (action ("Cancel Timer" . cancel-timer
)
6753 ("Describe Function" .
(lambda (tm) (describe-function (timer--function tm
))))
6754 ("Find Function" .
(lambda (tm) (find-function (timer--function tm
)))))
6755 (persistent-action .
(lambda (tm) (describe-function (timer--function tm
))))
6756 (persistent-help .
"Describe Function"))
6759 ;;;; Default `anything-sources'
6760 ;; Setting `anything-sources' is DEPRECATED, but it seems that newbies
6761 ;; tend to invoke M-x anything directly. So I offer default setting.
6762 (setq anything-sources
6763 '(anything-c-source-buffers+
6764 anything-c-source-recentf
6765 anything-c-source-files-in-current-dir
+))
6768 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
6769 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el")
6771 (when (fboundp 'expectations
)
6773 (desc "candidates-file plug-in")
6774 (expect '(anything-p-candidats-file-init)
6775 (assoc-default 'init
6776 (car (anything-compile-sources
6778 (candidates-file .
"test.txt")))
6779 '(anything-compile-source--candidates-file)))))
6780 (expect '(anything-p-candidats-file-init
6782 (assoc-default 'init
6783 (car (anything-compile-sources
6785 (candidates-file .
"test.txt")
6786 (init .
(lambda () 1))))
6787 '(anything-compile-source--candidates-file)))))
6788 (expect '(anything-p-candidats-file-init
6790 (assoc-default 'init
6791 (car (anything-compile-sources
6793 (candidates-file .
"test.txt")
6794 (init (lambda () 1))))
6795 '(anything-compile-source--candidates-file)))))
6796 (desc "anything-c-source-buffers")
6797 (expect '(("Buffers" ("foo" "curbuf")))
6798 (stub buffer-list
=> '("curbuf" " hidden" "foo" "*anything*"))
6799 (let ((anything-c-boring-buffer-regexp
6804 " *Echo Area" " *Minibuf"))))
6805 (flet ((buffer-name (x) x
))
6806 (anything-test-candidates 'anything-c-source-buffers
))))
6807 (desc "anything-c-stringify")
6809 (anything-c-stringify "str1"))
6811 (anything-c-stringify 'str2
))
6812 (desc "anything-c-symbolify")
6814 (anything-c-symbolify "sym1"))
6816 (anything-c-symbolify 'sym2
)))))
6818 (provide 'anything-config
)
6820 ;;; Local Variables:
6821 ;;; time-stamp-format: "%:y-%02m-%02d %02H:%02M:%02S (%Z) %u"
6824 ;; How to save (DO NOT REMOVE!!)
6825 ;; (progn (magit-push) (emacswiki-post "anything-config.el"))
6826 ;;; anything-config.el ends here
6828 ;;; LocalWords: Tassilo Patrovics Vagn Johansen Dahl Clementson infos
6829 ;;; LocalWords: Kamphausen informations McBrayer Volpiatto bbdb bb
6830 ;;; LocalWords: iswitchb imenu Recentf sym samewindow pos bol eol
6831 ;;; LocalWords: aif str lst func attrib recentf lessp prin mapatoms commandp
6832 ;;; LocalWords: cmd stb Picklist picklist mapcan subentry destructuring dirs
6833 ;;; LocalWords: darwin locat MacOS mdfind Firstname Lastname calc prepend jids
6834 ;;; LocalWords: dotimes Thierry online vname
6835 ;;; LocalWords: csharp javascript lua makefile cperl zcat lineno buf
6836 ;;; LocalWords: multiline href fn cand NewTitle cwd filepath thru ret
6837 ;;; LocalWords: bfn fOpen UNC cygdrive nt xdg macos FILE's elc rx svn hg
6838 ;;; LocalWords: CANDIDATE's darcs facep pathname args pathnames subseq priorty
6839 ;;; LocalWords: Vokes rfind berkeley JST ffap lacarte bos
6840 ;;; LocalWords: Lacarte Minibuf epp LaCarte bm attrset migemo attr conf mklist
6841 ;;; LocalWords: startpos noselect dont desc