summary refs log tree commit diff
path: root/emacs/custom/fcuny-org.el
blob: d5fe6628a4afc8716c2f35e4a27bf64bcd715a0a (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
;;; fcuny-org.el --- Configure org-mode
;;; Commentary:
;;; Code:

(require 'fcuny-vars)
(require 'fcuny-clipboard)

(require 'use-package)

(use-package org-ml
  :ensure t)

(use-package htmlize
  :ensure t)

(use-package org
  :ensure t
  :commands (org-check-agenda-file org-protocol-capture)
  :mode (("\\.txt\\'" . org-mode))
  :hook ((org-mode                     . org-indent-mode)
         (org-mode                     . org-hide-block-all)
         (org-mode                     . visual-line-mode)
         (org-capture-after-finalize   . org-save-all-org-buffers)
         (org-capture-prepare-finalize . org-save-all-org-buffers))
  :bind (("C-c c" . org-capture))

  :init
  ;; save all the org buffers after refilling tasks
  (advice-add 'org-refile :after
              (lambda (&rest _)
                (org-save-all-org-buffers)))

  :config
  (defvar load-language-list '((emacs-lisp . t)
                               (python . t)
                               (shell . t)))
  (use-package ob-go
    :ensure t
    :init (cl-pushnew '(go . t) load-language-list))

  (org-babel-do-load-languages 'org-babel-load-languages
                               load-language-list)

  :custom
  (org-directory fcuny/org-directory)
  ;; hide emphasis markup
  (org-hide-emphasis-markers t)

  ;; when archiving, inherit the tags from the parent
  (org-archive-subtree-add-inherited-tags t)

  ;; display unicode characters
  (org-pretty-entities t)

  ;; log the time of completion
  (org-log-done 'time)
  (org-log-into-drawer t)

  (org-startup-indented t)

  (org-cycle-separator-lines 0)
  (org-startup-folded 'content)
  (org-todo-keywords '((sequence "TODO" "STARTED" "WAITING" "|" "DONE" "CANCELED")))

  ;; priorities
  (org-priority-start-cycle-with-default nil) ;; Start one over/under default value.
  (org-highest-priority ?A)
  (org-lowest-priority ?D)
  (org-default-priority ?C) ;; Ensures unset tasks have low priority.

  ;; refile
  (org-refile-use-cache nil)
  (org-refile-targets `((,(expand-file-name "tasks.org" org-directory) :maxlevel . 1)
                        (,(expand-file-name "notes.org" org-directory) :maxlevel . 1)
                        (,(expand-file-name "projects.org" org-directory) :tag . "project")))
  (org-refile-use-outline-path 'file)
  (org-outline-path-complete-in-steps nil)
  (org-refile-allow-creating-parent-nodes 'confirm)

  ;; 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)

  ;; I want to follow links on RET
  (org-return-follows-link t)

  ;; some configurations for exporting document
  (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.rbx.com/browse/%s")
     ("go"   . "http://go/%s")))

  ;; entries
  (org-blank-before-new-entry nil)
  (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)

  (org-reverse-note-order t))

(use-package org-agenda
  :ensure nil
  :after (org)
  :bind (("C-c a" . org-agenda))
  :custom
  (org-agenda-files `(,(expand-file-name "inbox.org" org-directory)
                      ,(expand-file-name "notes.org" org-directory)
                      ,(expand-file-name "tasks.org" org-directory)
                      ,(expand-file-name "projects.org" org-directory)
                      ,(expand-file-name "bookmarks.org" org-directory)
                      ,(expand-file-name "journal.org" org-directory)))
  (org-agenda-show-all-dates t)
  (calendar-week-start-day 1)
  (org-agenda-custom-commands nil)
  (org-agenda-start-on-weekday 1)

  :config
  (add-to-list 'org-agenda-custom-commands
               '("A" "Agenda"
                 ((agenda ""
                          ((org-agenda-span 'week)))
                  (todo "TODO"
                        ((org-agenda-overriding-header "To Refile")
                         (org-agenda-files `(,(expand-file-name "inbox.org" org-directory)))))
                  (todo "STARTED"
                        ((org-agenda-overriding-header "In Progress")))
                  (todo "WAITING"
                        ((org-agenda-overriding-header "Blocked")))
                  (todo "TODO"
                        ((org-agenda-overriding-header "Not yet started")
                         (org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled))))))))

(defun fcuny/org-capture/link ()
  "Make a TODO entry with a link in clipboard.
The page title is used as an entry heading."
  (let* ((url-string (s-trim (fcuny/clipboard-get-contents)))
         (pdf (string-suffix-p "pdf" url-string)))
    (unless pdf
      (let ((page-title (org-web-tools--html-title (org-web-tools--get-url url-string))))
        (concat "* "
                page-title
                "\t%^g"
                "\n:PROPERTIES:\n:CREATED: %T\n:URL: "
                url-string
                "\n:END:\n%?")))))

(use-package org-web-tools
  :ensure t)

(use-package org-capture
  :ensure nil
  :after (org)
  :custom
  (org-capture-templates
   `(("t" "Todo" entry (file "inbox.org")
      "* TODO [#D] %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n")

     ("n" "Note" entry (file "notes.org")
      "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n")

     ("l" "Bookmark" entry (file "bookmarks.org")
      (function fcuny/org-capture/link))

     ("j" "Journal" entry
      (file+olp+datetree "journal.org")
      "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n" :tree-type day))))

(provide 'fcuny-org)
;;; fcuny-org.el ends here