Publish draft moved

This commit is contained in:
Willem van den Ende
2025-05-04 18:28:03 +01:00
parent b350812edb
commit 8bb1bbf233
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -5,7 +5,7 @@
(defun qwan/copy-filename ()
"Push the file name of the currently visited buffer to the kill ring."
"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"))
@@ -13,3 +13,17 @@
(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)))