diff options
| -rw-r--r-- | guix.scm | 76 | ||||
| -rw-r--r-- | org-todo-file.el | 61 |
2 files changed, 137 insertions, 0 deletions
diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..e9621ad --- /dev/null +++ b/guix.scm @@ -0,0 +1,76 @@ +;;; guix.scm --- Guix package for Emacs-org-todo-file + +;; 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 contains Guix package for development version of +;; emacs-org-todo-file. To build or install, run: +;; +;; guix build --file=guix.scm +;; guix package --install-from-file=guix.scm + +;; The main purpose of this file though is to make a development +;; environment for building emacs-org-todo-file: +;; +;; guix environment --pure --load=guix.scm + +;;; Code: + +(use-modules ((guix licenses) #:prefix license:) + (guix build utils) + (guix build-system emacs) + (guix gexp) + (guix git-download) + (guix packages) + (ice-9 popen) + (ice-9 rdelim)) + +(define %source-dir (dirname (current-filename))) + +(define (git-output . args) + "Execute 'git ARGS ...' command and return its output without trailing +newspace." + (with-directory-excursion %source-dir + (let* ((port (apply open-pipe* OPEN_READ "git" args)) + (output (read-string port))) + (close-port port) + (string-trim-right output #\newline)))) + +(define (current-commit) + (git-output "log" "-n" "1" "--pretty=format:%H")) + +(define emacs-org-todo-file + (let ((commit (current-commit))) + (package + (name "emacs-org-todo-file") + (version (string-append "0.0.1" "-" (string-take commit 7))) + (source (local-file %source-dir + #:recursive? #t + #:select? (git-predicate %source-dir))) + (build-system emacs-build-system) + (home-page "https://github.com/wigust/emacs-org-todo-file") + (synopsis "Create new daily Org files") + (description "This package provides an Emacs function to create +daily Org todo files.") + (license license:gpl3+)))) + +emacs-org-todo-file + +;;; guix.scm ends here 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 |
