summary refs log tree commit diff
path: root/emacs.d/custom/fcuny-org.el
blob: 0ac83caea0afb754843ddf3d045f03b9a1f0793e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
(require 'fcuny-vars)

(use-package dash
  :ensure t)

(use-package org
  :after (dash)
  :ensure t

  :hook ((org-mode              . visual-line-mode)
         (org-mode              . org-indent-mode)
         (org-capture-mode-hook . delete-other-windows))

  :bind (("C-c c" . org-capture)
         ("C-c a" . org-agenda)
         ("C-c o" . hydra-org-menu/body))

  :config
  (progn ()
    (org-babel-do-load-languages
     'org-babel-load-languages
     '((shell . t)
       (python . t)
       (emacs-lisp . t))))

  :custom
  ;; cosmetic
  (org-pretty-entities t)
  (org-startup-indented t)
  (org-tags-column -120)

  ;; files
  (org-directory (expand-file-name "~/Documents/notebooks"))
  (org-archive-dir (concat org-directory "/archive/"))

  (org-default-projects-dir (concat org-directory "/projects"))
  (org-default-personal-dir (concat org-directory "/personal"))
  (org-default-completed-dir (concat org-directory "/completed"))
  (org-default-technical-dir (concat org-directory "/technical"))

  (org-default-completed-file nil)
  (org-default-inbox-file (concat org-directory "/inbox.org"))
  (org-default-tasks-file (concat org-directory "/tasks.org"))
  (org-default-incubate-file (concat org-directory "/incubate.org"))
  (org-default-media-file (concat org-directory "/media.org"))
  (org-default-notes-file (concat org-directory "/notes.org"))

  ;; how to manage tasks
  (org-todo-keywords '((sequence "TODO(t)" "DOING(g)" "|" "DONE(d)")
                       (sequence "|" "CANCELED(c)")))

  ;; agenda related
  (org-agenda-start-on-weekday 1)
  (org-agenda-files `(,org-default-projects-dir
                      ,org-default-inbox-file
                      ,org-default-tasks-file))

  ;; org babel related
  ;; prevent the conversion of spaces into tabs (necessary for Python code exports)
  (org-src-fontify-natively t)
  (org-src-preserve-indentation t)
  (org-edit-src-content-indentation t)

  ;; behavior
  ;; I want to follow links on RET
  (org-return-follows-link t)
  (org-enforce-todo-dependencies t)
  (org-export-with-toc nil)
  (org-export-with-section-numbers nil)

  ;; A few abbreviations I use regularly
  (org-link-abbrev-alist
   '(("src"  . "~/workspace/%s")
     ("jira" . "https://jira.twitter.biz/browse/%s")
     ("ph"   . "https://phabricator.twitter.biz/%s")
     ("go"   . "http://go/%s")))

  ;; entries
  (org-blank-before-new-entry (quote ((heading . nil)
				      (plain-list-item . nil))))

  ;; see https://github.com/abo-abo/swiper/issues/986
  (org-goto-interface 'outline-path-completion)

  ;; refile and capture
  (org-refile-use-outline-path 'file)
  (org-outline-path-complete-in-steps nil)
  (org-refile-allow-creating-parent-nodes 'confirm)
  (org-refile-targets (append '((org-default-media-file :level . 1)
                                (org-default-notes-file :level . 0))
                              (->>
                               (directory-files org-default-projects-dir nil ".org$")
                               (-remove-item (file-name-base org-default-media-file))
                               (--remove (s-starts-with? "." it))
                               (--map (format "%s/%s" org-default-projects-dir it))
                               (--map (cons it (cons :level 1))))))

  (org-capture-templates
   `(("t" "task entry" entry
      (file ,org-default-inbox-file )
      "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n%i\n\nfrom: %a")))

  :config
  (defhydra hydra-org-menu (:columns 6)
     "
  ^Navigate^      ^Refile^       ^Move^           ^Update^        ^Go To^        ^Dired^
  ^^^^^^^^^^---------------------------------------------------------------------------------------
  _k_: ↑ previous _t_: tasks     _m X_: projects  _T_: todo task  _g t_: tasks    _g X_: projects
  _j_: ↓ next     _p_: personal  _m P_: personal  _S_: schedule   _g x_: inbox    _g P_: personal
  _c_: archive    _r_: refile    _m T_: technical _D_: deadline   _g n_: notes    _g T_: technical
  _d_: delete     _i_: incubate                 _R_: rename                   _g C_: completed
  "
    ("<up>" org-previous-visible-heading)
    ("<down>" org-next-visible-heading)
    ("k" org-previous-visible-heading)
    ("j" org-next-visible-heading)
    ("c" fcuny/org-archive-subtree-as-completed)
    ("d" org-cut-subtree)
    ("t" fcuny/org-refile-to-task)
    ("i" fcuny/org-refile-to-incubate)
    ("p" fcuny/org-refile-to-personal-notes)
    ("r" org-refile)
    ("m X" fcuny/org-refile-to-projects-dir)
    ("m P" fcuny/org-refile-to-personal-dir)
    ("m T" fcuny/org-refile-to-technical-dir)
    ("T" org-todo)
    ("S" org-schedule)
    ("D" org-deadline)
    ("R" org-rename-header)
    ("g t" (find-file-other-window org-default-tasks-file))
    ("g i" (find-file-other-window org-default-incubate-file))
    ("g x" (find-file-other-window org-default-inbox-file))
    ("g c" (find-file-other-window org-default-completed-file))
    ("g n" (find-file-other-window org-default-notes-file))
    ("g X" (dired org-default-projects-dir))
    ("g P" (dired org-default-personal-dir))
    ("g T" (dired org-default-technical-dir))
    ("g C" (dired org-default-completed-dir))
    ("[\t]" (org-cycle))
    ("s" (org-save-all-org-buffers) "save")
    ("q" nil "quit")))

(use-package htmlize
  :ensure t)

(use-package org-journal
  :ensure t
  :after (org)
  :custom
  (org-journal-file-format "%Y-%m.org")
  (org-journal-dir "~/Documents/notebooks/journal/")
  (org-journal-date-format "#+TITLE: Monthly Journal Entry - %e %b %Y (%A)")
  (org-journal-file-type `monthly))

(provide 'fcuny-org)