Last time I blabbed about why
anything.el is rad, but left you hanging with just a few out-of-the-box implications or that rad-ness. This time, let’s use
anything.el to make our own anything.
anything.el customization is making your own anything command. You’ll find an example of this in
(defun my-anything ()
anything-other-buffer is a simplified version of
anything that takes a list of sources for its first argument and a buffer name as its second. So
M-x my-anything now gives you an
anything selection buffer for all them sources there. You’ll find a wealth of pre-baked sources to choose from in
The next level of awesomeness comes when you create your own source, which is cheese easy. Do a
C-h v on
anything-sources. Here you’ll get a lengthy description of how to set one of these buggers up. I’ve made the world’s simplest, most contrived, and most stupidly named source below.
‘((name . "Name for My Source")
(candidates . ("a" "list" "of" "files"))
(type . file)))
There are three mandatory keys:
candidates, and either
type. Here I’m pretending to be looking at a list of files, so my type is
file. Types provide common actions for things you’ll commonly be working with. They’re a shortcut to actually writing your own actions.
Now that we’ve got a source, let’s make an anything command that uses it.
(defun anything-for-pretend-files ()
Try out this custom command and hit tab on one of the items to see what you can get with the
file type. You can find a list of types with a
C-h v of
If you’re not using a
type, you’re using an
action key takes a list of alists, each of which maps one name string to one function. Something like this:
(action . (("Action name" . (lambda (selection)
Of course, that lambda could be a function name. Let’s make a real action. A real stupid action!
‘((name . "Things To Say")
(candidates . ("Llama" "Guano" "Mochaccino" "Colostomy"))
(action . (("Say it!" .
("Spray it!" .
(message (concat selection "thpppt"))))))))
(defun anything-things-to-say ()
"*anything things to say*"))
“Say it!” is the default action, it’s what happens when we hit
return. “Spray it!” is an alternate action, which we can select by hitting
tab on an item. Remember that this action selection screen is another
anything screen, so you can arrow and
C-p through it, but you can also just start typing what you want.
Now these examples are collosally stewpid. What’s more, they use only a tiny fraction of the shite tonne of source options
anything‘ll take. If your curiosity is tingling,
C-h v anything-sources and prepare to have your amazement blown.
And if you’re really and truly rapt, tune in next time, when we’ll make a for real
anything-project-files source that lets you fly around the files of your gigantic, deeply nested project like an airbus on an eightball. It’ll be fun.