Tagged with elisp

Elisp to create a pelican blog entry

This is a quick one, mainly just to test out the little bit of elisp code that I wrote to automate the creation of blog posts. Which is what I am doing now. So meta.

Here's the code:

(defvar *blog-root*   "/path/to/pelican/website/content/")
(defvar *blog-author* "Your Name")

(defun strip-nonfile-chars (s)
  (replace-regexp-in-string "[^0-9a-zA-Z_ ]" "" s))

(defun space-to-dash (s)
  (replace-regexp-in-string " " "-" s))

(defun title-to-blog-filename (title)
  (concat (downcase (space-to-dash (strip-nonfile-chars title)))

(defun start-blog-entry ()
  "Creates a new markdown blog entry for pelican"
  (let ((title (read-from-minibuffer "Title of new blog entry? ")))
    (find-file (concat *blog-root* (title-to-blog-filename title)))
    (insert (format (concat "Title: %s\n"
                            "Date: %s\n"
                            "Category: Blog\n"
                            "Author: %s\n\n")
                    (format-time-string "%Y-%m-%d %R")

Fill in the vars, bind the start-blog-entry function to your favorite key sequence, and off you go.

Tagged , , , ,