Pick anything with Peepopen on emacs

As you might already know, I use emacs+orgmode for most of my information management needs and GTDness. There’s really nothing else out there that reaches the simplicity of plain text files managed by such a powerful PIM meta-framework.

I’ve been also using Peepopen, the new fuzzy-search based file-picker from topfunky. Peepopen indexes a list of files in a given directory and allows you to reach the wanted file with as few types as possible, taking advantage of fuzzy-search logic.

You could think it would be used only to pick up files from a software project, but the truth is, it can be used to pick files wherever you want.

I keep a reference system by piling up files into my ~/org/wiki directory. If I have something worthy to write about any subject, or if I need to study about something, I, just create a new org file in this directory and start typing.

In this sense, I’m going off the patterns of orgmode, which encourages few big files managed by the powerful agenda view. If I were being a org-purist, I would probably be using a big reference file, and each org top-level headline would separate the different contents. However, I can’t really get used to that and I prefer to separate my subjects physically into different filenames, at least for reference-like data. I might be adding one or two very important files from the wiki dir into the agenda if it is something that I really need to get my attention into currently, but that’s it. Besides, org-agenda doesn’t work well if you add tons of files into its lists, it just gets too slow.

So, what I wanted was a quick and easy way to get to my “wiki” pages — “Well why not use Peepopen” — I asked myself. Well, why not?

What I did was to dig into peepopen.el, I then took a glance at the peepopen-goto-file-gui function. Happened this was the function I needed. Following the path of least effort, I just copied the function definition and pasted on my org.el configuration file. Then I modified it to accept an argument, which is the root path for Peepopen:

(defun peepopen-goto-file-gui-manual (arg)
“Uses external GUI app to quickly jump to a file in the project.”
(interactive)
(defun string-join (separator strings)
“Join all STRINGS using SEPARATOR.”
(mapconcat ‘identity strings separator))
(let ((root arg))
(when (null root)
(error
(concat
“Can’t find a suitable project root (”
(string-join ” ” *textmate-project-roots* )
“)”)))
(shell-command-to-string
(format “open -a PeepOpen ‘%s’”
(expand-file-name root)))))

(defun find-wiki () “Find files in the wiki dir” (interactive) (peepopen-goto-file-gui-manual “~/org/wiki”))

(global-set-key (kbd “s-w”) ‘find-wiki)

I then defined a function find-wiki, which happens to be a simple wrapper that calls peepopen-goto-file-gui-manual with the path I want. Finally, I bind super-w to find-wiki.

Then, whenever I type s-w, Peepopen fires up listing my reference files, and allows me quickly pick and open the one I want in emacs. Beatiful and simple!


The point is, you can use Peepopen to pick anything, anywhere. It will use the current opened file as reference by default, but if you want to force a location, you can use this function and pass the path as argument.

It would be cool if Peepopen would allow me to type in a filename that doesn’t exist and visit this path on emacs ;)

You can check the code for this and more on http://github.com/celoserpa/emacs-starter-kit, forked from topfunky’s starter-kit.

One Comment

  1. Very useful! Someone was asking for just this feature. I’ll add it to the next release of the app.

    Thanks!

Leave a Reply