April 20th 2026 - Things I Worked On

Added creating a blog post

I added a function for quickly creating a blog post. It uses an optional template file to prefill the post.

(setq my/blog-post-template "post-template.org")

The code for creating a blog post. It prefills the post file name with a date prefix because that's how I like to name my files. If this changes in the future I'll extract it into a var.

(defun my/blog-create-post ()
  "Create a new blog post file and prompt for its name.
If the chosen file is empty and `my/blog-post-template' is
defined, populate the new buffer with the template's contents"
  (interactive)
  (let* ((file-date (concat (format-time-string "%Y-%m-%d") "_"))
         (post-file-name (read-string "file name: " file-date))
         (post-file-path
          (expand-file-name post-file-name my/blog-local-directory))
         (template-file-path
          (expand-file-name my/blog-post-template my/blog-local-directory))
         (date (my/blog--create-post-date)))
    (find-file post-file-path)
    (when (and (zerop (buffer-size))
               (boundp 'my/blog-post-template))
        (insert-file-contents template-file-path)
        (goto-char (point-min))
        (while (search-forward "[DATE]" nil t)
          (replace-match date)))
    (goto-char (point-max))))

The code for formatting the template date:

(defun my/blog--create-post-date ()
  "return a string representing the current date in blog post format."
  (let* ((day (string-to-number (format-time-string "%d")))
         (suffix (cond ((memq day '(1 21 31)) "st")
                       ((memq day '(2 22))    "nd")
                       ((memq day '(3 23))    "rd")
                       (t                     "th"))))
    (format-time-string (format "%%B %d%s %%Y" day suffix))))

Added tabs keybindings

Hide tab bar if there is only 1 tab open

(setq tab-bar-show 1)

Key Bindings

(global-set-key (kbd "M-t") 'tab-new)
(global-set-key (kbd "M-w") 'tab-close)
(global-set-key (kbd "M-T") 'tab-undo)

(global-set-key (kbd "A-M-<right>") 'tab-next)
(global-set-key (kbd "A-M-<left>") 'tab-previous)