From 13a89331feb7b8adb03d765df3c99c1cbb48e89a Mon Sep 17 00:00:00 2001 From: Peng Li Date: Mon, 10 Apr 2017 23:59:17 +0800 Subject: [PATCH] Add blog-tool.el file --- blog-tool.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ my-publish.el | 2 -- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 blog-tool.el diff --git a/blog-tool.el b/blog-tool.el new file mode 100644 index 0000000..0590733 --- /dev/null +++ b/blog-tool.el @@ -0,0 +1,55 @@ +;;; blog-tool.el --- Some utility functions of blog -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Peng Li + +;; Author: Peng Li +;; Keywords: lisp + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Some functions to create post/page + +;;; Code: + +(require 'org) + +(defconst blog-root-dir (file-name-directory (buffer-file-name))) + + +(defun blog-tool-create-post () + "Create a post." + (interactive) + (let ((title (read-from-minibuffer "Title:")) + (date (format-time-string "%Y-%m-%d")) + (filename "")) + (setq filename + (concat blog-root-dir "/posts/" + date "-" + (replace-regexp-in-string " " "-" title) + ".org")) + (find-file filename) + (insert (concat + "#+TITLE: " title "\n" + "#+AUTHOR: " my-name "\n" + "#+EMAIL: " my-email "\n" + "#+DATE: " date " " (format-time-string "%A") "\n" + "\n")))) + + + + +(provide 'blog-tool) +;;; blog-tool.el ends here diff --git a/my-publish.el b/my-publish.el index a8562f9..f9e0da0 100644 --- a/my-publish.el +++ b/my-publish.el @@ -24,8 +24,6 @@ ;;; Code: -;; (defconst root-dir "~/Private/blog/") - (require 'org) (require 'ox-publish) (require 'htmlize) -- 2.11.0