First impressions with emacs

Learning emacs really sucks. Let's do this.

My current stack

Because I'm insane, I decided to give Emacs a try. While I'm still pretty pleased with Omnifocus, I do find limitations with it. I also store all kinds of notes in Quiver. Anytime I'm working on anything, I keep my notes in Quiver. I had been keeping a worklog in it, but it got goofy when work (and the associated notes) span multiple days. I also use PyCharm as my IDE. That I definitely like, but if I want to open a single file, I'm going to pop open vim, sublime text, or even just textedit.

Why I'm looking at Emacs

For years, I've been hearing amazing things about orgmode. It's used for todo lists, project planning, documents, and journals. People also like using emacs as an python ide. Everyone that uses emacs seems to really like it, and it keeps showing up as a good looking solution to different problems I'd like to solve. There's even a slack client for it. I decided that I should really give emacs a shot before discarding any solution because it happened to be emacs based. You see, emacs has a super steep learning curve, and when you use it, you essentially join a cult.

Round 1

So I decided to dive in. I found a number of people recommending How to learn emacs as a good place for beginners. The first page has this juicy tidbit:

What I need from you is commitment (a couple of dedicated hours of study per week, and to use Emacs as your day-to-day editor) and patience (be willing to give up your favorite IDE’s features, at least for a month or two).

That's pretty intimidating, but to be fair, Vim takes a long time to master. Those firs starting out need to learn what a modal editor is, how to switch between insert and command mode, how to navigate, how to do search and replace, how to delete lines, and possibly how to use vim's internal clipboard operations. That's all before you get into customizing and extending the program to turn it into an ide.

I put a couple hours in the first weekend, and a little bit of time the following week going through the examples. But I got bored and real life kept me away.

Round 2

Seeing sometime ahead of me, I figured I'd try again. I went back and forth between plain emacs, spacemacs and prelude. I did research all over about how people got started with emacs. Lots of heavy opinions on "starting pure", or using a starter pack like spacemacs/prelude. For those with vim leanings, there is an "evil mode" that provides some vim keybindings and emulation. I came across the Mastering Emacs book which gots some good feedback on reddit.
I started reading a copy of the book with pure emacs open. It's 277 pages long and I got to about page 30 before I started falling asleep. However, here are some key things to know:

  • Emacs isn't based on files, but based on buffers (which may contain a file).
  • What we call a window, emacs calls a frame.
  • A frame contains multiple windows (or window panes)
  • You can assign any buffer to any window, or even have multiple windows showing the same buffer.

Round 3 - Just edit some python already

Screw reading books and working through tutorials. I'm just going to go ahead and start using emacs and then google every time I got stuck. That's how I learned vim back in the late 90s, except I didn't have google back then. In fact, I didn't even have Internet at home back then. I had to go to school, search altavista, download manuals and deb packages to floppy disk, then take them home and transfer them.

I figure, just use the stupid program this week and expect normal operations to take longer while I work things out.

I don't know how to exit vim

So first things first, I took the popular advice and installed spacemacs, which gives me fancy color themes and evil mode.

  1. If you fire up emacs, it's a decent gui, complete with helpful menus and mouse integration. You can open a file, edit, save it exit almost as easily as any other text editor. File -> Visit new file and File -> Open do make you type in the path the file instead of a file open dialog gui, but there is a sort of autocomplete/directory listing interface.
  2. Emacs with spacemacs takes a long time to load. It's on par with pycharm slow load times. Kind of sucks if emacs is closed and you just want to open a file. The one book I says that I should run emacs in a a server mode and just use the emacsclient binary for all subsequent starts. Ok, fine - if I have emacs up all day long, that's doable.
  3. Emacs can run a shell. You can run shell which runs your default shell (bash in my case) in a buffer. Emacs fans call this the inferior shell. The "emacs shell" or shell is promoted as superior. It's a bash-inspired shell written in elisp. Both shells suck. I thought I'd be able to run a terminal in a window below the file I'm editing like I do in pycharm, but it's extremely frustrating working in this shell. Ctrl-C is "C-c C-c", and it's really easy to end up no typing over output from a pervious command. Worst of all, I could not activate a virtualenv in either shell. This means I couldn't drop to a shell and run python ad-hoc python tools. While there may be some amazing tweaks and features these shells bring, I found it much like working on a bad serial connection.
  4. When I opened a python file, spacemacs detected this and asked if I wanted to install the python layer. This gave me nice syntax highlighting, but I didn't get any autocomplete like I was hoping for. I know that "helm" is enabled, but there is perhaps something else I have to do for autocomplete to work.

