{"id":652,"date":"2015-08-17T11:11:37","date_gmt":"2015-08-17T18:11:37","guid":{"rendered":"http:\/\/pchristensen.com\/blog\/?p=652"},"modified":"2015-08-17T11:11:37","modified_gmt":"2015-08-17T18:11:37","slug":"finding-things-fast-in-emacs","status":"publish","type":"post","link":"http:\/\/pchristensen.com\/blog\/articles\/finding-things-fast-in-emacs\/","title":{"rendered":"Finding Things Fast in Emacs"},"content":{"rendered":"<p>I use emacs, and it is super powerful, but out of the box, it has some rough edges. Finding files in stock emacs isn&#8217;t great.<\/p>\n<p>I used to use a plugin called find-things-fast (<a href=\"https:\/\/github.com\/eglaysher\/find-things-fast\">https:\/\/github.com\/eglaysher\/find-things-fast<\/a>), 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.<\/p>\n<p>Find all files in Git repo:<\/p>\n<pre>git ls-files<\/pre>\n<p>Run a regex to strip out the ending file extension:<\/p>\n<pre>git ls-files | perl -ne 'while(\/\\.[^\\.\\\/]+$\/g) {print \"$&amp;\";}'<\/pre>\n<p>Sort the lines, and filter down to unique extensions:<\/p>\n<pre>git ls-files | perl -ne 'while(\/\\.[^\\.\\\/]+$\/g) {print \"$&amp;\";}' | sort | uniq<\/pre>\n<p>Append this to a file:<\/p>\n<pre>git ls-files | perl -ne 'while(\/\\.[^\\.\\\/]+$\/g) {print \"$&amp;\";}' | sort | uniq &gt;&gt; ~\/src\/file_extensions.txt<\/pre>\n<p>Run this command in each project.<\/p>\n<p>Create a sorted unique list from all projects:<\/p>\n<pre>sort ~\/src\/file_extensions.txt | uniq &gt; ~\/src\/sorted_file_extensions.txt<\/pre>\n<p>The I used an emacs editor macro to make an elisp list of wildcard strings, that looked like this:<\/p>\n<pre>'(\"*.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\")<\/pre>\n<p>I customized the variable ftf-filetypes, restarted emacs, and now if works like a dream again. Thanks <a href=\"https:\/\/github.com\/eglaysher\">Elliot<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use emacs, and it is super powerful, but out of the box, it has some rough edges. Finding files in stock emacs isn&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[20,10],"tags":[],"class_list":{"0":"post-652","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-emacs","7":"category-programming","8":"entry"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pazgP-aw","_links":{"self":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":0,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchristensen.com\/blog\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}