;;; qwan/qwan-blog.el -*- lexical-binding: t; -*- ;;; (provide 'qwan-blog) (defun qwan/copy-filename () "Push the file name of the currently visited buffer to the kill ring. Useful for markdown links" (interactive) (unless buffer-file-name (error "The current buffer doesn't visit a file")) (kill-new buffer-file-name) (message "Copied %s" buffer-file-name)) (defun qwan/publish-draft () "Publish this in the _posts folder" (interactive) (let* ((dest-dir "../_posts") (current-file (buffer-file-name)) (blogpost-name (file-name-nondirectory current-file)) (current-date (format-time-string "%Y-%m-%d")) (new-filename (concat current-date "-" blogpost-name)) (source-path current-file) (dest-path (concat dest-dir "/" new-filename))) (rename-file source-path dest-path) (set-visited-file-name dest-path) (set-buffer-modified-p nil) (message "Successfully moved %s to %s" source-path dest-path)))