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")
2274 (if anything-c-info-pages
2275 anything-c-info-pages
2276 (setq anything-c-info-pages
2277 (save-window-excursion
2280 (Info-find-node "dir" "top")
2281 (goto-char (point-min))
2282 (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.")
2284 (while (re-search-forward info-topic-regexp nil t
)
2285 (add-to-list 'topics
(match-string-no-properties 1)))
2286 (goto-char (point-min))
2289 (action .
(("Show with Info" .
(lambda (node-str)
2290 (info (replace-regexp-in-string
2291 "^[^:]+: " "" node-str
))))))
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"
2607 .
(lambda (candidate)
2608 (let ((wfiles (woman-file-name-all-completions candidate
)))
2609 (if (> (length wfiles
) 1)
2610 (woman-find-file (anything-comp-read "ManFile: " wfiles
2612 (woman candidate
))))))
2613 ;; Woman does not work OS X
2614 ;; http://xahlee.org/emacs/modernization_man_page.html
2615 (action-transformer .
(lambda (actions candidate
)
2616 (if (eq system-type
'darwin
)
2617 '(("Show with Man" . man
))
2619 (requires-pattern .
2)))
2620 ;; (anything 'anything-c-source-man-pages)
2623 ;;; Complex command history
2624 (defvar anything-c-source-complex-command-history
2625 '((name .
"Complex Command History")
2626 (candidates .
(lambda () (mapcar 'prin1-to-string command-history
)))
2628 ;; (anything 'anything-c-source-complex-command-history)
2631 (defvar anything-c-source-extended-command-history
2632 '((name .
"Emacs Commands History")
2633 (candidates . extended-command-history
)
2635 ;; (anything 'anything-c-source-extended-command-history)
2638 (defvar anything-c-source-emacs-commands
2639 '((name .
"Emacs Commands")
2640 (candidates .
(lambda ()
2642 (mapatoms (lambda (a)
2644 (push (symbol-name a
)
2646 (sort commands
'string-lessp
))))
2648 (requires-pattern .
2))
2649 "Source for completing and invoking Emacs commands.
2650 A command is a function with interactive spec that can
2651 be invoked with `M-x'.
2653 To get non-interactive functions listed, use
2654 `anything-c-source-emacs-functions'.")
2655 ;; (anything 'anything-c-source-emacs-commands)
2657 ;; Another replacement of `M-x' that act exactly like the
2658 ;; vanilla Emacs one, no problem of windows configuration, prefix args
2659 ;; are passed before calling `M-x' (e.g C-u M-x..).
2661 (defun anything-M-x ()
2662 "Preconfigured `anything' for Emacs commands.
2663 It is `anything' replacement of regular `M-x' `execute-extended-command'."
2665 (let ((command (anything-comp-read "M-x " obarray
2668 :requires-pattern
2)))
2669 (call-interactively (intern command
))))
2672 (defvar anything-c-source-lacarte
2673 '((name .
"Lacarte")
2674 (init .
(lambda () (require 'lacarte
)))
2675 (candidates .
(lambda () (delete '(nil) (lacarte-get-overall-menu-item-alist))))
2676 (candidate-number-limit .
9999)
2677 (action . anything-c-call-interactively
))
2680 http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el")
2681 ;; (anything 'anything-c-source-lacarte)
2685 (defvar anything-c-source-emacs-functions
2686 '((name .
"Emacs Functions")
2687 (candidates .
(lambda ()
2689 (mapatoms (lambda (a)
2691 (push (symbol-name a
) commands
))))
2692 (sort commands
'string-lessp
))))
2694 (requires-pattern .
2))
2695 "Source for completing Emacs functions.")
2696 ;; (anything 'anything-c-source-emacs-functions)
2698 ;;; With abbrev expansion
2699 ;;; Similar to my exec-abbrev-cmd.el
2700 ;;; See http://www.tsdh.de/cgi-bin/wiki.pl/exec-abbrev-cmd.el
2701 (defvar anything-c-function-abbrev-regexp nil
2702 "The regexp for `anything-c-source-emacs-functions-with-abbrevs'.
2703 Regexp built from the current `anything-pattern' interpreting it
2705 Only for internal use.")
2707 (defun anything-c-match-function-by-abbrev (candidate)
2708 "Return non-nil if `anything-pattern' is an abbreviation of the function CANDIDATE.
2710 Abbreviations are made by taking the first character from each
2711 word in the function's name, e.g. \"bb\" is an abbrev for
2712 `bury-buffer', \"stb\" is an abbrev for `switch-to-buffer'."
2713 (string-match anything-c-function-abbrev-regexp candidate
))
2715 (defvar anything-c-source-emacs-functions-with-abbrevs
2716 (append anything-c-source-emacs-functions
2717 '((match anything-c-match-function-by-abbrev
2718 anything-c-string-match
))
2721 (defadvice anything-update
2722 (before anything-c-update-function-abbrev-regexp activate
)
2723 (let ((char-list (append anything-pattern nil
))
2725 (dolist (c char-list
)
2726 (setq str
(concat str
(list c
) "[^-]*-")))
2727 (setq str
(concat (substring str
0 (1- (length str
))) "$"))
2728 (setq anything-c-function-abbrev-regexp str
))))))))
2729 ;; (anything 'anything-c-source-emacs-functions-with-abbrevs)
2731 (defvar anything-c-source-advice
2732 '((name .
"Function Advice")
2733 (candidates . anything-c-advice-candidates
)
2734 (action ("Toggle Enable/Disable" . anything-c-advice-toggle
))
2735 ;; (real-to-display . anything-c-advice-real-to-display)
2738 (persistent-action . anything-c-advice-persistent-action
)
2739 (persistent-help .
"Describe function / C-u C-z: Toggle advice")))
2740 ;; (anything 'anything-c-source-advice)
2741 ;; (let ((debug-on-signal t))(anything 'anything-c-source-advice))
2744 (defun anything-c-advice-candidates ()
2746 (loop for
(fname) in ad-advised-functions
2747 for function
= (intern fname
)
2749 (loop for class in ad-advice-classes append
2750 (loop for advice in
(ad-get-advice-info-field function class
)
2751 for enabled
= (ad-advice-enabled advice
)
2755 (if enabled
"Enabled " "Disabled")
2756 (propertize fname
'face
'font-lock-function-name-face
)
2757 (ad-make-single-advice-docstring advice class nil
))
2758 (list function class advice
))))))
2760 (defun anything-c-advice-persistent-action (func-class-advice)
2761 (if current-prefix-arg
2762 (anything-c-advice-toggle func-class-advice
)
2763 (describe-function (car func-class-advice
))))
2765 (defun anything-c-advice-toggle (func-class-advice)
2766 (destructuring-bind (function class advice
) func-class-advice
2767 (cond ((ad-advice-enabled advice
)
2768 (ad-advice-set-enabled advice nil
)
2769 (message "Disabled"))
2771 (ad-advice-set-enabled advice t
)
2772 (message "Enabled")))
2773 (ad-activate function
)
2774 (and anything-in-persistent-action
2775 (anything-c-advice-update-current-display-string))))
2777 (defun anything-c-advice-update-current-display-string ()
2778 (anything-edit-current-selection
2779 (let ((newword (cond ((looking-at "Disabled") "Enabled")
2780 ((looking-at "Enabled") "Disabled")))
2783 (delete-region (point) (progn (forward-word 1) (point)))
2784 (insert newword
)))))
2787 (defun anything-manage-advice ()
2788 "Preconfigured `anything' to disable/enable function advices."
2790 (anything-other-buffer 'anything-c-source-advice
"*anything advice*"))
2794 (defvar anything-c-source-emacs-variables
2795 '((name .
"Emacs Variables")
2796 (candidates .
(lambda ()
2797 (sort (all-completions "" obarray
'boundp
) 'string-lessp
)))
2799 (requires-pattern .
2))
2800 "Source for completing Emacs variables.")
2801 ;; (anything 'anything-c-source-emacs-variables)
2805 (eval-when-compile (require 'bookmark
))
2806 (defvar anything-c-source-bookmarks
2807 '((name .
"Bookmarks")
2809 (require 'bookmark
)))
2810 (candidates . bookmark-all-names
)
2812 "See (info \"(emacs)Bookmarks\").")
2813 ;; (anything 'anything-c-source-bookmarks)
2816 (defvar anything-c-source-bookmark-set
2817 '((name .
"Set Bookmark")
2819 (action . bookmark-set
))
2820 "See (info \"(emacs)Bookmarks\").")
2821 ;; (anything 'anything-c-source-bookmark-set)
2823 ;;; Visible Bookmarks
2824 ;; (install-elisp "http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el")
2827 ;; http://d.hatena.ne.jp/grandVin/20080911/1221114327
2828 (defvar anything-c-source-bm
2829 '((name .
"Visible Bookmarks")
2830 (init . anything-c-bm-init
)
2831 (candidates-in-buffer)
2835 http://www.nongnu.org/bm/")
2837 (defun anything-c-bm-init ()
2838 "Init function for `anything-c-source-bm'."
2839 (when (require 'bm nil t
)
2841 (let ((bookmarks (bm-lists))
2842 (buf (anything-candidate-buffer 'global
)))
2843 (dolist (bm (sort* (append (car bookmarks
) (cdr bookmarks
))
2844 '< :key
'overlay-start
))
2845 (let ((start (overlay-start bm
))
2846 (end (overlay-end bm
))
2847 (annotation (or (overlay-get bm
'annotation
) "")))
2848 (unless (< (- end start
) 1) ; org => (if (< (- end start) 2)
2849 (let ((str (format "%5d: [%s]: %s\n"
2850 (line-number-at-pos start
)
2852 (buffer-substring start
(1- end
)))))
2853 (with-current-buffer buf
(insert str
))))))))))
2855 ;;; Special bookmarks
2856 (defvar anything-c-source-bookmarks-ssh
2857 '((name .
"Bookmarks-ssh")
2859 (require 'bookmark
)))
2860 (candidates .
(lambda () (anything-c-collect-bookmarks :ssh t
)))
2862 "See (info \"(emacs)Bookmarks\").")
2863 ;; (anything 'anything-c-source-bookmarks-ssh)
2865 (defvar anything-c-source-bookmarks-su
2866 '((name .
"Bookmarks-root")
2868 (require 'bookmark
)))
2869 (candidates .
(lambda () (anything-c-collect-bookmarks :su t
)))
2870 (filtered-candidate-transformer anything-c-highlight-bookmark-su
)
2873 "See (info \"(emacs)Bookmarks\").")
2874 ;; (anything 'anything-c-source-bookmarks-su)
2876 (defvar anything-c-source-bookmarks-local
2877 '((name .
"Bookmarks-Local")
2879 (require 'bookmark
)))
2880 (candidates .
(lambda () (anything-c-collect-bookmarks :local t
)))
2881 (filtered-candidate-transformer
2882 anything-c-adaptive-sort
2883 anything-c-highlight-bookmark
)
2885 "See (info \"(emacs)Bookmarks\").")
2886 ;; (anything 'anything-c-source-bookmarks-local)
2888 (defun* anything-c-collect-bookmarks
(&key local su sudo ssh
)
2889 (let* ((lis-all (bookmark-all-names))
2890 (lis-loc (cond (local (loop for i in lis-all
2891 unless
(string-match "^(ssh)\\|^(su)" i
)
2893 (su (loop for i in lis-all
2894 when
(string-match "^(su)" i
)
2896 (sudo (loop for i in lis-all
2897 when
(string-match "^(sudo)" i
)
2899 (ssh (loop for i in lis-all
2900 when
(string-match "^(ssh)" i
)
2902 (sort lis-loc
'string-lessp
)))
2904 (defun anything-c-bookmark-root-logged-p ()
2906 (dolist (i (mapcar #'buffer-name
(buffer-list)))
2907 (when (string-match (format "*tramp/%s ." anything-su-or-sudo
) i
)
2908 (throw 'break t
)))))
2910 (defun anything-c-highlight-bookmark-su (files source
)
2911 (if (anything-c-bookmark-root-logged-p)
2912 (anything-c-highlight-bookmark files source
)
2913 (anything-c-highlight-not-logged files source
)))
2915 (defun anything-c-highlight-not-logged (files source
)
2916 (loop for i in files
2917 collect
(propertize i
'face anything-c-bookmarks-face3
)))
2919 (defun anything-c-highlight-bookmark (bookmarks source
)
2920 "Used as `candidate-transformer' to colorize bookmarks.
2921 Work both with standard Emacs bookmarks and bookmark-extensions.el."
2922 (loop for i in bookmarks
2923 for pred
= (bookmark-get-filename i
)
2924 for bufp
= (and (fboundp 'bmkext-get-buffer-name
)
2925 (bmkext-get-buffer-name i
))
2926 for handlerp
= (and (fboundp 'bookmark-get-handler
)
2927 (bookmark-get-handler i
))
2928 for isw3m
= (and (fboundp 'bmkext-w3m-bookmark-p
)
2929 (bmkext-w3m-bookmark-p i
))
2930 for isgnus
= (and (fboundp 'bmkext-gnus-bookmark-p
)
2931 (bmkext-gnus-bookmark-p i
))
2932 for isman
= (and (fboundp 'bmkext-man-bookmark-p
) ; Man
2933 (bmkext-man-bookmark-p i
))
2934 for iswoman
= (and (fboundp 'bmkext-woman-bookmark-p
) ; Woman
2935 (bmkext-woman-bookmark-p i
))
2936 for handlerp
= (bookmark-get-handler i
)
2937 for isannotation
= (bookmark-get-annotation i
)
2938 for isabook
= (string= (bookmark-prop-get i
'type
) "addressbook")
2939 ;; Add a * if bookmark have annotation
2940 if
(and isannotation
(not (string-equal isannotation
"")))
2941 do
(setq i
(concat "*" i
))
2943 if
(eq handlerp
'Info-bookmark-jump
)
2944 collect
(propertize i
'face
'anything-bmkext-info
'help-echo pred
)
2947 collect
(propertize i
'face
'anything-bmkext-w3m
'help-echo pred
)
2950 collect
(propertize i
'face
'anything-bmkext-gnus
'help-echo pred
)
2952 if
(or iswoman isman
)
2953 collect
(propertize i
'face
'anything-bmkext-man
'help-echo pred
)
2955 if
(and (not pred
) isabook
)
2956 collect
(propertize i
'face
'((:foreground
"Tomato")))
2958 if
(and pred
(file-directory-p pred
))
2959 collect
(propertize i
'face anything-c-bookmarks-face1
'help-echo pred
)
2961 if
(and pred
(not (file-directory-p pred
)) (file-exists-p pred
)
2962 (not (or iswoman isman
)))
2963 collect
(propertize i
'face
'anything-bmkext-file
'help-echo pred
)))
2966 ;;; Faces for bookmarks
2967 (defface anything-bmkext-info
2968 '((t (:foreground
"green")))
2969 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2972 (defface anything-bmkext-w3m
2973 '((t (:foreground
"yellow")))
2974 "*Face used for W3m Emacs bookmarks (not w3m bookmarks)."
2977 (defface anything-bmkext-gnus
2978 '((t (:foreground
"magenta")))
2979 "*Face used for Gnus bookmarks."
2982 (defface anything-bmkext-man
2983 '((t (:foreground
"Orange4")))
2984 "*Face used for Woman/man bookmarks."
2987 (defface anything-bmkext-no--file
2988 '((t (:foreground
"grey")))
2989 "*Face used for non--file bookmarks."
2992 (defface anything-bmkext-file
2993 '((t (:foreground
"Deepskyblue2")))
2994 "*Face used for non--file bookmarks."
2997 (defface anything-bookmarks-su-face
'((t (:foreground
"red")))
2998 "Face for su/sudo bookmarks."
3001 (defvar anything-c-bookmarks-face1
'anything-dir-heading
)
3002 (defvar anything-c-bookmarks-face2
'anything-file-name
)
3003 (defvar anything-c-bookmarks-face3
'anything-bookmarks-su-face
)
3006 ;;; Sources to filter bookmark-extensions bookmarks.
3007 ;; Dependency: http://mercurial.intuxication.org/hg/emacs-bookmark-extension
3008 ;; If you want to enable google-maps in addressbook you will need
3009 ;; Julien Danjou google-maps-el package available here:
3010 ;; http://julien.danjou.info/google-maps-el.html
3012 (defun anything-c-bmkext-filter-setup-alist (fn &rest args
)
3013 "Return a filtered `bookmark-alist' sorted alphabetically."
3015 with alist
= (if args
3016 (apply #'(lambda (x) (funcall fn x
)) args
)
3021 finally return
(sort sa
'string-lessp
)))
3024 (defvar anything-c-source-bmkext-addressbook
3025 '((name .
"Bookmark Addressbook")
3027 (require 'bookmark-extensions
)
3028 (bookmark-maybe-load-default-file)))
3029 (candidates . anything-c-bmkext-addressbook-setup-alist
)
3031 .
(lambda (candidate)
3032 (let ((bmk (anything-bookmark-get-bookmark-from-name
3034 (bookmark--jump-via bmk
'pop-to-buffer
))))
3035 (persistent-help .
"Show contact - Prefix with C-u to append")
3036 (filtered-candidate-transformer
3037 anything-c-adaptive-sort
3038 anything-c-highlight-bookmark
)
3039 (action .
(("Show person's data"
3040 .
(lambda (candidate)
3041 (let ((bmk (anything-bookmark-get-bookmark-from-name
3043 (current-prefix-arg anything-current-prefix-arg
))
3044 (bookmark-jump bmk
))))
3046 .
(lambda (candidate)
3047 (let ((bmk (anything-bookmark-get-bookmark-from-name
3049 (if anything-current-prefix-arg
3050 (addressbook-set-mail-buffer1 bmk
'append
)
3051 (addressbook-set-mail-buffer1 bmk
)))))
3053 .
(lambda (candidate)
3054 (let ((bmk (anything-bookmark-get-bookmark-from-name
3056 (addressbook-bookmark-edit
3057 (assoc bmk bookmark-alist
)))))
3058 ("Insert Email at point"
3059 .
(lambda (candidate)
3060 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3062 (mlist (split-string
3064 'email
(assoc bmk bookmark-alist
))
3067 (if (> (length mlist
) 1)
3069 "Insert Mail Address: " mlist
:must-match t
)
3072 .
(lambda (candidate)
3073 (let ((bmk (anything-bookmark-get-bookmark-from-name
3075 (bookmark-show-annotation bmk
))))
3077 .
(lambda (candidate)
3078 (let ((bmk (anything-bookmark-get-bookmark-from-name
3080 (bookmark-edit-annotation bmk
))))
3082 .
(lambda (candidate)
3083 (let* ((bmk (anything-bookmark-get-bookmark-from-name
3085 (full-bmk (assoc bmk bookmark-alist
)))
3086 (addressbook-google-map full-bmk
))))))))
3089 (defun anything-c-bmkext-addressbook-setup-alist ()
3090 "Specialized filter function for bookmarks w3m."
3091 (anything-c-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only
))
3094 (defvar anything-c-source-bookmark-w3m
3095 '((name .
"Bookmark W3m")
3097 (require 'bookmark-extensions
)
3098 (bookmark-maybe-load-default-file)))
3099 (candidates . anything-c-bookmark-w3m-setup-alist
)
3100 (filtered-candidate-transformer
3101 anything-c-adaptive-sort
3102 anything-c-highlight-bookmark
)
3104 ;; (anything 'anything-c-source-bookmark-w3m)
3106 (defun anything-c-bookmark-w3m-setup-alist ()
3107 "Specialized filter function for bookmarks w3m."
3108 (anything-c-bmkext-filter-setup-alist 'bmkext-w3m-alist-only
))
3111 (defvar anything-c-source-bookmark-images
3112 '((name .
"Bookmark Images")
3114 (require 'bookmark-extensions
)
3115 (bookmark-maybe-load-default-file)))
3116 (candidates . anything-c-bookmark-images-setup-alist
)
3117 (filtered-candidate-transformer
3118 anything-c-adaptive-sort
3119 anything-c-highlight-bookmark
)
3121 ;; (anything 'anything-c-source-bookmark-images)
3123 (defun anything-c-bookmark-images-setup-alist ()
3124 "Specialized filter function for images bookmarks."
3125 (anything-c-bmkext-filter-setup-alist 'bmkext-image-file-alist-only
))
3128 (defvar anything-c-source-bookmark-man
3129 '((name .
"Bookmark Woman&Man")
3131 (require 'bookmark-extensions
)
3132 (bookmark-maybe-load-default-file)))
3133 (candidates . anything-c-bookmark-man-setup-alist
)
3134 (filtered-candidate-transformer
3135 anything-c-adaptive-sort
3136 anything-c-highlight-bookmark
)
3138 ;; (anything 'anything-c-source-bookmark-man)
3140 (defun anything-c-bookmark-man-setup-alist ()
3141 "Specialized filter function for bookmarks w3m."
3142 (append (anything-c-bmkext-filter-setup-alist 'bmkext-man-alist-only
)
3143 (anything-c-bmkext-filter-setup-alist 'bmkext-woman-alist-only
)))
3146 (defvar anything-c-source-bookmark-gnus
3147 '((name .
"Bookmark Gnus")
3149 (require 'bookmark-extensions
)
3150 (bookmark-maybe-load-default-file)))
3151 (candidates . anything-c-bookmark-gnus-setup-alist
)
3152 (filtered-candidate-transformer
3153 anything-c-adaptive-sort
3154 anything-c-highlight-bookmark
)
3156 ;; (anything 'anything-c-source-bookmark-gnus)
3158 (defun anything-c-bookmark-gnus-setup-alist ()
3159 "Specialized filter function for bookmarks gnus."
3160 (anything-c-bmkext-filter-setup-alist 'bmkext-gnus-alist-only
))
3163 (defvar anything-c-source-bookmark-info
3164 '((name .
"Bookmark Info")
3166 (require 'bookmark-extensions
)
3167 (bookmark-maybe-load-default-file)))
3168 (candidates . anything-c-bookmark-info-setup-alist
)
3169 (filtered-candidate-transformer
3170 anything-c-adaptive-sort
3171 anything-c-highlight-bookmark
)
3173 ;; (anything 'anything-c-source-bookmark-info)
3175 (defun anything-c-bookmark-info-setup-alist ()
3176 "Specialized filter function for bookmarks info."
3177 (anything-c-bmkext-filter-setup-alist 'bmkext-info-alist-only
))
3179 ;; Local Files&directories
3180 (defvar anything-c-source-bookmark-files
&dirs
3181 '((name .
"Bookmark Files&Directories")
3183 (require 'bookmark-extensions
)
3184 (bookmark-maybe-load-default-file)))
3185 (candidates . anything-c-bookmark-local-files-setup-alist
)
3186 (filtered-candidate-transformer
3187 anything-c-adaptive-sort
3188 anything-c-highlight-bookmark
)
3190 ;; (anything 'anything-c-source-bookmark-files&dirs)
3192 (defun anything-c-bookmark-local-files-setup-alist ()
3193 "Specialized filter function for bookmarks locals files."
3194 (anything-c-bmkext-filter-setup-alist 'bmkext-local-file-alist-only
))
3196 ;; Su Files&directories
3197 (defvar anything-c-source-bookmark-su-files
&dirs
3198 '((name .
"Bookmark Root-Files&Directories")
3200 (require 'bookmark-extensions
)
3201 (bookmark-maybe-load-default-file)))
3202 (candidates . anything-c-bookmark-su-files-setup-alist
)
3203 (filtered-candidate-transformer
3204 anything-c-adaptive-sort
3205 anything-c-highlight-bookmark-su
)
3207 ;; (anything 'anything-c-source-bookmark-su-files&dirs)
3209 (defun anything-c-bookmark-su-files-setup-alist ()
3210 "Specialized filter function for bookmarks su/sudo files."
3212 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3214 for isfile
= (bookmark-get-filename i
)
3215 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3217 (string-match tramp-file-name-regexp isfile
)))
3218 for issu
= (and istramp
3219 (string-match bmkext-su-or-sudo-regexp isfile
))
3223 ;; Ssh Files&directories
3224 (defvar anything-c-source-bookmark-ssh-files
&dirs
3225 '((name .
"Bookmark Ssh-Files&Directories")
3227 (require 'bookmark-extensions
)
3228 (bookmark-maybe-load-default-file)))
3229 (candidates . anything-c-bookmark-ssh-files-setup-alist
)
3230 (filtered-candidate-transformer . anything-c-adaptive-sort
)
3232 ;; (anything 'anything-c-source-bookmark-ssh-files&dirs)
3234 (defun anything-c-bookmark-ssh-files-setup-alist ()
3235 "Specialized filter function for bookmarks ssh files."
3237 with l
= (anything-c-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only
)
3239 for isfile
= (bookmark-get-filename i
)
3240 for istramp
= (and isfile
(boundp 'tramp-file-name-regexp
)
3242 (string-match tramp-file-name-regexp isfile
)))
3243 for isssh
= (and istramp
3244 (string-match "/ssh:" isfile
))
3249 ;; All bookmark-extensions sources.
3251 (defun anything-bookmark-ext ()
3252 "Preconfigured `anything' for bookmark-extensions sources.
3253 Needs bookmark-ext.el
3255 http://mercurial.intuxication.org/hg/emacs-bookmark-extension"
3257 (anything '(anything-c-source-bookmark-files&dirs
3258 anything-c-source-bookmark-w3m
3259 anything-c-source-bmkext-addressbook
3260 anything-c-source-bookmark-gnus
3261 anything-c-source-bookmark-info
3262 anything-c-source-bookmark-man
3263 anything-c-source-bookmark-images
3264 anything-c-source-bookmark-su-files
&dirs
3265 anything-c-source-bookmark-ssh-files
&dirs
)
3266 nil
"SearchBookmark: " nil nil
"*anything bmkext*"))
3269 ;; Firefox bookmarks
3270 ;; You will have to set firefox to import bookmarks in his html file bookmarks.html.
3271 ;; (only for firefox versions >=3)
3272 ;; To achieve that, open about:config in firefox and double click on this line to enable value
3274 ;; user_pref("browser.bookmarks.autoExportHTML", false);
3275 ;; You should have now:
3276 ;; user_pref("browser.bookmarks.autoExportHTML", true);
3278 (defvar anything-firefox-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|about\\|file\\)://[^ ]*")
3279 (defvar anything-firefox-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3281 (defun anything-get-firefox-user-init-dir ()
3282 "Guess the default Firefox user directory name."
3283 (let* ((moz-dir (concat (getenv "HOME") "/.mozilla/firefox/"))
3285 (with-current-buffer (find-file-noselect (concat moz-dir
"profiles.ini"))
3286 (goto-char (point-min))
3287 (when (search-forward "Path=" nil t
)
3288 (buffer-substring-no-properties (point) (point-at-eol))))))
3289 (file-name-as-directory (concat moz-dir moz-user-dir
))))
3291 (defun anything-guess-firefox-bookmark-file ()
3292 "Return the path of the Firefox bookmarks file."
3293 (concat (anything-get-firefox-user-init-dir) "bookmarks.html"))
3295 (defun anything-html-bookmarks-to-alist (file url-regexp bmk-regexp
)
3296 "Parse html bookmark FILE and return an alist with (title . url) as elements."
3297 (let (bookmarks-alist url title
)
3299 (insert-file-contents file
)
3300 (goto-char (point-min))
3303 (when (re-search-forward "href=\\|^ *<DT><A HREF=" nil t
)
3305 (when (re-search-forward url-regexp nil t
)
3306 (setq url
(concat "\"" (match-string 0))))
3308 (when (re-search-forward bmk-regexp nil t
)
3309 (setq title
(match-string 1)))
3310 (push (cons title url
) bookmarks-alist
))))
3311 (nreverse bookmarks-alist
)))
3314 (defvar anything-c-firefox-bookmarks-alist nil
)
3315 (defvar anything-c-source-firefox-bookmarks
3316 '((name .
"Firefox Bookmarks")
3318 (setq anything-c-firefox-bookmarks-alist
3319 (anything-html-bookmarks-to-alist
3320 (anything-guess-firefox-bookmark-file)
3321 anything-firefox-bookmark-url-regexp
3322 anything-firefox-bookmarks-regexp
))))
3323 (candidates .
(lambda ()
3325 anything-c-firefox-bookmarks-alist
)))
3326 (filtered-candidate-transformer
3327 anything-c-adaptive-sort
3328 anything-c-highlight-firefox-bookmarks
)
3329 (action .
(("Browse Url Firefox" .
(lambda (candidate)
3331 (anything-c-firefox-bookmarks-get-value candidate
))))
3332 ("Browse Url w3m" .
(lambda (candidate)
3334 (anything-c-firefox-bookmarks-get-value candidate
))))
3335 ("Copy Url" .
(lambda (elm)
3336 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))))))
3338 ;; (anything 'anything-c-source-firefox-bookmarks)
3340 (defun anything-c-firefox-bookmarks-get-value (elm)
3341 (replace-regexp-in-string "\"" ""
3343 anything-c-firefox-bookmarks-alist
))))
3346 (defun anything-c-highlight-firefox-bookmarks (bookmarks source
)
3347 (loop for i in bookmarks
3348 collect
(propertize i
3349 'face
'((:foreground
"YellowGreen"))
3350 'help-echo
(anything-c-firefox-bookmarks-get-value i
))))
3353 (eval-when-compile (require 'w3m-bookmark nil t
))
3354 (unless (and (require 'w3m nil t
)
3355 (require 'w3m-bookmark nil t
))
3356 (defvar w3m-bookmark-file
"~/.w3m/bookmark.html"))
3359 (defface anything-w3m-bookmarks-face
'((t (:foreground
"cyan1" :underline t
)))
3360 "Face for w3m bookmarks" :group
'anything
)
3362 (defvar anything-w3m-bookmarks-regexp
">\\([^><]+.[^</a>]\\)")
3363 (defvar anything-w3m-bookmark-url-regexp
"\\(https\\|http\\|ftp\\|file\\)://[^>]*")
3364 (defvar anything-c-w3m-bookmarks-alist nil
)
3365 (defvar anything-c-source-w3m-bookmarks
3366 '((name .
"W3m Bookmarks")
3368 (setq anything-c-w3m-bookmarks-alist
3369 (anything-html-bookmarks-to-alist
3371 anything-w3m-bookmark-url-regexp
3372 anything-w3m-bookmarks-regexp
))))
3373 (candidates .
(lambda ()
3374 (mapcar #'car anything-c-w3m-bookmarks-alist
)))
3375 (filtered-candidate-transformer
3376 anything-c-adaptive-sort
3377 anything-c-highlight-w3m-bookmarks
)
3378 (action .
(("Browse Url" .
(lambda (candidate)
3379 (anything-c-w3m-browse-bookmark candidate
)))
3380 ("Copy Url" .
(lambda (elm)
3381 (kill-new (anything-c-w3m-bookmarks-get-value elm
))))
3382 ("Browse Url Firefox" .
(lambda (candidate)
3383 (anything-c-w3m-browse-bookmark candidate t
)))
3384 ("Delete Bookmark" .
(lambda (candidate)
3385 (anything-c-w3m-delete-bookmark candidate
)))
3386 ("Rename Bookmark" .
(lambda (candidate)
3387 (anything-c-w3m-rename-bookmark candidate
)))))
3388 (persistent-action .
(lambda (candidate)
3389 (if current-prefix-arg
3390 (anything-c-w3m-browse-bookmark candidate t
)
3391 (anything-c-w3m-browse-bookmark candidate nil t
))))
3392 (persistent-help .
"Open URL with emacs-w3m in new tab / \
3393 C-u \\[anything-execute-persistent-action]: Open URL with Firefox"))
3394 "Needs w3m and emacs-w3m.
3396 http://w3m.sourceforge.net/
3397 http://emacs-w3m.namazu.org/")
3399 ;; (anything 'anything-c-source-w3m-bookmarks)
3401 (defun anything-c-w3m-bookmarks-get-value (elm)
3402 (replace-regexp-in-string
3403 "\"" "" (cdr (assoc elm anything-c-w3m-bookmarks-alist
))))
3405 (defun anything-c-w3m-browse-bookmark (elm &optional use-firefox new-tab
)
3406 (let* ((fn (if use-firefox
'browse-url-firefox
'w3m-browse-url
))
3407 (arg (and (eq fn
'w3m-browse-url
) new-tab
)))
3408 (funcall fn
(anything-c-w3m-bookmarks-get-value elm
) arg
)))
3410 (defun anything-c-highlight-w3m-bookmarks (bookmarks source
)
3411 (loop for i in bookmarks
3413 i
'face
'anything-w3m-bookmarks-face
3414 'help-echo
(anything-c-w3m-bookmarks-get-value i
))))
3417 (defun anything-c-w3m-delete-bookmark (elm)
3419 (find-file-literally w3m-bookmark-file
)
3420 (goto-char (point-min))
3421 (when (re-search-forward elm nil t
)
3423 (delete-region (point)
3424 (line-end-position))
3425 (delete-blank-lines))
3426 (save-buffer (current-buffer))
3427 (kill-buffer (current-buffer))))
3429 (defun anything-c-w3m-rename-bookmark (elm)
3430 (let* ((old-title (replace-regexp-in-string ">" "" elm
))
3431 (new-title (read-string "NewTitle: " old-title
)))
3433 (find-file-literally w3m-bookmark-file
)
3434 (goto-char (point-min))
3435 (when (re-search-forward (concat elm
"<") nil t
)
3436 (goto-char (1- (point)))
3437 (delete-char (- (length old-title
)))
3439 (save-buffer (current-buffer))
3440 (kill-buffer (current-buffer)))))
3443 ;;; Elisp library scan
3444 (defvar anything-c-source-elisp-library-scan
3445 '((name .
"Elisp libraries (Scan)")
3446 (init .
(anything-c-elisp-library-scan-init))
3447 (candidates-in-buffer)
3448 (action ("Find library" .
(lambda (candidate)
3449 (find-file (find-library-name candidate
))))
3450 ("Find library other window" .
(lambda (candidate)
3451 (find-file-other-window (find-library-name candidate
))))
3452 ("Load library" .
(lambda (candidate)
3453 (load-library candidate
))))))
3454 ;; (anything 'anything-c-source-elisp-library-scan)
3456 (defun anything-c-elisp-library-scan-init ()
3457 "Init anything buffer status."
3458 (let ((anything-buffer (anything-candidate-buffer 'global
))
3459 (library-list (anything-c-elisp-library-scan-list)))
3460 (with-current-buffer anything-buffer
3461 (dolist (library library-list
)
3462 (insert (format "%s\n" library
))))))
3464 (defun anything-c-elisp-library-scan-list (&optional dirs string
)
3465 "Do completion for file names passed to `locate-file'.
3466 DIRS is directory to search path.
3467 STRING is string to match."
3468 ;; Use `load-path' as path when ignore `dirs'.
3469 (or dirs
(setq dirs load-path
))
3470 ;; Init with blank when ignore `string'.
3471 (or string
(setq string
""))
3472 ;; Get library list.
3473 (let ((string-dir (file-name-directory string
))
3474 ;; File regexp that suffix match `load-file-rep-suffixes'.
3475 (match-regexp (format "^.*\\.el%s$" (regexp-opt load-file-rep-suffixes
)))
3480 (setq dir default-directory
))
3482 (setq dir
(expand-file-name string-dir dir
)))
3483 (when (file-directory-p dir
)
3484 (dolist (file (file-name-all-completions
3485 (file-name-nondirectory string
) dir
))
3486 ;; Suffixes match `load-file-rep-suffixes'.
3487 (setq name
(if string-dir
(concat string-dir file
) file
))
3488 (if (string-match match-regexp name
)
3489 (add-to-list 'names name
)))))
3494 (defvar anything-c-imenu-delimiter
" / ")
3496 (defvar anything-c-imenu-index-filter nil
)
3497 (make-variable-buffer-local 'anything-c-imenu-index-filter
)
3499 (defvar anything-c-cached-imenu-alist nil
)
3500 (make-variable-buffer-local 'anything-c-cached-imenu-alist
)
3502 (defvar anything-c-cached-imenu-candidates nil
)
3503 (make-variable-buffer-local 'anything-c-cached-imenu-candidates
)
3505 (defvar anything-c-cached-imenu-tick nil
)
3506 (make-variable-buffer-local 'anything-c-cached-imenu-tick
)
3508 (eval-when-compile (require 'imenu
))
3509 (setq imenu-auto-rescan t
)
3511 (defun anything-imenu-create-candidates (entry)
3512 "Create candidates with ENTRY."
3513 (if (listp (cdr entry
))
3514 (mapcan (lambda (sub)
3515 (if (consp (cdr sub
))
3518 (concat (car entry
) anything-c-imenu-delimiter subentry
))
3519 (anything-imenu-create-candidates sub
))
3520 (list (concat (car entry
) anything-c-imenu-delimiter
(car sub
)))))
3524 (defvar anything-c-source-imenu
3526 (init .
(lambda () (require 'imenu
)))
3527 (candidates . anything-c-imenu-candidates
)
3528 (persistent-action .
(lambda (elm)
3529 (anything-c-imenu-default-action elm
)
3530 (unless (fboundp 'semantic-imenu-tag-overlay
)
3531 (anything-match-line-color-current-line))))
3532 (persistent-help .
"Show this entry")
3533 (action . anything-c-imenu-default-action
))
3534 "See (info \"(emacs)Imenu\")")
3536 ;; (anything 'anything-c-source-imenu)
3538 (defun anything-c-imenu-candidates ()
3539 (with-current-buffer anything-current-buffer
3540 (let ((tick (buffer-modified-tick)))
3541 (if (eq anything-c-cached-imenu-tick tick
)
3542 anything-c-cached-imenu-candidates
3543 (setq imenu--index-alist nil
)
3544 (setq anything-c-cached-imenu-tick tick
3545 anything-c-cached-imenu-candidates
3548 'anything-imenu-create-candidates
3549 (setq anything-c-cached-imenu-alist
3550 (let ((index (imenu--make-index-alist)))
3551 (if anything-c-imenu-index-filter
3552 (funcall anything-c-imenu-index-filter index
)
3554 (setq anything-c-cached-imenu-candidates
3555 (mapcar #'(lambda (x)
3559 anything-c-cached-imenu-candidates
))))))
3561 (setq imenu-default-goto-function
'imenu-default-goto-function
)
3562 (defun anything-c-imenu-default-action (elm)
3563 "The default action for `anything-c-source-imenu'."
3564 (let ((path (split-string elm anything-c-imenu-delimiter
))
3565 (alist anything-c-cached-imenu-alist
))
3566 (if (> (length path
) 1)
3568 (setq alist
(assoc (car path
) alist
))
3569 (setq elm
(cadr path
))
3570 (imenu (assoc elm alist
)))
3571 (imenu (assoc elm alist
)))))
3574 (defvar anything-c-ctags-modes
3575 '( c-mode c
++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode
3576 makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode
3577 scheme-mode sh-mode slang-mode sql-mode tcl-mode
))
3579 (defun anything-c-source-ctags-init ()
3580 (when (and buffer-file-name
3581 (memq major-mode anything-c-ctags-modes
)
3582 (anything-current-buffer-is-modified))
3583 (with-current-buffer (anything-candidate-buffer 'local
)
3584 (call-process-shell-command
3585 (if (string-match "\\.el\\.gz$" anything-buffer-file-name
)
3586 (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) " anything-buffer-file-name
)
3587 (format "ctags -e -u -f- --fields=n %s " anything-buffer-file-name
))
3588 nil
(current-buffer))
3589 (goto-char (point-min))
3591 (delete-region (point-min) (point))
3592 (loop while
(and (not (eobp)) (search-forward "\001" (point-at-eol) t
))
3593 for lineno-start
= (point)
3594 for lineno
= (buffer-substring lineno-start
(1- (search-forward "," (point-at-eol) t
)))
3597 (insert (format "%5s:" lineno
))
3598 (search-forward "\177" (point-at-eol) t
)
3599 (delete-region (1- (point)) (point-at-eol))
3600 (forward-line 1)))))
3602 (defvar anything-c-source-ctags
3603 '((name .
"Exuberant ctags")
3604 (init . anything-c-source-ctags-init
)
3605 (candidates-in-buffer)
3608 "Needs Exuberant Ctags.
3610 http://ctags.sourceforge.net/")
3611 ;; (anything 'anything-c-source-ctags)
3614 (eval-when-compile (require 'semantic nil t
))
3615 (declare-function semantic-format-tag-summarize
"ext:format.el" (tag &optional parent color
) t
)
3616 (declare-function semantic-tag-components
"ext:tag.el" (tag) t
)
3617 (declare-function semantic-go-to-tag
"ext:tag-file.el" (tag) t
)
3618 (defvar anything-semantic-candidates nil
)
3620 (defun anything-semantic-construct-candidates (tags depth
)
3621 (when (require 'semantic nil t
)
3623 (mapcar (lambda (tag)
3625 (let ((type (semantic-tag-type tag
))
3626 (class (semantic-tag-class tag
)))
3627 (if (or (and (stringp type
)
3628 (or (string= type
"class")
3629 (string= type
"namespace")))
3630 (eq class
'function
)
3631 (eq class
'variable
))
3632 (cons (cons (concat (make-string (* depth
2) ?\s
)
3633 (semantic-format-tag-summarize tag nil t
)) tag
)
3634 (anything-semantic-construct-candidates (semantic-tag-components tag
)
3638 (defun anything-semantic-default-action (candidate)
3639 (let ((tag (cdr (assoc candidate anything-semantic-candidates
))))
3640 (semantic-go-to-tag tag
)))
3642 (defvar anything-c-source-semantic
3643 '((name .
"Semantic Tags")
3645 (setq anything-semantic-candidates
3646 (ignore-errors (anything-semantic-construct-candidates (semantic-fetch-tags) 0)))))
3647 (candidates .
(lambda ()
3648 (if anything-semantic-candidates
3649 (mapcar 'car anything-semantic-candidates
))))
3650 (persistent-action .
(lambda (elm)
3651 (anything-semantic-default-action elm
)
3652 (anything-match-line-color-current-line)))
3653 (persistent-help .
"Show this entry")
3654 (action . anything-semantic-default-action
)
3655 "Needs semantic in CEDET.
3657 http://cedet.sourceforge.net/semantic.shtml
3658 http://cedet.sourceforge.net/"))
3660 ;; (anything 'anything-c-source-semantic)
3662 ;;; Function is called by
3664 (defun anything-simple-call-tree ()
3665 "Preconfigured `anything' for simple-call-tree. List function relationships.
3667 Needs simple-call-tree.el.
3668 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el"
3670 (anything-other-buffer
3671 '(anything-c-source-simple-call-tree-functions-callers
3672 anything-c-source-simple-call-tree-callers-functions
)
3673 "*anything simple-call-tree*"))
3675 (defvar anything-c-source-simple-call-tree-functions-callers
3676 '((name .
"Function is called by")
3677 (init . anything-c-simple-call-tree-functions-callers-init
)
3679 (candidates . anything-c-simple-call-tree-candidates
)
3680 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3681 (persistent-help .
"Show function definitions by rotation")
3682 (action ("Find definition selected by persistent-action" .
3683 anything-c-simple-call-tree-find-definition
)))
3684 "Needs simple-call-tree.el.
3685 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3687 (defvar anything-c-simple-call-tree-tick nil
)
3688 (make-variable-buffer-local 'anything-c-simple-call-tree-tick
)
3689 (defun anything-c-simple-call-tree-analyze-maybe ()
3690 (unless (eq (buffer-chars-modified-tick) anything-c-simple-call-tree-tick
)
3691 (simple-call-tree-analyze)
3692 (setq anything-c-simple-call-tree-tick
(buffer-chars-modified-tick))))
3694 (defun anything-c-simple-call-tree-init-base (function message
)
3695 (require 'simple-call-tree
)
3697 (when (anything-current-buffer-is-modified)
3698 (anything-c-simple-call-tree-analyze-maybe)
3699 (let ((list (funcall function simple-call-tree-alist
)))
3700 (with-current-buffer (anything-candidate-buffer 'local
)
3701 (dolist (entry list
)
3702 (let ((funcs (concat " " (mapconcat #'identity
(cdr entry
) "\n "))))
3703 (insert (car entry
) message
3704 (if (string= funcs
" ")
3709 (defun anything-c-simple-call-tree-functions-callers-init ()
3710 (anything-c-simple-call-tree-init-base 'simple-call-tree-invert
" is called by\n"))
3712 (defun anything-c-simple-call-tree-candidates ()
3713 (with-current-buffer (anything-candidate-buffer)
3714 (split-string (buffer-string) "\n\n")))
3716 (defvar anything-c-simple-call-tree-related-functions nil
)
3717 (defvar anything-c-simple-call-tree-function-index
0)
3718 (defun anything-c-simple-call-tree-persistent-action (candidate)
3719 (unless (eq last-command
'anything-execute-persistent-action
)
3720 (setq anything-c-simple-call-tree-related-functions
3721 (delete "no functions."
3723 (replace-regexp-in-string " \\| is called by\\| calls " "" candidate
)
3725 (setq anything-c-simple-call-tree-function-index -
1))
3726 (incf anything-c-simple-call-tree-function-index
)
3727 (anything-c-simple-call-tree-find-definition candidate
))
3729 (defun anything-c-simple-call-tree-find-definition (candidate)
3730 (find-function (intern
3731 (nth (mod anything-c-simple-call-tree-function-index
3732 (length anything-c-simple-call-tree-related-functions
))
3733 anything-c-simple-call-tree-related-functions
))))
3735 ;; (anything 'anything-c-source-simple-call-tree-functions-callers)
3738 (defvar anything-c-source-simple-call-tree-callers-functions
3739 '((name .
"Function calls")
3740 (init . anything-c-simple-call-tree-callers-functions-init
)
3742 (candidates . anything-c-simple-call-tree-candidates
)
3743 (persistent-action . anything-c-simple-call-tree-persistent-action
)
3744 (persistent-help .
"Show function definitions by rotation")
3745 (action ("Find definition selected by persistent-action" .
3746 anything-c-simple-call-tree-find-definition
)))
3747 "Needs simple-call-tree.el.
3748 http://www.emacswiki.org/cgi-bin/wiki/download/simple-call-tree.el")
3750 (defun anything-c-simple-call-tree-callers-functions-init ()
3751 (anything-c-simple-call-tree-init-base 'identity
" calls \n"))
3753 ;; (anything 'anything-c-source-simple-call-tree-callers-functions)
3755 ;;; Commands/Options with doc
3756 (defvar anything-c-auto-document-data nil
)
3757 (make-variable-buffer-local 'anything-c-auto-document-data
)
3758 (defvar anything-c-source-commands-and-options-in-file
3759 '((name .
"Commands/Options in file")
3761 .
(lambda (x) (format "Commands/Options in %s"
3762 (buffer-local-value 'buffer-file-name anything-current-buffer
))))
3763 (candidates . anything-command-and-options-candidates
)
3766 "List Commands and Options with doc. It needs auto-document.el .
3768 http://www.emacswiki.org/cgi-bin/wiki/download/auto-document.el")
3770 (eval-when-compile (require 'auto-document nil t
))
3771 (defun anything-command-and-options-candidates ()
3772 (with-current-buffer anything-current-buffer
3773 (when (and (require 'auto-document nil t
)
3774 (eq major-mode
'emacs-lisp-mode
)
3775 (or (anything-current-buffer-is-modified)
3776 (not anything-c-auto-document-data
)))
3777 (or imenu--index-alist
(imenu--make-index-alist t
))
3778 (setq anything-c-auto-document-data
3779 (destructuring-bind (commands options
)
3780 (adoc-construct anything-current-buffer
)
3782 (loop for
(command . doc
) in commands
3783 for cmdname
= (symbol-name command
)
3785 (cons (format "Command: %s\n %s"
3786 (propertize cmdname
'face font-lock-function-name-face
)
3787 (adoc-first-line doc
))
3788 (assoc cmdname imenu--index-alist
)))
3789 (loop with var-alist
= (cdr (assoc "Variables" imenu--index-alist
))
3790 for
(option doc default
) in options
3791 for optname
= (symbol-name option
)
3793 (cons (format "Option: %s\n %s\n default = %s"
3794 (propertize optname
'face font-lock-variable-name-face
)
3795 (adoc-first-line doc
)
3796 (adoc-prin1-to-string default
))
3799 anything-c-auto-document-data
))
3801 ;; (anything 'anything-c-source-commands-and-options-in-file)
3803 ;;;; <Color and Face>
3805 (defvar anything-c-source-customize-face
3806 '((name .
"Customize Face")
3808 (unless (anything-candidate-buffer)
3809 (save-window-excursion (list-faces-display))
3810 (anything-candidate-buffer (get-buffer "*Faces*")))))
3811 (candidates-in-buffer)
3812 (get-line . buffer-substring
)
3813 (action .
(lambda (line)
3814 (customize-face (intern (car (split-string line
))))))
3815 (requires-pattern .
3))
3816 "See (info \"(emacs)Faces\")")
3817 ;; (anything 'anything-c-source-customize-face)
3820 (defvar anything-c-source-colors
3822 (init .
(lambda () (unless (anything-candidate-buffer)
3823 (save-window-excursion (list-colors-display))
3824 (anything-candidate-buffer (get-buffer "*Colors*")))))
3825 (candidates-in-buffer)
3826 (get-line . buffer-substring
)
3827 (action ("Copy Name" .
(lambda (candidate)
3828 (kill-new (anything-c-colors-get-name candidate
))))
3829 ("Copy RGB" .
(lambda (candidate)
3830 (kill-new (anything-c-colors-get-rgb candidate
))))
3831 ("Insert Name" .
(lambda (candidate)
3832 (with-current-buffer anything-current-buffer
3833 (insert (anything-c-colors-get-name candidate
)))))
3834 ("Insert RGB" .
(lambda (candidate)
3835 (with-current-buffer anything-current-buffer
3836 (insert (anything-c-colors-get-rgb candidate
))))))))
3837 ;; (anything 'anything-c-source-colors)
3839 (defun anything-c-colors-get-name (candidate)
3841 (replace-regexp-in-string
3844 (insert (capitalize candidate
))
3845 (goto-char (point-min))
3846 (search-forward-regexp "\\s-\\{2,\\}")
3847 (delete-region (point) (point-max))
3850 (defun anything-c-colors-get-rgb (candidate)
3852 (replace-regexp-in-string
3855 (insert (capitalize candidate
))
3856 (goto-char (point-max))
3857 (search-backward-regexp "\\s-\\{2,\\}")
3858 (delete-region (point) (point-min))
3861 ;;;; <Search Engine>
3862 ;;; Tracker desktop search
3863 (defvar anything-c-source-tracker-search
3864 '((name .
"Tracker Search")
3865 (candidates .
(lambda ()
3866 (start-process "tracker-search-process" nil
3870 (requires-pattern .
3)
3872 "Source for retrieving files matching the current input pattern
3873 with the tracker desktop search.")
3874 ;; (anything 'anything-c-source-tracker-search)
3876 ;;; Spotlight (MacOS X desktop search)
3877 (defvar anything-c-source-mac-spotlight
3879 (candidates .
(lambda ()
3880 (start-process "mdfind-process" nil
"mdfind" anything-pattern
)))
3882 (requires-pattern .
3)
3884 "Source for retrieving files via Spotlight's command line
3886 ;; (anything 'anything-c-source-mac-spotlight)
3891 (defvar anything-c-source-kill-ring
3892 '((name .
"Kill Ring")
3893 (init .
(lambda () (anything-attrset 'last-command last-command
)))
3894 (candidates . anything-c-kill-ring-candidates
)
3895 (action . anything-c-kill-ring-action
)
3899 "Source for browse and insert contents of kill-ring.")
3901 (defun anything-c-kill-ring-candidates ()
3902 (loop for kill in kill-ring
3903 unless
(or (< (length kill
) anything-kill-ring-threshold
)
3904 (string-match "^[\\s\\t]+$" kill
))
3907 (defun anything-c-kill-ring-action (str)
3908 "Insert STR in `kill-ring' and set STR to the head.
3909 If this action is executed just after `yank', replace with STR as yanked string."
3910 (setq kill-ring
(delete str kill-ring
))
3911 (if (not (eq (anything-attr 'last-command
) 'yank
))
3912 (insert-for-yank str
)
3914 (let ((inhibit-read-only t
)
3915 (before (< (point) (mark t
))))
3917 (funcall (or yank-undo-function
'delete-region
) (point) (mark t
))
3918 (funcall (or yank-undo-function
'delete-region
) (mark t
) (point)))
3919 (setq yank-undo-function nil
)
3920 (set-marker (mark-marker) (point) (current-buffer))
3921 (insert-for-yank str
)
3922 ;; Set the window start back where it was in the yank command,
3924 (set-window-start (selected-window) yank-window-start t
)
3926 ;; This is like exchange-point-and-mark, but doesn't activate the mark.
3927 ;; It is cleaner to avoid activation, even though the command
3928 ;; loop would deactivate the mark because we inserted text.
3929 (goto-char (prog1 (mark t
)
3930 (set-marker (mark-marker) (point) (current-buffer)))))))
3933 ;; (anything 'anything-c-source-kill-ring)
3936 ;; DO NOT include these sources in `anything-sources' use
3937 ;; the commands `anything-mark-ring', `anything-global-mark-ring' or
3938 ;; `anything-all-mark-rings' instead.
3940 (defun anything-c-source-mark-ring-candidates ()
3941 (flet ((get-marks (pos)
3945 (let ((line (car (split-string (thing-at-point 'line
) "[\n\r]"))))
3946 (when (string= "" line
)
3947 (setq line
"<EMPTY LINE>"))
3948 (format "%7d: %s" (line-number-at-pos) line
)))))
3949 (with-current-buffer anything-current-buffer
3951 with marks
= (cons (mark-marker) mark-ring
)
3954 for m
= (get-marks i
)
3955 unless
(member m recip
)
3956 collect m into recip
3957 finally return recip
))))
3959 (defvar anything-mark-ring-cache nil
)
3960 (defvar anything-c-source-mark-ring
3961 '((name .
"mark-ring")
3963 (setq anything-mark-ring-cache
3964 (ignore-errors (anything-c-source-mark-ring-candidates)))))
3965 (candidates .
(lambda ()
3966 (anything-aif anything-mark-ring-cache
3968 (action .
(("Goto line" .
(lambda (candidate)
3969 (anything-goto-line (string-to-number candidate
))))))
3970 (persistent-action .
(lambda (candidate)
3971 (anything-goto-line (string-to-number candidate
))
3972 (anything-match-line-color-current-line)))
3973 (persistent-help .
"Show this line")))
3975 ;; (anything 'anything-c-source-mark-ring)
3978 (defun anything-mark-ring ()
3979 "Preconfigured `anything' for `anything-c-source-mark-ring'."
3981 (anything 'anything-c-source-mark-ring
))
3983 ;;; Global-mark-ring
3984 (defvar anything-c-source-global-mark-ring
3985 '((name .
"global-mark-ring")
3986 (candidates . anything-c-source-global-mark-ring-candidates
)
3987 (action .
(("Goto line" .
(lambda (candidate)
3988 (let ((items (split-string candidate
":")))
3989 (switch-to-buffer (second items
))
3990 (anything-goto-line (string-to-number (car items
))))))))
3991 (persistent-action .
(lambda (candidate)
3992 (let ((items (split-string candidate
":")))
3993 (switch-to-buffer (second items
))
3994 (anything-goto-line (string-to-number (car items
)))
3995 (anything-match-line-color-current-line))))
3996 (persistent-help .
"Show this line")))
3998 (defun anything-c-source-global-mark-ring-candidates ()
4000 (with-current-buffer (marker-buffer m
)
4004 (if (string= "" line
)
4005 (setq line
"<EMPTY LINE>")
4006 (setq line
(car (split-string (thing-at-point 'line
) "[\n\r]"))))
4007 (format "%7d:%s: %s" (line-number-at-pos) (marker-buffer m
) line
)))))
4009 with marks
= global-mark-ring
4012 for gm
= (unless (or (string-match
4013 "^ " (format "%s" (marker-buffer i
)))
4014 (null (marker-buffer i
)))
4016 when
(and gm
(not (member gm recip
)))
4017 collect gm into recip
4018 finally return recip
)))
4020 ;; (anything 'anything-c-source-global-mark-ring)
4023 (defun anything-global-mark-ring ()
4024 "Preconfigured `anything' for `anything-c-source-global-mark-ring'."
4026 (anything 'anything-c-source-global-mark-ring
))
4029 (defun anything-all-mark-rings ()
4030 "Preconfigured `anything' for `anything-c-source-global-mark-ring' and \
4031 `anything-c-source-mark-ring'."
4033 (anything '(anything-c-source-global-mark-ring
4034 anything-c-source-mark-ring
)))
4037 ;;; Insert from register
4038 (defvar anything-c-source-register
4039 '((name .
"Registers")
4040 (candidates . anything-c-register-candidates
)
4041 (action-transformer . anything-c-register-action-transformer
)
4044 "See (info \"(emacs)Registers\")")
4046 (defun anything-c-register-candidates ()
4047 "Collecting register contents and appropriate commands."
4048 (loop for
(char . val
) in register-alist
4049 for key
= (single-key-description char
)
4050 for string-actions
= (cond
4052 (list (int-to-string val
)
4054 'increment-register
))
4056 (let ((buf (marker-buffer val
)))
4058 (list "a marker in no buffer")
4060 "a buffer position:"
4063 (int-to-string (marker-position val
)))
4065 'insert-register
))))
4066 ((and (consp val
) (window-configuration-p (car val
)))
4067 (list "window configuration."
4069 ((and (consp val
) (frame-configuration-p (car val
)))
4070 (list "frame configuration."
4072 ((and (consp val
) (eq (car val
) 'file
))
4073 (list (concat "file:"
4074 (prin1-to-string (cdr val
))
4077 ((and (consp val
) (eq (car val
) 'file-query
))
4078 (list (concat "file:a file-query reference: file "
4081 (int-to-string (car (cdr (cdr val
))))
4085 (let ((lines (format "%4d" (length val
))))
4086 (list (format "%s: %s\n" lines
4087 (truncate-string-to-width
4088 (mapconcat 'identity
(list (car val
))
4089 ;; (mapconcat (lambda (y) y) val
4090 "^J") (- (window-width) 15)))
4093 (list ;; without properties
4094 (substring-no-properties val
)
4097 'prepend-to-register
))
4100 collect
(cons (format "register %3s: %s" key
(car string-actions
))
4101 (cons char
(cdr string-actions
)))))
4103 (defun anything-c-register-action-transformer (actions register-and-functions
)
4104 "Decide actions by the contents of register."
4105 (loop with func-actions
=
4108 (lambda (c) (insert-register (car c
))))
4110 "Jump to Register" .
4111 (lambda (c) (jump-to-register (car c
))))
4113 "Append Region to Register" .
4114 (lambda (c) (append-to-register (car c
) (region-beginning) (region-end))))
4115 (prepend-to-register
4116 "Prepend Region to Register" .
4117 (lambda (c) (prepend-to-register (car c
) (region-beginning) (region-end))))
4119 "Increment Prefix Arg to Register" .
4120 (lambda (c) (increment-register anything-current-prefix-arg
(car c
)))))
4121 for func in
(cdr register-and-functions
)
4122 for cell
= (assq func func-actions
)
4124 collect
(cdr cell
)))
4126 ;; (anything 'anything-c-source-register)
4128 ;;;; <Headline Extraction>
4129 (defvar anything-c-source-fixme
4130 '((name .
"TODO/FIXME/DRY comments")
4131 (headline .
"^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$")
4134 "Show TODO/FIXME/DRY comments in current file.")
4135 ;; (anything 'anything-c-source-fixme)
4137 (defvar anything-c-source-rd-headline
4138 '((name .
"RD HeadLine")
4139 (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$")
4140 (condition .
(memq major-mode
'(rdgrep-mode rd-mode
)))
4146 http://en.wikipedia.org/wiki/Ruby_Document_format")
4147 ;; (anything 'anything-c-source-rd-headline)
4149 (defvar anything-c-source-oddmuse-headline
4150 '((name .
"Oddmuse HeadLine")
4151 (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$"
4152 "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$")
4153 (condition .
(memq major-mode
'(oddmuse-mode yaoddmuse-mode
)))
4156 "Show Oddmuse headlines, such as EmacsWiki.")
4157 ;; (anything 'anything-c-source-oddmuse-headline)
4159 (defvar anything-c-source-emacs-source-defun
4160 '((name .
"Emacs Source DEFUN")
4161 (headline .
"DEFUN\\|DEFVAR")
4162 (condition .
(string-match "/emacs2[0-9].+/src/.+c$" (or buffer-file-name
""))))
4163 "Show DEFUN/DEFVAR in Emacs C source file.")
4164 ;; (anything 'anything-c-source-emacs-source-defun)
4166 (defvar anything-c-source-emacs-lisp-expectations
4167 '((name .
"Emacs Lisp Expectations")
4168 (headline .
"(desc[ ]\\|(expectations")
4169 (condition .
(eq major-mode
'emacs-lisp-mode
)))
4170 "Show descriptions (desc) in Emacs Lisp Expectations.
4172 http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
4173 ;; (anything 'anything-c-source-emacs-lisp-expectations)
4175 (defvar anything-c-source-emacs-lisp-toplevels
4176 '((name .
"Emacs Lisp Toplevel / Level 4 Comment / Linkd Star")
4177 (headline .
"^(\\|(@\\*\\|^;;;;")
4178 (get-line . buffer-substring
)
4179 (condition .
(eq major-mode
'emacs-lisp-mode
))
4181 "Show top-level forms, level 4 comments and linkd stars (optional) in Emacs Lisp.
4182 linkd.el is optional because linkd stars are extracted by regexp.
4183 http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el")
4184 ;; (anything 'anything-c-source-emacs-lisp-toplevels)
4186 (defvar anything-c-source-org-headline
4187 '((name .
"Org HeadLine")
4189 "^\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4190 "^\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4191 "^\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4192 "^\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4193 "^\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4194 "^\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4195 "^\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$"
4196 "^\\*\\*\\*\\*\\*\\*\\*\\* \\(.+?\\)\\([ \t]*:[a-zA-Z0-9_@:]+:\\)?[ \t]*$")
4197 (condition .
(eq major-mode
'org-mode
))
4200 (persistent-action .
(lambda (elm)
4201 (anything-c-action-line-goto elm
)
4204 .
(lambda (actions candidate
)
4205 '(("Go to Line" . anything-c-action-line-goto
)
4206 ("Insert Link to This Headline" . anything-c-org-headline-insert-link-to-headline
)))))
4207 "Show Org headlines.
4208 org-mode is very very much extended text-mode/outline-mode.
4210 See (find-library \"org.el\")
4211 See http://orgmode.org for the latest version.")
4213 (defun anything-c-org-headline-insert-link-to-headline (lineno-and-content)
4216 (anything-goto-line (car lineno-and-content
))
4217 (and (looking-at org-complex-heading-regexp
)
4218 (org-make-link-string (concat "*" (match-string 4)))))))
4220 ;; (anything 'anything-c-source-org-headline)
4222 ;;; Anything yaoddmuse
4223 ;; Be sure to have yaoddmuse.el installed
4224 ;; install-elisp may be required if you want to install elisp file from here.
4225 (defvar anything-yaoddmuse-use-cache-file nil
)
4226 (defvar anything-c-yaoddmuse-cache-file
"~/.emacs.d/yaoddmuse-cache.el")
4227 (defvar anything-c-yaoddmuse-ew-cache nil
)
4228 (defvar anything-c-source-yaoddmuse-emacswiki-edit-or-view
4229 '((name .
"Yaoddmuse Edit or View (EmacsWiki)")
4230 (candidates .
(lambda ()
4231 (if anything-yaoddmuse-use-cache-file
4233 (unless anything-c-yaoddmuse-ew-cache
4234 (load anything-c-yaoddmuse-cache-file
)
4235 (setq anything-c-yaoddmuse-ew-cache
4236 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4237 anything-c-yaoddmuse-ew-cache
)
4238 (yaoddmuse-update-pagename t
)
4239 (gethash "EmacsWiki" yaoddmuse-pages-hash
))))
4240 (action .
(("Edit page" .
(lambda (candidate)
4241 (yaoddmuse-edit "EmacsWiki" candidate
)))
4242 ("Browse page" .
(lambda (candidate)
4243 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4244 ("Browse page other window" .
(lambda (candidate)
4246 (split-window-vertically))
4247 (yaoddmuse-browse-page "EmacsWiki" candidate
)))
4248 ("Browse diff" .
(lambda (candidate)
4249 (yaoddmuse-browse-page-diff "EmacsWiki" candidate
)))
4250 ("Copy URL" .
(lambda (candidate)
4251 (kill-new (yaoddmuse-url "EmacsWiki" candidate
))
4252 (message "Have copy page %s's URL to yank." candidate
)))
4253 ("Create page" .
(lambda (candidate)
4254 (yaoddmuse-edit "EmacsWiki" anything-input
)))
4255 ("Update cache" .
(lambda (candidate)
4256 (if anything-yaoddmuse-use-cache-file
4258 (anything-yaoddmuse-cache-pages t
)
4259 (setq anything-c-yaoddmuse-ew-cache
4260 (gethash "EmacsWiki" yaoddmuse-pages-hash
)))
4261 (yaoddmuse-update-pagename))))))
4262 (action-transformer anything-c-yaoddmuse-action-transformer
))
4263 "Needs yaoddmuse.el.
4265 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4267 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view)
4269 (defvar anything-c-source-yaoddmuse-emacswiki-post-library
4270 '((name .
"Yaoddmuse Post library (EmacsWiki)")
4271 (init .
(anything-yaoddmuse-init))
4272 (candidates-in-buffer)
4273 (action .
(("Post library and Browse" .
(lambda (candidate)
4274 (yaoddmuse-post-file (find-library-name candidate
)
4276 (file-name-nondirectory (find-library-name candidate
))
4278 ("Post library" .
(lambda (candidate)
4279 (yaoddmuse-post-file (find-library-name candidate
)
4281 (file-name-nondirectory (find-library-name candidate
))))))))
4282 "Needs yaoddmuse.el.
4284 http://www.emacswiki.org/emacs/download/yaoddmuse.el")
4286 ;; (anything 'anything-c-source-yaoddmuse-emacswiki-post-library)
4288 (defun anything-c-yaoddmuse-action-transformer (actions candidate
)
4289 "Allow the use of `install-elisp' only on elisp files."
4290 (if (string-match "\.el$" candidate
)
4291 (append actions
'(("Install Elisp" .
(lambda (elm)
4292 (install-elisp-from-emacswiki elm
)))))
4296 (defun anything-yaoddmuse-cache-pages (&optional load
)
4297 "Fetch the list of files on emacswiki and create cache file.
4298 If load is non--nil load the file and feed `yaoddmuse-pages-hash'."
4300 (yaoddmuse-update-pagename)
4302 (find-file anything-c-yaoddmuse-cache-file
)
4304 (insert "(puthash \"EmacsWiki\" '(")
4305 (loop for i in
(gethash "EmacsWiki" yaoddmuse-pages-hash
)
4307 (insert (concat "(\"" (car i
) "\") ")))
4308 (insert ") yaoddmuse-pages-hash)\n")
4310 (kill-buffer (current-buffer))
4311 (when (or current-prefix-arg
4313 (load anything-c-yaoddmuse-cache-file
))))
4316 (defun anything-yaoddmuse-emacswiki-edit-or-view ()
4317 "Preconfigured `anything' to edit or view EmacsWiki page.
4321 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4323 (anything 'anything-c-source-yaoddmuse-emacswiki-edit-or-view
))
4326 (defun anything-yaoddmuse-emacswiki-post-library ()
4327 "Preconfigured `anything' to post library to EmacsWiki.
4331 http://www.emacswiki.org/emacs/download/yaoddmuse.el"
4333 (anything 'anything-c-source-yaoddmuse-emacswiki-post-library
))
4335 (defun anything-yaoddmuse-init ()
4336 "Init anything buffer status."
4337 (let ((anything-buffer (anything-candidate-buffer 'global
))
4338 (library-list (yaoddmuse-get-library-list)))
4339 (with-current-buffer anything-buffer
4340 ;; Insert library name.
4341 (dolist (library library-list
)
4342 (insert (format "%s\n" library
)))
4344 (sort-lines nil
(point-min) (point-max)))))
4347 (defvar anything-c-source-eev-anchor
4348 '((name .
"Anchors")
4352 (with-current-buffer anything-current-buffer
4353 (loop initially
(goto-char (point-min))
4354 while
(re-search-forward (format ee-anchor-format
"\\([^\.].+\\)") nil t
)
4355 for anchor
= (match-string-no-properties 1)
4356 collect
(cons (format "%5d:%s"
4357 (line-number-at-pos (match-beginning 0))
4358 (format ee-anchor-format anchor
)) anchor
))))))
4359 (persistent-action .
(lambda (item)
4361 (anything-match-line-color-current-line)))
4362 (persistent-help .
"Show this entry")
4363 (action .
(("Goto link" . ee-to
)))))
4364 ;; (anything 'anything-c-source-eev-anchor)
4368 (defvar anything-c-source-org-keywords
4369 '((name .
"Org Keywords")
4370 (init . anything-c-org-keywords-init
)
4371 (candidates . anything-c-org-keywords-candidates
)
4372 (action . anything-c-org-keywords-insert
)
4373 (persistent-action . anything-c-org-keywords-show-help
)
4374 (persistent-help .
"Show an example and info page to describe this keyword.")
4377 ;; (anything 'anything-c-source-org-keywords)
4378 (defvar anything-c-org-keywords-info-location
4379 '(("#+TITLE:" .
"(org)Export options")
4380 ("#+AUTHOR:" .
"(org)Export options")
4381 ("#+DATE:" .
"(org)Export options")
4382 ("#+EMAIL:" .
"(org)Export options")
4383 ("#+DESCRIPTION:" .
"(org)Export options")
4384 ("#+KEYWORDS:" .
"(org)Export options")
4385 ("#+LANGUAGE:" .
"(org)Export options")
4386 ("#+TEXT:" .
"(org)Export options")
4387 ("#+TEXT:" .
"(org)Export options")
4388 ("#+OPTIONS:" .
"(org)Export options")
4389 ("#+BIND:" .
"(org)Export options")
4390 ("#+LINK_UP:" .
"(org)Export options")
4391 ("#+LINK_HOME:" .
"(org)Export options")
4392 ("#+LATEX_HEADER:" .
"(org)Export options")
4393 ("#+EXPORT_SELECT_TAGS:" .
"(org)Export options")
4394 ("#+EXPORT_EXCLUDE_TAGS:" .
"(org)Export options")
4395 ("#+INFOJS_OPT" .
"(org)Javascript support")
4396 ("#+BEGIN_HTML" .
"(org)Quoting HTML tags")
4397 ("#+BEGIN_LaTeX" .
"(org)Quoting LaTeX code")
4398 ("#+ORGTBL" .
"(org)Radio tables")
4399 ("#+HTML:" .
"(org)Quoting HTML tags")
4400 ("#+LaTeX:" .
"(org)Quoting LaTeX code")
4401 ("#+BEGIN:" .
"(org)Dynamic blocks") ;clocktable columnview
4402 ("#+BEGIN_EXAMPLE" .
"(org)Literal examples")
4403 ("#+BEGIN_QUOTE" .
"(org)Paragraphs")
4404 ("#+BEGIN_VERSE" .
"(org)Paragraphs")
4405 ("#+BEGIN_SRC" .
"(org)Literal examples")
4406 ("#+CAPTION" .
"(org)Tables in HTML export")
4407 ("#+LABEL" .
"(org)Tables in LaTeX export")
4408 ("#+ATTR_HTML" .
"(org)Links")
4409 ("#+ATTR_LaTeX" .
"(org)Images in LaTeX export")))
4411 (defun anything-c-org-keywords-init ()
4412 (unless (anything-attr 'keywords-examples
)
4414 (anything-attrset 'keywords-examples
4418 (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x
)
4419 (cons (match-string 2 x
) (match-string 1 x
)))
4420 (org-split-string (org-get-current-options) "\n"))
4421 (mapcar 'list org-additional-option-like-keywords
)))
4422 (anything-attrset 'keywords
(mapcar 'car
(anything-attr 'keywords-examples
)))))
4424 (defun anything-c-org-keywords-candidates ()
4425 (and (eq (buffer-local-value 'major-mode anything-current-buffer
) 'org-mode
)
4426 (anything-attr 'keywords
)))
4428 (defun anything-c-org-keywords-insert (keyword)
4429 (cond ((string-match "BEGIN" keyword
)
4430 (insert "#+" keyword
" ")
4432 (insert "\n" (replace-regexp-in-string "BEGIN" "END" keyword
) "\n")))
4434 (insert "#+" keyword
" "))))
4436 (defun anything-c-org-keywords-show-help (keyword)
4437 (info (or (assoc-default (concat "#+" keyword
) anything-c-org-keywords-info-location
)
4438 "(org)In-buffer settings"))
4439 (search-forward (concat "#+" keyword
) nil t
)
4440 (anything-persistent-highlight-point)
4441 (message "%s" (or (cdr (assoc keyword
(anything-attr 'keywords-examples
))) "")))
4445 (defvar anything-c-source-picklist
4446 '((name .
"Picklist")
4447 (candidates .
(lambda () (mapcar 'car picklist-list
)))
4449 ;; (anything 'anything-c-source-picklist)
4452 (defvar bbdb-records
)
4453 (defvar bbdb-buffer-name
)
4454 (declare-function bbdb
"ext:bbdb-com")
4455 (declare-function bbdb-current-record
"ext:bbdb-com")
4456 (declare-function bbdb-redisplay-one-record
"ext:bbdb-com")
4457 (declare-function bbdb-record-net
"ext:bbdb-com" (string) t
)
4458 (declare-function bbdb-current-record
"ext:bbdb-com")
4459 (declare-function bbdb-dwim-net-address
"ext:bbdb-com")
4460 (declare-function bbdb-records
"ext:bbdb-com"
4461 (&optional dont-check-disk already-in-db-buffer
))
4463 (defun anything-c-bbdb-candidates ()
4464 "Return a list of all names in the bbdb database. The format
4465 is \"Firstname Lastname\"."
4466 (mapcar (lambda (bbdb-record)
4467 (replace-regexp-in-string
4469 (concat (aref bbdb-record
0) " " (aref bbdb-record
1))))
4472 (defun anything-c-bbdb-create-contact (actions candidate
)
4473 "Action transformer that returns only an entry to add the
4474 current `anything-pattern' as new contact. All other actions are
4476 (if (string= candidate
"*Add to contacts*")
4477 '(("Add to contacts" .
(lambda (actions)
4478 (bbdb-create-internal
4479 (read-from-minibuffer "Name: " anything-c-bbdb-name
)
4480 (read-from-minibuffer "Company: ")
4481 (read-from-minibuffer "Email: ")
4484 (read-from-minibuffer "Note: ")))))
4487 (defun anything-c-bbdb-get-record (candidate)
4488 "Return record that match CANDIDATE."
4489 (bbdb candidate nil
)
4490 (set-buffer "*BBDB*")
4491 (bbdb-current-record))
4493 (defvar anything-c-bbdb-name nil
4494 "Only for internal use.")
4496 (defvar anything-c-source-bbdb
4498 (candidates . anything-c-bbdb-candidates
)
4499 (action ("Send a mail" . anything-c-bbdb-compose-mail
)
4500 ("View person's data" . anything-c-bbdb-view-person-action
))
4501 (filtered-candidate-transformer .
(lambda (candidates source
)
4502 (setq anything-c-bbdb-name anything-pattern
)
4503 (if (not candidates
)
4504 (list "*Add to contacts*")
4506 (action-transformer .
(lambda (actions candidate
)
4507 (anything-c-bbdb-create-contact actions candidate
))))
4510 http://bbdb.sourceforge.net/")
4511 ;; (anything 'anything-c-source-bbdb)
4513 (defun anything-c-bbdb-view-person-action (candidate)
4514 "View BBDB data of single CANDIDATE or marked candidates."
4515 (anything-aif (anything-marked-candidates)
4516 (let ((bbdb-append-records (length it
)))
4518 (bbdb-redisplay-one-record (anything-c-bbdb-get-record i
))))
4519 (bbdb-redisplay-one-record (anything-c-bbdb-get-record candidate
))))
4521 (defun anything-c-bbdb-collect-mail-addresses ()
4522 "Return a list of all mail addresses of records in bbdb buffer."
4523 (with-current-buffer bbdb-buffer-name
4524 (loop for i in bbdb-records
4525 if
(bbdb-record-net (car i
))
4526 collect
(bbdb-dwim-net-address (car i
)))))
4528 (defun anything-c-bbdb-compose-mail (candidate)
4529 "Compose a mail with all records of bbdb buffer."
4530 (anything-c-bbdb-view-person-action candidate
)
4531 (let* ((address-list (anything-c-bbdb-collect-mail-addresses))
4532 (address-str (mapconcat 'identity address-list
",\n ")))
4533 (compose-mail address-str
)))
4535 ;;; Evaluation Result
4536 (defvar anything-c-source-evaluation-result
4537 '((name .
"Evaluation Result")
4540 (filtered-candidate-transformer .
(lambda (candidates source
)
4543 (with-current-buffer anything-current-buffer
4545 (eval (read anything-pattern
))))
4547 (action ("Copy result to kill-ring" .
(lambda (candidate)
4548 (with-current-buffer anything-buffer
4549 (let ((end (save-excursion
4550 (goto-char (point-max))
4551 (search-backward "\n")
4553 (kill-region (point) end
))))))))
4554 ;; (anything 'anything-c-source-evaluation-result)
4557 (defun anything-eval-expression (arg)
4558 "Preconfigured anything for `anything-c-source-evaluation-result'."
4560 (anything 'anything-c-source-evaluation-result
(when arg
(thing-at-point 'sexp
))
4561 nil nil nil
"*anything eval*"))
4564 (defun anything-eval-expression-with-eldoc ()
4565 "Preconfigured anything for `anything-c-source-evaluation-result' with `eldoc' support. "
4568 (let ((timer (run-with-idle-timer eldoc-idle-delay
4569 'repeat
'anything-eldoc-show-in-eval
)))
4571 (call-interactively 'anything-eval-expression
)
4572 (cancel-timer timer
)))
4573 (call-interactively 'anything-eval-expression
)))
4575 (defun anything-eldoc-show-in-eval ()
4576 "Return eldoc in a tooltip for current minibuffer input."
4577 (let* ((str-all (minibuffer-completion-contents))
4581 (goto-char (point-max))
4582 (unless (looking-back ")\\|\"") (forward-char -
1))
4583 (eldoc-current-symbol))))
4584 (doc (or (eldoc-get-var-docstring sym
)
4585 (eldoc-get-fnsym-args-string
4586 (car (eldoc-fnsym-in-current-sexp))))))
4587 (when doc
(tooltip-show doc
))))
4589 ;;; Calculation Result
4590 (defvar anything-c-source-calculation-result
4591 '((name .
"Calculation Result")
4593 (filtered-candidate-transformer .
(lambda (candidates source
)
4596 (calc-eval anything-pattern
)
4598 (action ("Copy result to kill-ring" . kill-new
))))
4599 ;; (anything 'anything-c-source-calculation-result)
4601 ;;; Google Suggestions
4602 (defvar anything-gg-sug-lgh-flag
0)
4603 (defun anything-c-google-suggest-fetch (input)
4604 "Fetch suggestions for INPUT from XML buffer.
4605 Return an alist with elements like (data . number_results)."
4606 (let ((request (concat anything-c-google-suggest-url
4607 (url-hexify-string input
))))
4610 with result-alist
= (xml-get-children
4611 (car (xml-parse-region (point-min) (point-max)))
4612 'CompleteSuggestion
)
4613 for i in result-alist
4614 for data
= (cdr (caadr (assoc 'suggestion i
)))
4615 for nqueries
= (cdr (caadr (assoc 'num_queries i
)))
4616 for ldata
= (length data
)
4618 (when (> ldata anything-gg-sug-lgh-flag
)
4619 (setq anything-gg-sug-lgh-flag ldata
))
4620 collect
(cons data nqueries
) into cont
4621 finally return cont
)))
4622 (if anything-google-suggest-use-curl-p
4624 (call-process "curl" nil t nil request
)
4626 (with-current-buffer
4627 (url-retrieve-synchronously request
)
4631 (defun anything-c-google-suggest-set-candidates ()
4632 "Set candidates with result and number of google results found."
4633 (let ((suggestions (anything-c-google-suggest-fetch anything-input
)))
4634 (setq suggestions
(loop for i in suggestions
4635 for interval
= (- anything-gg-sug-lgh-flag
(length (car i
)))
4636 for elm
= (concat (car i
)
4637 (make-string (+ 2 interval
) ?
)
4638 "(" (cdr i
) " results)")
4639 collect
(cons elm
(car i
))))
4640 (if (some (lambda (data) (equal (cdr data
) anything-input
)) suggestions
)
4642 ;; if there is no suggestion exactly matching the input then
4643 ;; prepend a Search on Google item to the list
4646 (list (cons (concat "Search for " "'" anything-input
"'" " on Google")
4647 anything-input
))))))
4650 (defun anything-c-google-suggest-action (candidate)
4651 "Default action to jump to a google suggested candidate."
4652 (anything-c-browse-url (concat anything-c-google-suggest-search-url
4653 (url-hexify-string candidate
))))
4656 (defvar anything-c-source-google-suggest
4657 '((name .
"Google Suggest")
4658 (candidates . anything-c-google-suggest-set-candidates
)
4659 (action .
(("Google Search" . anything-c-google-suggest-action
)))
4661 (requires-pattern .
3)
4664 ;; (anything 'anything-c-source-google-suggest)
4666 ;;; Yahoo suggestions
4668 (defun anything-c-yahoo-suggest-fetch (input)
4669 "Fetch Yahoo suggestions for INPUT from XML buffer.
4670 Return an alist with elements like (data . number_results)."
4671 (let ((request (concat anything-c-yahoo-suggest-url
4672 (url-hexify-string input
))))
4675 with result-alist
= (xml-get-children
4676 (car (xml-parse-region (point-min) (point-max)))
4678 for i in result-alist
4679 collect
(caddr i
))))
4680 (with-current-buffer
4681 (url-retrieve-synchronously request
)
4684 (defun anything-c-yahoo-suggest-set-candidates ()
4685 "Set candidates with Yahoo results found."
4686 (let ((suggestions (anything-c-yahoo-suggest-fetch anything-input
)))
4690 (list (cons (concat "Search for " "'" anything-input
"'" " on Yahoo")
4691 anything-input
))))))
4693 (defun anything-c-yahoo-suggest-action (candidate)
4694 "Default action to jump to a Yahoo suggested candidate."
4695 (anything-c-browse-url (concat anything-c-yahoo-suggest-search-url
4696 (url-hexify-string candidate
))))
4698 (defvar anything-c-source-yahoo-suggest
4699 '((name .
"Yahoo Suggest")
4700 (candidates . anything-c-yahoo-suggest-set-candidates
)
4701 (action .
(("Yahoo Search" . anything-c-yahoo-suggest-action
)))
4703 (requires-pattern .
3)
4706 ;; (anything 'anything-c-source-yahoo-suggest)
4709 ;;; Need external program surfraw.
4710 ;;; http://surfraw.alioth.debian.org/
4712 (require 'browse-url
)
4713 (defvar w3m-command nil
)
4714 (defvar anything-c-home-url
"http://www.google.fr"
4715 "*Default url to use as home url.")
4717 (defvar anything-browse-url-default-browser-alist
4718 `((,w3m-command . w3m-browse-url
)
4719 (,browse-url-firefox-program . browse-url-firefox
)
4720 (,browse-url-kde-program . browse-url-kde
)
4721 (,browse-url-gnome-moz-program . browse-url-gnome-moz
)
4722 (,browse-url-mozilla-program . browse-url-mozilla
)
4723 (,browse-url-galeon-program . browse-url-galeon
)
4724 (,browse-url-netscape-program . browse-url-netscape
)
4725 (,browse-url-mosaic-program . browse-url-mosaic
)
4726 (,browse-url-xterm-program . browse-url-text-xterm
))
4727 "*Alist of (executable . function) to try to find a suitable url browser.")
4729 (defun anything-browse-url-default-browser (url &rest args
)
4730 "Find a suitable browser and ask it to load URL."
4731 (let ((default-browser (loop
4732 for i in anything-browse-url-default-browser-alist
4733 when
(and (car i
) (executable-find (car i
))) return
(cdr i
))))
4735 (apply default-browser url args
)
4736 (error "No usable browser found"))))
4738 (defun* anything-c-browse-url
(&optional
(url anything-c-home-url
))
4739 "Default command to browse URL."
4740 (if browse-url-browser-function
4742 (anything-browse-url-default-browser url
)))
4744 (defun anything-c-build-elvi-list ()
4745 "Return list of all engines and descriptions handled by surfraw."
4748 (call-process "surfraw" nil t nil
4750 (split-string (buffer-string) "\n"))))
4753 (defun anything-surfraw (pattern engine
)
4754 "Preconfigured `anything' to search PATTERN with search ENGINE."
4755 (interactive (list (read-string "SearchFor: ")
4758 (anything-c-build-elvi-list)
4760 (let* ((engine-nodesc (car (split-string engine
)))
4761 (url (with-temp-buffer
4762 (apply 'call-process
"surfraw" nil t nil
4763 (list engine-nodesc
"-p" pattern
))
4764 (replace-regexp-in-string
4765 "\n" "" (buffer-string)))))
4766 (if (string= engine-nodesc
"W")
4767 (anything-c-browse-url)
4768 (anything-c-browse-url url
))))
4773 (defun anything-emms-stream-edit-bookmark (elm)
4774 "Change the information of current emms-stream bookmark from anything."
4776 (let* ((cur-buf anything-current-buffer
)
4777 (bookmark (assoc elm emms-stream-list
))
4778 (name (read-from-minibuffer "Description: "
4780 (url (read-from-minibuffer "URL: "
4782 (fd (read-from-minibuffer "Feed Descriptor: "
4783 (int-to-string (nth 2 bookmark
))))
4784 (type (read-from-minibuffer "Type (url, streamlist, or lastfm): "
4785 (format "%s" (car (last bookmark
))))))
4788 (when (re-search-forward (concat "^" name
) nil t
)
4790 (emms-stream-delete-bookmark)
4791 (emms-stream-add-bookmark name url
(string-to-number fd
) type
)
4792 (emms-stream-save-bookmarks-file)
4794 (switch-to-buffer cur-buf
)))))
4796 (defun anything-emms-stream-delete-bookmark (elm)
4797 "Delete an emms-stream bookmark from anything."
4799 (let* ((cur-buf anything-current-buffer
)
4800 (bookmark (assoc elm emms-stream-list
))
4801 (name (nth 0 bookmark
)))
4804 (when (re-search-forward (concat "^" name
) nil t
)
4806 (emms-stream-delete-bookmark)
4807 (emms-stream-save-bookmarks-file)
4809 (switch-to-buffer cur-buf
)))))
4811 (defvar anything-c-source-emms-streams
4812 '((name .
"Emms Streams")
4814 (emms-stream-init)))
4815 (candidates .
(lambda ()
4816 (mapcar 'car emms-stream-list
)))
4817 (action .
(("Play" .
(lambda (elm)
4818 (let* ((stream (assoc elm emms-stream-list
))
4819 (fn (intern (concat "emms-play-" (symbol-name (car (last stream
))))))
4820 (url (second stream
)))
4822 ("Delete" . anything-emms-stream-delete-bookmark
)
4823 ("Edit" . anything-emms-stream-edit-bookmark
)))
4824 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4825 ;; (anything 'anything-c-source-emms-streams)
4827 ;; Don't forget to set `emms-source-file-default-directory'
4828 (defvar anything-c-source-emms-dired
4829 '((name .
"Music Directory")
4830 (candidates .
(lambda ()
4831 (cddr (directory-files emms-source-file-default-directory
))))
4833 (("Play Directory" .
(lambda (item)
4834 (emms-play-directory
4837 emms-source-file-default-directory
))))
4838 ("Open dired in file's directory" .
(lambda (item)
4839 (anything-c-open-dired
4842 emms-source-file-default-directory
))))))
4843 (filtered-candidate-transformer . anything-c-adaptive-sort
)))
4844 ;; (anything 'anything-c-source-emms-dired)
4846 (defface anything-emms-playlist
4847 '((t (:foreground
"Springgreen4" :underline t
)))
4848 "*Face used for tracks in current emms playlist."
4851 (defun anything-c-emms-files-modifier (candidates)
4852 (let ((current-playlist (with-current-emms-playlist
4854 with cur-list
= (emms-playlist-tracks-in-region
4855 (point-min) (point-max))
4857 collect
(assoc-default 'info-file i
)))))
4858 (loop for i in candidates
4859 if
(member i current-playlist
)
4860 collect
(propertize i
'face
'anything-emms-playlist
) into lis
4861 else collect i into lis finally return lis
)))
4863 (defun anything-c-emms-play-current-playlist ()
4864 "Play current playlist."
4865 (with-current-emms-playlist
4866 (emms-playlist-first)
4867 (emms-playlist-mode-play-smart)))
4869 (defvar anything-c-source-emms-files
4870 '((name .
"Emms files")
4871 (candidates .
(lambda ()
4872 (loop for v being the hash-values in emms-cache-db
4873 for name
= (assoc-default 'name v
)
4874 unless
(string-match "^http:" name
) collect name
)))
4875 (candidate-transformer . anything-c-emms-files-modifier
)
4876 (action .
(("Play file" . emms-play-file
)
4877 ("Add to Playlist and play"
4878 .
(lambda (candidate)
4880 (dolist (i (anything-marked-candidates))
4881 (emms-add-playlist-file i
))
4882 (unless emms-player-playing-p
4883 (anything-c-emms-play-current-playlist))))))))
4885 ;; (anything 'anything-c-source-emms-files)
4887 ;;; Jabber Contacts (jabber.el)
4888 (defun anything-c-jabber-online-contacts ()
4889 "List online Jabber contacts."
4892 (dolist (item (jabber-concat-rosters) jids
)
4893 (when (get item
'connected
)
4894 (push (if (get item
'name
)
4895 (cons (get item
'name
) item
)
4896 (cons (symbol-name item
) item
)) jids
))))))
4898 (defvar anything-c-source-jabber-contacts
4899 '((name .
"Jabber Contacts")
4900 (init .
(lambda () (require 'jabber
)))
4901 (candidates .
(lambda () (mapcar 'car
(anything-c-jabber-online-contacts))))
4902 (action .
(lambda (x)
4904 (jabber-read-account)
4906 (cdr (assoc x
(anything-c-jabber-online-contacts)))))))))
4907 ;; (anything 'anything-c-source-jabber-contacts)
4911 (defvar anything-source-select-buffer
"*anything source select*")
4912 (defvar anything-c-source-call-source
4913 `((name .
"Call anything source")
4914 (candidate-number-limit)
4915 (candidates .
(lambda ()
4916 (loop for vname in
(all-completions "anything-c-source-" obarray
)
4917 for var
= (intern vname
)
4918 for name
= (ignore-errors (assoc-default 'name
(symbol-value var
)))
4919 if name collect
(cons (format "%s `%s'"
4920 name
(propertize vname
'face
'font-lock-variable-name-face
))
4922 (action .
(("Invoke anything with selected source" .
4924 (setq anything-candidate-number-limit
9999)
4925 (anything candidate nil nil nil nil
4926 anything-source-select-buffer
)))
4927 ("Describe variable" . describe-variable
)
4928 ("Find variable" . find-variable
)))
4929 (persistent-action . describe-variable
)
4930 (persistent-help .
"Show description of this source")))
4931 ;; (anything 'anything-c-source-call-source)
4934 (defun anything-call-source ()
4935 "Preconfigured `anything' to call anything source."
4937 (anything 'anything-c-source-call-source nil nil nil nil
4938 anything-source-select-buffer
))
4940 (defun anything-call-source-from-anything ()
4941 "Call anything source within `anything' session."
4943 (setq anything-input-idle-delay
0)
4944 (anything-set-sources '(anything-c-source-call-source)))
4946 ;;; Execute Preconfigured anything.
4947 (defvar anything-c-source-anything-commands
4948 '((name .
"Preconfigured Anything")
4949 (candidates . anything-c-anything-commands-candidates
)
4951 (candidate-number-limit)))
4952 ;; (anything 'anything-c-source-anything-commands)
4954 (defun anything-c-anything-commands-candidates ()
4955 (loop for
(cmd . desc
) in
(anything-c-list-preconfigured-anything)
4956 collect
(cons (if (where-is-internal cmd nil t
)
4957 (substitute-command-keys (format "M-x %s (\\[%s]) : %s" cmd cmd desc
))
4958 (substitute-command-keys (format "\\[%s] : %s" cmd desc
)))
4962 (defun anything-execute-anything-command ()
4963 "Preconfigured `anything' to execute preconfigured `anything'."
4965 (anything-other-buffer 'anything-c-source-anything-commands
4966 "*anything commands*"))
4970 (defun anything-c-occur-goto-line (candidate)
4971 "Goto line action for anything-c-source-occur."
4972 (anything-goto-line (string-to-number candidate
)))
4974 (defun anything-c-occur-persistent-action (candidate)
4975 "Persistent action for anything occur source."
4976 (anything-c-occur-goto-line candidate
)
4977 (anything-match-line-color-current-line))
4979 (defun anything-c-get-occur-candidates ()
4980 "Get `anything-c-source-occur' candidates."
4982 (let ((count (occur-engine
4984 (list anything-current-buffer
) (current-buffer)
4985 list-matching-lines-default-context-lines nil
4986 list-matching-lines-buffer-name-face
4987 nil list-matching-lines-face
4988 (not (eq occur-excluded-properties t
)))))
4990 (cdr (split-string (buffer-string) "\n" t
))))))
4992 (defvar anything-c-source-occur
4994 (candidates . anything-c-get-occur-candidates
)
4995 (persistent-action . anything-c-occur-persistent-action
)
4996 (persistent-help .
"Goto Line")
4997 (action . anything-c-occur-goto-line
)
4998 (requires-pattern .
1)
5001 ;; (anything 'anything-c-source-occur)
5004 (defun anything-occur ()
5005 "Preconfigured Anything for Occur source."
5007 (anything-other-buffer 'anything-c-source-occur
"*Anything Occur*"))
5009 ;; Do many actions for input
5010 (defvar anything-c-source-create
5014 (action-transformer . anything-create--actions
))
5015 "Do many create actions from `anything-pattern'.
5016 See also `anything-create--actions'.")
5017 ;; (anything 'anything-c-source-create)
5019 (defun anything-create-from-anything ()
5020 "Run `anything-create' from `anything' as a fallback."
5022 (anything-run-after-quit 'anything-create nil anything-pattern
))
5025 (defun anything-create (&optional string initial-input
)
5026 "Preconfigured `anything' to do many create actions from STRING.
5027 See also `anything-create--actions'."
5029 (setq string
(or string
(read-string "Create Anything: " initial-input
)))
5030 (anything '(((name .
"Anything Create")
5031 (header-name .
(lambda (_) (format "Action for \"%s\"" string
)))
5032 (candidates . anything-create--actions
)
5033 (candidate-number-limit)
5034 (action .
(lambda (func) (funcall func string
)))))))
5036 (defun anything-create--actions (&rest ignored
)
5037 "Default actions for `anything-create' / `anything-c-source-create'."
5039 (lambda (pair) (and (consp pair
) (functionp (cdr pair
))))
5040 (append anything-create--actions-private
5041 '(("find-file" . find-file
)
5042 ("find-file other window" . find-file-other-window
)
5043 ("New buffer" . switch-to-buffer
)
5044 ("New buffer other window" . switch-to-buffer-other-window
)
5045 ("Bookmark Set" . bookmark-set
)
5047 (lambda (x) (set-register (read-char "Register: ") x
)))
5048 ("Insert Linkd star" . linkd-insert-star
)
5049 ("Insert Linkd Tag" . linkd-insert-tag
)
5050 ("Insert Linkd Link" . linkd-insert-link
)
5051 ("Insert Linkd Lisp" . linkd-insert-lisp
)
5052 ("Insert Linkd Wiki" . linkd-insert-wiki
)
5053 ("Google Search" . google
)))))
5055 ;; Minibuffer History
5056 (defvar anything-c-source-minibuffer-history
5057 '((name .
"Minibuffer History")
5058 (header-name .
(lambda (name) (format "%s (%s)" name minibuffer-history-variable
)))
5059 (candidates .
(lambda () (let ((history (symbol-value minibuffer-history-variable
)))
5060 (if (consp (car history
))
5061 (mapcar 'prin1-to-string history
)
5065 ;; (anything 'anything-c-source-minibuffer-history)
5068 (defvar anything-c-source-elscreen
5069 '((name .
"Elscreen")
5070 (candidates .
(lambda ()
5071 (if (cdr (elscreen-get-screen-to-name-alist))
5073 (loop for sname in
(elscreen-get-screen-to-name-alist)
5074 append
(list (format "[%d] %s" (car sname
) (cdr sname
))) into lst
5075 finally
(return lst
))
5076 #'(lambda (a b
) (compare-strings a nil nil b nil nil
))))))
5077 (action .
(("Change Screen".
5079 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))))
5082 (dolist (i (anything-marked-candidates))
5083 (elscreen-goto (- (aref i
1) (aref "0" 0)))
5087 (elscreen-goto (- (aref candidate
1) (aref "0" 0)))
5088 (elscreen-kill-others)))))))
5089 ;; (anything 'anything-c-source-elscreen)
5094 (defvar anything-c-top-command
"COLUMNS=%s top -b -n 1"
5095 "Top command (batch mode). %s is replaced with `frame-width'.")
5096 (defvar anything-c-source-top
5097 '((name .
"Top (Press C-c C-u to refresh)")
5098 (init . anything-c-top-init
)
5099 (candidates-in-buffer)
5100 (display-to-real . anything-c-top-display-to-real
)
5101 (update . anything-c-top-update
)
5103 ("kill (TERM)" .
(lambda (pid) (anything-c-top-sh (format "kill -TERM %s" pid
))))
5104 ("kill (KILL)" .
(lambda (pid) (anything-c-top-sh (format "kill -KILL %s" pid
))))
5105 ("Copy PID" .
(lambda (pid) (kill-new pid
))))))
5106 ;; (anything 'anything-c-source-top)
5108 (defun anything-c-top-sh (cmd)
5109 (message "Executed %s\n%s" cmd
(shell-command-to-string cmd
)))
5111 (defun anything-c-top-init ()
5112 (with-current-buffer (anything-candidate-buffer 'global
)
5113 (call-process-shell-command
5114 (format anything-c-top-command
5115 (- (frame-width) (if anything-enable-digit-shortcuts
4 0)))
5116 nil
(current-buffer))))
5118 (defun anything-c-top-display-to-real (line)
5119 (car (split-string line
)))
5121 (defun anything-c-top-update ()
5122 (let ((anything-source-name (assoc-default 'name anything-c-source-top
))) ;UGLY HACK
5123 (anything-c-top-init)))
5126 (defun anything-top ()
5127 "Preconfigured `anything' for top command."
5129 (let ((anything-samewindow t
)
5130 (anything-enable-shortcuts)
5131 (anything-display-function 'anything-default-display-buffer
)
5132 (anything-candidate-number-limit 9999))
5133 (save-window-excursion
5134 (delete-other-windows)
5135 (anything-other-buffer 'anything-c-source-top
"*anything top*"))))
5138 (defvar anything-c-source-absolute-time-timers
5139 '((name .
"Absolute Time Timers")
5140 (candidates . timer-list
)
5142 ;; (anything 'anything-c-source-absolute-time-timers)
5144 (defvar anything-c-source-idle-time-timers
5145 '((name .
"Idle Time Timers")
5146 (candidates . timer-idle-list
)
5148 ;; (anything 'anything-c-source-idle-time-timers)
5150 (defun anything-c-timer-real-to-display (timer)
5151 (destructuring-bind (triggered t1 t2 t3 repeat-delay func args idle-delay
)
5152 (append timer nil
) ;use `append' to convert vector->list
5153 (format "%s repeat=%5S %s(%s)"
5154 (let ((time (list t1 t2 t3
)))
5156 (format-time-string "idle-for=%5s" time
)
5157 (format-time-string "%m/%d %T" time
)))
5160 (mapconcat 'prin1-to-string args
" "))))
5162 ;;; X RandR resolution change
5163 ;;; FIXME I do not care multi-display.
5164 (defvar anything-c-xrandr-output
"VGA")
5165 (defvar anything-c-xrandr-screen
"0")
5166 (defvar anything-c-source-xrandr-change-resolution
5167 '((name .
"Change Resolution")
5171 (call-process "xrandr" nil
(current-buffer) nil
5172 "--screen" anything-c-xrandr-screen
"-q")
5174 (loop while
(re-search-forward " \\([0-9]+x[0-9]+\\)" nil t
)
5175 collect
(match-string 1)))))
5177 ("Change Resolution" .
(lambda (mode)
5178 (call-process "xrandr" nil nil nil
5179 "--screen" anything-c-xrandr-screen
5180 "--output" anything-c-xrandr-output
5182 ;; (anything 'anything-c-source-xrandr-change-resolution)
5185 (defun anything-c-persistent-xfont-action (elm)
5186 "Show current font temporarily"
5187 (let ((current-font (cdr (assoc 'font
(frame-parameters))))
5190 (progn (set-frame-font default-font
'keep-size
) (sit-for 2))
5191 (set-frame-font current-font
))))
5193 (defvar anything-c-xfonts-cache nil
)
5194 (defvar anything-c-source-xfonts
5195 '((name .
"X Fonts")
5197 (unless anything-c-xfonts-cache
5198 (setq anything-c-xfonts-cache
5199 (x-list-fonts "*")))))
5200 (candidates . anything-c-xfonts-cache
)
5201 (action .
(("Copy to kill ring" .
(lambda (elm)
5203 ("Set Font" .
(lambda (elm)
5205 (set-frame-font elm
'keep-size
)
5206 (message "New font have been copied to kill ring")))))
5207 (persistent-action . anything-c-persistent-xfont-action
)
5208 (persistent-help .
"Switch to this font temporarily")))
5211 (defun anything-select-xfont ()
5212 "Preconfigured `anything' to select Xfont."
5214 (anything-other-buffer 'anything-c-source-xfonts
"*anything select* xfont"))
5216 ;; (anything 'anything-c-source-xfonts)
5218 ;;; Source for Debian/Ubuntu users
5219 (defvar anything-c-source-apt
5221 (init . anything-c-apt-init
)
5222 (candidates-in-buffer)
5223 (candidate-transformer anything-c-apt-candidate-transformer
)
5224 (display-to-real . anything-c-apt-display-to-real
)
5225 (candidate-number-limit .
9999)
5227 ("Show package description" . anything-c-apt-cache-show
)
5228 ("Install package" . anything-c-apt-install
)
5229 ("Remove package" . anything-c-apt-uninstall
)
5230 ("Purge package" . anything-c-apt-purge
))
5231 (persistent-action . anything-c-apt-persistent-action
)
5232 (persistent-help .
"Show - C-u Refresh")))
5233 ;; (anything 'anything-c-source-apt)
5235 (defvar anything-c-apt-query
"emacs")
5236 (defvar anything-c-apt-search-command
"apt-cache search '%s'")
5237 (defvar anything-c-apt-show-command
"apt-cache show '%s'")
5238 (defvar anything-c-apt-installed-packages nil
)
5240 (defface anything-apt-installed
5241 '((t (:foreground
"green")))
5242 "*Face used for apt installed candidates."
5245 (defun anything-c-apt-refresh ()
5246 "Refresh installed candidates list."
5247 (setq anything-c-apt-installed-packages nil
)
5248 (anything-force-update))
5250 (defun anything-c-apt-persistent-action (candidate)
5251 "Persistent action for APT source."
5252 (if current-prefix-arg
5253 (anything-c-apt-refresh)
5254 (anything-c-apt-cache-show candidate
)))
5257 (defun anything-apt (query)
5258 "Preconfigured `anything' : frontend of APT package manager."
5259 (interactive "sAPT search: ")
5260 (let ((anything-c-apt-query query
))
5261 (anything 'anything-c-source-apt
)))
5263 (defun anything-c-apt-candidate-transformer (candidates)
5264 "Show installed candidates in a different color."
5267 for cand in candidates
5268 for name
= (anything-c-apt-display-to-real cand
)
5269 if
(member name anything-c-apt-installed-packages
)
5270 collect
(propertize cand
'face
'anything-apt-installed
) into all
5271 else collect cand into all finally return all
))
5273 (defun anything-c-apt-init ()
5274 "Initialize list of debian packages."
5275 (unless anything-c-apt-installed-packages
5276 (message "Updating installed candidate list...")
5277 (setq anything-c-apt-installed-packages
5279 (call-process-shell-command "dpkg --get-selections"
5280 nil
(current-buffer))
5281 (loop for i in
(split-string (buffer-string) "\n" t
)
5282 collect
(car (split-string i
))))))
5283 (with-current-buffer
5284 (anything-candidate-buffer
5285 (get-buffer-create (format "*anything-apt:%s*" anything-c-apt-query
)))
5287 (call-process-shell-command
5288 (format anything-c-apt-search-command anything-c-apt-query
)
5289 nil
(current-buffer)))
5290 (message "Updating installed candidate list...done"))
5292 (defun anything-c-apt-display-to-real (line)
5293 "Return only name of a debian package.
5294 LINE is displayed like:
5295 package name - description."
5296 (car (split-string line
" - ")))
5299 (defun anything-c-shell-command-if-needed (command)
5300 (interactive "sShell command: ")
5301 (if (get-buffer command
) ; if the buffer already exists
5302 (switch-to-buffer command
) ; then just switch to it
5303 (switch-to-buffer command
) ; otherwise create it
5304 (insert (shell-command-to-string command
))))
5306 (defun anything-c-apt-cache-show (package)
5307 (anything-c-shell-command-if-needed (format anything-c-apt-show-command package
)))
5309 (defun anything-c-apt-install (package)
5310 (anything-c-apt-install1 package
:action
'install
))
5312 (defun anything-c-apt-uninstall (package)
5313 (anything-c-apt-install1 package
:action
'uninstall
))
5315 (defun anything-c-apt-purge (package)
5316 (anything-c-apt-install1 package
:action
'purge
))
5318 (defun* anything-c-apt-install1
(candidate &key action
)
5319 (ansi-term (getenv "SHELL") "anything apt")
5321 (let ((command (case action
5322 ('install
"sudo apt-get install '%s'")
5323 ('uninstall
"sudo apt-get remove '%s'")
5324 ('purge
"sudo apt-get purge '%s'")
5325 (t (error "Unknow action"))))
5327 (goto-char (point-max))
5328 (insert (format command candidate
))
5330 (if (y-or-n-p (format "%s package" (symbol-name action
)))
5332 (setq anything-c-external-commands-list nil
)
5333 (setq anything-c-apt-installed-packages nil
)
5334 (term-char-mode) (term-send-input))
5335 (delete-region beg end
) (term-send-eof) (kill-buffer))))
5337 ;; (anything-c-apt-install "jed")
5339 ;;; Sources for gentoo users
5340 (defvar anything-c-gentoo-use-flags nil
)
5341 (defvar anything-c-gentoo-buffer
"*anything-gentoo-output*")
5342 (defvar anything-c-cache-gentoo nil
)
5343 (defvar anything-c-cache-world nil
)
5344 (defvar anything-c-source-gentoo
5345 '((name .
"Portage sources")
5347 (get-buffer-create anything-c-gentoo-buffer
)
5348 (unless anything-c-cache-gentoo
5349 (anything-c-gentoo-setup-cache))
5350 (unless anything-c-cache-world
5351 (setq anything-c-cache-world
(anything-c-gentoo-get-world)))
5352 (anything-c-gentoo-init-list)))
5353 (candidates-in-buffer)
5355 (candidate-transformer anything-c-highlight-world
)
5356 (action .
(("Show package" .
(lambda (elm)
5357 (anything-c-gentoo-eshell-action elm
"eix")))
5358 ("Show history" .
(lambda (elm)
5359 (if (member elm anything-c-cache-world
)
5360 (anything-c-gentoo-eshell-action elm
"genlop -qe")
5361 (message "No infos on packages not yet installed"))))
5362 ("Copy in kill-ring" . kill-new
)
5363 ("insert at point" . insert
)
5364 ("Browse HomePage" .
(lambda (elm)
5365 (let ((urls (anything-c-gentoo-get-url elm
)))
5366 (browse-url (anything-comp-read "Url: " urls
:must-match t
)))))
5367 ("Show extra infos" .
(lambda (elm)
5368 (if (member elm anything-c-cache-world
)
5369 (anything-c-gentoo-eshell-action elm
"genlop -qi")
5370 (message "No infos on packages not yet installed"))))
5371 ("Show use flags" .
(lambda (elm)
5372 (anything-c-gentoo-default-action elm
"equery" "-C" "u")
5373 (font-lock-add-keywords nil
'(("^\+.*" . font-lock-variable-name-face
)))
5374 (font-lock-mode 1)))
5375 ("Run emerge pretend" .
(lambda (elm)
5376 (anything-c-gentoo-eshell-action elm
"emerge -p")))
5377 ("Emerge" .
(lambda (elm)
5378 (anything-gentoo-install elm
:action
'install
)))
5379 ("Unmerge" .
(lambda (elm)
5380 (anything-gentoo-install elm
:action
'uninstall
)))
5381 ("Show dependencies" .
(lambda (elm)
5382 (anything-c-gentoo-default-action elm
"equery" "-C" "d")))
5383 ("Show related files" .
(lambda (elm)
5384 (anything-c-gentoo-default-action elm
"equery" "files")))
5385 ("Refresh" .
(lambda (elm)
5386 (anything-c-gentoo-setup-cache)
5387 (setq anything-c-cache-world
(anything-c-gentoo-get-world))))))))
5389 ;; (anything 'anything-c-source-gentoo)
5391 (defun* anything-gentoo-install
(candidate &key action
)
5392 (setq anything-c-external-commands-list nil
)
5393 (ansi-term (getenv "SHELL") "anything gentoo")
5395 (let ((command (case action
5396 ('install
"sudo emerge -av ")
5397 ('uninstall
"sudo emerge -avC ")
5398 (t (error "Unknow action"))))
5399 (elms (mapconcat 'identity
(anything-marked-candidates) " "))
5401 (goto-char (point-max))
5402 (insert (concat command elms
))
5404 (term-char-mode) (term-send-input)))
5406 (defun anything-c-gentoo-default-action (elm command
&rest args
)
5407 "Gentoo default action that use `anything-c-gentoo-buffer'."
5408 (if (member elm anything-c-cache-world
)
5410 (switch-to-buffer anything-c-gentoo-buffer
)
5412 (let ((com-list (append args
(list elm
))))
5413 (apply #'call-process command nil t nil
5415 (message "No infos on packages not yet installed")))
5417 (defvar anything-c-source-use-flags
5418 '((name .
"Use Flags")
5420 (unless anything-c-gentoo-use-flags
5421 (anything-c-gentoo-setup-use-flags-cache))
5422 (anything-c-gentoo-get-use)))
5423 (candidates-in-buffer)
5425 (candidate-transformer anything-c-highlight-local-use
)
5426 (action .
(("Description"
5428 (switch-to-buffer anything-c-gentoo-buffer
)
5430 (apply #'call-process
"euse" nil t nil
5433 (font-lock-add-keywords nil
`((,elm . font-lock-variable-name-face
)))
5434 (font-lock-mode 1)))
5437 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -E")))
5440 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -D")))
5443 (anything-c-gentoo-eshell-action elm
"*sudo -p Password: euse -P")))
5444 ("Show which dep use this flag"
5446 (switch-to-buffer anything-c-gentoo-buffer
)
5448 (apply #'call-process
"equery" nil t nil
5454 ;; (anything 'anything-c-source-use-flags)
5456 (defun anything-c-gentoo-init-list ()
5457 "Initialize buffer with all packages in Portage."
5458 (let* ((portage-buf (get-buffer-create "*anything-gentoo*"))
5459 (buf (anything-candidate-buffer 'portage-buf
)))
5460 (with-current-buffer buf
5461 (dolist (i anything-c-cache-gentoo
)
5462 (insert (concat i
"\n"))))))
5464 (defun anything-c-gentoo-setup-cache ()
5465 "Set up `anything-c-cache-gentoo'"
5466 (setq anything-c-cache-gentoo
5467 (split-string (with-temp-buffer
5468 (call-process "eix" nil t nil
5472 (defun anything-c-gentoo-eshell-action (elm command
)
5473 (when (get-buffer "*EShell Command Output*")
5474 (kill-buffer "*EShell Command Output*"))
5475 (message "Wait searching...")
5476 (let ((buf-fname (buffer-file-name anything-current-buffer
)))
5477 (if (and buf-fname
(string-match tramp-file-name-regexp buf-fname
))
5479 (save-window-excursion
5480 (pop-to-buffer "*scratch*")
5481 (eshell-command (format "%s %s" command elm
)))
5482 (pop-to-buffer "*EShell Command Output*"))
5483 (eshell-command (format "%s %s" command elm
)))))
5485 (defun anything-c-gentoo-get-use ()
5486 "Initialize buffer with all use flags."
5487 (let* ((use-buf (get-buffer-create "*anything-gentoo-use*"))
5488 (buf (anything-candidate-buffer 'use-buf
)))
5489 (with-current-buffer buf
5490 (dolist (i anything-c-gentoo-use-flags
)
5491 (insert (concat i
"\n"))))))
5494 (defun anything-c-gentoo-setup-use-flags-cache ()
5495 "Setup `anything-c-gentoo-use-flags'"
5496 (setq anything-c-gentoo-use-flags
5497 (split-string (with-temp-buffer
5498 (call-process "eix" nil t nil
5499 "--print-all-useflags")
5502 (defun anything-c-gentoo-get-url (elm)
5503 "Return a list of urls from eix output."
5505 with url-list
= (split-string
5507 (call-process "eix" nil t nil
5508 elm
"--format" "<homepage>\n")
5512 when
(and (string-match "^http://.*" i
)
5513 (not (member i all
)))
5515 finally return all
))
5517 (defun anything-c-gentoo-get-world ()
5518 "Return list of all installed package on your system."
5519 (split-string (with-temp-buffer
5520 (call-process "qlist" nil t nil
5524 (defun anything-c-gentoo-get-local-use ()
5525 (split-string (with-temp-buffer
5526 (call-process "portageq" nil t nil
5531 (defface anything-gentoo-match-face
'((t (:foreground
"red")))
5532 "Face for anything-gentoo installed packages."
5533 :group
'traverse-faces
)
5535 (defun anything-c-highlight-world (eix)
5536 "Highlight all installed package."
5538 if
(member i anything-c-cache-world
)
5539 collect
(propertize i
'face
'anything-gentoo-match-face
)
5543 (defun anything-c-highlight-local-use (use-flags)
5544 (let ((local-uses (anything-c-gentoo-get-local-use)))
5545 (loop for i in use-flags
5546 if
(member i local-uses
)
5547 collect
(propertize i
'face
'anything-gentoo-match-face
)
5551 (defvar anything-c-source-emacs-process
5552 '((name .
"Emacs Process")
5553 (candidates .
(lambda () (mapcar #'process-name
(process-list))))
5554 (action ("Kill Process" .
(lambda (elm) (delete-process (get-process elm
)))))))
5556 ;; (anything 'anything-c-source-emacs-process)
5558 ;; Run Externals commands within Emacs
5559 (defmacro* anything-comp-hash-get-items
(hash-table &key test
)
5560 "Get the list of all keys/values of hash-table."
5561 `(let ((li-items ()))
5562 (maphash #'(lambda (x y
)
5564 (when (funcall ,test y
)
5565 (push (list x y
) li-items
))
5566 (push (list x y
) li-items
)))
5570 (defun anything-comp-read-get-candidates (collection &optional test
)
5571 "Convert collection to list.
5572 If collection is an `obarray', a test is maybe needed, otherwise
5573 the list would be incomplete.
5575 (cond ((and (listp collection
) test
)
5576 (loop for i in collection when
(funcall test i
) collect i
))
5577 ((and (eq collection obarray
) test
)
5578 (loop for s being the symbols of collection
5579 when
(funcall test s
) collect s
))
5580 ((and (vectorp collection
) test
)
5581 (loop for i across collection when
(funcall test i
) collect i
))
5582 ((vectorp collection
)
5583 (loop for i across collection collect i
))
5584 ((and (hash-table-p collection
) test
)
5585 (anything-comp-hash-get-items collection
:test test
))
5586 ((hash-table-p collection
)
5587 (anything-comp-hash-get-items collection
))
5590 (defun* anything-comp-read
(prompt collection
&key test initial-input
5591 (buffer "*Anything Completions*") must-match
5592 (requires-pattern 0))
5593 "Anything `completing-read' emulation.
5594 Collection can be a list, vector, obarray or hash-table."
5595 (when (get-buffer anything-action-buffer
)
5596 (kill-buffer anything-action-buffer
))
5598 `((name .
"Completions")
5601 (let ((cands (anything-comp-read-get-candidates collection test
)))
5602 (if (or must-match
(string= anything-pattern
""))
5603 cands
(append (list anything-pattern
) cands
)))))
5604 (requires-pattern .
,requires-pattern
)
5606 (action .
(("candidate" .
,'identity
))))
5607 initial-input prompt
'noresume nil buffer
)
5610 (defun anything-c-get-pid-from-process-name (process-name)
5611 "Get pid from running process PROCESS-NAME."
5612 (loop with process-list
= (list-system-processes)
5613 for pid in process-list
5614 for process
= (assoc-default 'comm
(process-attributes pid
))
5615 when
(and process
(string-match process-name process
))
5619 (defun anything-run-or-raise (exe &optional file
)
5620 "Generic command that run asynchronously EXE.
5621 If EXE is already running just jump to his window if `anything-raise-command'
5623 When FILE argument is provided run EXE with FILE.
5624 In this case EXE must be provided as \"EXE %s\"."
5625 (let ((real-com (car (split-string (replace-regexp-in-string " %s" "" exe
)))))
5626 (if (or (get-process real-com
)
5627 (anything-c-get-pid-from-process-name real-com
))
5628 (if anything-raise-command
5629 (shell-command (format anything-raise-command real-com
))
5630 (error "Error: %s is already running" real-com
))
5631 (when (member real-com anything-c-external-commands-list
)
5632 (message "Starting %s..." real-com
)
5634 (start-process-shell-command real-com nil
(format exe file
))
5635 (start-process-shell-command real-com nil real-com
))
5636 (set-process-sentinel
5637 (get-process real-com
)
5638 #'(lambda (process event
)
5639 (when (string= event
"finished\n")
5640 (when anything-raise-command
5641 (shell-command (format anything-raise-command
"emacs")))
5642 (message "%s process...Finished." process
))))
5643 (setq anything-c-external-commands-list
5644 (push (pop (nthcdr (anything-c-position
5645 real-com anything-c-external-commands-list
5647 anything-c-external-commands-list
))
5648 anything-c-external-commands-list
))))))
5651 (defun anything-c-run-external-command (program)
5652 "Preconfigured `anything' to run External PROGRAM asyncronously from Emacs.
5653 If program is already running exit with error.
5654 You can set your own list of commands with
5655 `anything-c-external-commands-list'."
5659 (anything-c-external-commands-list-1 'sort
)
5661 (anything-run-or-raise program
))
5663 (defsubst* anything-c-position
(item seq
&key
(test 'eq
))
5664 "A simple and faster replacement of CL `position'."
5665 (loop for i in seq for index from
0
5666 when
(funcall test i item
) return index
))
5668 (defvar anything-c-source-ratpoison-commands
5669 '((name .
"Ratpoison Commands")
5670 (init . anything-c-ratpoison-commands-init
)
5671 (candidates-in-buffer)
5672 (action ("Execute the command" . anything-c-ratpoison-commands-execute
))
5673 (display-to-real . anything-c-ratpoison-commands-display-to-real
)
5674 (candidate-number-limit)))
5675 ;; (anything 'anything-c-source-ratpoison-commands)
5677 (defun anything-c-ratpoison-commands-init ()
5678 (unless (anything-candidate-buffer)
5679 (with-current-buffer (anything-candidate-buffer 'global
)
5680 ;; with ratpoison prefix key
5682 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help"))
5683 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5684 (replace-match "<ratpoison> \\1: \\2"))
5685 (goto-char (point-max))
5688 (call-process "ratpoison" nil
(current-buffer) nil
"-c" "help top"))
5689 (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t
)
5690 (replace-match "\\1: \\2")))))
5692 (defun anything-c-ratpoison-commands-display-to-real (display)
5693 (and (string-match ": " display
)
5694 (substring display
(match-end 0))))
5696 (defun anything-c-ratpoison-commands-execute (candidate)
5697 (call-process "ratpoison" nil nil nil
"-ic" candidate
))
5700 (defun anything-ratpoison-commands ()
5701 "Preconfigured `anything' to execute ratpoison commands."
5703 (anything-other-buffer 'anything-c-source-ratpoison-commands
5704 "*anything ratpoison commands*"))
5706 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5708 (defvar anything-c-external-commands-list nil
5709 "A list of all external commands the user can execute. If this
5710 variable is not set by the user, it will be calculated
5713 (defun anything-c-external-commands-list-1 (&optional sort
)
5714 "Returns a list of all external commands the user can execute.
5716 If `anything-c-external-commands-list' is non-nil it will
5717 return its contents. Else it calculates all external commands
5718 and sets `anything-c-external-commands-list'.
5720 The code is ripped out of `eshell-complete-commands-list'."
5721 (if anything-c-external-commands-list
5722 anything-c-external-commands-list
5723 (setq anything-c-external-commands-list
5724 (let* ((paths (split-string (getenv "PATH") path-separator
))
5725 (cwd (file-name-as-directory
5726 (expand-file-name default-directory
)))
5727 (path "") (comps-in-path ())
5728 (file "") (filepath "") (completions ()))
5729 ;; Go thru each path in the search path, finding completions.
5731 (setq path
(file-name-as-directory
5732 (expand-file-name (or (car paths
) ".")))
5734 (and (file-accessible-directory-p path
)
5735 (file-name-all-completions "" path
)))
5736 ;; Go thru each completion found, to see whether it should be
5737 ;; used, e.g. see if it's executable.
5738 (while comps-in-path
5739 (setq file
(car comps-in-path
)
5740 filepath
(concat path file
))
5741 (if (and (not (member file completions
))
5742 (or (string-equal path cwd
)
5743 (not (file-directory-p filepath
)))
5744 (file-executable-p filepath
))
5745 (setq completions
(cons file completions
)))
5746 (setq comps-in-path
(cdr comps-in-path
)))
5747 (setq paths
(cdr paths
)))
5749 (sort completions
#'(lambda (x y
) (string< x y
)))
5752 (defun anything-c-file-buffers (filename)
5753 "Returns a list of buffer names corresponding to FILENAME."
5754 (let ((name (expand-file-name filename
))
5756 (dolist (buf (buffer-list) buf-list
)
5757 (let ((bfn (buffer-file-name buf
)))
5758 (when (and bfn
(string= name bfn
))
5759 (push (buffer-name buf
) buf-list
))))))
5761 (defun anything-c-delete-file (file)
5762 "Delete the given file after querying the user.
5763 Ask to kill buffers associated with that file, too."
5764 (let ((buffers (anything-c-file-buffers file
)))
5765 (dired-delete-file file
'dired-recursive-deletes
)
5767 (dolist (buf buffers
)
5768 (when (y-or-n-p (format "Kill buffer %s, too? " buf
))
5769 (kill-buffer buf
))))))
5771 (defun anything-get-mailcap-for-file (filename)
5772 "Get the command to use for FILENAME from mailcap files.
5773 The command is like <command %s> and is meant to use with `format'."
5774 (mailcap-parse-mailcaps)
5775 (let* ((ext (file-name-extension filename
))
5776 (mime (when ext
(mailcap-extension-to-mime ext
))))
5777 (when mime
(mailcap-mime-info mime
))))
5779 (defun anything-c-open-file-externally (file)
5780 "Open FILE with an external tool found in .mailcap file.
5781 If not found or a prefix arg is given query the user which tool to use."
5782 (let* ((fname (expand-file-name file
))
5783 (collection (anything-c-external-commands-list-1 'sort
))
5784 (def-prog (anything-get-mailcap-for-file fname
))
5785 (program (or (unless (or anything-current-prefix-arg
5791 collection
:must-match t
)
5793 (anything-run-or-raise program file
)))
5796 (defun w32-shell-execute-open-file (file)
5797 (interactive "fOpen file:")
5799 (w32-shell-execute "open" (replace-regexp-in-string ;for UNC paths
5801 (replace-regexp-in-string ; strip cygdrive paths
5802 "/cygdrive/\\(.\\)" "\\1:"
5803 file nil nil
) nil t
))))
5805 (defun anything-c-open-file-with-default-tool (file)
5806 "Open FILE with the default tool on this platform."
5807 (if (eq system-type
'windows-nt
)
5808 (w32-shell-execute-open-file file
)
5809 (start-process "anything-c-open-file-with-default-tool"
5811 (cond ((eq system-type
'gnu
/linux
)
5813 ((or (eq system-type
'darwin
) ;; Mac OS X
5814 (eq system-type
'macos
)) ;; Mac OS 9
5818 (defun anything-c-open-dired (file)
5819 "Opens a dired buffer in FILE's directory. If FILE is a
5820 directory, open this directory."
5821 (if (file-directory-p file
)
5823 (dired (file-name-directory file
))
5824 (dired-goto-file file
)))
5826 (defun anything-c-display-to-real-line (candidate)
5827 (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate
)
5828 (list (string-to-number (match-string 1 candidate
)) (match-string 2 candidate
))
5829 (error "Line number not found")))
5831 (defun anything-c-action-line-goto (lineno-and-content)
5832 (apply #'anything-goto-file-line
(anything-interpret-value (anything-attr 'target-file
))
5833 (append lineno-and-content
5834 (list (if (and (anything-attr-defined 'target-file
)
5835 (not anything-in-persistent-action
))
5836 'find-file-other-window
5839 (defun* anything-c-action-file-line-goto
(file-line-content &optional
(find-file-function #'find-file
))
5840 (apply #'anything-goto-file-line
5841 (if (stringp file-line-content
)
5842 ;; Case: filtered-candidate-transformer is skipped
5843 (cdr (anything-c-filtered-candidate-transformer-file-line-1 file-line-content
))
5844 file-line-content
)))
5847 (defun anything-c-filtered-candidate-transformer-file-line (candidates source
)
5848 (delq nil
(mapcar 'anything-c-filtered-candidate-transformer-file-line-1 candidates
)))
5850 (defun anything-c-filtered-candidate-transformer-file-line-1 (candidate)
5851 (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate
)
5852 (let ((filename (match-string 1 candidate
))
5853 (lineno (match-string 2 candidate
))
5854 (content (match-string 3 candidate
)))
5855 (cons (format "%s:%s\n %s"
5856 (propertize filename
'face compilation-info-face
)
5857 (propertize lineno
'face compilation-line-face
)
5859 (list (expand-file-name
5861 (or (anything-interpret-value (anything-attr 'default-directory
))
5862 (and (anything-candidate-buffer)
5864 'default-directory
(anything-candidate-buffer)))))
5865 (string-to-number lineno
) content
)))))
5867 (defun* anything-goto-file-line
(file lineno content
&optional
(find-file-function #'find-file
))
5868 (anything-aif (anything-attr 'before-jump-hook
)
5870 (when file
(funcall find-file-function file
))
5871 (if (anything-attr-defined 'adjust
)
5872 (anything-c-goto-line-with-adjustment lineno content
)
5873 (anything-goto-line lineno
))
5874 (unless (anything-attr-defined 'recenter
)
5875 (set-window-start (get-buffer-window anything-current-buffer
) (point)))
5876 (anything-aif (anything-attr 'after-jump-hook
)
5878 (when anything-in-persistent-action
5879 (anything-match-line-color-current-line)))
5881 (defun anything-find-file-as-root (candidate)
5882 (find-file (concat "/" anything-su-or-sudo
"::" (expand-file-name candidate
))))
5884 (defun anything-find-many-files (ignore)
5885 (mapc 'find-file
(anything-marked-candidates)))
5887 ;; borrowed from etags.el
5888 ;; (anything-c-goto-line-with-adjustment (line-number-at-pos) ";; borrowed from etags.el")
5889 (defun anything-c-goto-line-with-adjustment (line line-content
)
5892 ;; This constant is 1/2 the initial search window.
5893 ;; There is no sense in making it too small,
5894 ;; since just going around the loop once probably
5895 ;; costs about as much as searching 2000 chars.
5898 pat
(concat (if (eq selective-display t
)
5899 "\\(^\\|\^m\\) *" "^ *") ;allow indent
5900 (regexp-quote line-content
)))
5901 ;; If no char pos was given, try the given line number.
5902 (setq startpos
(progn (anything-goto-line line
) (point)))
5903 (or startpos
(setq startpos
(point-min)))
5904 ;; First see if the tag is right at the specified location.
5905 (goto-char startpos
)
5906 (setq found
(looking-at pat
))
5907 (while (and (not found
)
5909 (goto-char (- startpos offset
))
5912 (re-search-forward pat
(+ startpos offset
) t
)
5913 offset
(* 3 offset
))) ; expand search window
5915 (re-search-forward pat nil t
)
5916 (error "not found")))
5917 ;; Position point at the right place
5918 ;; if the search string matched an extra Ctrl-m at the beginning.
5919 (and (eq selective-display t
)
5922 (beginning-of-line))
5924 (anything-document-attribute 'default-directory
"type . file-line"
5925 "`default-directory' to interpret file.")
5926 (anything-document-attribute 'before-jump-hook
"type . file-line / line"
5927 "Function to call before jumping to the target location.")
5928 (anything-document-attribute 'after-jump-hook
"type . file-line / line"
5929 "Function to call after jumping to the target location.")
5930 (anything-document-attribute 'adjust
"type . file-line"
5931 "Search around line matching line contents.")
5932 (anything-document-attribute 'recenter
"type . file-line / line"
5933 "`recenter' after jumping.")
5934 (anything-document-attribute 'target-file
"type . line"
5935 "Goto line of target-file.")
5938 (defun anything-c-call-interactively (cmd-or-name)
5939 "Execute CMD-OR-NAME as Emacs command.
5940 It is added to `extended-command-history'.
5941 `anything-current-prefix-arg' is used as the command's prefix argument."
5942 (setq extended-command-history
5943 (cons (anything-c-stringify cmd-or-name
)
5944 (delete (anything-c-stringify cmd-or-name
) extended-command-history
)))
5945 (let ((current-prefix-arg anything-current-prefix-arg
)
5946 (cmd (anything-c-symbolify cmd-or-name
)))
5947 (if (stringp (symbol-function cmd
))
5948 (execute-kbd-macro (symbol-function cmd
))
5949 (setq this-command cmd
)
5950 (call-interactively cmd
))))
5953 (defun anything-c-set-variable (var)
5954 "Set value to VAR interactively."
5956 (let ((sym (anything-c-symbolify var
)))
5957 (set sym
(eval-minibuffer (format "Set %s: " var
)
5958 (prin1-to-string (symbol-value sym
))))))
5960 ;; (anything-c-set-variable 'hh)
5962 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Persistent Action Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5963 (defvar anything-match-line-overlay-face nil
)
5964 (defvar anything-match-line-overlay nil
)
5966 (defun anything-match-line-color-current-line (&optional start end buf face rec
)
5967 "Highlight and underline current position"
5968 (let ((args (list (or start
(line-beginning-position))
5969 (or end
(1+ (line-end-position)))
5971 (if (not anything-match-line-overlay
)
5972 (setq anything-match-line-overlay
(apply 'make-overlay args
))
5973 (apply 'move-overlay anything-match-line-overlay args
)))
5974 (overlay-put anything-match-line-overlay
5975 'face
(or face anything-match-line-overlay-face
))
5980 (defalias 'anything-persistent-highlight-point
'anything-match-line-color-current-line
)
5982 (defface anything-overlay-line-face
'((t (:background
"IndianRed4" :underline t
)))
5983 "Face for source header in the anything buffer." :group
'anything
)
5985 (setq anything-match-line-overlay-face
'anything-overlay-line-face
)
5987 (defun anything-match-line-cleanup ()
5988 (when anything-match-line-overlay
5989 (delete-overlay anything-match-line-overlay
)
5990 (setq anything-match-line-overlay nil
)))
5992 (defun anything-match-line-update ()
5993 (when anything-match-line-overlay
5994 (delete-overlay anything-match-line-overlay
)
5995 (anything-match-line-color-current-line)))
5997 (add-hook 'anything-cleanup-hook
'anything-match-line-cleanup
)
5998 (add-hook 'anything-after-persistent-action-hook
'anything-match-line-update
)
6000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Actions Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6002 (defun anything-c-transform-file-load-el (actions candidate
)
6003 "Add action to load the file CANDIDATE if it is an emacs lisp
6004 file. Else return ACTIONS unmodified."
6005 (if (member (file-name-extension candidate
) '("el" "elc"))
6006 (append actions
'(("Load Emacs Lisp File" . load-file
)))
6009 (defun anything-c-transform-file-browse-url (actions candidate
)
6010 "Add an action to browse the file CANDIDATE if it in a html
6011 file or URL. Else return ACTIONS unmodified."
6012 (let ((browse-action '("Browse with Browser" . browse-url
)))
6013 (cond ((string-match "^http\\|^ftp" candidate
)
6014 (cons browse-action actions
))
6015 ((string-match "\\.html?$" candidate
)
6016 (append actions
(list browse-action
)))
6020 (defun anything-c-transform-function-call-interactively (actions candidate
)
6021 "Add an action to call the function CANDIDATE interactively if
6022 it is a command. Else return ACTIONS unmodified."
6023 (if (commandp (intern-soft candidate
))
6024 (append actions
'(("Call Interactively"
6026 anything-c-call-interactively
)))
6030 (defun anything-c-transform-sexp-eval-command-sexp (actions candidate
)
6031 "If CANDIDATE's `car' is a command, then add an action to
6032 evaluate it and put it onto the `command-history'."
6033 (if (commandp (car (read candidate
)))
6034 ;; Make it first entry
6035 (cons '("Eval and put onto command-history" .
6037 (let ((sym (read sexp
)))
6039 (setq command-history
6040 (cons sym command-history
)))))
6044 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Candidate Transformers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6046 (defun anything-c-skip-boring-buffers (buffers)
6047 (anything-c-skip-entries buffers anything-c-boring-buffer-regexp
))
6049 (defun anything-c-skip-current-buffer (buffers)
6050 (if anything-allow-skipping-current-buffer
6051 (remove (buffer-name anything-current-buffer
) buffers
)
6054 (defun anything-c-shadow-boring-buffers (buffers)
6055 "Buffers matching `anything-c-boring-buffer-regexp' will be
6056 displayed with the `file-name-shadow' face if available."
6057 (anything-c-shadow-entries buffers anything-c-boring-buffer-regexp
))
6060 (defun anything-c-shadow-boring-files (files)
6061 "Files matching `anything-c-boring-file-regexp' will be
6062 displayed with the `file-name-shadow' face if available."
6063 (anything-c-shadow-entries files anything-c-boring-file-regexp
))
6065 (defun anything-c-skip-boring-files (files)
6066 "Files matching `anything-c-boring-file-regexp' will be skipped."
6067 (anything-c-skip-entries files anything-c-boring-file-regexp
))
6068 ;; (anything-c-skip-boring-files '("README" "/src/.svn/hoge"))
6070 (defun anything-c-skip-current-file (files)
6071 "Current file will be skipped."
6072 (remove (buffer-file-name anything-current-buffer
) files
))
6074 (defun anything-c-w32-pathname-transformer (args)
6075 "Change undesirable features of windows pathnames to ones more acceptable to
6076 other candidate transformers."
6077 (if (eq system-type
'windows-nt
)
6079 (replace-regexp-in-string "/cygdrive/\\(.\\)" "\\1:" x
))
6081 (replace-regexp-in-string "\\\\" "/" y
)) args
))
6084 (defun anything-c-shorten-home-path (files)
6085 "Replaces /home/user with ~."
6086 (let ((home (replace-regexp-in-string "\\\\" "/" ; stupid Windows...
6088 (mapcar (lambda (file)
6089 (if (and (stringp file
) (string-match home file
))
6090 (cons (replace-match "~" nil nil file
) file
)
6095 (defun anything-c-mark-interactive-functions (functions)
6096 "Mark interactive functions (commands) with (i) after the function name."
6098 (loop for function in functions
6099 do
(push (cons (concat function
6100 (when (commandp (intern-soft function
)) " (i)"))
6103 finally
(return (nreverse list
)))))
6105 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Adaptive Sorting of Candidates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6106 (defvar anything-c-adaptive-done nil
6107 "nil if history information is not yet stored for the current
6110 (defvar anything-c-adaptive-history nil
6111 "Contains the stored history information.
6112 Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)")
6114 (defadvice anything-initialize
(before anything-c-adaptive-initialize activate
)
6115 "Advise `anything-initialize' to reset `anything-c-adaptive-done'
6116 when anything is started."
6117 (setq anything-c-adaptive-done nil
))
6119 (defadvice anything-exit-minibuffer
(before anything-c-adaptive-exit-minibuffer activate
)
6120 "Advise `anything-exit-minibuffer' to store history information
6121 when a candidate is selected with RET."
6122 (anything-c-adaptive-store-selection))
6124 (defadvice anything-select-action
(before anything-c-adaptive-select-action activate
)
6125 "Advise `anything-select-action' to store history information
6126 when the user goes to the action list with TAB."
6127 (anything-c-adaptive-store-selection))
6129 (defun anything-c-source-use-adaptative-p (&optional source-name
)
6130 "Return current source only if it use adaptative history, nil otherwise."
6131 (let* ((source (or source-name
(anything-get-current-source)))
6132 (adapt-source (or (assoc-default 'filtered-candidate-transformer
6133 (assoc (assoc-default 'type source
)
6134 anything-type-attributes
))
6135 (assoc-default 'candidate-transformer
6136 (assoc (assoc-default 'type source
)
6137 anything-type-attributes
))
6138 (assoc-default 'filtered-candidate-transformer source
)
6139 (assoc-default 'candidate-transformer source
))))
6140 (if (listp adapt-source
)
6141 (when (member 'anything-c-adaptive-sort adapt-source
) source
)
6142 (when (eq adapt-source
'anything-c-adaptive-sort
) source
))))
6144 (defun anything-c-adaptive-store-selection ()
6145 "Store history information for the selected candidate."
6146 (unless anything-c-adaptive-done
6147 (setq anything-c-adaptive-done t
)
6148 (let ((source (anything-c-source-use-adaptative-p)))
6150 (let* ((source-name (or (assoc-default 'type source
)
6151 (assoc-default 'name source
)))
6152 (source-info (or (assoc source-name anything-c-adaptive-history
)
6154 (push (list source-name
) anything-c-adaptive-history
)
6155 (car anything-c-adaptive-history
))))
6156 (selection (anything-get-selection))
6157 (selection-info (progn
6160 (let ((found (assoc selection
(cdr source-info
))))
6165 ;; move entry to the beginning of the
6166 ;; list, so that it doesn't get
6167 ;; trimmed when the history is
6170 (delete found
(cdr source-info
)))
6173 (cadr source-info
)))
6174 (pattern-info (progn
6175 (setcdr selection-info
6177 (let ((found (assoc anything-pattern
(cdr selection-info
))))
6180 (cons anything-pattern
0)
6182 ;; move entry to the beginning of the
6183 ;; list, so if two patterns used the
6184 ;; same number of times then the one
6185 ;; used last appears first in the list
6186 (setcdr selection-info
6187 (delete found
(cdr selection-info
)))
6189 (cdr selection-info
)))
6190 (cadr selection-info
))))
6192 ;; increase usage count
6193 (setcdr pattern-info
(1+ (cdr pattern-info
)))
6195 ;; truncate history if needed
6196 (if (> (length (cdr selection-info
)) anything-c-adaptive-history-length
)
6197 (setcdr selection-info
6198 (subseq (cdr selection-info
) 0 anything-c-adaptive-history-length
))))))))
6200 (if (file-readable-p anything-c-adaptive-history-file
)
6201 (load-file anything-c-adaptive-history-file
))
6202 (add-hook 'kill-emacs-hook
'anything-c-adaptive-save-history
)
6204 (defun anything-c-adaptive-save-history ()
6205 "Save history information to file given by `anything-c-adaptive-history-file'."
6209 ";; -*- mode: emacs-lisp -*-\n"
6210 ";; History entries used for anything adaptive display.\n")
6211 (prin1 `(setq anything-c-adaptive-history
',anything-c-adaptive-history
)
6214 (write-region (point-min) (point-max) anything-c-adaptive-history-file nil
6215 (unless (interactive-p) 'quiet
))))
6217 (defun anything-c-adaptive-sort (candidates source
)
6218 "Sort the CANDIDATES for SOURCE by usage frequency.
6219 This is a filtered candidate transformer you can use for the
6220 attribute `filtered-candidate-transformer' of a source in
6221 `anything-sources' or a type in `anything-type-attributes'."
6222 (let* ((source-name (or (assoc-default 'type source
)
6223 (assoc-default 'name source
)))
6224 (source-info (assoc source-name anything-c-adaptive-history
)))
6225 (if (not source-info
)
6226 ;; if there is no information stored for this source then do nothing
6230 ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT)
6232 (mapcar (lambda (candidate-info)
6234 (dolist (pattern-info (cdr candidate-info
))
6235 (if (not (equal (car pattern-info
)
6237 (incf count
(cdr pattern-info
))
6239 ;; if current pattern is equal to the previously
6240 ;; used one then this candidate has priority
6241 ;; (that's why its count is boosted by 10000) and
6242 ;; it only has to compete with other candidates
6243 ;; which were also selected with the same pattern
6244 (setq count
(+ 10000 (cdr pattern-info
)))
6246 (cons (car candidate-info
) count
)))
6250 ;; sort the list in descending order, so candidates with highest
6251 ;; priorty come first
6252 (setq usage
(sort usage
(lambda (first second
)
6253 (> (cdr first
) (cdr second
)))))
6255 ;; put those candidates first which have the highest usage count
6256 (dolist (info usage
)
6257 (when (member* (car info
) candidates
6258 :test
'anything-c-adaptive-compare
)
6259 (push (car info
) sorted
)
6260 (setq candidates
(remove* (car info
) candidates
6261 :test
'anything-c-adaptive-compare
))))
6263 ;; and append the rest
6264 (append (reverse sorted
) candidates nil
)))))
6266 (defun anything-c-adaptive-compare (x y
)
6267 "Compare candidates X and Y taking into account that the
6268 candidate can be in (DISPLAY . REAL) format."
6269 (equal (if (listp x
)
6276 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Outliner ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6277 (defvar anything-outline-goto-near-line-flag t
)
6278 (defvar anything-outline-using nil
)
6279 (defun anything-after-update-hook--outline ()
6280 (if (and (eq anything-outline-using t
)
6281 (eq anything-outline-goto-near-line-flag t
))
6282 (anything-outline-goto-near-line)))
6283 (add-hook 'anything-after-update-hook
'anything-after-update-hook--outline
)
6285 (defun anything-outline-goto-near-line ()
6286 (with-anything-window
6287 ;; TODO need consideration whether to update position by every input.
6288 (when t
; (equal anything-pattern "")
6289 (anything-goto-line 2)
6290 (let ((lineno (with-current-buffer anything-current-buffer
6291 (line-number-at-pos (car anything-current-position
)))))
6293 (while (<= (progn (skip-chars-forward " ")
6294 (or (number-at-point) lineno
))
6299 (return-from exit
))))
6301 (and (bobp) (forward-line 1))
6302 (and (anything-pos-header-line-p) (forward-line -
2))
6303 (anything-mark-current-line)))))
6305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Plug-in ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6306 ;; Plug-in: info-index
6307 (defun* anything-c-info-init
(&optional
(file (anything-attr 'info-file
)))
6309 (unless (anything-candidate-buffer)
6310 (save-window-excursion
6313 (tobuf (anything-candidate-buffer 'global
))
6314 (infobuf (current-buffer))
6316 (dolist (node (or (anything-attr 'index-nodes
) (Info-index-nodes)))
6317 (Info-goto-node node
)
6318 (goto-char (point-min))
6319 (while (search-forward "\n* " nil t
)
6320 (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t
)
6321 '(save-current-buffer (buffer-substring-no-properties (point-at-bol) (point-at-eol)) result
)
6322 (setq s
(point-at-bol)
6324 (with-current-buffer tobuf
6325 (insert-buffer-substring infobuf s e
)
6326 (insert "\n"))))))))))
6328 (defun anything-c-info-goto (node-line)
6329 (Info-goto-node (car node-line
))
6330 (anything-goto-line (cdr node-line
)))
6332 (defun anything-c-info-display-to-real (line)
6334 "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line
)
6335 (cons (format "(%s)%s" (anything-attr 'info-file
) (match-string 2 line
))
6336 (string-to-number (or (match-string 3 line
) "1")))))
6338 (defun anything-c-make-info-source (file)
6339 `((name .
,(concat "Info Index: " file
))
6341 (init . anything-c-info-init
)
6342 (display-to-real . anything-c-info-display-to-real
)
6343 (get-line . buffer-substring
)
6344 (candidates-in-buffer)
6345 (action ("Goto node" . anything-c-info-goto
))))
6347 (defun anything-compile-source--info-index (source)
6348 (anything-aif (anything-interpret-value (assoc-default 'info-index source
))
6349 (anything-c-make-info-source it
)
6351 (add-to-list 'anything-compile-source-functions
'anything-compile-source--info-index
)
6353 (anything-document-attribute 'info-index
"info-index plugin"
6354 "Create a source of info index very easily.
6356 ex. (defvar anything-c-source-info-wget '((info-index . \"wget\"))")
6358 (anything-document-attribute 'index-nodes
"info-index plugin (optional)"
6359 "Index nodes of info file.
6361 If it is omitted, `Info-index-nodes' is used to collect index nodes.
6362 Some info files are missing index specification.
6364 ex. See `anything-c-source-info-screen'.")
6366 ;; Plug-in: candidates-file
6367 (defun anything-compile-source--candidates-file (source)
6368 (if (assoc-default 'candidates-file source
)
6369 `((init anything-p-candidats-file-init
6370 ,@(let ((orig-init (assoc-default 'init source
)))
6371 (cond ((null orig-init
) nil
)
6372 ((functionp orig-init
) (list orig-init
))
6374 (candidates-in-buffer)
6377 (add-to-list 'anything-compile-source-functions
'anything-compile-source--candidates-file
)
6379 (defun anything-p-candidats-file-init ()
6380 (destructuring-bind (file &optional updating
)
6381 (anything-mklist (anything-attr 'candidates-file
))
6382 (setq file
(anything-interpret-value file
))
6383 (with-current-buffer (anything-candidate-buffer (find-file-noselect file
))
6385 (buffer-disable-undo)
6387 (auto-revert-mode 1)))))
6389 (anything-document-attribute 'candidates-file
"candidates-file plugin"
6390 "Use a file as the candidates buffer.
6392 1st argument is a filename, string or function name or variable name.
6393 If optional 2nd argument is non-nil, the file opened with `auto-revert-mode'.")
6395 ;; Plug-in: headline
6396 (defun anything-compile-source--anything-headline (source)
6397 (if (assoc-default 'headline source
)
6398 (append '((init . anything-headline-init
)
6399 (get-line . buffer-substring
)
6402 '((candidates-in-buffer)
6403 (persistent-help .
"Show this line")))
6405 (add-to-list 'anything-compile-source-functions
'anything-compile-source--anything-headline
)
6407 (defun anything-headline-init ()
6408 (when (and (anything-current-buffer-is-modified)
6409 (with-current-buffer anything-current-buffer
6410 (eval (or (anything-attr 'condition
) t
))))
6411 (anything-headline-make-candidate-buffer
6412 (anything-interpret-value (anything-attr 'headline
))
6413 (anything-interpret-value (anything-attr 'subexp
)))))
6415 (anything-document-attribute 'headline
"Headline plug-in"
6416 "Regexp string for anything-headline to scan.")
6417 (anything-document-attribute 'condition
"Headline plug-in"
6418 "A sexp representing the condition to use anything-headline.")
6419 (anything-document-attribute 'subexp
"Headline plug-in"
6420 "Display (match-string-no-properties subexp).")
6423 (defun anything-headline-get-candidates (regexp subexp
)
6424 (with-current-buffer anything-current-buffer
6426 (goto-char (point-min))
6427 (if (functionp regexp
) (setq regexp
(funcall regexp
)))
6428 (let (hierarchy curhead
)
6430 (if (numberp subexp
)
6431 (cons (match-string-no-properties subexp
) (match-beginning subexp
))
6432 (cons (buffer-substring (point-at-bol) (point-at-eol))
6434 (hierarchies (headlines)
6435 (1+ (loop for
(_ . hierarchy
) in headlines
6436 maximize hierarchy
)))
6438 (loop for i from
0 to hierarchy
6439 collecting
(aref curhead i
)))
6440 (arrange (headlines)
6441 (unless (null headlines
) ; FIX headlines empty bug!
6442 (loop with curhead
= (make-vector (hierarchies headlines
) "")
6443 for
((str . pt
) . hierarchy
) in headlines
6444 do
(aset curhead hierarchy str
)
6447 (format "H%d:%s" (1+ hierarchy
)
6448 (mapconcat 'identity
(vector-0-n curhead hierarchy
) " / "))
6453 (loop for re in regexp
6454 for hierarchy from
0
6455 do
(goto-char (point-min))
6458 while
(re-search-forward re nil t
)
6459 collect
(cons (matched) hierarchy
)))
6460 (lambda (a b
) (> (cdar b
) (cdar a
)))))
6461 (loop while
(re-search-forward regexp nil t
)
6462 collect
(matched))))))))
6465 (defun anything-headline-make-candidate-buffer (regexp subexp
)
6466 (with-current-buffer (anything-candidate-buffer 'local
)
6467 (loop for
(content . pos
) in
(anything-headline-get-candidates regexp subexp
)
6470 (with-current-buffer anything-current-buffer
6471 (line-number-at-pos pos
))
6474 (defun anything-headline-goto-position (pos recenter
)
6477 (set-window-start (get-buffer-window anything-current-buffer
) (point))))
6479 (defun anything-revert-buffer (candidate)
6480 (with-current-buffer candidate
6481 (when (buffer-modified-p)
6482 (revert-buffer t t
))))
6484 (defun anything-revert-marked-buffers (candidate)
6485 (dolist (i (anything-marked-candidates))
6486 (anything-revert-buffer i
)))
6488 (defun anything-kill-marked-buffers (candidate)
6489 (dolist (i (anything-marked-candidates))
6492 ;; Plug-in: persistent-help
6493 (defun anything-compile-source--persistent-help (source)
6494 (append source
'((header-line . anything-persistent-help-string
))))
6495 (add-to-list 'anything-compile-source-functions
'anything-compile-source--persistent-help
)
6497 (defun anything-persistent-help-string ()
6498 (substitute-command-keys
6499 (concat "\\<anything-map>\\[anything-execute-persistent-action]: "
6500 (or (anything-interpret-value (anything-attr 'persistent-help
))
6501 (anything-aif (or (assoc-default 'persistent-action
6502 (anything-get-current-source))
6503 (assoc-default 'action
6504 (anything-get-current-source)))
6505 (cond ((symbolp it
) (symbol-name it
))
6506 ((listp it
) (or (ignore-errors (caar it
)) ""))))
6508 " (keeping session)")))
6510 (anything-document-attribute 'persistent-help
"persistent-help plug-in"
6511 "A string to explain persistent-action of this source.
6512 It also accepts a function or a variable name.")
6514 ;;; (anything '(((name . "persistent-help test")(candidates "a")(persistent-help . "TEST"))))
6516 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6518 (defun anything-c-find-file-or-marked (candidate)
6519 "Open file CANDIDATE or open anything marked files in background."
6520 (let ((marked (anything-marked-candidates)))
6521 (if (> (length marked
) 1)
6522 (dolist (i marked
) (find-file-noselect i
))
6523 (find-file-at-point candidate
))))
6525 ;; FIXME there is a bug in dired that confuse all dired commands
6526 ;; when using this feature, so i suspend it until bug is fixed in emacs.
6528 ;; (defun anything-c-create-dired-on-marked (candidate)
6529 ;; "Create a new dired buffer with only marked candidates."
6530 ;; (let ((marked (anything-marked-candidates))
6531 ;; (buffer-name (read-string "New Dired Buffer: ")))
6532 ;; (dired (cons buffer-name marked))))
6534 (defun anything-delete-marked-files (ignore)
6535 (let* ((files (anything-marked-candidates))
6536 (len (length files
)))
6538 (format "Delete *%s File(s):\n%s"
6540 (mapconcat (lambda (f) (format "- %s\n" f
)) files
""))))
6541 (message "(No deletions performed)")
6543 (set-text-properties 0 (length i
) nil i
)
6544 (anything-c-delete-file i
))
6545 (message "%s File(s) deleted" len
))))
6547 (defun anything-ediff-marked-buffers (candidate &optional merge
)
6548 "Ediff 2 marked buffers or 1 marked buffer and current-buffer.
6549 With optional arg `merge' call `ediff-merge-buffers'."
6550 (let ((lg-lst (length (anything-marked-candidates)))
6554 (error "Error:You have to mark at least 1 buffer"))
6556 (setq buf1 anything-current-buffer
6557 buf2
(first (anything-marked-candidates))))
6559 (setq buf1
(first (anything-marked-candidates))
6560 buf2
(second (anything-marked-candidates))))
6562 (error "Error:To much buffers marked!")))
6564 (ediff-merge-buffers buf1 buf2
)
6565 (ediff-buffers buf1 buf2
))))
6567 (defun anything-bookmark-get-bookmark-from-name (bmk)
6568 "Return bookmark name even if it is a bookmark with annotation.
6569 e.g prepended with *.
6570 Return nil if bmk is not a valid bookmark."
6571 (let ((bookmark (replace-regexp-in-string "\*" "" bmk
)))
6572 (if (assoc bookmark bookmark-alist
)
6574 (when (assoc bmk bookmark-alist
)
6577 (defun anything-delete-marked-bookmarks (elm)
6578 "Delete this bookmark or all marked bookmarks."
6579 (let ((bookmark (anything-bookmark-get-bookmark-from-name elm
)))
6580 (anything-aif (anything-marked-candidates)
6582 (let ((bmk (anything-bookmark-get-bookmark-from-name i
)))
6583 (bookmark-delete bmk
'batch
)))
6584 (bookmark-delete bookmark
'batch
))))
6586 (defun anything-require-or-error (feature function
)
6587 (or (require feature nil t
)
6588 (error "Need %s to use `%s'." feature function
)))
6590 (defun anything-find-buffer-on-elscreen (candidate)
6591 "Open buffer in new screen, if marked buffers open all in elscreens."
6592 (anything-require-or-error 'elscreen
'anything-find-buffer-on-elscreen
)
6593 (anything-aif (anything-marked-candidates)
6595 (let ((target-screen (elscreen-find-screen-by-buffer
6596 (get-buffer i
) 'create
)))
6597 (elscreen-goto target-screen
)))
6598 (let ((target-screen (elscreen-find-screen-by-buffer
6599 (get-buffer candidate
) 'create
)))
6600 (elscreen-goto target-screen
))))
6602 (defun anything-elscreen-find-file (file)
6603 (anything-require-or-error 'elscreen
'anything-elscreen-find-file
)
6604 (elscreen-find-file file
))
6606 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6608 ;;;; Type Attributes
6609 (define-anything-type-attribute 'buffer
6612 '(("Switch to buffer other window" . switch-to-buffer-other-window
)
6613 ("Switch to buffer" . switch-to-buffer
))
6614 '(("Switch to buffer" . switch-to-buffer
)
6615 ("Switch to buffer other window" . switch-to-buffer-other-window
)
6616 ("Switch to buffer other frame" . switch-to-buffer-other-frame
)))
6617 ,(and (locate-library "elscreen") '("Display buffer in Elscreen" . anything-find-buffer-on-elscreen
))
6618 ("Display buffer" . display-buffer
)
6619 ("Revert buffer" . anything-revert-buffer
)
6620 ("Revert Marked buffers" . anything-revert-marked-buffers
)
6621 ("Kill buffer" . kill-buffer
)
6622 ("Kill Marked buffers" . anything-kill-marked-buffers
)
6623 ("Ediff Marked buffers" . anything-ediff-marked-buffers
)
6624 ("Ediff Merge marked buffers" .
(lambda (candidate)
6625 (anything-ediff-marked-buffers candidate t
))))
6626 (persistent-help .
"Show this buffer")
6627 (candidate-transformer anything-c-skip-current-buffer anything-c-skip-boring-buffers
))
6628 "Buffer or buffer name.")
6630 (define-anything-type-attribute 'file
6633 '(("Find file other window" . find-file-other-window
)
6634 ("Find file(s)" . anything-find-many-files
)
6635 ("Find file as root" . anything-find-file-as-root
))
6636 '(("Find file" . anything-find-many-files
)
6637 ("Find file as root" . anything-find-file-as-root
)
6638 ("Find file other window" . find-file-other-window
)
6639 ("Find file other frame" . find-file-other-frame
)))
6640 ("Open dired in file's directory" . anything-c-open-dired
)
6641 ("Delete file(s)" . anything-delete-marked-files
)
6642 ("Open file externally" . anything-c-open-file-externally
)
6643 ("Open file with default tool" . anything-c-open-file-with-default-tool
))
6644 (persistent-help .
"Show this file")
6645 (action-transformer anything-c-transform-file-load-el
6646 anything-c-transform-file-browse-url
)
6647 (candidate-transformer anything-c-w32-pathname-transformer
6648 anything-c-skip-current-file
6649 anything-c-skip-boring-files
6650 anything-c-shorten-home-path
))
6653 (define-anything-type-attribute 'command
6654 `((action ("Call interactively" . anything-c-call-interactively
)
6655 ("Describe command" . anything-c-describe-function
)
6656 ("Add command to kill ring" . anything-c-kill-new
)
6657 ("Go to command's definition" . anything-c-find-function
))
6658 ;; Sort commands according to their usage count.
6659 (filtered-candidate-transformer . anything-c-adaptive-sort
)
6660 (persistent-action . anything-c-describe-function
))
6661 "Command. (string or symbol)")
6663 (define-anything-type-attribute 'function
6664 '((action ("Describe function" . anything-c-describe-function
)
6665 ("Add function to kill ring" . anything-c-kill-new
)
6666 ("Go to function's definition" . anything-c-find-function
))
6667 (action-transformer anything-c-transform-function-call-interactively
)
6668 (candidate-transformer anything-c-mark-interactive-functions
))
6669 "Function. (string or symbol)")
6671 (define-anything-type-attribute 'variable
6672 '((action ("Describe variable" . anything-c-describe-variable
)
6673 ("Add variable to kill ring" . anything-c-kill-new
)
6674 ("Go to variable's definition" . anything-c-find-variable
)
6675 ("Set variable" . anything-c-set-variable
)))
6678 (define-anything-type-attribute 'sexp
6679 '((action ("Eval s-expression" .
(lambda (c) (eval (read c
))))
6680 ("Add s-expression to kill ring" . kill-new
))
6681 (action-transformer anything-c-transform-sexp-eval-command-sexp
))
6682 "String representing S-Expressions.")
6684 (define-anything-type-attribute 'bookmark
6686 ("Jump to bookmark" .
(lambda (candidate)
6687 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
))
6688 (current-prefix-arg anything-current-prefix-arg
))
6689 (bookmark-jump bookmark
))
6691 ("Jump to BM other window" .
(lambda (candidate)
6692 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6693 (bookmark-jump-other-window bookmark
))
6695 ("Bookmark edit annotation" .
(lambda (candidate)
6696 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6697 (bookmark-edit-annotation bookmark
))))
6698 ("Bookmark show annotation" .
(lambda (candidate)
6699 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6700 (bookmark-show-annotation bookmark
))))
6701 ("Delete bookmark(s)" . anything-delete-marked-bookmarks
)
6702 ,@(when (fboundp 'bmkext-edit-bookmark
)
6703 '(("Edit Bookmark" .
(lambda (candidate)
6704 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6705 (bmkext-edit-bookmark bookmark
))))))
6706 ("Rename bookmark" .
(lambda (candidate)
6707 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6708 (bookmark-rename bookmark
))))
6709 ("Relocate bookmark" .
(lambda (candidate)
6710 (let ((bookmark (anything-bookmark-get-bookmark-from-name candidate
)))
6711 (bookmark-relocate bookmark
))))))
6714 (define-anything-type-attribute 'line
6715 '((display-to-real . anything-c-display-to-real-line
)
6716 (action ("Go to Line" . anything-c-action-line-goto
)))
6717 "LINENO:CONTENT string, eg. \" 16:foo\".
6719 Optional `target-file' attribute is a name of target file.
6721 Optional `before-jump-hook' attribute is a function with no
6722 arguments which is called before jumping to position.
6724 Optional `after-jump-hook' attribute is a function with no
6725 arguments which is called after jumping to position.
6727 If `adjust' attribute is specified, searches the line whose
6728 content is CONTENT near the LINENO.
6730 If `recenter' attribute is specified, the line is displayed at
6731 the center of window, otherwise at the top of window.
6734 (define-anything-type-attribute 'file-line
6735 `((filtered-candidate-transformer anything-c-filtered-candidate-transformer-file-line
)
6737 (action ("Go to" . anything-c-action-file-line-goto
)))
6738 "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\".
6740 Optional `default-directory' attribute is a default-directory
6741 FILENAME is interpreted.
6743 Optional `before-jump-hook' attribute is a function with no
6744 arguments which is called before jumping to position.
6746 Optional `after-jump-hook' attribute is a function with no
6747 arguments which is called after jumping to position.
6749 If `adjust' attribute is specified, searches the line whose
6750 content is CONTENT near the LINENO.
6752 If `recenter' attribute is specified, the line is displayed at
6753 the center of window, otherwise at the top of window.
6756 (define-anything-type-attribute 'timer
6757 '((real-to-display . anything-c-timer-real-to-display
)
6758 (action ("Cancel Timer" . cancel-timer
)
6759 ("Describe Function" .
(lambda (tm) (describe-function (timer--function tm
))))
6760 ("Find Function" .
(lambda (tm) (find-function (timer--function tm
)))))
6761 (persistent-action .
(lambda (tm) (describe-function (timer--function tm
))))
6762 (persistent-help .
"Describe Function"))
6765 ;;;; Default `anything-sources'
6766 ;; Setting `anything-sources' is DEPRECATED, but it seems that newbies
6767 ;; tend to invoke M-x anything directly. So I offer default setting.
6768 (setq anything-sources
6769 '(anything-c-source-buffers+
6770 anything-c-source-recentf
6771 anything-c-source-files-in-current-dir
+))
6774 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
6775 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el")
6777 (when (fboundp 'expectations
)
6779 (desc "candidates-file plug-in")
6780 (expect '(anything-p-candidats-file-init)
6781 (assoc-default 'init
6782 (car (anything-compile-sources
6784 (candidates-file .
"test.txt")))
6785 '(anything-compile-source--candidates-file)))))
6786 (expect '(anything-p-candidats-file-init
6788 (assoc-default 'init
6789 (car (anything-compile-sources
6791 (candidates-file .
"test.txt")
6792 (init .
(lambda () 1))))
6793 '(anything-compile-source--candidates-file)))))
6794 (expect '(anything-p-candidats-file-init
6796 (assoc-default 'init
6797 (car (anything-compile-sources
6799 (candidates-file .
"test.txt")
6800 (init (lambda () 1))))
6801 '(anything-compile-source--candidates-file)))))
6802 (desc "anything-c-source-buffers")
6803 (expect '(("Buffers" ("foo" "curbuf")))
6804 (stub buffer-list
=> '("curbuf" " hidden" "foo" "*anything*"))
6805 (let ((anything-c-boring-buffer-regexp
6810 " *Echo Area" " *Minibuf"))))
6811 (flet ((buffer-name (x) x
))
6812 (anything-test-candidates 'anything-c-source-buffers
))))
6813 (desc "anything-c-stringify")
6815 (anything-c-stringify "str1"))
6817 (anything-c-stringify 'str2
))
6818 (desc "anything-c-symbolify")
6820 (anything-c-symbolify "sym1"))
6822 (anything-c-symbolify 'sym2
)))))
6824 (provide 'anything-config
)
6826 ;;; Local Variables:
6827 ;;; time-stamp-format: "%:y-%02m-%02d %02H:%02M:%02S (%Z) %u"
6830 ;; How to save (DO NOT REMOVE!!)
6831 ;; (progn (magit-push) (emacswiki-post "anything-config.el"))
6832 ;;; anything-config.el ends here
6834 ;;; LocalWords: Tassilo Patrovics Vagn Johansen Dahl Clementson infos
6835 ;;; LocalWords: Kamphausen informations McBrayer Volpiatto bbdb bb
6836 ;;; LocalWords: iswitchb imenu Recentf sym samewindow pos bol eol
6837 ;;; LocalWords: aif str lst func attrib recentf lessp prin mapatoms commandp
6838 ;;; LocalWords: cmd stb Picklist picklist mapcan subentry destructuring dirs
6839 ;;; LocalWords: darwin locat MacOS mdfind Firstname Lastname calc prepend jids
6840 ;;; LocalWords: dotimes Thierry online vname
6841 ;;; LocalWords: csharp javascript lua makefile cperl zcat lineno buf
6842 ;;; LocalWords: multiline href fn cand NewTitle cwd filepath thru ret
6843 ;;; LocalWords: bfn fOpen UNC cygdrive nt xdg macos FILE's elc rx svn hg
6844 ;;; LocalWords: CANDIDATE's darcs facep pathname args pathnames subseq priorty
6845 ;;; LocalWords: Vokes rfind berkeley JST ffap lacarte bos
6846 ;;; LocalWords: Lacarte Minibuf epp LaCarte bm attrset migemo attr conf mklist
6847 ;;; LocalWords: startpos noselect dont desc