journaling.art

July 7th, 2013

I use Emacs, and one of the key roles I use Emacs for is journaling — keeping a log of what I do, as regards to work (I could do a better job of personal journaling, but I wouldn’t need or use Emacs for that, I’d probably put that in a paper-based journal). For computer work — whether it’s day-job related, freelance-related, or personal-project related, tracking what I did and when can be invaluable when I try to recreate a setup or recall what I was doing last month when project X started working/failing.

 

For years I used a simple journal, original built by someone else, that I had enhanced. It’s up at github, but I’ve recently (April/May 2013) started using org-mode and I am happier (sorry, old-journal-code!).

 

The below extract is taken from my org-init.el file, and needs some tweaking. They were inspired by Journaling with Emacs OrgMode. There is still some reliance on global-functions (aren’t they all, in Emacs-lisp?) from my old journal-mode, but they do the job of opening a new file where I need it. Then org-mode does all the rest.

(global-set-key "\C-c\M-jw" 'org-journal-work)
(global-set-key "\C-c\M-jp" 'org-journal-personal)
(global-set-key "\C-c\M-jf" 'org-journal-freelance)
(defun org-journal-work ()
  "Send work-based directory to org-journal for day-job journaling."
  (interactive)
  (org-journal "D:/home/Personal/org-journal-work/" "work"))
 
(defun org-journal-personal ()
  "Send dropbox-based directory to org-journal for personal journaling."
  (interactive)
  (org-journal "D:/Dropbox/Emacs/org/org-journal-personal/" "personal"))
 
 
(defun org-journal-freelance ()
  "Send dropbox-based directory to org-journal for freelance journaling."
  (interactive)
  (org-journal "D:/Dropbox/Emacs/org/org-journal-freelance/" "freelance"))
 
(defun org-journal (&optional root suffix)
  "Open .org file named after today's date, format YYYY-MM-DD-Day.jnl,
in subdirectory named in variable root, set in ~/.emacs,
else as defined below.
"
  (interactive)
  (progn
    (setq root (or root "D:/Dropbox/Emacs/org-journal/"))
    (setq default-directory (year-month-dir root))
    (setq todays-date (format-time-string "%Y-%m-%d-%a" nil))
    (let ((sfx (if suffix (concat "." suffix) "")))
    (setq filename (concat todays-date sfx ".org")))
 
    (list (read-file-name
"Open journal-org file: " default-directory filename nil filename)))
 
  (find-file filename) ;; switch to buffer if exists, or open file
 
  ;; following lines based on http://metajack.im/2009/01/01/journaling-with-emacs-orgmode/
  (widen)
  ;; heading is not working correctly if it is the result of (today)
  (let ((isearch-forward t) (heading (get-today)))
        (beginning-of-buffer)
        (unless (org-goto-local-search-headings heading nil t)
          ((lambda ()
             (org-insert-heading)
             (insert heading)
             (insert "\n\n"))))
        (end-of-buffer)
        ;; (org-show-entry)
        (widen)
        ;; (org-narrow-to-subtree)
        ;; (end-of-buffer)
        ;; (backward-char 2)
        ;; (unless (= (current-column) 2)
        ;; (insert "\n\n "))
))

no comments yet.

comments RSS trackBack identifier URI

leave a comment

  • syndicate

    • Add to MyMSN
    • Add to MyYahoo
    • Add to Google Reader
    • Add to Bloglines
    • Add to Newsgator
    • Add to NewsIsFree