Deleting trailing whitespace for auto savers

real-auto-save is a great package if you like that sort of thing. For example, I like every file to always be saved without me worrying about doing it myself, so I stick with the default save occurring every 10 seconds. A really nice function to call on write-file-hooks is delete-trailing-whitespace, but, with 10s saves this means that in the middle of typing you have spaces eaten and this is clearly unacceptable!
Here is an attempt at a tweaked cleanup function that cleans up every line in the file but for the current line on which your cursor sits:

(defun gcr/delete-trailing-whitespace ()
  "Apply delete-trailing-whitespace to everything but the current line."
  (interactive)
  (let ((first-part-start (point-min))
        (first-part-end (point-at-bol))
        (second-part-start (point-at-eol))
        (second-part-end (point-max)))
    (delete-trailing-whitespace first-part-start first-part-end)
    (delete-trailing-whitespace second-part-start second-part-end)))

Cask for the truly impatient

Thanks to some kind Emacsers I’m now in the modern age using Cask, and what ease it brings to using Emacs. It is truly a joy; anyone not using Emacs for fear of difficulty pulling in packages can let go of their hesitation. It is as easy as writing one config file, installing the packages, and adding a couple lines to your Emacs init script. Here are the basic steps:

  • Clone the cask repo.
  • Add the bin dir to your path.
  • Create a file named Cask, add it to your VCS, and create a link to it from your .emacs.d directory
  • Add a repo and packages to the file.
  • From your .emacs.d directory, run ‘cask’
  • Add the cask load and init to your init file.
  • Start Emacs.

Excellent work by that team.

Used Motorcycle Checklist Email Template

Here is a template that I have found successful in minimizing the hassle for a motorcycle seller and maximizing the information summary for a motorcycle buyer. Credit is due to those who helped me with this; foul is due to me for any mistakes. It follows:
Hello,
Regarding your motorcycle for sale, I put together the following questions to make it pleasant both for you as a seller and me as a buyer:
In case I want to set up an appointment to test-ride and purchase the bike, at what phone number(s) are you reachable throughout the day?
My cell phone number is ###-###-####.
Why are you selling it?
Do you have the title?
Is the title in your name?
Is there a lien against the title?
Does the VIN on the bike match the VIN on the title?
Has this bike been rebuilt?
Did you follow the standard maintenance schedule for the motorcycle?
Are service records available?
If so for how long?
When is the last time that the the brake pads, hoses, or any of the fluids were changed (and which ones)?
When is the next service due?
What year is it?
How many miles does it have?
Has it ever been tipped over?
Does it come with any after-market items:
* Body (seat, fender extension, foot pegs, levers, tip over bars, handlebar risers, passenger backrest, heated grips, throttle lock, tank bra)?
* Braking(lines, pads, rebuilds, rotors)?
* Electrical(battery, horn, power outlet for heated gear)?
* Engine/Transmission(air filter, seals, cooling, spark plugs, exhaust)?
* Fuel System(fuel tank quick release, carbs, jet kit, filter)?
* General(vendor owners manual, Clymer manual, cover, wheel lock (any method))?
* Hardware(stainless screws)?
* Lighting(mounts, light kits, dual-headlight, tail lights)?
* Luggage(top case mount, top case (Givi etcetera), tankbag?
* Suspension(shocks, fork brace, )?
* Windshield(Givi, Rifle, lip add-on)?
Do you allow a test-ride before purchasing the bike?
Do you accept a cashiers check?
How much are you asking?
Is that negotiable?
Best wishes,
firstname lastname

Interactive Image Generation with Racket

Not sure whether I blogged about this or not already, but I sure could not find it so here goes.
A while back my buddy Bruce needed some randomly generated images in a particular format for a project. The specs were more of a “I’ll know it when I see it” kind of thing so I volunteered to help out and have some fun with Racket in the process.
The nifty part is that during development and also use you may preview the images directly inside of DrRacket. This feature made the work so, so fun (other editors do this, too).
Here is a copy of the code. Try running manual.scm and the image will show up in the REPL. If you run automatic.scm it will dump the image in /tmp.

Pro Git Book Review

As a Subversion master-user I was hoping for a lot from \_Pro Git and was rewarded greatly. The author gives Git a fair shake without throwing Subversion under the bus. He does a great job teaching not just the tools, but the culture and “how to think” the Git way. The latter is devoid in literally every tutorial I’ve seen online, and I’m not sure it is even possible to sum it up in anything less than the entirety of this book. The length is just fine, chapter are brief, terse, light, and information packed. The multitude of tools and approaches revealed in the book make it worth reading, and buying, too. Although the book is free online, the author should be rewarded with a purchase. Before reading this I spent 5 months using Git with the typical docs: man pages, stackoverflow.com, and random posts. This book pulled everything together, it was kind of like sitting with a hacker who really groks it all (as you will see in the last chapter), and that alone is priceless. 5/5

Addendum: the formatting and graphics in the Kindle version look excellent (forgot to mention this key point as not all Kindle books look this great).