kkk-org.el 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ;;; kkk-org.el --- Org Mode Configuration -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2023 Vinicius Teshima <vini.tes@pm.me>
  3. ;; Author: Vinicius Teshima <vini.tes@pm.me>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;;; Commentary:
  15. ;; Org Config
  16. ;;; Code:
  17. (require 'kkk-utils)
  18. (defvar kkk-org--capture-folder "~/Sync/Documents/Emacs/Captures/")
  19. (defvar kkk-org--agenda-folder "~/Sync/Documents/Emacs/Agenda/")
  20. (kkk-utils-mkdir kkk-org--capture-folder)
  21. (kkk-utils-mkdir kkk-org--agenda-folder)
  22. (defun kkk-org--capture-folder+file (FILE)
  23. "Will concat `kkk-org--capture-folder' with FILE."
  24. (concat kkk-org--capture-folder FILE))
  25. (defun kkk-org--agenda-folder+file (FILE)
  26. "Will concat `kkk-org--agenda-folder' with FILE."
  27. (concat kkk-org--agenda-folder FILE))
  28. (defconst kkk-org--capture-work-task-template
  29. "** %^{Task Number} :task:
  30. :PROPERTIES:
  31. :DATE_CREATE: %^U
  32. :DESC: %^{Enter the Description}
  33. :SECS: 0
  34. :MERGED: N
  35. :END:
  36. *** COMMENT Links
  37. **** Task
  38. **** PR
  39. ***** QA
  40. ****** Description
  41. #+begin_src markdown
  42. #+end_src
  43. ***** PROD
  44. ****** Description
  45. #+begin_src markdown
  46. #+end_src
  47. %i
  48. %?")
  49. (use-package org-agenda
  50. :straight nil
  51. :bind (("C-c a" . org-agenda))
  52. :config
  53. (setq org-agenda-span 'day
  54. org-agenda-start-with-log-mode t)
  55. (setq org-agenda-files (list (kkk-org--agenda-folder+file "Agenda.org")))
  56. )
  57. (defun kkk-org--make-work-capture-template (keys what)
  58. "KEYS WHAT."
  59. (list keys what 'entry
  60. (list 'file+headline "~/Sync/Work/BRANCHES.org" what)
  61. kkk-org--capture-work-task-template))
  62. (defun kkk-org--make-work-templates (prefix list)
  63. "PREFIX LIST."
  64. (unless (symbolp list)
  65. (error "LIST *MUST* be a SYMBOL"))
  66. (unless (stringp prefix)
  67. (error "PREFIX *MUST* be a STRING"))
  68. (let ((s_ (shell-command-to-string
  69. "grep '^* ' ~/Sync/Work/BRANCHES.org | tr -d '* '")))
  70. (let* ((i_ 0)
  71. (t_ (string-lines s_))
  72. (l_ (length t_)))
  73. (while (< i_ l_)
  74. (let ((it_ (nth i_ t_)))
  75. (unless (string-empty-p it_)
  76. (add-to-list list (kkk-org--make-work-capture-template
  77. (concat prefix (int-to-string i_)) it_)
  78. t)
  79. )
  80. )
  81. (setq i_ (1+ i_))
  82. )
  83. )
  84. )
  85. )
  86. (use-package org-capture
  87. :straight nil
  88. :bind (("C-c c" . org-capture))
  89. :init
  90. (setq org-capture-templates
  91. (list
  92. (list "t" "Todo"
  93. 'entry
  94. (list 'file+headline
  95. (kkk-org--capture-folder+file "Todo.org")
  96. "Tasks")
  97. "* TODO %?\n%i\n%a")
  98. (list "j" "Journal"
  99. 'entry
  100. (list 'file+headline
  101. (kkk-org--capture-folder+file "Journal.org")
  102. "Journal")
  103. "* %?\nEntered on %U\n%i\n%a")
  104. (list "i" "Idea"
  105. 'entry
  106. (list 'file+headline
  107. (kkk-org--capture-folder+file "Ideas.org")
  108. "Ideas")
  109. "* %?\n%i\n%a")
  110. '("w" "Work")
  111. '("wt" "Task")
  112. )
  113. )
  114. (kkk-org--make-work-templates "wt" 'org-capture-templates)
  115. )
  116. (org-babel-do-load-languages
  117. 'org-babel-load-languages
  118. '((emacs-lisp . t)
  119. (python . t)
  120. (shell . t)))
  121. (require 'org-tempo)
  122. (dolist (it '(("sh" . "src shell") ("el" . "src emacs-lisp")
  123. ("py" . "src python") ("c" . "src C") ("lu" . "src lua")
  124. ("md" . "src markdown") ("sql" . "src sql")))
  125. (add-to-list 'org-structure-template-alist it))
  126. (use-package org
  127. :config
  128. (setq org-ellipsis " ▼"
  129. org-src-preserve-indentation t
  130. org-return-follows-link t
  131. ;; Org-Agenda
  132. org-log-done 'time
  133. org-log-into-drawer t)
  134. (setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)"))))
  135. (provide 'kkk-org)
  136. ;;; kkk-org.el ends here