|
93 | 93 | (org-agenda-start-day nil) ;; i.e. today |
94 | 94 | (org-agenda-span 14) |
95 | 95 | (org-agenda-files '("~/org/personal/" |
| 96 | + "~/org/orgzly/errand.org" |
96 | 97 | "~/org/work/")) |
97 | 98 | (org-agenda-custom-commands '(("w" "Weekly Agenda" |
98 | 99 | ((agenda "" ((org-super-agenda-groups |
|
134 | 135 | (use-package cl-lib) |
135 | 136 | (use-package ox) |
136 | 137 |
|
137 | | -(defun my-org-confirm-babel-evaluate (lang body) |
138 | | - (not (string= lang "emacs-elisp"))) |
139 | | - |
140 | | -;; Special functions to insert week-based object entries |
141 | | - |
142 | | -(defun current-year () |
143 | | - (nth 5 (decode-time (current-time)))) |
144 | | - |
145 | | -(defun my-calendar-iso-day-to-gregorian (week-number week-day) |
146 | | - "Return gregorian day corresponding to WEEK-NUMBER and WEEK-DAY. |
147 | | -WEEK-DAY is expressed as an integer in the range 0..6: |
148 | | -1 = Monday, 2 = Tuesday, ..., 0 = Sunday." |
149 | | - (calendar-gregorian-from-absolute |
150 | | - (calendar-iso-to-absolute (list week-number week-day (current-year))))) |
151 | | - |
152 | | -(defun my-gregorian-date-as-string (date) |
153 | | - (cl-destructuring-bind (month day year) date |
154 | | - (format "%4d-%02d-%02d" year month day))) |
155 | | - |
156 | | -(defun my-current-week-number () |
157 | | - "Return ISO8601 week number for today." |
158 | | - (format-time-string "%V" (current-time))) |
159 | | - |
160 | | -(defvar day-properties-string ":PROPERTIES:\n:COLUMNS: %25ITEM %TAGS %PRIORITY %TODO\n:END:") |
161 | | - |
162 | | -(defun my-week-heading (week-number) |
163 | | - "Return a string representing the heading for WEEK-NUMBER todo entries subtree." |
164 | | - (let ((week-begin-date (my-calendar-iso-day-to-gregorian week-number 1)) |
165 | | - (week-end-date (my-calendar-iso-day-to-gregorian week-number 5))) |
166 | | - (format "Week %d (%s - %s)" |
167 | | - week-number |
168 | | - (my-gregorian-date-as-string week-begin-date) |
169 | | - (my-gregorian-date-as-string week-end-date)))) |
170 | | - |
171 | | -(defun my-today-heading () |
172 | | - "Return a string representing the heading for today's todo entries subtree." |
173 | | - (format-time-string "%A" (current-time))) |
174 | | - |
175 | | -(defun one-week-from-today () |
176 | | - (format-time-string "%Y-%m-%d" |
177 | | - (+ (time-convert nil 'integer) |
178 | | - (* 3600 24 7)))) |
179 | | - |
180 | | -(org-babel-do-load-languages |
181 | | - 'org-babel-load-languages |
182 | | - '((perl . t) |
183 | | - (shell . t) |
184 | | - (python . t) |
185 | | - (sql . t) |
186 | | - (sqlite . t) |
187 | | - (gnuplot . t) |
188 | | - (R . t) |
189 | | - (plantuml . t) |
190 | | - (http . t) |
191 | | - (lisp . t) |
192 | | - (dot . t))) |
193 | | - |
194 | | -(defun my-insert-current-week-item (week-number) |
195 | | - "Insert 1-week-worth structure for entering todo entries for WEEK-NUMBER." |
196 | | - (interactive "P") |
197 | | - (insert (format "* %s\n" (my-week-heading week-number))) |
198 | | - (dolist (week-day-name '(Monday |
199 | | - Tuesday |
200 | | - Wednesday |
201 | | - Thursday |
202 | | - Friday |
203 | | - Saturday |
204 | | - Sunday)) |
205 | | - (insert (format "** %s\n%s\n" week-day-name day-properties-string)))) |
206 | | - |
207 | | -(defun my-org-set-item-deadline (week-number) |
208 | | - (let ((week-end-date (my-calendar-iso-day-to-gregorian week-number 5))) |
209 | | - (org-deadline nil (my-gregorian-date-as-string week-end-date)))) |
210 | | - |
211 | | -(defun my-org-set-tree-deadline (week-number) |
212 | | - (interactive "P") |
213 | | - (org-map-entries (lambda () (my-org-set-item-deadline week-number)) nil 'tree)) |
214 | | - |
215 | | -;; Experimental |
216 | | -;; a more natural way to use indirect buffers |
217 | | -;; not sure about the keybinding |
218 | | - |
219 | | -(defun open-subtree-in-another-window () |
220 | | - "Open subtree at point into another window." |
221 | | - (interactive) |
222 | | - (org-tree-to-indirect-buffer) |
223 | | - (windmove-right)) |
224 | | - |
225 | | -(defun my-find-today-heading () |
226 | | - (let ((m (org-find-olp `(,(my-week-heading |
227 | | - (string-to-number (my-current-week-number))) |
228 | | - ,(my-today-heading)) |
229 | | - ;; In current buffer, because we're using file+function |
230 | | - t))) |
231 | | - (set-buffer (marker-buffer m)) |
232 | | - (org-capture-put-target-region-and-position) |
233 | | - (widen) |
234 | | - (goto-char m) |
235 | | - (set-marker m nil))) |
236 | | - |
237 | | -(defun my-org-jump-to-today () |
238 | | - "Move cursor to the heading corresponding to today." |
239 | | - (interactive) |
240 | | - (my-find-today-heading)) |
241 | | - |
242 | | -(defun orgzly-files () |
243 | | - (file-expand-wildcards "~/Dropbox/orgzly/*.org")) |
244 | | - |
245 | | -(add-to-list 'org-latex-classes |
246 | | - '("tufte-handout" |
247 | | - "\\documentclass{tufte-handout}" |
248 | | - ("\\section{%s}" . "\\section*{%s}") |
249 | | - ("\\subsection{%s}" . "\\subsection*{%s}") |
250 | | - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") |
251 | | - ("\\paragraph{%s}" . "\\paragraph*{%s}") |
252 | | - ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) |
253 | | - |
254 | | - |
255 | | -(setq-default org-download-method 'attach ;; Screenshots are stored in data/ directory by ID. Easier to manage |
256 | | - org-download-heading-lvl nil |
257 | | - org-download-delete-image-after-download t |
258 | | - org-download-screenshot-method "echo" |
259 | | - org-download-screenshot-file "/tmp/screenshot.png" |
260 | | - org-download-image-org-width 800 |
261 | | - ;; Don't annotate |
262 | | - org-download-annotate-function (lambda (link) "")) |
263 | | - |
264 | | -;; My customized org-download to incorporate flameshot gui Workaround to setup flameshot, which enables annotation. |
265 | | -;; In flameshot, set filename as "screenshot", and the command as "flameshot gui -p /tmp", so that we always ends up |
266 | | -;; with /tmp/screenshot.png. Nullify org-download-screenshot-method by setting it to `echo', so that essentially we |
267 | | -;; are only calling (org-download-image org-download-screenshot-file). |
268 | | -(defun my-org-download-screenshot () |
269 | | - "Capture screenshot and insert the resulting file. |
270 | | -The screenshot tool is determined by `org-download-screenshot-method'." |
271 | | - (interactive) |
272 | | - (let ((tmp-file "/tmp/screenshot.png")) |
273 | | - (delete-file tmp-file) |
274 | | - (call-process-shell-command "flameshot gui -p /tmp/") |
275 | | - ;; Because flameshot exit immediately, keep polling to check file existence |
276 | | - (while (not (file-exists-p tmp-file)) |
277 | | - (sleep-for 2)) |
278 | | - (org-download-image tmp-file))) |
279 | | -(global-set-key (kbd "<C-print>") 'my-org-download-screenshot) |
280 | | - |
281 | 138 | (provide 'larsen-orgmode) |
0 commit comments