995ed9fd372dd00e8a35b15569d3a9af26ebc74b
[james/home/home-etc.git] / .emacs.d / config / org.el
1 ;; org mode
2 (require 'org)
3 ;; required in upper level, before this file gets sourced.
4 ;; The idea is I don't need this if I don't have my org files.
5 (load-library "org-compat")
6 ;;(require 'org-install)
7 ;;(require 'org-protocol)
8 ;;(require 'org-publish)
9 (require 'org-feed)
10 ;; I manage org files myself.
11 ;; I really don't wish work files to end up on personal devices.
12 (add-hook 'org-mode-hook
13           (lambda()
14             (org-defkey org-mode-map "\C-c[" 'undefined)
15             (org-defkey org-mode-map "\C-c]" 'undefined))
16           'append)
17
18 ;; I want to get all org files in a directory
19 ;; http://stackoverflow.com/questions/17215868/recursively-adding-org-files-in-a-top-level-directory-for-org-agenda-files-take
20
21 (defun jr/load-org-agenda-files-recursively (dir)
22   "Find all directories in DIR."
23   (unless (file-directory-p dir) (error "Not a directory `%s'" dir))
24   (unless (equal (directory-files dir nil org-agenda-file-regexp t) nil)
25     (add-to-list 'org-agenda-files dir))
26   (dolist (file (directory-files dir nil nil t))
27     (unless (member file '("." ".."))
28       (let ((file (concat dir file "/")))
29         (when (file-directory-p file)
30           (jr/load-org-agenda-files-recursively file))))))
31
32 (when (file-directory-p "~/doc/org")
33   (jr/load-org-agenda-files-recursively "~/doc/org/" )) ; trailing slash required
34 ;;(add-to-list 'org-agenda-files '"~/")
35 ;;(jr/load-org-agenda-files-recursively "~/.etc/")
36 ;;(jr/load-org-agenda-files-recursively "~/src/" ) ; trailing slash required
37 ;;(jr/load-org-agenda-files-recursively "~/src01/" ) ; trailing slash required
38 (when (file-directory-p "~/doc/org")
39   (setq org-directory "~/doc/org"))
40
41 ;; (if (file-exists-p "~/doc/org")
42 ;;     (if (boundp 'org-agenda-files)
43 ;;         (add-to-list 'org-agenda-files '"~/doc/org")
44 ;;       (setq org-agenda-files  '("~/doc/org"))))
45 ;; (if (file-exists-p "~/doc/org/lowes")
46 ;;     (add-to-list 'org-agenda-files '"~/doc/org/lowes"))
47 ;; (if (file-exists-p "~/src/wiki/jamestechnotes.com")
48 ;;     (add-to-list 'org-agenda-files '"~/src/wiki/jamestechnotes.com"))
49 ;; (if (file-exists-p "~/src")
50 ;;     (add-to-list 'org-agenda-files '"~/src"))
51 ;; (if (file-exists-p "~/src01")
52 ;;     (add-to-list 'org-agenda-files '"~/src01"))
53 ;;k(setq org-mobile-files (org-agenda-files))
54
55 ;; setup for MobileOrg
56 ;;(cond ((file-exists-p "~/doc/org")
57 ;;       (setq org-directory "~/doc/org")
58 ;;       (setq org-mobile-directory "~/doc/MobileOrg")
59 ;;       (setq org-mobile-inbox-for-pull "~/doc/org/MobileInbox.org"))
60 ;;      (t
61 ;;       (setq org-directory "~")
62 ;;       (setq org-mobile-directory "~/tmp")
63 ;;       (setq org-mobile-inbox-for-pull "~/tmp/MobileInbox.org")))
64
65 ;;(setq org-file-apps org-file-apps-defaults-gnu)
66 ;;(delete '("\\.pdf\\'" . default) org-file-apps)
67 ;;(add-to-list 'org-file-apps '(("\\.pdf\\'" . "evince \"%s\"")))
68
69 ;; setup todo things.
70 (setq org-todo-keywords
71       '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
72         (sequence "NEW" "IN-PROGRESS" "|" "DONE") ;; jira
73         (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE")))
74
75 (setq org-use-fast-todo-selection t)
76 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
77
78 (setq org-todo-state-tags-triggers
79       (quote (("CANCELLED" ("CANCELLED" . t))
80               ("WAITING" ("WAITING" . t))
81               ("HOLD" ("WAITING" . t) ("HOLD" . t))
82               (done ("WAITING") ("HOLD"))
83               ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
84               ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
85               ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
86
87 ; Tags
88 (setq org-tag-alist (quote ((:startgroup)
89                             ("@home" . ?H)
90                             ("@lowes" . ?l)
91                             (:endgroup)
92                             ("PHONE" . ?p)
93                             ("PERSONAL" . ?P)
94                             ("crypt" . ?E)
95                             ("WORK" . ?W)
96                             ("NOTE" . ?n)
97                             ("WIKI" . ?w)
98                             ("FLAGGED" . ??))))
99
100 (setq org-fast-tag-selection-single-key (quote expert))
101
102 (setq org-agenda-tags-todo-honor-ignore-options t)
103 (setq org-agenda-span 1) ;; show day to start
104 (setq org-deadline-warning-days 14)
105 (setq org-agenda-show-all-dates t)
106 (setq org-agenda-skip-deadline-if-done t)
107 (setq org-agenda-skip-scheduled-if-done t)
108 (setq org-agenda-start-on-weekday nil)
109
110 ;; setup for ics
111 (setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo todo-start))
112 (setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-start))
113 (setq org-icalendar-categories '(category todo-state all-tags))
114 (setq org-icalendar-store-UID t)
115 (setq org-icalendar-alarm-time 15)
116
117 (setq org-default-notes-file "~/doc/org/refile.org")
118
119 (require 'org-contacts nil 'noerror)
120 (setq org-contacts-files '("~/doc/org/contacts.org"))
121
122
123
124 (setq org-capture-templates
125       (quote (("t" "todo" entry (file "~/doc/org/refile.org")
126                "* TODO %?\n%a\n  %i")
127               ("n" "note" entry (file "~/doc/org/refile.org")
128                "* %? :NOTE:\n%a\n  %i")
129               ("j" "Journal" entry (file+datetree "~/doc/org/diary.org")
130                "* %?\n  %i")
131               ("w" "org-protocol" entry (file "~/doc/org/refile.org")
132                "* TODO Review %c\n  %i")
133               ("p" "Phone call" entry (file "~/doc/org/refile.org")
134                "* PHONE %? :PHONE:")
135               ;; todo from email
136               ("m" "todo" entry (file+headline "~/doc/org/refile.org" "Taskss")
137                "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
138 ;              ("c" "Contacts" entry (file+headline "~/doc/org/contacts.org" "Contacts")
139               ("c" "Contacts" entry (file "~/doc/org/contacts.org")
140                "* %(org-contacts-template-name)
141 :PROPERTIES:%(org-contacts-template-email)
142 :Phone:
143 :Cell:
144 :Fax:
145 :Company:
146 :Street:
147 :City:
148 :State:
149 :Postal:
150 :URL:
151 :Notes:
152 :END:")
153               )))
154
155 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
156 (setq org-refile-targets (quote ((nil :maxlevel . 9)
157                                  (org-agenda-files :maxlevel . 9))))
158
159 ; Use full outline paths for refile targets - we file directly with IDO
160 (setq org-refile-use-outline-path t)
161
162 ; Targets complete directly with IDO
163 ;(setq org-outline-path-complete-in-steps nil) ido is broke for refile
164
165 ; Allow refile to create parent tasks with confirmation
166 ;;(setq org-refile-allow-creating-parent-nodes (quote confirm))
167
168 ; Use IDO for both buffer and file completion and ido-everywhere to t
169 (setq org-completion-use-ido nil) ;; this is broken 9 sept 15
170
171 (require 'org-crypt)
172 (org-crypt-use-before-save-magic)
173 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
174 (setq org-crypt-key "D8467AFB")
175
176 ;; load EasyPG... be careful with autosave
177 (require 'epa-file)
178 (epa-file-enable)
179   
180 ;;;; Refile settings
181 ; Exclude DONE state tasks from refile targets
182 (defun bh/verify-refile-target ()
183   "Exclude todo keywords with a done state from refile targets"
184   (not (member (nth 2 (org-heading-components)) org-done-keywords)))
185
186 (setq org-refile-target-verify-function 'bh/verify-refile-target)
187
188 ;;agenda
189 (setq org-agenda-dim-blocked-tasks t)
190 (setq org-agenda-compact-blocks t)
191
192 ;; Custom agenda command definitions
193 (setq org-agenda-custom-commands
194       (quote (("N" "Notes" tags "NOTE"
195                ((org-agenda-overriding-header "Notes")
196                 (org-tags-match-list-sublevels t)))
197               ("h" "Habits" tags-todo "STYLE=\"habit\""
198                ((org-agenda-overriding-header "Habits")
199                 (org-agenda-sorting-strategy
200                  '(todo-state-down effort-up category-keep))))
201               (" " "Agenda"
202                ((agenda "" nil)
203                 (tags "REFILE"
204                       ((org-agenda-overriding-header "Tasks to Refile")
205                        (org-tags-match-list-sublevels nil)))
206                 (tags-todo "-CANCELLED/!"
207                            ((org-agenda-overriding-header "Stuck Projects")
208                             (org-tags-match-list-sublevels 'indented)
209                             (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
210                 (tags-todo "-WAITING-CANCELLED/!NEXT"
211                            ((org-agenda-overriding-header "Next Tasks")
212                             (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
213                             (org-agenda-todo-ignore-scheduled t)
214                             (org-agenda-todo-ignore-deadlines t)
215                             (org-tags-match-list-sublevels t)
216                             (org-agenda-sorting-strategy
217                              '(todo-state-down effort-up category-keep))))
218                 (tags-todo "jira"
219                       ((org-agenda-overriding-header "Jira Tasks")
220                        (org-tags-match-list-sublevel)))
221                 (tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
222                            ((org-agenda-overriding-header "Tasks")
223                             (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
224                             (org-agenda-todo-ignore-scheduled t)
225                             (org-agenda-todo-ignore-deadlines t)
226                             (org-agenda-sorting-strategy
227                              '(category-keep))))
228                 (tags-todo "-CANCELLED/!"
229                            ((org-agenda-overriding-header "Projects")
230                             (org-agenda-skip-function 'bh/skip-non-projects)
231                             (org-agenda-sorting-strategy
232                              '(category-keep))))
233                 (tags-todo "-CANCELLED/!WAITING|HOLD"
234                            ((org-agenda-overriding-header "Waiting and Postponed Tasks")
235                             (org-agenda-skip-function 'bh/skip-projects-and-habits)
236                             (org-agenda-todo-ignore-scheduled t)
237                             (org-agenda-todo-ignore-deadlines t)))
238                 (tags "-REFILE/"
239                       ((org-agenda-overriding-header "Tasks to Archive")
240                        (org-agenda-skip-function 'bh/skip-non-archivable-tasks))))
241                nil)
242               ("r" "Tasks to Refile" tags "REFILE"
243                ((org-agenda-overriding-header "Tasks to Refile")
244                 (org-tags-match-list-sublevels nil)))
245               ("#" "Stuck Projects" tags-todo "-CANCELLED/!"
246                ((org-agenda-overriding-header "Stuck Projects")
247                 (org-agenda-skip-function 'bh/skip-non-stuck-projects)))
248               ("n" "Next Tasks" tags-todo "-WAITING-CANCELLED/!NEXT"
249                ((org-agenda-overriding-header "Next Tasks")
250                 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
251                 (org-agenda-todo-ignore-scheduled t)
252                 (org-agenda-todo-ignore-deadlines t)
253                 (org-tags-match-list-sublevels t)
254                 (org-agenda-sorting-strategy
255                  '(todo-state-down effort-up category-keep))))
256               ("R" "Tasks" tags-todo "-REFILE-CANCELLED/!-HOLD-WAITING"
257                ((org-agenda-overriding-header "Tasks")
258                 (org-agenda-skip-function 'bh/skip-project-tasks-maybe)
259                 (org-agenda-sorting-strategy
260                  '(category-keep))))
261               ("p" "Projects" tags-todo "-CANCELLED/!"
262                ((org-agenda-overriding-header "Projects")
263                 (org-agenda-skip-function 'bh/skip-non-projects)
264                 (org-agenda-sorting-strategy
265                  '(category-keep))))
266               ("w" "Waiting Tasks" tags-todo "-CANCELLED/!WAITING|HOLD"
267                ((org-agenda-overriding-header "Waiting and Postponed tasks"))
268                (org-agenda-skip-function 'bh/skip-projects-and-habits)
269                (org-agenda-todo-ignore-scheduled 'future)
270                (org-agenda-todo-ignore-deadlines 'future))
271               ("A" "Tasks to Archive" tags "-REFILE/"
272                ((org-agenda-overriding-header "Tasks to Archive")
273                 (org-agenda-skip-function 'bh/skip-non-archivable-tasks))))))
274
275
276
277
278
279 (setq org-modules (quote (org-habit org-id)))
280 (setq org-habit-graph-column 50)
281 (setq global-auto-revert-mode t)
282 (setq org-crypt-disable-auto-save nil)
283 (setq org-stuck-projects (quote ("" nil nil "")))
284
285 (setq org-list-demote-modify-bullet (quote (("+" . "-")
286                                             ("*" . "-")
287                                             ("1." . "-")
288                                             ("1)" . "-"))))
289 (setq org-tags-match-list-sublevels t)
290 (setq org-agenda-persistent-filter t)
291 (setq split-width-threshold 120)
292 (setq org-agenda-skip-additional-timestamps-same-entry t)
293 (setq org-table-use-standard-references (quote from))
294 (setq org-agenda-window-setup 'current-window)
295 (setq org-clone-delete-id t)
296 (setq org-cycle-include-plain-lists t)
297 ;; make fonts come out right in html
298 (setq org-src-fontify-natively t)
299 ;;(setq org-structure-template-alist
300 ;;      (quote (("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")
301 ;;              ("e" "#+begin_example\n?\n#+end_example" "<example>\n?\n</example>")
302 ;;              ("q" "#+begin_quote\n?\n#+end_quote" "<quote>\n?\n</quote>")
303 ;;              ("v" "#+begin_verse\n?\n#+end_verse" "<verse>\n?\n/verse>")
304 ;;              ("c" "#+begin_center\n?\n#+end_center" "<center>\n?\n/center>")
305 ;;              ("l" "#+begin_latex\n?\n#+end_latex" "<literal style=\"latex\">\n?\n</literal>")
306 ;;              ("L" "#+latex: " "<literal style=\"latex\">?</literal>")
307 ;;              ("h" "#+begin_html\n?\n#+end_html" "<literal style=\"html\">\n?\n</literal>")
308 ;;              ("H" "#+html: " "<literal style=\"html\">?</literal>")
309 ;;              ("a" "#+begin_ascii\n?\n#+end_ascii")
310 ;; ;;             ("A" "#+ascii: ")
311 ;;              ("i" "#+index: ?" "#+index: ?")
312 ;;              ("I" "#+include %file ?" "<include file=%file markup=\"?\">"))))
313
314 (setq org-startup-indented t
315       org-export-headline-levels 10)
316 (defun bh/mark-next-parent-tasks-todo ()
317   "Visit each parent task and change NEXT states to TODO"
318   (let ((mystate (or (and (fboundp 'state)
319                           state)
320                      (nth 2 (org-heading-components)))))
321     (when (equal mystate "NEXT")
322       (save-excursion
323         (while (org-up-heading-safe)
324           (when (member (nth 2 (org-heading-components)) (list "NEXT"))
325             (org-todo "TODO")))))))
326
327 (add-hook 'org-after-todo-state-change-hook 'bh/mark-next-parent-tasks-todo 'append)
328 (add-hook 'org-clock-in-hook 'bh/mark-next-parent-tasks-todo 'append)
329 (run-at-time "00:59" 3600 'org-save-all-org-buffers)
330
331 (defun bh/find-project-task ()
332   "Move point to the parent (project) task if any"
333   (save-restriction
334     (widen)
335     (let ((parent-task (save-excursion (org-back-to-heading 'invisible-ok) (point))))
336       (while (org-up-heading-safe)
337         (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
338           (setq parent-task (point))))
339       (goto-char parent-task)
340       parent-task)))
341
342 (defun bh/is-project-p ()
343   "Any task with a todo keyword subtask"
344   (save-restriction
345     (widen)
346     (let ((has-subtask)
347           (subtree-end (save-excursion (org-end-of-subtree t)))
348           (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
349       (save-excursion
350         (forward-line 1)
351         (while (and (not has-subtask)
352                     (< (point) subtree-end)
353                     (re-search-forward "^\*+ " subtree-end t))
354           (when (member (org-get-todo-state) org-todo-keywords-1)
355             (setq has-subtask t))))
356       (and is-a-task has-subtask))))
357
358 (defun bh/is-project-subtree-p ()
359   "Any task with a todo keyword that is in a project subtree.
360 Callers of this function already widen the buffer view."
361   (let ((task (save-excursion (org-back-to-heading 'invisible-ok)
362                               (point))))
363     (save-excursion
364       (bh/find-project-task)
365       (if (equal (point) task)
366           nil
367         t))))
368
369 (defun bh/is-task-p ()
370   "Any task with a todo keyword and no subtask"
371   (save-restriction
372     (widen)
373     (let ((has-subtask)
374           (subtree-end (save-excursion (org-end-of-subtree t)))
375           (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
376       (save-excursion
377         (forward-line 1)
378         (while (and (not has-subtask)
379                     (< (point) subtree-end)
380                     (re-search-forward "^\*+" subtree-end t))
381           (when (member (org-get-todo-state) org-todo-keywords-1)
382             (setq has-subtask t))))
383       (and is-a-task (not has-subtask)))))
384
385 (defun bh/is-subproject-p ()
386   "Any task with is a subtask of another project"
387   (let ((is-subproject)
388         (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
389     (save-excursion
390       (while (and (not is-subproject) (org-up-heading-safe))
391         (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
392           (setq is-subproject t))))
393     (and is-a-task is-subproject)))
394
395 (defun bh/list-sublevels-for-projects-indented ()
396   "Set org-tags-match-list-sublevels so when restricted to a subtree we list all subtasks.
397   This is normally used by skipping functions where this variable is already local to the agenda."
398   (if (marker-buffer org-agenda-restrict-begin)
399       (setq org-tags-match-list-sublevels 'indented)
400     (setq org-tags-match-list-sublevels nil))
401   nil)
402
403 (defun bh/list-sublevels-for-projects ()
404   "Set org-tags-match-list-sublevels so when restricted to a subtree we list all subtasks.
405   This is normally used by skipping functions where this variable is already local to the agenda."
406   (if (marker-buffer org-agenda-restrict-begin)
407       (setq org-tags-match-list-sublevels t)
408     (setq org-tags-match-list-sublevels nil))
409   nil)
410
411 (defun bh/skip-non-stuck-projects ()
412   "Skip trees that are not stuck projects"
413   (save-restriction
414     (widen)
415     (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
416       (if (bh/is-project-p)
417           (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
418                  (has-next (save-excursion
419                              (forward-line 1)
420                              (and (< (point) subtree-end)
421                                   (re-search-forward "^\\*+ \\(NEXT\\) " subtree-end t)))))
422             (if has-next
423                 next-headline
424               nil)) ; a stuck project, has subtasks but no next task
425         next-headline))))
426
427 (defun bh/skip-non-projects ()
428   "Skip trees that are not projects"
429   (bh/list-sublevels-for-projects-indented)
430   (if (save-excursion (bh/skip-non-stuck-projects))
431       (save-restriction
432         (widen)
433         (let ((subtree-end (save-excursion (org-end-of-subtree t))))
434           (if (bh/is-project-p)
435               nil
436             subtree-end)))
437     (org-end-of-subtree t)))
438
439 (defun bh/skip-project-trees-and-habits ()
440   "Skip trees that are projects"
441   (save-restriction
442     (widen)
443     (let ((subtree-end (save-excursion (org-end-of-subtree t))))
444       (cond
445        ((bh/is-project-p)
446         subtree-end)
447        ((org-is-habit-p)
448         subtree-end)
449        (t
450         nil)))))
451
452 (defun bh/skip-projects-and-habits-and-single-tasks ()
453   "Skip trees that are projects, tasks that are habits, single non-project tasks"
454   (save-restriction
455     (widen)
456     (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
457       (cond
458        ((org-is-habit-p)
459         next-headline)
460        ((bh/is-project-p)
461         next-headline)
462        ((and (bh/is-task-p) (not (bh/is-project-subtree-p)))
463         next-headline)
464        (t
465         nil)))))
466
467 (defun bh/skip-project-tasks-maybe ()
468   "Show tasks related to the current restriction.
469 When restricted to a project, skip project and sub project tasks, habits, NEXT tasks, and loose tasks.
470 When not restricted, skip project and sub-project tasks, habits, and project related tasks."
471   (save-restriction
472     (widen)
473     (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
474            (next-headline (save-excursion (or (outline-next-heading) (point-max))))
475            (limit-to-project (marker-buffer org-agenda-restrict-begin)))
476       (cond
477        ((bh/is-project-p)
478         next-headline)
479        ((org-is-habit-p)
480         subtree-end)
481        ((and (not limit-to-project)
482              (bh/is-project-subtree-p))
483         subtree-end)
484        ((and limit-to-project
485              (bh/is-project-subtree-p)
486              (member (org-get-todo-state) (list "NEXT")))
487         subtree-end)
488        (t
489         nil)))))
490
491 (defun bh/skip-projects-and-habits ()
492   "Skip trees that are projects and tasks that are habits"
493   (save-restriction
494     (widen)
495     (let ((subtree-end (save-excursion (org-end-of-subtree t))))
496       (cond
497        ((bh/is-project-p)
498         subtree-end)
499        ((org-is-habit-p)
500         subtree-end)
501        (t
502         nil)))))
503
504 (defun bh/skip-non-subprojects ()
505   "Skip trees that are not projects"
506   (let ((next-headline (save-excursion (outline-next-heading))))
507     (if (bh/is-subproject-p)
508         nil
509       next-headline)))
510 (setq org-archive-mark-done nil)
511 (setq org-archive-location "%s_archive::* Archived Tasks")
512
513 (defun bh/skip-non-archivable-tasks ()
514   "Skip trees that are not available for archiving"
515   (save-restriction
516     (widen)
517     (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
518       ;; Consider only tasks with done todo headings as archivable candidates
519       (if (member (org-get-todo-state) org-done-keywords)
520           (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
521                  (daynr (string-to-int (format-time-string "%d" (current-time))))
522                  (a-month-ago (* 60 60 24 (+ daynr 1)))
523                  (last-month (format-time-string "%Y-%m-" (time-subtract (current-time) (seconds-to-time a-month-ago))))
524                  (this-month (format-time-string "%Y-%m-" (current-time)))
525                  (subtree-is-current (save-excursion
526                                        (forward-line 1)
527                                        (and (< (point) subtree-end)
528                                             (re-search-forward (concat last-month "\\|" this-month) subtree-end t)))))
529             (if subtree-is-current
530                 next-headline ; Has a date in this month or last month, skip it
531               nil))  ; available to archive
532         (or next-headline (point-max))))))
533
534 ;;(setq org-log-done t)
535
536 ; Erase all reminders and rebuilt reminders for today from the agenda
537 (defun bh/org-agenda-to-appt ()
538   (interactive)
539   (setq appt-time-msg-list nil)
540   (org-agenda-to-appt))
541
542 ; Rebuild the reminders everytime the agenda is displayed
543 (add-hook 'org-finalize-agenda-hook 'bh/org-agenda-to-appt 'append)
544
545 ; This is at the end of my .emacs - so appointments are set up when Emacs starts
546 (bh/org-agenda-to-appt)
547
548 ; Activate appointments so we get notifications
549 (appt-activate t)
550
551 ; If we leave Emacs running overnight - reset the appointments one minute after midnight
552 (run-at-time "24:01" nil 'bh/org-agenda-to-appt)
553
554
555 ;; Keep tasks with dates on the global todo lists
556 (setq org-agenda-todo-ignore-with-date nil)
557
558 ;; Keep tasks with deadlines on the global todo lists
559 (setq org-agenda-todo-ignore-deadlines nil)
560
561 ;; Keep tasks with scheduled dates on the global todo lists
562 (setq org-agenda-todo-ignore-scheduled nil)
563
564 ;; Keep tasks with timestamps on the global todo lists
565 (setq org-agenda-todo-ignore-timestamp nil)
566
567 ;; Remove completed deadline tasks from the agenda view
568 (setq org-agenda-skip-deadline-if-done t)
569
570 ;; Remove completed scheduled tasks from the agenda view
571 (setq org-agenda-skip-scheduled-if-done t)
572
573 ;; Remove completed items from search results
574 (setq org-agenda-skip-timestamp-if-done t)
575
576
577 (setq org-agenda-include-diary nil)
578 (setq org-agenda-diary-file "~/doc/org/diary.org")
579 (setq org-agenda-insert-diary-extract-time t)
580 (setq org-agenda-text-search-extra-files (quote (agenda-archives)))
581 (setq org-agenda-repeating-timestamp-show-all t)
582
583 ;; Show all agenda dates - even if they are empty
584 (setq org-agenda-show-all-dates t)
585
586 ;; Sorting order for tasks on the agenda
587 (setq org-agenda-sorting-strategy
588       (quote ((agenda habit-down time-up user-defined-up priority-down effort-up category-keep)
589               (todo category-up priority-down effort-up)
590               (tags category-up priority-down effort-up)
591               (search category-up))))
592
593 ;; Start the weekly agenda on Monday
594 ;;(setq org-agenda-start-on-weekday 1)
595
596 ;; Enable display of the time grid so we can see the marker for the current time
597 (setq org-agenda-time-grid '((daily today remove-match)
598                               (0 300 600 800 1000 1200 1300 1500 1700 1900 2100 2300 2400)
599                               "......" "----------------"))
600
601 ;; Display tags farther right
602 (setq org-agenda-tags-column -102)
603
604 ;;
605 ;; Agenda sorting functions
606 ;;
607 (setq org-agenda-cmp-user-defined 'bh/agenda-sort)
608
609 (defun bh/agenda-sort (a b)
610   "Sorting strategy for agenda items.
611 Late deadlines first, then scheduled, then non-late deadlines"
612   (let (result num-a num-b)
613     (cond
614      ; time specific items are already sorted first by org-agenda-sorting-strategy
615
616      ; non-deadline and non-scheduled items next
617      ((bh/agenda-sort-test 'bh/is-not-scheduled-or-deadline a b))
618
619      ; deadlines for today next
620      ((bh/agenda-sort-test 'bh/is-due-deadline a b))
621
622      ; late deadlines next
623      ((bh/agenda-sort-test-num 'bh/is-late-deadline '< a b))
624
625      ; scheduled items for today next
626      ((bh/agenda-sort-test 'bh/is-scheduled-today a b))
627
628      ; late scheduled items next
629      ((bh/agenda-sort-test-num 'bh/is-scheduled-late '> a b))
630
631      ; pending deadlines last
632      ((bh/agenda-sort-test-num 'bh/is-pending-deadline '< a b))
633
634      ; finally default to unsorted
635      (t (setq result nil)))
636     result))
637
638 (defmacro bh/agenda-sort-test (fn a b)
639   "Test for agenda sort"
640   `(cond
641     ; if both match leave them unsorted
642     ((and (apply ,fn (list ,a))
643           (apply ,fn (list ,b)))
644      (setq result nil))
645     ; if a matches put a first
646     ((apply ,fn (list ,a))
647      (setq result -1))
648     ; otherwise if b matches put b first
649     ((apply ,fn (list ,b))
650      (setq result 1))
651     ; if none match leave them unsorted
652     (t nil)))
653
654 (defmacro bh/agenda-sort-test-num (fn compfn a b)
655   `(cond
656     ((apply ,fn (list ,a))
657      (setq num-a (string-to-number (match-string 1 ,a)))
658      (if (apply ,fn (list ,b))
659          (progn
660            (setq num-b (string-to-number (match-string 1 ,b)))
661            (setq result (if (apply ,compfn (list num-a num-b))
662                             -1
663                           1)))
664        (setq result -1)))
665     ((apply ,fn (list ,b))
666      (setq result 1))
667     (t nil)))
668
669 (defun bh/is-not-scheduled-or-deadline (date-str)
670   (and (not (bh/is-deadline date-str))
671        (not (bh/is-scheduled date-str))))
672
673 (defun bh/is-due-deadline (date-str)
674   (string-match "Deadline:" date-str))
675
676 (defun bh/is-late-deadline (date-str)
677   (string-match "In *\\(-.*\\)d\.:" date-str))
678
679 (defun bh/is-pending-deadline (date-str)
680   (string-match "In \\([^-]*\\)d\.:" date-str))
681
682 (defun bh/is-deadline (date-str)
683   (or (bh/is-due-deadline date-str)
684       (bh/is-late-deadline date-str)
685       (bh/is-pending-deadline date-str)))
686
687 (defun bh/is-scheduled (date-str)
688   (or (bh/is-scheduled-today date-str)
689       (bh/is-scheduled-late date-str)))
690
691 (defun bh/is-scheduled-today (date-str)
692   (string-match "Scheduled:" date-str))
693
694 (defun bh/is-scheduled-late (date-str)
695   (string-match "Sched\.\\(.*\\)x:" date-str))
696
697 (require 'org-git-link nil 'noerror)
698 (require 'org-checklist nil 'noerror)
699 (setq org-enforce-todo-dependencies t)
700 (setq org-hide-leading-stargs nil)
701 (setq org-startup-indented t)
702 (setq org-cycle-separator-lines 2)
703 (setq org-blank-before-new-entry (quote ((heading)
704                                          (plain-list-item . auto))))
705 (setq org-insert-heading-respect-content nil)
706 (setq org-reverse-note-order nil)
707 (setq org-show-following-heading t)
708 (setq org-show-hierarchy-above t)
709 (setq org-show-siblings (quote ((default))))
710 (setq org-deadline-warning-days 30)
711 (setq org-log-done (quote time))
712 (setq org-log-into-drawer "LOGBOOK")
713
714
715 ;;(setq org-ditaa-jar-path "~/java/ditaa0_6b.jar")
716 (setq org-plantuml-jar-path "/usr/share/plantuml/plantuml.jar")
717
718 (add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
719
720 ; Make babel results blocks lowercase
721 (setq org-babel-results-keyword "results")
722
723 (defun bh/display-inline-images ()
724   (condition-case nil
725       (org-display-inline-images)
726     (error nil)))
727
728 (org-babel-do-load-languages
729  'org-babel-load-languages
730  '((emacs-lisp . t)
731          (dot . t)
732          (ditaa . t)
733          (R . t)
734          (python . t)
735          (ruby . t)
736          (gnuplot . t)
737          (clojure . t)
738          (sh . t)
739          (ledger . t)
740          (org . t)
741          (plantuml . t)
742          (latex . t)
743          (makefile . t)
744 ))
745
746 ; Do not prompt to confirm evaluation
747 ; This may be dangerous - make sure you understand the consequences
748 ; of setting this -- see the docstring for details
749 (setq org-confirm-babel-evaluate nil)
750
751 ; Cache all babel results blocks by default
752 ; For graphics generation this is way faster if nothing changes
753 (setq org-babel-default-header-args
754      (cons '(:cache . "yes")
755      (assq-delete-all :cache org-babel-default-header-args)))
756
757 ; Use fundamental mode when editing plantuml blocks with C-c '
758 (add-to-list 'org-src-lang-modes (quote ("plantuml" . fundamental)))
759
760 ; publishing
761
762 ; experimenting with docbook exports - not finished
763 (setq org-docbook-xsl-fo-proc-command "fop %s %s")
764 (setq org-docbook-xslt-proc-command "xsltproc --output %s /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl %s")
765 ;
766 ; Inline images in HTML instead of producting links to the image
767 (setq org-html-inline-images t)
768 ; Do not use sub or superscripts - I currently don't need this functionality in my documents
769 ;(setq org-export-with-sub-superscripts nil)
770 ; Use org.css from the norang website for export document stylesheets
771 ;;(setq org-export-html-style-extra "<link rel=\"stylesheet\" href=\"http://doc.norang.ca/org.css\" type=\"text/css\" />")
772 (setq org-html-style-include-default nil)
773 ; Do not generate internal css formatting for HTML exports
774 (setq org-htmlize-output-type (quote inline-css))
775 ; Export with LaTeX fragments
776 (setq org-with-LaTeX-fragments t)
777 ; I wish to do abstracts nad lists...
778 (defun org-latex-no-toc (depth)
779   (when depth
780     (format "%% Org-mode is exporting headings to %s levels.\n"
781             depth)))
782 ;;(setq org-latex-format-toc-function 'org-latex-no-toc)
783 ;; now part of org-mode (require 'org-special-blocks)
784
785 ; use minted
786 (add-to-list 'org-latex-packages-alist '("" "minted"))
787 (setq org-latex-listings 'minted)
788 (setq org-latex-minted-options
789       '(("frame" "single")
790         ("fontsize" "\\scriptsize")
791         ;("xleftmargin" "50pt")
792         ;("xrightmargin" "50pt")
793         ("linenos" "")))
794 ;; cywin doesn't have texi2dvi
795 (if (eq system-type 'cygwin)
796     (setq org-latex-pdf-process '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
797                                   "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
798                                   "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
799   (setq org-latex-pdf-process '("texi2dvi --pdf --tidy --shell-escape --batch %f")))
800 ; List of projects
801 ; norang       - http://www.norang.ca/
802 ; doc          - http://doc.norang.ca/
803 ; org-mode-doc - http://doc.norang.ca/org-mode.html and associated files
804 ; org          - miscellaneous todo lists for publishing
805 (setq org-publish-project-alist
806       ;
807       ; http://www.norang.ca/  (norang website)
808       ; norang-org are the org-files that generate the content
809       ; norang-extra are images and css files that need to be included
810       ; norang is the top-level project that gets published
811       (quote (("norang-org"
812                :base-directory "~/git/www.norang.ca"
813                :publishing-directory "/ssh:www-data@www:~/www.norang.ca/htdocs"
814                :recursive t
815                :table-of-contents nil
816                :base-extension "org"
817                :publishing-function org-publish-org-to-html
818                :style-include-default nil
819                :section-numbers nil
820                :table-of-contents nil
821                :style "<link rel=\"stylesheet\" href=\"norang.css\" type=\"text/css\" />"
822                :author-info nil
823                :creator-info nil)
824               ("norang-extra"
825                :base-directory "~/git/www.norang.ca/"
826                :publishing-directory "/ssh:www-data@www:~/www.norang.ca/htdocs"
827                :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
828                :publishing-function org-publish-attachment
829                :recursive t
830                :author nil)
831               ("norang"
832                :components ("norang-org" "norang-extra"))
833               ;
834               ; http://doc.norang.ca/  (norang website)
835               ; doc-org are the org-files that generate the content
836               ; doc-extra are images and css files that need to be included
837               ; doc is the top-level project that gets published
838               ("doc-org"
839                :base-directory "~/git/doc.norang.ca/"
840                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs"
841                :recursive nil
842                :section-numbers nil
843                :table-of-contents nil
844                :base-extension "org"
845                :publishing-function (org-publish-org-to-html org-publish-org-to-org)
846                :style-include-default nil
847                :style "<link rel=\"stylesheet\" href=\"/org.css\" type=\"text/css\" />"
848                :author-info nil
849                :creator-info nil)
850               ("doc-extra"
851                :base-directory "~/git/doc.norang.ca/"
852                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs"
853                :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
854                :publishing-function org-publish-attachment
855                :recursive nil
856                :author nil)
857               ("doc"
858                :components ("doc-org" "doc-extra"))
859               ("doc-private-org"
860                :base-directory "~/git/doc.norang.ca/private"
861                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs/private"
862                :recursive nil
863                :section-numbers nil
864                :table-of-contents nil
865                :base-extension "org"
866                :publishing-function (org-publish-org-to-html org-publish-org-to-org)
867                :style-include-default nil
868                :style "<link rel=\"stylesheet\" href=\"/org.css\" type=\"text/css\" />"
869                :auto-sitemap t
870                :sitemap-filename "index.html"
871                :sitemap-title "Norang Private Documents"
872                :sitemap-style "tree"
873                :author-info nil
874                :creator-info nil)
875               ("doc-private-extra"
876                :base-directory "~/git/doc.norang.ca/private"
877                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs/private"
878                :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
879                :publishing-function org-publish-attachment
880                :recursive nil
881                :author nil)
882               ("doc-private"
883                :components ("doc-private-org" "doc-private-extra"))
884               ;
885               ; Miscellaneous pages for other websites
886               ; org are the org-files that generate the content
887               ("org-org"
888                :base-directory "~/git/org/"
889                :publishing-directory "/ssh:www-data@www:~/org"
890                :recursive t
891                :section-numbers nil
892                :table-of-contents nil
893                :base-extension "org"
894                :publishing-function org-publish-org-to-html
895                :style-include-default nil
896                :style "<link rel=\"stylesheet\" href=\"/org.css\" type=\"text/css\" />"
897                :author-info nil
898                :creator-info nil)
899               ;
900               ; http://doc.norang.ca/  (norang website)
901               ; org-mode-doc-org this document
902               ; org-mode-doc-extra are images and css files that need to be included
903               ; org-mode-doc is the top-level project that gets published
904               ; This uses the same target directory as the 'doc' project
905               ("org-mode-doc-org"
906                :base-directory "~/git/org-mode-doc/"
907                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs"
908                :recursive t
909                :section-numbers nil
910                :table-of-contents nil
911                :base-extension "org"
912                :publishing-function (org-publish-org-to-html org-publish-org-to-org)
913                :plain-source t
914                :htmlized-source t
915                :style-include-default nil
916                :style "<link rel=\"stylesheet\" href=\"/org.css\" type=\"text/css\" />"
917                :author-info nil
918                :creator-info nil)
919               ("org-mode-doc-extra"
920                :base-directory "~/git/org-mode-doc/"
921                :publishing-directory "/ssh:www-data@www:~/doc.norang.ca/htdocs"
922                :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
923                :publishing-function org-publish-attachment
924                :recursive t
925                :author nil)
926               ("org-mode-doc"
927                :components ("org-mode-doc-org" "org-mode-doc-extra"))
928               ;
929               ; http://doc.norang.ca/  (norang website)
930               ; org-mode-doc-org this document
931               ; org-mode-doc-extra are images and css files that need to be included
932               ; org-mode-doc is the top-level project that gets published
933               ; This uses the same target directory as the 'doc' project
934               ("tmp-org"
935                :base-directory "/tmp/publish/"
936                :publishing-directory "/ssh:www-data@www:~/www.norang.ca/htdocs/tmp"
937                :recursive t
938                :section-numbers nil
939                :table-of-contents nil
940                :base-extension "org"
941                :publishing-function (org-publish-org-to-html org-publish-org-to-org)
942                :style "<link rel=\"stylesheet\" href=\"http://doc.norang.ca/org.css\" type=\"text/css\" />"
943                :plain-source t
944                :htmlized-source t
945                :style-include-default nil
946                :auto-sitemap t
947                :sitemap-filename "index.html"
948                :sitemap-title "Test Publishing Area"
949                :sitemap-style "tree"
950                :author-info t
951                :creator-info t)
952               ("tmp-extra"
953                :base-directory "/tmp/publish/"
954                :publishing-directory "/ssh:www-data@www:~/www.norang.ca/htdocs/tmp"
955                :base-extension "css\\|pdf\\|png\\|jpg\\|gif"
956                :publishing-function org-publish-attachment
957                :recursive t
958                :author nil)
959               ("tmp"
960                :components ("tmp-org" "tmp-extra")))))
961
962 (setq org-publish-project-alist
963       '(
964         ("doc-jtn-com-private"
965          :base-directory "~/doc/doc.jamestechnotes.com-private"
966          :base-extension "org"
967          :publishing-directory "/ssh:chara.dreamhost.com:~/doc.jamestechnotes.com/private"
968          :recursive t
969          :publishing-functino org-publish-org-to-html
970          :headline-levels 6
971          :auto-preamble t
972          )
973         ("doc-jtn" :components ("doc-jtn-com-private"))
974         ("jamestechnotes-com"
975          :base-directory "~/src/wiki/jamestechnotes.com"
976          :base-extension "org"
977          :publishing-directory "~/public_html/"
978          :recursive t
979          :publishing-function (org-publish-org-to-html org-publish-org-to-org)
980          :headline-levels 6
981          :auto-preamble t
982          :auto-sitemap nil
983          :makeindex nil
984          :style "<meta name=\"author\" content=\"James Richardson\" /><meta name=\"authorurl\" content=\"http://jamestechnotes.com\" /><link href=\"http://www.myopenid.com/server\" rel=\"openid.server\" /><link href=\"http://www.myopenid.com/server\" rel=\"openid2.provider\" /><link href=\"http://james-richardson-jr.myopenid.com/\" rel=\"openid.delegate\" /><link href=\"http://james-richardson-jr.myopenid.com/\" rel=\"openid2.local_id\" /><link href=\"https://plus.google.com/100087072360376597478\" rel=\"publisher\" /><link href=\"http://jamestechnotes.com\" rel=\"author\"/> <link rel=\"stylesheet\" title=\"Standard\" href=\"/css/org.css\" type=\"text/css\"/>"
985          :html-preamble "<div id=\"menu\"><a href=\"index.html\">Home</a> | <a href=\"about.html\">About</a></div>"
986          )
987         ("jamestechnotes-com-static"
988          :base-directory "~/src/wiki/jamestechnotes.com"
989          :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|ogg\\|swf\\|txt"
990          :publishing-directory "~/public_html"
991          :recursive t
992          :publishing-function org-publish-attachment
993          )
994         ("jamestechnotes" :components ("jamestechnotes-com" "jamestechnotes-com-static"))
995         ))
996 ; I'm lazy and don't want to remember the name of the project to publish when I modify
997 ; a file that is part of a project.  So this function saves the file, and publishes
998 ; the project that includes this file
999 ;
1000 ; It's bound to C-S-F12 so I just edit and hit C-S-F12 when I'm done and move on to the next thing
1001 (defun bh/save-then-publish ()
1002   (interactive)
1003   (save-buffer)
1004   (org-save-all-org-buffers)
1005   (org-publish-current-project))
1006
1007 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1008
1009 ;; push
1010 ;;(defvar org-mobile-push-timer nil
1011 ;;  "Timer that `org-mobile-push-timer' uses to reschedule itself, or nil")
1012
1013 ;;(defun org-mobile-push-with-delay (secs)
1014 ;;  (when org-mobile-push-timer
1015 ;;    (cancel-timer org-mobile-push-timer))
1016 ;;  (setq org-mobile-push-timer
1017 ;;      (run-with-idle-timer
1018 ;;       (* 1 secs) nil 'org-mobile-push)))
1019
1020 ;; (add-hook 'after-save-hook
1021 ;;        (lambda()
1022 ;;          (when (eq major-mode 'org-mode)
1023 ;;            (dolist (file (org-mobile-files-alist))
1024 ;;              (if (string= (expand-file-name (car file)) (buffer-file-name))
1025 ;;                  (org-mobile-push-with-delay 30))))))
1026
1027 ;;(run-at-time "00:05" 86400 '(lambda () (org-mobile-push-with-delay 1)))
1028
1029 ;; pul
1030 ;;(org-mobile-pull)
1031
1032 ;;(defun install-monitor (file secs)
1033 ;;  (run-with-timer 0 secs
1034 ;;    (lambda (f p)
1035 ;;      (unless (< p (second (time-since (elt (file-attributes f) 5))))
1036 ;;        (org-mobile-pull)))
1037 ;;    file secs))
1038
1039 ;; (install-monitor (file-truename
1040 ;;                   (concat
1041 ;;                    (file-name-as-directory org-mobile-directory)
1042 ;;                    org-mobile-capture-file))
1043 ;;                  5)
1044
1045 ;;(run-with-timer 0 (* 60 60) 'org-mobile-pull) ; pull every hour
1046
1047
1048 ;; ;; export org mode buffer as html w/o header crap
1049 ;; (global-set-key (kbd "<f9> x") 'jr/connections)
1050 ;; (defun jr/connections (arg)
1051 ;;   (interactive "P")
1052 ;;   (org-as-html arg nil nil t))
1053
1054 ;; rss feeds
1055 ;; (setq org-feed-alist
1056 ;;       '(("Armed and Dangerous"
1057 ;;       "http://esr.ibiblio.org/?feed=rss2"
1058 ;;       "~/doc/org/todo.org" "catb")
1059 ;;      ("Git Annex"
1060 ;;       "https://git-annex.branchable.com/forum/index.rss"
1061 ;;       "~/doc/org/todo.org" "gitannex")
1062 ;;      ("Ikiwki"
1063 ;;       "http://ikiwiki.info/news/index.rss"
1064 ;;       "~/doc/org/todo.org" "ikiwiki")
1065 ;;      ("myglpus"
1066 ;;       "http://gplusrss.com/rss/feed/2eec32c7a808ca3556325d3160b5ebd3546e7948ad7f8"
1067 ;;       "~/doc/org/todo.org" "mygplus")
1068 ;;      ("bofh"
1069 ;;       "http://www.theregister.co.uk/data_centre/bofh/headlines.rss"
1070 ;;       "~/doc/org/todo.org" "BOFH")
1071 ;;      ("reg-servers"
1072 ;;       "http://www.theregister.co.uk/data_centre/servers/headlines.rss"
1073 ;;       "~/doc/org/todo.org" "reg-servers")
1074 ;;      ("reg-os"
1075 ;;       "http://www.theregister.co.uk/software/os/headlines.rss"
1076 ;;       "~/doc/org/todo.org" "reg-os")
1077 ;;      ("reg-apps"
1078 ;;       "http://www.theregister.co.uk/software/apps/headlines.rss"
1079 ;;       "~/doc/org/todo.org" "reg-apps")
1080 ;;      ("reg-dev"
1081 ;;       "http://www.theregister.co.uk/software/developer/headlines.rss"
1082 ;;       "~/doc/org/todo.org" "reg-dev")
1083 ;;      ("reg-stob"
1084 ;;       "http://www.theregister.co.uk/software/stob/headlines.rss"
1085 ;;       "~/doc/org/todo.org" "reg-stob")
1086 ;;      ("reg-sci"
1087 ;;       "http://www.theregister.co.uk/science/special_projects_bureau/headlines.rss"
1088 ;;       "~/doc/org/todo.org" "reg-sci")
1089 ;;      ("sci-american"
1090 ;;       "http://rss.sciam.com/sciam/topic/quantum-physics"
1091 ;;       "~/doc/org/todo.org" "sci-american")
1092 ;;      ("roku"
1093 ;;       "http://blog.roku.com/feed/"
1094 ;;       "~/doc/org/todo.org" "roku")
1095 ;;      ("xkcd"
1096 ;;       "http://xkcd.com/rss.xml"
1097 ;;       "~/doc/org/todo.org" "xkcd")
1098 ;;      ("dilbert"
1099 ;;       "http://www.comicsyndicate.org/Feed/Dilbert"
1100 ;;       "~/doc/org/todo.org" "dilbert")
1101 ;;      ("bloom"
1102 ;;       "http://www.comicsyndicate.org/Feed/Bloom%20County"
1103 ;;       "~/doc/org/todo.org" "bloom")
1104 ;;      ("rush"
1105 ;;       "http://feeds.feedburner.com/rushLimbaugh-AllContent"
1106 ;;       "~/doc/org/todo.org" "rush")))
1107 (setq org-feed-default-template
1108       "\n* %h\n  SCHEDULED: %T\n  %description\n  %a\n")
1109
1110 ;; setup solar
1111 (setq calendar-latitude 35.6
1112       calendar-longitude -80.8
1113       calendar-location-name "Mooresville, NC"
1114       calendar-time-zone -300
1115       calendar-standard-time-zone-name "EST"
1116       calendar-daylight-time-zone-name "EDT")
1117
1118 ;; org-weather
1119 (when (require 'org-weather nil 'noerror)
1120   (setq org-weather-location "Mooresville, NC"
1121         org-weather-api-url "http://api.openweathermap.org/data/2.5/forecast/daily?q=%s&mode=json&units=imperial&cnt=7&APPID=%s"
1122         org-weather-temperature-unit "°F")
1123   (org-weather-refresh))
1124
1125 ;; effort and clocking
1126 ; Set default column view headings: Task Effort Clock_Summary
1127 (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
1128
1129 ; global Effort estimate values
1130 ; global STYLE property values for completion
1131 (setq org-global-properties (quote (("Effort_ALL" . "0:15 0:30 0:45 1:00 2:00 3:00 4:00 5:00 6:00 8:00")
1132                                     ("STYLE_ALL" . "habit"))))
1133
1134
1135 ;; org-jira
1136 ;; set defcustom before loading
1137 (setq jiralib-url "https://tools.lowes.com/jira"
1138       ;;jiralib-wsdl-descriptor-url "https://tools.lowes.com/jira/rpc/soap/jirasoapservice-v2?wsdl"
1139       org-jira-working-dir "~/doc/org/lowes"
1140       org-jira-use-status-as-todo t)
1141 ;;(require 'org-jira nil 'noerror)
1142 (setq request-message-level 'debug
1143       request-log-level 'debug)
1144
1145 (defun jr/insert-latex-boilerplate ()
1146     "Insert boilerplate into current buffer"
1147   (interactive)
1148   (insert "#+LATEX_CLASS: article
1149 #+LATEX_CLASS_OPTIONS:
1150 #+LATEX_HEADER:
1151 #+LATEX_HEADER_EXTRA:
1152 #+DESCRIPTION:
1153 #+KEYWORDS:
1154 #+SUBTITLE:
1155 #+LATEX_COMPILER: pdflatex
1156 #+DATE: \\today
1157
1158 #+OPTIONS: ':nil *:t -:t ::t <:t H:10 \\n:nil ^:t arch:headline
1159 #+OPTIONS: author:t broken-links:nil c:nil creator:nil
1160 #+OPTIONS: d:(not \"LOGBOOK\") date:t e:t email:nil f:t inline:t num:t
1161 #+OPTIONS: p:nil pri:nil prop:nil stat:t tags:t tasks:t tex:t
1162 #+OPTIONS: timestamp:t title:t toc:nil todo:t |:t
1163 #+TITLE: set this
1164 #+AUTHOR: James Richardson
1165 #+EMAIL: james.richardson@lowes.com
1166 #+LANGUAGE: en
1167 #+SELECT_TAGS: export
1168 #+EXCLUDE_TAGS: noexport
1169 #+CREATOR: Emacs 25.1.1 (Org mode 9.0.5)
1170
1171 #+LaTeX: \\thispagestyle{empty}
1172
1173 #+BEGIN_abstract
1174 #+END_abstract
1175
1176 #+LaTeX: \\newpage
1177 #+LaTex: \\twocolumn
1178 #+LaTeX: \\pagestyle{plain}
1179 #+LaTeX: \\setcounter{page}{1}
1180 #+LaTeX: \\pagenumbering{roman}
1181
1182 #+LATEX: \\tableofcontents
1183 #+LATEX: \\listoftables
1184 #+LATEX: \\listoffigures
1185 #+LATEX: \\listoflistings
1186 #+LaTeX: \\onecolumn
1187 #+LaTeX: \\pagestyle{headings}
1188 #+LaTeX: \\setcounter{page}{1}
1189 #+LaTeX: \\pagenumbering{arabic}
1190
1191 Text here
1192
1193 #+LaTeX: \\newpage
1194 #+LaTeX: \\appendix
1195
1196 Appendices here"))