When a task require some structure, spans on multiple days or simply needs to be recorded, I create a file for it following a simple structure. It needs a "plan" and a "body". When I invoke this `nc-new-task` script, I simply enter the title with hyphens (eg: "create-telemetry-events") and a new file named "create-telemetry-events.org" is created with the content of a template that has everything I need to start planning the task.
(defun get-file-content-as-string (filepath)
"Returns a file content as a string"
(with-temp-buffer
(insert-file-contents filepath)
(buffer-string)))
(defun nc-new-task ()
"Prompts a hyphen title for the task filename"
(interactive)
(let* (
(title (read-string "Enter title: "))
(directory "~/Dropbox/org_sync/agenda/tasks/")
(today (format-time-string "%Y%m%d"))
(filename (format "%s-%s.org" today title))
(filepath (concat directory filename))
)
(with-temp-file filepath)
(write-region (get-file-content-as-string "~/.emacs.d/nc/nc-new-task-template.org") nil filepath)
(find-file-other-window filepath)
))
(defadvice nc-new-task(after do-something)
"Move at the beginning, expand the org file and move to the end"
(with-current-buffer (current-buffer)
(set-window-point
(get-buffer-window (current-buffer) 'visible)
(point-min))
(org-cycle)
(set-window-point
(get-buffer-window (current-buffer) 'visible)
(- (point-max) 1))))
(ad-activate 'nc-new-task)
(provide 'nc-new-task)