[Emacs] Generalize kat's org-mode journal system so I can use it too
This commit is contained in:
@@ -58,41 +58,11 @@ This makes evil-mode play nice with org-fc
|
|||||||
(file+datetree "~/org/weekly_reviews.org")
|
(file+datetree "~/org/weekly_reviews.org")
|
||||||
(file "~/org/weekly_review_template.org")))))
|
(file "~/org/weekly_review_template.org")))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** Journal
|
||||||
** Daily Journal Entries
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun imalison:journal-filepath-for-date (&optional date)
|
(setq imalison:journal-template-filepath
|
||||||
(interactive (list (org-read-date)))
|
(imalison:join-paths org-directory "templates" "daily-journal-template.org"))
|
||||||
(let ((date-str (or date (format-time-string "%Y-%m-%d"))))
|
|
||||||
(imalison:join-paths
|
|
||||||
org-directory "journal" (concat date-str ".org"))))
|
|
||||||
|
|
||||||
(defun imalison:open-todays-org-journal ()
|
|
||||||
(interactive)
|
|
||||||
(imalison:open-org-journal (format-time-string "%Y-%m-%d")))
|
|
||||||
|
|
||||||
(defun imalison:get-journal-template ()
|
|
||||||
(with-temp-buffer
|
|
||||||
(insert-file-contents (imalison:join-paths org-directory "templates" "daily-journal-template.org"))
|
|
||||||
(buffer-string)))
|
|
||||||
|
|
||||||
(defun imalison:open-org-journal (&optional date)
|
|
||||||
(interactive (list (org-read-date nil nil nil "Select a date:")))
|
|
||||||
(let* ((filepath (imalison:journal-filepath-for-date date))
|
|
||||||
(file-existed (file-exists-p filepath))
|
|
||||||
(date-str (or date (format-time-string "%Y-%m-%d")))
|
|
||||||
(time-vals (append '(0 0 0) (nthcdr 3 (parse-time-string date-str))))
|
|
||||||
(original-format-time-string (symbol-function 'format-time-string)))
|
|
||||||
(find-file filepath)
|
|
||||||
(when (not file-existed)
|
|
||||||
(cl-letf (((symbol-function 'format-time-string)
|
|
||||||
(lambda (format-string &optional _time _universal)
|
|
||||||
(funcall original-format-time-string format-string (apply #'encode-time time-vals)))))
|
|
||||||
(insert (org-capture-fill-template (imalison:get-journal-template)))))))
|
|
||||||
|
|
||||||
(bind-key "C-c j" 'imalison:open-todays-org-journal)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Insert a link to a task selected from agenda
|
** Insert a link to a task selected from agenda
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun imalison:insert-link-to-agenda ()
|
(defun imalison:insert-link-to-agenda ()
|
||||||
|
|||||||
@@ -594,6 +594,43 @@ specific time, they should appear in the agenda at that time!
|
|||||||
(defun imalison:make-org-linked-todo-template ()
|
(defun imalison:make-org-linked-todo-template ()
|
||||||
(imalison:make-org-todo-template "[#C] %? %A"))
|
(imalison:make-org-todo-template "[#C] %? %A"))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
*** Journal
|
||||||
|
#+begin_src emacs-lisp :tangle org-config-config.el
|
||||||
|
(defun imalison:journal-filepath-for-date (&optional date)
|
||||||
|
(interactive (list (org-read-date)))
|
||||||
|
(let ((date-str (or date (format-time-string "%Y-%m-%d"))))
|
||||||
|
(imalison:join-paths
|
||||||
|
org-directory "journal" (concat date-str ".org"))))
|
||||||
|
|
||||||
|
(defun imalison:open-todays-org-journal ()
|
||||||
|
(interactive)
|
||||||
|
(imalison:open-org-journal (format-time-string "%Y-%m-%d")))
|
||||||
|
|
||||||
|
(defvar imalison:journal-template-filepath
|
||||||
|
(imalison:join-paths org-directory "capture-templates" "journal.org"))
|
||||||
|
|
||||||
|
(defun imalison:get-journal-template ()
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents imalison:journal-template-filepath)
|
||||||
|
(buffer-string)))
|
||||||
|
|
||||||
|
(defun imalison:open-org-journal (&optional date)
|
||||||
|
(interactive (list (org-read-date nil nil nil "Select a date:")))
|
||||||
|
(let* ((filepath (imalison:journal-filepath-for-date date))
|
||||||
|
(file-existed (file-exists-p filepath))
|
||||||
|
(date-str (or date (format-time-string "%Y-%m-%d")))
|
||||||
|
(time-vals (append '(0 0 0) (nthcdr 3 (parse-time-string date-str))))
|
||||||
|
(original-format-time-string (symbol-function 'format-time-string)))
|
||||||
|
(find-file filepath)
|
||||||
|
(when (not file-existed)
|
||||||
|
(cl-letf (((symbol-function 'format-time-string)
|
||||||
|
(lambda (format-string &optional _time _universal)
|
||||||
|
(funcall original-format-time-string format-string (apply #'encode-time time-vals)))))
|
||||||
|
(insert (org-capture-fill-template (imalison:get-journal-template)))))))
|
||||||
|
|
||||||
|
(bind-key "C-c j" 'imalison:open-todays-org-journal)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
*** Templates
|
*** Templates
|
||||||
#+begin_src emacs-lisp :tangle org-config-config.el
|
#+begin_src emacs-lisp :tangle org-config-config.el
|
||||||
(use-package org-capture
|
(use-package org-capture
|
||||||
@@ -632,7 +669,15 @@ SCHEDULED: %^t
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CREATED: %U
|
:CREATED: %U
|
||||||
:STYLE: habit
|
:STYLE: habit
|
||||||
:END:")))
|
:END:"))
|
||||||
|
(add-to-list 'org-capture-templates
|
||||||
|
'("w" "Weekly Planning and Self Assesment"
|
||||||
|
plain
|
||||||
|
(function (lambda ()
|
||||||
|
(find-file (let ((date (format-time-string "%Y-%m-%d")))
|
||||||
|
(expand-file-name (concat date ".org")
|
||||||
|
"~/org/weekly")))))
|
||||||
|
(file "~/org/capture-templates/weekly.org"))))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Babel
|
** Babel
|
||||||
#+begin_src emacs-lisp :tangle org-config-config.el
|
#+begin_src emacs-lisp :tangle org-config-config.el
|
||||||
|
|||||||
Reference in New Issue
Block a user