Minor refactor

master
Kaushal Modi 8 years ago
parent d8848b71a0
commit 20a6f12213
  1. 59
      ox-hugo.el

@ -1367,36 +1367,35 @@ cannot be formatted in Hugo-compatible format."
(org-hugo--plist-get-true-p info :hugo-auto-set-lastmod))
(let* ((curr-time (org-current-time))
(lastmod-str (format-time-string date-fmt curr-time)))
(if (or (> org-hugo-suppress-lastmod-period 0.0)
(< org-hugo-suppress-lastmod-period 0.0))
(let* ((suppress-period (if (< 0.0 org-hugo-suppress-lastmod-period)
org-hugo-suppress-lastmod-period
(- org-hugo-suppress-lastmod-period)))
(date-str (org-hugo--get-date info date-fmt))
(date-time (apply #'encode-time
(mapcar (lambda (el) (or el 0))
(parse-time-string date-str))))
;; It's safe to assume that
;; `current-time' will always be
;; >= the post date.
(delta (float-time
(time-subtract curr-time date-time))))
;; (message "[ox-hugo suppress-lastmod] current-time = %S (decoded = %S)"
;; curr-time (decode-time curr-time))
;; (message "[ox-hugo suppress-lastmod] lastmod-str = %S"
;; lastmod-str )
;; (message "[ox-hugo suppress-lastmod] date-str = %S"
;; date-str)
;; (message "[ox-hugo suppress-lastmod] date-time = %S (decoded = %S)"
;; date-time (decode-time date-time))
;; (message "[ox-hugo suppress-lastmod] suppress-period = %S"
;; suppress-period)
;; (message "[ox-hugo suppress-lastmod] delta = %S" delta)
(when (>= delta suppress-period)
lastmod-str))
(progn
;; (message "[ox-hugo suppress-lastmod] not suppressed")
lastmod-str))))
(if (= 0.0 org-hugo-suppress-lastmod-period)
(progn
;; (message "[ox-hugo suppress-lastmod] not suppressed")
lastmod-str)
(let* ((suppress-period (if (< 0.0 org-hugo-suppress-lastmod-period)
org-hugo-suppress-lastmod-period
(- org-hugo-suppress-lastmod-period)))
(date-str (org-hugo--get-date info date-fmt))
(date-time (apply #'encode-time
(mapcar (lambda (el) (or el 0))
(parse-time-string date-str))))
;; It's safe to assume that
;; `current-time' will always be
;; >= the post date.
(delta (float-time
(time-subtract curr-time date-time))))
;; (message "[ox-hugo suppress-lastmod] current-time = %S (decoded = %S)"
;; curr-time (decode-time curr-time))
;; (message "[ox-hugo suppress-lastmod] lastmod-str = %S"
;; lastmod-str )
;; (message "[ox-hugo suppress-lastmod] date-str = %S"
;; date-str)
;; (message "[ox-hugo suppress-lastmod] date-time = %S (decoded = %S)"
;; date-time (decode-time date-time))
;; (message "[ox-hugo suppress-lastmod] suppress-period = %S"
;; suppress-period)
;; (message "[ox-hugo suppress-lastmod] delta = %S" delta)
(when (>= delta suppress-period)
lastmod-str)))))
;; Else.. do nothing.
(t
nil)))

Loading…
Cancel
Save