projectile for projects

Spacemacs bundled an add-on called projectile. This is pretty nice. Incidentally, "bbatsov" writes a lot of stuff for emacs, including the previously mentioned prelude. People recommend prelude over spacemacs because they feel spacemacs adds could add complexity that could confuse a beginner once they get past the initial learning curve. Ie, spacemacs is good for super beginners, but bad for intermediate users. Or so I've heard.

Anyways, this add some nice functionality. Open a file inside a directory that is under git control, and it establishes all files in the directory as a project. If you have all your projects in a directory like ~/projects, you can teach emacs about all them at once.

M-x projectile-discover-projects-in-directory ~/projects

Once you scan them all, you can run C-c p F to show a list of all known projects and select one to open. Open a file in any project and it puts you in project mode. There are shortcuts to see all files in the project, if you open a shell it drops you in the project directory. You can also quickly switch between recently opened files, perform in-project search and replace.

org-mode

So far, org-mode has been my most positive experience. I wrote up a general outline of a software I'm working on and I found it much easier to write with and organize than when I write in markdown.

It's not markdown, and expecting to be able to use things like markdown code blocks will disapoint you. But it's definitely learnable and I can see myself using it.

You just go ahead and open a file ending in .org and start writing. Headers start with * instead of # but otherwise will be familiar to a markdown user.

The real nice bit of org mode is as you learn the hot keys and easy shortcuts. Key combinations will create new headings and list entry, or you can move an entire section up, down, indent or outdent.

If you type < s <TAB>, it expands to a ‘src’ code block:

#+BEGIN_SRC 

#+END_SRC

I only did some basic outlining, but it seemed workable. I can see emacs/orgmode possibly replacing quiver as my primary notebook. It won't be easy, because quiver has a this nice feature were you just start writing a note and that note may or may not get a title. There is no need to save that note to a file, because it's saved within the quiver datastore. Emacs will want me to save a file for each note.

Probably a next step is to test out the orgmode-journal. After that, dive into orgmode and Getting Things Done. If I can put my omnifocus tasks into emacs and use it as a daily work notebook, then this time invested so far won't be entirely put to waste.

Follow up: I came across this orgmode day planner approach, which seems even more workable than the GTD approach linked above.

bits and bobs for 2017

Abusing my blog to record a few things. This is kind of a year-end wrap-up before Christmas, or a pre-pre New Years Eve post. I am off work till the end of the year, so this is kind of a good week to reflect and prepare for the upcoming year.

I cover a couple different things in this post, find the section you want.

  • Home Security Cameras
  • Financial Tools (quicken, ledger, hledger, beancount)

Security Cameras

tl;dr - I recommend Q-See NVR, refurbished 16-channel for $250 with 2TB drive

I've got a few cameras around my house. Two of them are analog cameras on a cheap LA View dvr bought off of woot (I've replaced it twice). I've ran zoneminder to pull the RTSP stream from it.

I also have some really cheap ESCAM 720p cameras. These things are amazingly cheap, and can be had for under $40. Zoneminder can pull these in as well.

The problem is that I keep finding zoneminder in some broken state. I also am not a fan of the "each frame is a file" apprach. I've started using shinobi. I like that better, but feel limited. Also, several times a week, one of the camera feeds goes dark and I have to re-enable it. I got a Windows PC setup and tried out iSpy. GenisuVision, and Xeoma. None of them have really stood out as a great system.

I decided to try out a more expensive hardware NVR. First I tried an Amcrest NVR, but it couldn't work with any of my existing cameras. Returned. I have a colleague that is a big fan of Q-See Analog DVRs, and the mobile app is pretty slick. I found a good deal on a refurbished 16-channel NVR for $250 with a 2TB hard drive included. This was an instant success. It picked up my ESCAM right away and starts recording.

The mobile app is a dream.


