Intro
A while ago I switched to Emacs pretty much "full time". I've worked at Twitter (for over 5 years!) and I've been an Android developer all that time. As a tech lead I probably spend equal time in Jira, Gmail, Google Docs, and writing code these days. When I do write code, it's 99% in Emacs. Even for Android development. I build from the command line, and I only open Android Studio when I need to debug something or want to step through the code. That's fairly often, but even then I don't edit much code while it's open.
When and why
Emacs has been my preferred editor for quite some time now, but I really began using it earnest when working at Netflix. In the video game studios I worked at we used a combination of Metrowerks CodeWarrior and Microsoft's Visual Studio© for game and tools code.
Then came Playstation3©, Xbox©, and Xbox360©. I spent time going in and out of various IDEs and editors.
One of my first responsibilities at Netflix was helping out a little bit on their PlayStation2© client (yes, you read that right). I was really just reviewing code that an external developer had written, and testing bugs and whatnot. I didn't write any significant portion of the code (that I recall). I used CodeWarrior back in the day for PS2© development and it was actually pretty good.
Then, as part of the core technology team at Netflix, I was no longer "just" working on the consoles, I was building and running Linux reference implementations, editing on Windows, Linux virtual machines, then Mac laptops, etc. I got tired of trying to remember various keybindings. If it's not obvious from the fact that I use Emacs, I prefer to keep my hands on the keyboard and not click around on too many GUI elements if I can help it.
Back to the point
So what do I miss out on? Here is what I don't get in Emacs that seems the most useful in Android Studio:
- Refactoring, taking semantics into account. Find-replace just isn't the same when you just mean to rename something that has a commonly used names.
- UI Designer, well it doesn't work half the time for our layouts anyways, but perhaps that is some kind of Twitter specific problem.
- Instant Run, this also doesn't work for us at Twitter
And what do I gain (in my opinion)?
- Emacs starts up faster, no re-indexing every time I switch branches, etc.
- I work on more than just Android code, I also edit configuration files, occasionally venture into the scala code, python if I have to tweak one of our tools (I don't really know python). Being able to seamlessly edit all of those things simultaneously is really nice. I'm sure Android studio can edit any file you attempt to, but I prefer "getting around" via Emacs and...
- Helm!
Helm
Helm has been a real game changer for me. I feel like it adds a super power of easily searching an extremely wide range or an extremely focused range. Read more about it's capabilities here.
From narrow to wide:
helm-occur
for searching within the current bufferhelm-do-grep-1
with specific paths for searching regexps of names of files within that path and it's children- I bind certain flavors of paths to different keys to search by "type" of file I'm looking for. For example in order to search within the resource files of an Android project:
This updates a cache of the directories to be searched for resources, and then searches within those directories for the specified regexp. I have a number of these canned flavors:(defun laa-update-search-res-dirs (dir) "Update the list of resource directories to search under DIR." (message "Updating resource directories.") (let ((res-dir-string (shell-command-to-string (concat "find " dir " -path \"*src/main/res\"")))) (split-string res-dir-string "\n" t))) (defun laa-search-res () "Search resource files in twitter for android." (interactive) (when (not laa-twitter-for-android-res-dirs) (setq laa-twitter-for-android-res-dirs (laa-update-search-res-dirs laa-twitter-for-android-dir))) (search-path laa-twitter-for-android-res-dirs '("*.xml")))
Not all of them need to update any cache, resources are just a bit cumbersome. Most of them just live search the file system (or with helms internal caching, most likely) which means I don't really wait around for some giant re-indexing all the time as I switch branches like with Android Studio.(when section-twitter (try-require 'laa-twitter) (global-set-key (kbd "C-c l t") 'laa-search-twitter-android) (global-set-key (kbd "C-c l r") 'laa-search-tfa-res) (global-set-key (kbd "C-c l s") 'laa-search-tfa-strings) (global-set-key (kbd "C-c l m") 'laa-search-twitter-media) (global-set-key (kbd "C-c l i") 'laa-search-twitter-ios) (global-set-key (kbd "C-c l c") 'laa-search-twitter-config) (global-set-key (kbd "C-c l f") 'laa-find-twitter-file) (global-set-key (kbd "C-c l g") 'laa-search-twitter-gradle) (global-set-key (kbd "C-c l d") 'laa-search-tfa-docs) (global-set-key (kbd "C-c l j") 'laa-jira-browse-ticket))
- I bind certain flavors of paths to different keys to search by "type" of file I'm looking for. For example in order to search within the resource files of an Android project:
helm-mini
for bring up and searching my recent buffers by name.helm-browse-project
for searching regexps of names of files within a set of directories. This one shows version control status as well, but I have learned not to use it in Twitter's monorepo (it's gigantic)!helm-filtered-bookmarks
for searching my bookmarks to anywhere in the filesystem.