;;---------------------- Agenda
(require 'org-habit)
(remap-global "C-à" 'org-agenda)
(remap-global "C-ç" 'org-capture)

;; My agenda files
(setq org-agenda-files (list "~/projects/blog/todo.org"))

;; Common variables for org-agenda
;; Important : agenda view does not show notes with imcomplete parents in Doom
(setq org-agenda-dim-blocked-notes nil
      org-agenda-start-day "today"
      org-agenda-skip-deadline-if-done t
      org-deadline-warning-days 0)

;; But it's easier to use org-super-agenda !
;;Warning : org-agenda-tag-filter-preset is set for all the view !! Cannot be used in blocks
(setq org-agenda-custom-commands
      '(("d" "daily"
	 ((agenda "" ((org-agenda-span 1))))
	 ((org-agenda-filter-preset '("+daily"))))
	("t" "today"
	 ((agenda "" ((org-agenda-span 1)
		      (org-super-agenda-groups
		       '((:name "Studying"
				;; :deadline today
				:tag "revisions")
			 (:name "Daily"
				:tag "daily")
			 (:name "Others"
				:todo "WAIT"
				:not (:tag ("revisions" "daily"))
				)
			 )))))
	 )))

;; ----------- Org + latex
;; (use-package org-ref
;;   :config
;;   (setq org-ref-completion-library 'org-ref-ivy-cite
;;         reftex-default-bibliography '("~/projects/sir/manuscript/references.bib")
;;         org-ref-bibliography-notes '("~/projects/blog/notes/books.org")
;;         org-ref-default-bibliography '("~/projects/sir/manuscript/references.bib")
;;         org-ref-pdf-directory "~/projects/blog/notes/pdfs/")
;;   ;; Customization : we want to insert the title of an entry in a reading list
;;   (push '("justtitle" . ((nil . "${title}"))) org-ref-formatted-citation-formats)

;;   ;; Helm bibtex configuration must be set
;;   (setq bibtex-completion-library-path '("~/projects/blog/notes/pdfs")
;;         bibtex-completion-bibliography '("~/projects/sir/manuscript/references.bib")
;;         bibtex-completion-library-path "~/projects/blog/notes/pdfs"
;;         bibtex-completion-notes-path "~/projects/blog/notes/books.org"
;;         ;; Do not open on default
;;         ivy-bibtex-default-action 'ivy-bibtex-insert-citation))

(setq org-latex-pdf-process '("latexmk -pdflatex='lualatex --shell-escape -interaction nonstopmode' -pdf -bibtex -f %f"))

;; Fast export: F5 is for users
(define-key org-mode-map (kbd "<f5>") #'(lambda() (interactive) (org-latex-export-to-pdf t)))

(setq revert-without-query '(".pdf")) ; Avoid confirmation with pdf
(require 'ox-beamer) ; Beamer presentations

;; Mimosis class for thesis
(add-to-list 'org-latex-classes
             '("mimosis"
               "\\documentclass{mimosis}
  [NO-DEFAULT-PACKAGES]
  [PACKAGES]
  [EXTRA]"
               ("\\chapter{%s}" . "\\addchap{%s}")
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

;;------------------------------- Workout template
(setq org-capture-templates
      '(
        ;; Workout
        ("h" "Handstand" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Handstand
 StW %^{StW}
 BtW %^{BtW}" )
	("j" "Jump ro»pe" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
	 "* Jump rope
%^{today}")
        ("l" "L-sit" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* L-sit
 %^{GtG}" )
        ("p" "Parkour")
        ("pm" "Parkour (passe-muraille)" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Parkour
Passe-muraille :
- cat hang (each side) : %^{Cat hang shimmy}
- top out (each side) : %^{Top out}
- cat hang leg press (each side) : %^{Cat hang leg press}
- cat hang pull-up (each side) : %^{Cat hang pull-up}
- knee raises (each side) : %^{Knee raises}
- passe-muraille: %^{passe-muraille}")
        ("po" "Parkour (autre)" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Parkour
%^{Parkour}")
        ("s" "Splits" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Splits
Standing splits (2-5s + rest) : %^{Standing splits}
Wall calf : %^{Wall calf}
Low lunge : %^{Low lunge}
Frog pose (dynamic) : %^{Frog pose}
Horse stance : %^{Horse stance}
Standing pancake : %^{Standing pancake}
Front split : %^{Front split}")
        ("r" "Running")
        ("rs" "Sprint" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Running
:PROPERTIES:
:type: sprint
:END:
%^{reps}p
%^{sprint}p
%^{rest}p
")
        ("ro" "Other" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Running
%^{type}p
%^{distance}p
%^{duration}p
%^{speed}p
")
        ("t" "Tricks" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
	 "* Tricks
Kip up : %^{kip-up}
Back flip : %^{backflip}
Front flip : %^{frontflip}
Front handspring : : %^{front handspring}")
        ("w" "Workout" entry (file+olp+datetree "~/projects/blog/notes/workout.org")
         "* Workout
RTO : %^{RTO}
Skin-the-cat : %^{Skin the cat}
L-sit : %^{L-sit}
Muscle-up L-sit : %^{Muscle-up}
Pistols (assisted) : %^{Pistols}
Extension (lower-back) : %^{Extension}
Front-lever row (tuck) : %^{Rows}
Planche on rings (tuck): %^{Planche tucked}
Norwegian curls: %^{Curls}
Compression : %^{Compression}"
         )

        ("c" "Cookbook" entry (file "~/projects/blog/notes/cooking.org") ;; Needs org-chef
         "%(org-chef-get-recipe-from-url)")
        ("m" "Manual Cookbook" entry (file "~/projects/blog/notes/cooking.org")
         "* %^{Recipe title: }\n  :PROPERTIES:\n  :source-url:\n  :servings:\n  :prep-time:\n  :cook-time:\n  :ready-in:\n  :END:\n** Ingredients\n   %?\n** Directions\n\n")
        ))

;; ------------------- Other
(add-to-list 'org-modules 'ol-gnus) ; Manage link to mail in gnus
(require 'ob-shell)