A quick little update to blogmore.el to fix a couple of issues introduced by the new YAML-parsing approach to reading frontmatter; both pretty much stemming from how falsy values are handled.
Simply put, both boolean false values, and also empty values (something that could commonly happen with tags and series) would end up showing up in the frontmatter as null. This release handles that situation.
Also, under the hood, I cleaned up some repeated boilerplate related to how the cached dump calls to BlogMore took place. The code for categories, tags and series data was almost exactly the same, save for the actual name of the thing being dumped. So I turned it all into a macro:
(defmacro blogmore--cache-dump (dump-name)
"Generate a function to get DUMP-NAME from BlogMore, with caching."
(let ((cache-name (intern (format "blogmore--current-%s-cache" dump-name)))
(getter-name (intern (format "blogmore--current-%s" dump-name))))
`(progn
(defvar ,cache-name nil
,(format "Cache for the list of %s from existing posts." dump-name))
(defun ,getter-name ()
,(format "Get a list of %s from existing posts." dump-name)
(or ,cache-name (setq ,cache-name (blogmore--list-of ,(symbol-name dump-name))))))))
and now the defvar that creates the variable that holds the cache, and the defun that creates the getter function for the data, are reduced to this for all three collections of values:
(blogmore--cache-dump categories)
(blogmore--cache-dump tags)
(blogmore--cache-dump series)
Sure, I probably could have done all of this in a single global, a central getter function, and a hash table, but the macro approach feels so much more elegant, and more... lispy.
Have a comment or query about this post? Feel free to drop me a line about it.