diff options
| author | Oleg Pykhalov <go.wigust@gmail.com> | 2018-03-22 08:09:27 +0300 |
|---|---|---|
| committer | Oleg Pykhalov <go.wigust@gmail.com> | 2018-03-22 08:13:31 +0300 |
| commit | 3e9cf10ec93c72aea38c9a45eca38270fe4f0f8f (patch) | |
| tree | 7853bede9e60d8f2ea61896f5e461a25ec54c89f /org-todo-file.el | |
| download | emacs-org-todo-file-master.tar.gz | |
Diffstat (limited to 'org-todo-file.el')
| -rw-r--r-- | org-todo-file.el | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/org-todo-file.el b/org-todo-file.el new file mode 100644 index 0000000..c2fac19 --- /dev/null +++ b/org-todo-file.el @@ -0,0 +1,61 @@ +;;; org-todo-file.el --- Manage daily Org todo files. + +;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> + +;; This file is part of Emacs-org-todo-file. + +;; Emacs-org-todo-file 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. +;; +;; Emacs-org-todo-file 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 Emacs-org-todo-file. +;; If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This file provides `org-todo-file-open', the function to create +;; daily Org files. +;; +;; Inspired by <https://gist.github.com/prathik/ae2899ae2c432dcb0cfe966aa3683eb3> +;; and <http://sachachua.com/blog/2018/01/2018-01-23-emacs-news/>. + +;;; Code: + +(defun org-todo-create-directory (directory) + "Creates the todo directory." + (if (file-exists-p directory) (message "Director exists") + (make-directory directory) + (message "Directory created"))) + +(defun org-todo-file-create-todo-file (directory filename) + "Checks if the todo file exists if not creates it." + (org-todo-file-todo-create-directory directory) + (if (file-exists-p filename) (message "Todo exists for the day") + (write-region "" nil filename))) + +(defun org-todo-file-open-todo-file (directory) + "Open a todo file for the current day." + (let ((filename (concat directory "/" + (format-time-string "%Y-%m-%d") ".org"))) + (org-todo-file-create-todo-file directory filename) + (find-file filename))) + +(defun org-todo-file-open-todo-file-interactive () + "Create a daily todo file. + +Track what needs to be done for the day. Plan your day better. + +See what you have accomplished at the end of the day." + (interactive) + (org-todo-file-open-todo-file org-directory)) + +(provide 'org-todo-file) + +;;; org-todo-file.el ends here |
