summaryrefslogtreecommitdiff
path: root/org-todo-file.el
blob: c2fac19821ef87b487d79da3fc0136b12d9e0b12 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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