Emacs skeleton for hugo, updated

A followup to this post on emacs and hugo. One thing that bugged me about that script was that I couldn’t get the timestamp right. It turns out the reason is described by Xah in this post at ergoemacs.

Note, for the time zone offset, both the formats 「hhmm」 and 「hh:mm」 are valid ISO 8601. However, Atom Webfeed spec seems to require 「hh:mm」.

Here’s the correct timestamp function from Xah:

(defun current-date-time-string ()
  "Returns current date-time string in full ISO 8601 format.
Example: 「2012-04-05T21:08:24-07:00」.

Note, for the time zone offset, both the formats 「hhmm」 and 「hh:mm」 are valid ISO 8601. However, Atom Webfeed spec seems to require 「hh:mm」."
  (concat
   (format-time-string "%Y-%m-%dT%T")
   ((lambda (ξx) (format "%s:%s" (substring ξx 0 3) (substring ξx 3 5))) (format-time-string "%z")) )
   )

And the corrected skeleton:

(define-skeleton kjs/yaml-skeleton
  ""
  ""
  "---
title: \"\"
description: \"\"
date: \""
(current-date-time-string)
"\"
tags: []
---

")

Advertisements