Using a File as a Template in Emacs

Minor Automation to Facilitate End of Week Reporting

At Forem, one of my responsibilities is writing up an end of week status report for the projects assigned to my team. Sometimes I delegate that responsibility (if there’s someone with more information for the week’s update).

I’ve found that I enjoy writing these reports. I spend about thirty minutes per project writing up the report. During that time I gather what’ve we done, what we’re planning to do next week, and write up any risks to the project.

Earlier this week, Allison, our head of engineering, provided an adjusted template to help facilitate writing consistent reports for tracking issues.

I figured I’d go ahead and automate Emacs 📖 to help me use that template.

Forem End of Week Status Update

The following emacs-lisp creates a buffer, from an existing template, to help kick off writing my end of week status reports.

(defvar jf/forem-eow-template
  "~/git/forem-internal-eng/.github/epic-progress-update.md"
  "The location of the template to use for end of week reporting.")

(cl-defun jf/forem-prepare-end-of-week-status-update (&key (template jf/forem-eow-template))
  "Create a buffer for writing up an Engineering End of Week Status Update.

TODO: Consider pulling down the latest version of that template."
  (interactive)
  (let* ((body (with-temp-buffer
		 (insert-file-contents template)
		 (buffer-string)))
	 (eow-buffer (get-buffer-create "*Forem EoW Update*")))
    (switch-to-buffer eow-buffer)
    (erase-buffer)
    (markdown-mode)
    (hammerspoon-edit-minor-mode)
    (insert body)
    (beginning-of-buffer)
    (kill-line)
    (insert (concat "## " (format-time-string "%Y-%m-%d")))))

Details

The above code:

  • copies the contents of the template
  • creates a new buffer titled *Forem EoW Update*
  • sets it as Markdown type content
  • enables Hammerspoon (see below)
  • pastes the contents into the new buffer
  • sets the first line to today’s date

I use Hammerspoon and the editWithEmacs.spoon to help me use Emacs for editing Emacs text areas. I wrote about that in Send Anything in OS X to Emacs for Editing. .

Conclusion

This little bit of automation ensures that I’m using the consistent template and am writing using my favorite computer tool. It’s a quick bit of automation, but one that I need to leverage at least once a week for the foreseeable future.