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