I do get higher resolution images, but when scaled for mobile playback and on a screenshot, obviously the resolution suffers.

Downsides: There is a downside in that accessing it with a web browser sucks - on MacOS it requires Safari and a binary plugin. However, they do have desktop clients for Mac and Windows. Once again, Linux is left out in the cold. I might still end up running Shinobi against the QTSee (or the cams directly) for a simple remote web interface.

The other downside is that I couldn't get my analog dvr added to the system. This isn't too big of a downer, because I'm going to replace those analog 480p cams with the higher quality 720p ESCams (maybe eventually 1080p cams).

Finances

tl;dr - I'm going to switch from Quicken to beancount for double-entry plain-text accounting.

I am planning to get a better handle on my finances in 2018. We're meeting all our bill payments, but I'm definitely not where I want to be with knowing where our money is going and planning for the future. For years, I used nothing substantial. I would do some balancing in spreadsheets, or try to use Mint, and I had Quicken for my business. In 2016, I used hledger for about 4 months to track finances. I really liked the concept of plain text accounting, but ultimately ended up purchasing Quicken and using that through the end of 2016 and all of 2017. I can essentially take a Tuesday and sync all my transactions down and reconcile it. In the world of personal finance, there are several camps, but two big ones are those that prefer syncing historical data (mint, quicken) and those that want you to be budget every transaction in advance, such as You Need A Budget and Every Dollar. There is overlap, especially since YNAB and EveryDollar have added syncing to their offerings. Plain Text Accounting/ledger/hledger fall into the second camp, with no sync capabilities.

That being said, I have used a program called reckon to import my main bank account into hledger. You go onto your bank website, download a CSV for a certain date range, and import it in. Even with Reckon, it was time consuming, and that's what led me to switch to Quicken. However, after using Quicken for 1.5 years, that can get time consuming as well. My family and I have a handful of credit cards, a mortgage, a car loan, checking accounts, savings accounts, 401k, roth ira, college savings, student loans, and a lot of transactions. For the most part, the bulk of our activity centers around a joint checking account. Just maintaining that one account in Quicken is a big time sink. If I don't update every Tuesday, it can take several hours to catch it up. This is because Quicken might mis or duplicate a transaction from the bank. Or something weird will happen. I might have everything caught up perfectly, and then the next time I'm in, I'll discover my balances are off going back 3 months. I'll have to spend time comparing statements and daily balances, going almost transaction by transaction - finding the most recent time when the balances match, then moving forward and fixing whatever caused it to diverge. I'll get things looking correct, then I'll jump forward a month and realize I had missed a divergence somewhere and I'll have to go back. By the time I get the main account squared away, I don't really feel like validating all the other accounts. If my Discover card balance is off, then I'll just have to go in an add a BALANCE ADJUSTMENT entry to bring it in line. I was trying to split my loan payments between principal and interest, but that went by the wayside.

Since I'm spending all of this time on Quicken reading every statement anyways, I decided I wouldn't be loosing much by going back to ledger. In fact, some banks such as US Bank has stopped offering integration with Quicken. So I'm going to start a brand new file and start tracking. This time, I'm going to dig around into web scraping. There are a lot of people out there that write tools to automatically log into their bank and download their CSV files. If I can semi-automate their retrieval, that will be a big win. I will also continue to use quickbooks to at least sync the data, but mainly to keep it as a backup if I decide to stop using ledger. I probably will not use it, but there is a quickbook to ledger converter

While I was reviewing hledger, I found another system called beancount. It is another plaintext double-entry accounting system, but it's designed to have [less trust in the user entering data]
(https://docs.google.com/document/d/1dW2vIjaXVJAf9hr7GlZVe3fJOkM-MtlVjvCO1ZpNLmg/edit?pli=1#heading=h.2ax1dztqboy7). There is a ledger2beancount tool, so I can import any ledger files I had previously or make along the way (though right now I'm looking at a fresh start), and beancount itself provides a solid export to ledger.

I'm going to start with beancount and see where it takes me. I might bounce a bit between beancount and ledger/hledger along the way. Beancount has some really nice web reports, and their example user in the tutorial sounds rather familiar.

Worst case, I can drift back to Quicken.