<commit_before>;;; lang/org/config.el

;; A few things you can expect
;;   + `org-capture' in a popup frame (can be invoked from outside emacs too)
;;   + Exported files are put in a centralized location (see
;;     `org-export-directory')
;;   + TODO A simpler attachment system (with auto-deleting support) and
;;     drag-and-drop for images and documents into org files
;;   + TODO Custom links for class notes
;;   + TODO An org-mode based CRM (including invoicing and pdf exporting) (see custom-crm)
;;   + TODO A tag-based file browser reminiscient of Evernote and Quiver (there's neotree too!)

(defvar +org-init-hook nil
  "TODO")

(add-hook 'org-load-hook '+org|init)
(add-hook 'org-mode-hook '+org|hook)

;; Custom variables
(defvar +org-dir (expand-file-name "~/work/org/")
  "The directory where org files are kept.")
(defvaralias 'org-directory '+org-dir)

(defvar +org-notes-dir (concat +org-dir "notes")
  "The directory where the notes are kept")

(defvar +org-attachment-dir ".attach/"
  "Where to store attachments (relative to current org file).")

;; (defvar-local +org-attachments-list '()
;;   "A list of attachments for the current buffer. This is so my custom attachment
;; system can keep track of each buffer's attachments.")

;; Ensure ELPA org is loaded instead of the built-in org.
(when-let (path (locate-library "org" nil doom--package-load-path))
  (push (file-name-directory path) load-path))

(load! +attach)
(load! +capture)
(load! +export)


;;
;; Config
;;

(defun +org|hook ()
  "Run everytime `org-mode' is enabled."
  (evil-org-mode +1)
  (visual-line-mode +1)
  (setq line-spacing 1)

  ;; If saveplace places the point in a folded position, unfold it on load
  (when (outline-invisible-p)
    (ignore-errors
      (save-excursion
        (outline-previous-visible-heading 1)
        (org-show-subtree))))

  (defun +org|update-cookies ()
    "Update counts on headlines (\"cookies\")."
    (when (and buffer-file-name (file-exists-p buffer-file-name))
      (org-update-statistics-cookies t)))

  (add-hook 'before-save-hook '+org|update-cookies nil t)
  (add-hook 'evil-insert-state-exit-hook '+org|update-cookies nil t))


(defun +org|init ()
  "Initializes org core."
  (define-minor-mode evil-org-mode
    "Evil-mode bindings for org-mode."
    :init-value nil
    :lighter " !"
    :keymap (make-sparse-keymap)
    :group 'evil-org)

  (setq-default
   org-export-coding-system 'utf-8

   ;; Appearance
   outline-blank-line t
   org-indent-mode-turns-on-hiding-stars t
   org-adapt-indentation nil
   org-blank-before-new-entry '((heading . nil) (plain-list-item . auto))
   org-cycle-separator-lines 1
   org-cycle-include-plain-lists t
   org-ellipsis '+doom-folded-face
   org-entities-user '(("flat" "\\flat" nil "" "" "266D" "♭")
                       ("sharp" "\\sharp" nil "" "" "266F" "♯"))
   org-fontify-done-headline t
   org-fontify-quote-and-verse-blocks t
   org-fontify-whole-heading-line t
   org-footnote-auto-label 'plain
   org-hide-emphasis-markers t
   org-hide-leading-stars t
   org-image-actual-width nil
   org-indent-indentation-per-level 2
   org-pretty-entities t
   org-pretty-entities-include-sub-superscripts t
   org-startup-folded t
   org-startup-indented t
   org-startup-with-inline-images nil
   org-tags-column 0
   org-use-sub-superscripts '{}

   ;; Behavior
   org-catch-invisible-edits 'show
   org-checkbox-hierarchical-statistics nil
   org-completion-use-ido nil ; Use ivy/counsel for refiling
   org-confirm-elisp-link-function nil
   org-default-priority ?C
   org-hidden-keywords '(title)
   org-hierarchical-todo-statistics t
   org-log-done t
   org-loop-over-headlines-in-active-region t
   org-outline-path-complete-in-steps nil
   org-refile-use-outline-path t
   org-special-ctrl-a/e t

   ;; Sorting/refiling
   org-archive-location (concat +org-dir "/archived/%s::")
   org-refile-targets '((nil . (:maxlevel . 2))) ; display full path in refile completion

   ;; Agenda
   org-agenda-restore-windows-after-quit nil
   org-agenda-skip-unavailable-files nil
   org-agenda-dim-blocked-tasks nil
   org-agenda-window-setup 'other-frame ; to get org-agenda to behave with shackle...
   org-agenda-inhibit-startup t
   org-agenda-files (directory-files +org-dir t "\\.org$" t)
   org-todo-keywords '((sequence "[ ](t)" "[-](p)" "[?](m)" "|" "[X](d)")
                       (sequence "TODO(T)" "|" "DONE(D)")
                       (sequence "IDEA(i)" "NEXT(n)" "ACTIVE(a)" "WAITING(w)" "LATER(l)" "|" "CANCELLED(c)"))


   ;; Babel
   org-confirm-babel-evaluate nil   ; you don't need my permission
   org-src-fontify-natively t       ; make code pretty
   org-src-preserve-indentation t
   org-src-tab-acts-natively t
   org-src-window-setup 'current-window
   org-edit-src-content-indentation 0<commit_msg>lang/org: highlight appointments in calendar (WIP)<commit_after>;;; lang/org/config.el

;; A few things you can expect
;;   + `org-capture' in a popup frame (can be invoked from outside emacs too)
;;   + Exported files are put in a centralized location (see
;;     `org-export-directory')
;;   + TODO A simpler attachment system (with auto-deleting support) and
;;     drag-and-drop for images and documents into org files
;;   + TODO Custom links for class notes
;;   + TODO An org-mode based CRM (including invoicing and pdf exporting) (see custom-crm)
;;   + TODO A tag-based file browser reminiscient of Evernote and Quiver (there's neotree too!)

(defvar +org-init-hook nil
  "TODO")

(add-hook 'org-load-hook '+org|init)
(add-hook 'org-mode-hook '+org|hook)

;; Custom variables
(defvar +org-dir (expand-file-name "~/work/org/")
  "The directory where org files are kept.")
(defvaralias 'org-directory '+org-dir)

(defvar +org-notes-dir (concat +org-dir "notes")
  "The directory where the notes are kept")

(defvar +org-attachment-dir ".attach/"
  "Where to store attachments (relative to current org file).")

;; (defvar-local +org-attachments-list '()
;;   "A list of attachments for the current buffer. This is so my custom attachment
;; system can keep track of each buffer's attachments.")

;; Ensure ELPA org is loaded instead of the built-in org.
(when-let (path (locate-library "org" nil doom--package-load-path))
  (push (file-name-directory path) load-path))

(load! +attach)
(load! +capture)
(load! +export)


;;
;; Config
;;

(defun +org|hook ()
  "Run everytime `org-mode' is enabled."
  (evil-org-mode +1)
  (visual-line-mode +1)
  (setq line-spacing 1)

  ;; If saveplace places the point in a folded position, unfold it on load
  (when (outline-invisible-p)
    (ignore-errors
      (save-excursion
        (outline-previous-visible-heading 1)
        (org-show-subtree))))

  (defun +org|update-cookies ()
    "Update counts on headlines (\"cookies\")."
    (when (and buffer-file-name (file-exists-p buffer-file-name))
      (org-update-statistics-cookies t)))

  (add-hook 'before-save-hook '+org|update-cookies nil t)
  (add-hook 'evil-insert-state-exit-hook '+org|update-cookies nil t))


(defun +org|init ()
  "Initializes org core."
  (define-minor-mode evil-org-mode
    "Evil-mode bindings for org-mode."
    :init-value nil
    :lighter " !"
    :keymap (make-sparse-keymap)
    :group 'evil-org)

  (setq-default
   org-export-coding-system 'utf-8

   ;; Appearance
   outline-blank-line t
   org-indent-mode-turns-on-hiding-stars t
   org-adapt-indentation nil
   org-blank-before-new-entry '((heading . nil) (plain-list-item . auto))
   org-cycle-separator-lines 1
   org-cycle-include-plain-lists t
   org-ellipsis '+doom-folded-face
   org-entities-user '(("flat" "\\flat" nil "" "" "266D" "♭")
                       ("sharp" "\\sharp" nil "" "" "266F" "♯"))
   org-fontify-done-headline t
   org-fontify-quote-and-verse-blocks t
   org-fontify-whole-heading-line t
   org-footnote-auto-label 'plain
   org-hide-emphasis-markers t
   org-hide-leading-stars t
   org-image-actual-width nil
   org-indent-indentation-per-level 2
   org-pretty-entities t
   org-pretty-entities-include-sub-superscripts t
   org-startup-folded t
   org-startup-indented t
   org-startup-with-inline-images nil
   org-tags-column 0
   org-use-sub-superscripts '{}

   ;; Behavior
   org-catch-invisible-edits 'show
   org-checkbox-hierarchical-statistics nil
   org-completion-use-ido nil ; Use ivy/counsel for refiling
   org-confirm-elisp-link-function nil
   org-default-priority ?C
   org-hidden-keywords '(title)
   org-hierarchical-todo-statistics t
   org-log-done t
   org-loop-over-headlines-in-active-region t
   org-outline-path-complete-in-steps nil
   org-refile-use-outline-path t
   org-special-ctrl-a/e t

   ;; Sorting/refiling
   org-archive-location (concat +org-dir "/archived/%s::")
   org-refile-targets '((nil . (:maxlevel . 2))) ; display full path in refile completion

   ;; Agenda
   diary-file (concat doom-local-dir "dairy/")
   calendar-mark-diary-entries-flag t
   org-agenda-restore-windows-after-quit nil
   org-agenda-skip-unavailable-files nil
   org-agenda-dim-blocked-tasks nil
   org-agenda-window-setup 'other-frame ; to get org-agenda to behave with shackle...
   org-agenda-inhibit-startup t
   org-agenda-files (directory-files +org-dir t "\\.org$" t)
   org-todo-keywords '((sequence "[ ](t)" "[-](p)" "[?](m)" "|" "[X](d)")
                       (sequence "TODO(T)" "|" "DONE(D)")
                       (sequence "IDEA(i)" "NEXT(n)" "ACTIVE(a)" "WAITING(w)" "LATER(l)" "|" "CANCELLED(c)"))


   ;; Babel
   org-confirm-babel-evaluate nil   ; you don't need my permission
   org-src-fontify-natively t       ; make code pretty
   org-src-preserve-indentation t
   org-src-tab-acts-natively t
   org-src-window-setup 'current-window
   org-edit-src-content-indentation 0
{'fraction_non_alphanumeric': 0.14535003079449804, 'fraction_numerical': 0.003284746458632724, 'mean_word_length': 3.165455322787516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '893481', 'n_tokens_mistral': 3524, 'n_tokens_neox': 3357, 'n_words': 852}