Add blog-tool.el file
authorPeng Li <seudut@gmail.com>
Mon, 10 Apr 2017 15:59:17 +0000 (23:59 +0800)
committerPeng Li <seudut@gmail.com>
Mon, 10 Apr 2017 15:59:17 +0000 (23:59 +0800)
blog-tool.el [new file with mode: 0644]
my-publish.el

diff --git a/blog-tool.el b/blog-tool.el
new file mode 100644 (file)
index 0000000..0590733
--- /dev/null
@@ -0,0 +1,55 @@
+;;; blog-tool.el --- Some utility functions of blog  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2017  Peng Li
+
+;; Author: Peng Li <seudut@gmail.com>
+;; 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 <http://www.gnu.org/licenses/>.
+
+;;; 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
index a8562f9..f9e0da0 100644 (file)
@@ -24,8 +24,6 @@
 
 ;;; Code:
 
-;; (defconst root-dir "~/Private/blog/")
-
 (require 'org)
 (require 'ox-publish)
 (require 'htmlize)