One Emacs SML Workflow

Being partial to the full-REPL-reboot style of development (ala DrRacket) for most situations I wanted the same thing in Emacs with sml-mode. The value add is that you know all of your files are saved and that your environment is in a fresh and known state. I came up with this:

(defun gcr/sml-eval-buffer ()
  "Intelligently evaluate a SML buffer."
  (interactive)
  (gcr/save-all-file-buffers)
  (let ((sml-process (get-process "sml")))
    (when sml-process
      (quit-process sml-process)))
  (sleep-for 0.25)
  (let ((sml-buffer (get-buffer "*sml*")))
    (when sml-buffer
      (kill-buffer sml-buffer)))
  (sml-prog-proc-load-file buffer-file-name t))

Only to be delighted (though not surprised) to find yet another nearly identical approach here by wenjun.yan:

(defun isml ()
  "If sml repl exists, then restart it else create a new repl"
  (interactive)
  (when (get-buffer "*sml*")
    (with-current-buffer "*sml*"
      (when (process-live-p "sml")
        (comint-send-eof)))
    (sleep-for 0.2))
  (sml-run "sml" ""))

My urge to attain Emacs Comint mastery only grows.

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