Today I did a few hours of pair programming. Pair programming is good because it forces you to constantly motivate every design and code decisions you make. As a nice side effect, you also improve your editing skills. Today I learned a lot of new Emacs shortcuts even though the person I coded with is not an Emacs user.

One of the first tasks was to create a module that mocks HTTP requests. That module would be very similar to the un-mocked module so I decided to use copy-file to create a copy. My college said, “why don’t you just save-as?”. I realized I had never used save as in Emacs despite being a daily Emacs user for years. I didn’t even know it existed, but it does. The command is called write-file and the shortcut is M-x M-w. It’s much better for this use case because it keeps the new file open. With copy-file you need to remember to change buffer to edit the newly created file.

Later during our session, we were looking at a quite large unit test with a lot of functions and objects. To easier get an overview my colleague asked me to hide some function bodies to make a better visual of the relevant functions. My immediate response was that it’s not possible, but I took a quick look at the Emacs menu and saw that it do in fact exist exactly that feature in js2-mode. To hide function bodies you can use js2-mode-toggle-hide-functions C-c C-f and to hide objects you can use js2-mode-toggle-element C-c C-o. This is something I would never think of doing while coding on my own, but after being “forced” to use it today, I will definitely use it in the future.