It’s been a while since we’ve had a EmacsGolf challenge but I just ran across this post from Cameron Saul with the perfect problem for us. Here’s the problem: Saul is writing some Java code that looks like this
TextView textViewRoute = (TextView)convertView.findViewById(R.id.textViewRoute); TextView textViewDirection = (TextView)convertView.findViewById(R.id.textViewDirection); TextView textViewStartStop = (TextView)convertView.findViewById(R.id.textViewStartStop); TextView textViewStartDist = (TextView)convertView.findViewById(R.id.textViewStartDist); TextView textViewStartPrediction = (TextView)convertView.findViewById(R.id.textViewStartPrediction); TextView textViewEndStop = (TextView)convertView.findViewById(R.id.textViewEndStop); TextView textViewEndDist = (TextView)convertView.findViewById(R.id.textViewEndDist); TextView textViewEndPrediction = (TextView)convertView.findViewById(R.id.textViewEndPrediction);
Notice that each line is the same except for a single symbol that is repeated twice. Saul says he wouldn’t have to write all this boilerplate if he were writing in a language that didn’t hate fun. My first thought was, “or if you had a decent editor.” So our job is to show Saul how to leverage Emacs to make this a trivial problem. You’ll appreciate the challenge more when you see his solution.
Update: Fuco points out that I didn’t specify a starting buffer. Let’s assume that the buffer is empty to begin with.