Peter Christensen

  • Presentations
  • Contact Me

Finding Things Fast in Emacs

August 17, 2015 by Peter Leave a Comment

I use emacs, and it is super powerful, but out of the box, it has some rough edges. Finding files in stock emacs isn’t great.

I used to use a plugin called find-things-fast (https://github.com/eglaysher/find-things-fast), but a previous employer had a codebase too big that made it grind to a halt. (Hint: different projects should be in different repos.) I grew out of the habit of using it, but when I upgraded and tried using it again, I got no results. Turns out the new version has a file extension whitelist, and the author sets it to his type of project, the Chromium project with lots of C++ file extensions. I wanted to use the file extensions for my projects, but rather than guess and make an ad-hoc list, I decided to roll up my command line sleeves and figure it out for real.

Find all files in Git repo:

git ls-files

Run a regex to strip out the ending file extension:

git ls-files | perl -ne 'while(/\.[^\.\/]+$/g) {print "$&";}'

Sort the lines, and filter down to unique extensions:

git ls-files | perl -ne 'while(/\.[^\.\/]+$/g) {print "$&";}' | sort | uniq

Append this to a file:

git ls-files | perl -ne 'while(/\.[^\.\/]+$/g) {print "$&";}' | sort | uniq >> ~/src/file_extensions.txt

Run this command in each project.

Create a sorted unique list from all projects:

sort ~/src/file_extensions.txt | uniq > ~/src/sorted_file_extensions.txt

The I used an emacs editor macro to make an elisp list of wildcard strings, that looked like this:

'("*.asd" "*.bash" "*.bowerrc" "*.clj" "*.cljs" "*.coffee" "*.conf" "*.css" "*.csv" "*.editorconfig" "*.el" "*.eot" "*.erb" "*.example" "*.gif" "*.gitattributes" "*.gitconfig" "*.gitignore" "*.gitkeep" "*.gitmodules" "*.goo" "*.haml" "*.htm" "*.html" "*.info" "*.irbrc" "*.jade" "*.jpg" "*.js" "*.jshintrc" "*.json" "*.k" "*.lisp" "*.lock" "*.lua" "*.md" "*.nrepl-port" "*.nvmrc" "*.orig" "*.png" "*.rake" "*.rb" "*.rdoc" "*.rspec" "*.ru" "*.ruby-gemset" "*.ruby-version" "*.scm" "*.scss" "*.sh" "*.sml" "*.ss" "*.swf" "*.texi" "*.text" "*.ttf" "*.txt" "*.woff" "*.xml" "*.yml" "*.zsh")

I customized the variable ftf-filetypes, restarted emacs, and now if works like a dream again. Thanks Elliot!

Filed Under: Emacs, Programming

Leave a Reply

You must be logged in to post a comment.

Categories

  • Blog
  • Book Review
  • Business
  • Clojure
  • Education
  • Emacs
  • Fun
  • iOS
  • Lisp
  • Personal Sprints
  • Pictures
  • Polyphasic
  • Presentations
  • Programming
  • Rails
  • Startups
  • Uncategorized

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in