A Bit of Elisp
10 January 2022

As it is still early in the year I am thinking about ways to get a few percent improvements in my work flow. Nothing major just reduce resistance barriers to doing certain things.

So I wrote a bit of elisp!

First the problem. I don't blog much and I would like to do it more. A resistance point is not coming up with ideas or even writing the post. It is from actually creating a new post and uploading it. Weird!

The actual act of creating a new markdown file. So to blog more I need to automate this.

I write all my posts in markdown and have a couple of custom scripts one python and one a shell script that process these files into the statically generated site you see before you.

The other pain point is manually uploading the statically generated site. That's for another night!

So as I use emacs I should solve this problem in elisp. Here is my first, and currently only, attempt at it.

  (defun spiderfl-frontmatter(title tags)
  "Insert date at top of file"
  (goto-char (point-min))
  (goto-char (point-min))
  (insert (concat "---\ntitle: " title) )
  (insert "date: " (format-time-string "%d %B %Y"))
  (insert (concat "tags: [" tags "]"))
  (insert "---")

(defun spiderfl-new-blog-post(post-name tags)
  "Create and set up na new post for spiderflock website"
  (interactive "sNew post: \nsTags (comma sep):")
  (let ((full-name (concat "~/code/projects/spiderflock/site/posts/" post-name ".md")))
    (message "creating post: %s" full-name)
    (find-file full-name)
    (spiderfl-frontmatter post-name tags)

It is not pretty that is for sure although it is for personal use so I don't mind hard coding strings. It took about an hour to figure out. I really don't know elisp so I am happy with the time and the results. Yep it doesn't cover edge cases but hey it is just for me.

Of course reducing friction does mean I may blog more and that means more low quality posts.

As an aside I still have voyagingmind.com so I can always repurpose that if I suddenly start writing quality content along side the noise of my life. Although then I have to make a decision on the content already there!

Further possible alterations to Spiderflock.

At that point it would be time to focus on creating posts rather than the site generation. Revisit in a few months to see if there are any further pain points.

Update: Turns out netlify cmd tool makes it really simple to upload your site. Wish I have look at it years ago.

Making it usable from emacs was also very easy:

(defun spiderfl-deploy-site()
  (let ((default-directory "~/code/projects/spiderflock/"))
    (shell-command "netlify deploy --dir=out --prod")

I think I may have just got addicted to using elisp to make my life easier!