init-org.el 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; Org mode
  2. ;;; TODO: org-import should be able to parse "|" in CSV files.
  3. (define-key org-mode-map (kbd "C-c C-a") 'org-agenda)
  4. (setq
  5. ;; Disable line splitting on M-RET.
  6. org-M-RET-may-split-line '((default))
  7. org-insert-heading-respect-content t
  8. org-enforce-todo-dependencies t
  9. org-deadline-warning-days 7
  10. org-agenda-default-appointment-duration 60
  11. org-agenda-columns-add-appointments-to-effort-sum t
  12. org-ellipsis " […]"
  13. org-adapt-indentation nil
  14. ;; Add keywords.
  15. org-todo-keywords '((sequence "TODO" "REVIEW" "DONE"))
  16. ;; org-todo-keyword-faces '(("REVIEW" :inherit org-done))
  17. ;; Priorities.
  18. org-priority-start-cycle-with-default nil
  19. org-default-priority 67
  20. ;; Org-mode aligns text.
  21. indent-tabs-mode nil)
  22. ;;; Agendas.
  23. (add-to-list 'org-agenda-files "~/personal/todo/todo.org")
  24. (defun ambrevar/org-switch-agenda-file (&optional other-window)
  25. "Switch between org-agenda and the first org-agenda-files."
  26. (interactive "P")
  27. (if (and buffer-file-name
  28. (member (expand-file-name buffer-file-name) (mapcar 'expand-file-name org-agenda-files)))
  29. (org-agenda)
  30. (let ((b (find-buffer-visiting (car org-agenda-files))))
  31. (if b
  32. (if (get-buffer-window b)
  33. (select-window (get-buffer-window b))
  34. (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) b))
  35. (funcall (if other-window 'find-file-other-window 'find-file) (car org-agenda-files))))))
  36. (defun ambrevar/org-switch-agenda-file-other-window ()
  37. "Like `ambrevar/org-switch-agenda-file' but use other window if possible."
  38. (interactive)
  39. (ambrevar/org-switch-agenda-file t))
  40. ;;; Set PDF association in Org-mode (original is 'default).
  41. (setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs)
  42. ;;; Hooks.
  43. (dolist (fun '(ambrevar/turn-off-linum ambrevar/turn-off-indent-tabs turn-off-auto-fill))
  44. (add-hook 'org-mode-hook fun))
  45. (when (require 'org-contacts nil t)
  46. (let ((contacts "~/personal/contacts/contacts.org"))
  47. (when (file-exists-p contacts)
  48. ;; When used to auto-complete e-mail addresses, the file is automatically
  49. ;; loaded. The buffer usually need not be restored by a desktop session.
  50. (when desktop-save-mode
  51. (setq desktop-files-not-to-save
  52. (concat (substring desktop-files-not-to-save 0 -2) "\\|" (regexp-quote (expand-file-name contacts)) "\\)")))
  53. (setq org-contacts-files (list contacts)))))
  54. (when (require 'org-bullets nil t)
  55. (add-hook 'org-mode-hook 'org-bullets-mode))
  56. (provide 'init-org)