Use :hook and :custom

This commit is contained in:
Dimitri Lozeve 2025-05-04 11:26:27 +02:00
parent d42375ecf2
commit 0578e99870

193
init.el
View file

@ -386,93 +386,96 @@
:bind (("C-c l" . org-store-link) :bind (("C-c l" . org-store-link)
("C-c a" . org-agenda) ("C-c a" . org-agenda)
("C-c c" . org-capture)) ("C-c c" . org-capture))
:config :custom
(setq org-agenda-files (list (file-name-concat notes-dir "planner.org"))) (org-agenda-files (list (file-name-concat notes-dir "planner.org")))
(setq org-default-notes-file (file-name-concat notes-dir "planner.org")) (org-default-notes-file (file-name-concat notes-dir "planner.org"))
;; List numbering with a. b. a) b), etc. ;; List numbering with a. b. a) b), etc.
(setq org-list-allow-alphabetical t) (org-list-allow-alphabetical t)
;; Fontify code in code blocks ;; Fontify code in code blocks
(setq org-src-fontify-natively t) (org-src-fontify-natively t)
;; Tabs in src blocks ;; Tabs in src blocks
(setq org-src-tab-acts-natively t) (org-src-tab-acts-natively t)
;; Full contents opened by default ;; Full contents opened by default
(setq org-startup-folded nil) (org-startup-folded nil)
;; Only one empty line is enough to separate headings when folded ;; Only one empty line is enough to separate headings when folded
(setq org-cycle-separator-lines 2) (org-cycle-separator-lines 2)
;; Refile to paths in the file (level1/level2/level3) ;; Refile to paths in the file (level1/level2/level3)
(setq org-refile-targets '((nil :maxlevel . 5))) (org-refile-targets '((nil :maxlevel . 5)))
(setq org-refile-use-outline-path t) (org-refile-use-outline-path t)
(setq org-outline-path-complete-in-steps nil) (org-outline-path-complete-in-steps nil)
(org-special-ctrl-a/e nil)
(setq org-special-ctrl-a/e nil)
(add-hook 'org-mode-hook #'visual-line-mode)
;; Set to the location of your Org files on your local system ;; Set to the location of your Org files on your local system
(setq org-directory notes-dir) (org-directory notes-dir)
;; Agenda
(setq org-agenda-block-separator ?─ (org-agenda-block-separator ?─)
org-agenda-time-grid '((daily today require-timed) (org-agenda-time-grid '((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000) (800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄") " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"))
org-agenda-current-time-string (org-agenda-current-time-string
"⭠ now ─────────────────────────────────────────────────") "⭠ now ─────────────────────────────────────────────────")
(setq org-agenda-custom-commands (org-agenda-custom-commands
(quote (quote
(("z" "Agenda and TODOs" (("z" "Agenda and TODOs"
((agenda "" ((agenda ""
((org-agenda-span 7) ((org-agenda-span 7)
(org-agenda-start-on-weekday 1) (org-agenda-start-on-weekday 1)
(org-agenda-prefix-format " %t%s ") (org-agenda-prefix-format " %t%s ")
(org-agenda-repeating-timestamp-show-all t) (org-agenda-repeating-timestamp-show-all t)
(org-agenda-hide-tags-regexp "\\work"))) (org-agenda-hide-tags-regexp "\\work")))
(tags-todo "work" (tags-todo "work"
((org-agenda-prefix-format "") ((org-agenda-prefix-format "")
(org-agenda-sorting-strategy '(priority-down tag-up)))) (org-agenda-sorting-strategy '(priority-down tag-up))))
(tags-todo "personal" (tags-todo "personal"
((org-agenda-prefix-format "") ((org-agenda-prefix-format "")
(org-agenda-sorting-strategy '(tag-up priority-down))))) (org-agenda-sorting-strategy '(tag-up priority-down)))))
((org-agenda-remove-tags 'prefix) ((org-agenda-remove-tags 'prefix)
(org-agenda-todo-ignore-scheduled 'future) (org-agenda-todo-ignore-scheduled 'future)
(org-agenda-todo-ignore-deadlines 'future) (org-agenda-todo-ignore-deadlines 'future)
(org-agenda-tags-todo-honor-ignore-options t)) (org-agenda-tags-todo-honor-ignore-options t))
("fortnight.html")) ("fortnight.html"))
("n" "Agenda and all TODOs" ("n" "Agenda and all TODOs"
((agenda "" nil) ((agenda "" nil)
(alltodo "" nil)) (alltodo "" nil))
nil)))) nil))))
(org-capture-templates
(setq org-clock-persist 'history) (quote
(("t" "Task" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** TODO %?")
("n" "Note" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** %?")
("e" "Event" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** %?\n%^T"))))
(org-clock-persist 'history)
(org-log-into-drawer t)
(org-structure-template-alist
(quote
(("a" . "export ascii")
("c" . "center")
("C" . "comment")
("e" . "example")
("E" . "export")
("h" . "export html")
("l" . "export latex")
("q" . "quote")
("s" . "src")
("v" . "verse")
("d" . "definition")
("t" . "theorem")
("p" . "proposition")
("P" . "proof"))))
;; Org babel
(org-confirm-babel-evaluate nil)
(org-src-preserve-indentation nil)
(org-edit-src-content-indentation 0)
(org-startup-with-latex-preview t)
:hook ((org-mode . visual-line-mode)
(org-babel-after-execute . org-redisplay-inline-images))
:config
(org-clock-persistence-insinuate) (org-clock-persistence-insinuate)
(setq org-capture-templates
(quote
(("t" "Task" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** TODO %?")
("n" "Note" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** %?")
("e" "Event" entry
(file+olp (file-name-concat notes-dir "planner.org") "Inbox")
"** %?\n%^T"))))
(setq org-log-into-drawer t)
(setq org-structure-template-alist
(quote
(("a" . "export ascii")
("c" . "center")
("C" . "comment")
("e" . "example")
("E" . "export")
("h" . "export html")
("l" . "export latex")
("q" . "quote")
("s" . "src")
("v" . "verse")
("d" . "definition")
("t" . "theorem")
("p" . "proposition")
("P" . "proof"))))
;; Org-babel ;; Org-babel
(org-babel-do-load-languages (org-babel-do-load-languages
@ -489,16 +492,9 @@
(shell . t) (shell . t)
(sqlite . t))) (sqlite . t)))
(setq org-confirm-babel-evaluate nil)
(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
(setq org-src-preserve-indentation nil
org-edit-src-content-indentation 0)
(setq
org-startup-with-latex-preview t
org-format-latex-options (plist-put org-format-latex-options :scale 0.6))
(require 'ox-latex) (require 'ox-latex)
(setq org-format-latex-options (plist-put org-format-latex-options :scale 0.6))
(add-to-list 'org-latex-classes (add-to-list 'org-latex-classes
'("koma-article" "\\documentclass{scrartcl}" '("koma-article" "\\documentclass{scrartcl}"
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
@ -537,9 +533,9 @@
(use-package ox-pandoc (use-package ox-pandoc
:ensure t :ensure t
:after (org) :after (org)
:config :custom
(setq org-pandoc-options '((standalone . t) (org-pandoc-options '((standalone . t)
(bibliography . (file-name-concat notes-dir "bibliography/bibliography.bib"))))) (bibliography . (file-name-concat notes-dir "bibliography/bibliography.bib")))))
(use-package ox-gfm (use-package ox-gfm
:ensure t :ensure t
@ -705,8 +701,7 @@
:ensure t :ensure t
:custom :custom
(org-download-method 'attach) (org-download-method 'attach)
:config :hook (dired-mode . org-download-enable))
(add-hook 'dired-mode-hook 'org-download-enable))
(use-package org-roam-ui (use-package org-roam-ui
:ensure :ensure
@ -797,15 +792,17 @@
(use-package eglot (use-package eglot
:ensure nil :ensure nil
:hook
(eglot-managed-mode . (lambda () (eglot-inlay-hints-mode nil)))
:custom
(eglot-events-buffer-config '(:size 0 :format full))
:config :config
(add-hook 'eglot-managed-mode-hook #'eglot-inlay-hints-mode nil)
(setq eglot-events-buffer-size 0)
(fset #'jsonrpc--log-event #'ignore)) (fset #'jsonrpc--log-event #'ignore))
(use-package eldoc-box (use-package eldoc-box
:ensure t :ensure t
:config :hook
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)) (eglot-managed-mode . eldoc-box-hover-mode))
(use-package apheleia (use-package apheleia
:ensure t :ensure t
@ -856,8 +853,8 @@
(use-package pet (use-package pet
:ensure t :ensure t
:config :hook
(add-hook 'python-base-mode-hook 'pet-mode -10)) (python-base-mode . (lambda () (pet-mode -10))))
(use-package paredit (use-package paredit
:ensure t :ensure t