dot/.config/doom/config.el
2023-12-20 03:08:40 +01:00

438 lines
16 KiB
EmacsLisp

(setq user-full-name "Phil Bajsicki")
;; must be set before `org` is loaded
(setq org-directory "~/enc/org/")
(setq org-agenda-files (directory-files-recursively "~/enc/org/" ".org$"))
(setq global-auto-revert-mode t)
(setq auth-sources '("~/.authinfo"))
(setq-default backup-inhibited t)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq-default indent-tabs-mode t)
(setq langtool-java-bin "/usr/bin/java")
(after! counsel
(setq counsel-outline-display-style 'title))
(load-theme 'doom-one t)
(doom-themes-neotree-config)
(doom-themes-org-config)
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Cascadia Code ligatures in programming modes
(ligature-set-ligatures 'org-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://"))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t)
(set-frame-parameter nil 'alpha-background 85)
(add-to-list 'default-frame-alist '(alpha-background . 85))
(setq display-line-numbers-type 'relative)
(setq next-screen-context-lines 4)
(setq-default global-visual-line-mode t)
(setq x-stretch-cursor t)
(setq column-number-mode t)
(global-set-key "\C-g" 'keyboard-quit)
(global-set-key "\C-cu" 'browse-url-chrome)
(setq straight-repository-branch "develop")
(use-package! pdf-tools
:defer t
:commands (pdf-loader-install)
:mode "\\.pdf\\'"
:bind (:map pdf-view-mode-map
("n" . pdf-view-next-line-or-next-page)
("p" . pdf-view-previous-line-or-previous-page)
("C-=" . pdf-view-enlarge)
("C--" . pdf-view-shrink))
:init (pdf-loader-install)
:config (add-to-list 'revert-without-query ".pdf"))
(add-hook 'pdf-view-mode-hook #'(lambda () (interactive (display-line-numbers-mode))))
(add-to-list 'auto-mode-alist
'("\\.org\\'" . org-mode))
(setq org-image-actual-width nil)
(setq org-enforce-todo-dependencies t)
(setq org-insert-heading-respect-content nil)
(setq org-reverse-note-order nil)
(setq org-show-following-heading t)
(setq org-show-hierarchy-above t)
(setq org-deadline-warning-days 7)
(setq org-blank-before-new-entry (quote ((heading . t)
(plain-list-item . nil))))
(setq org-todo-repeat-to-state "LOOP")
(setq org-remove-highlights-with-change nil)
(setq org-read-date-prefer-future nil)
(setq org-special-ctrl-a/e t)
(setq org-special-ctrl-k t)
(setq org-yank-adjusted-subtrees t)
(setq org-M-RET-may-split-line t)
(setq org-log-done (quote time))
(setq org-log-into-drawer t)
(setq org-catch-invisible-edits "smart")
(setq org-completion-use-ido t)
(setq org-use-property-inheritance nil)
(setq org-duration-format 'h:mm)
(setq org-hierarchical-todo-statistics t)
(defun my-org-tree-to-indirect-buffer (&optional arg)
"Create indirect buffer and narrow it to current subtree.
The buffer is named after the subtree heading, with the filename
appended. If a buffer by that name already exists, it is
selected instead of creating a new buffer."
(interactive "P")
(let* ((new-buffer-p)
(pos (point))
(buffer-name (let* ((heading (org-get-heading t t))
(level (org-outline-level))
(face (intern (concat "outline-" (number-to-string level))))
(heading-string (propertize (org-link-display-format heading)
'face face)))
(concat heading-string "::" (buffer-name))))
(new-buffer (or (get-buffer buffer-name)
(prog1 (condition-case nil
(make-indirect-buffer (current-buffer) buffer-name 'clone)
(error (make-indirect-buffer (current-buffer) buffer-name)))
(setq new-buffer-p t)))))
(switch-to-buffer new-buffer)
(when new-buffer-p
;; I don't understand why setting the point again is necessary, but it is.
(goto-char pos)
(rename-buffer buffer-name)
(org-narrow-to-subtree))))
(advice-add 'org-tree-to-indirect-buffer :override 'my-org-tree-to-indirect-buffer)
(setq org-element--cache-self-verify nil)
(modify-all-frames-parameters
'((right-divider-width . 2)
(internal-border-width . 0)))
(dolist (face '(window-divider
window-divider-first-pixel
window-divider-last-pixel))
(face-spec-reset-face face)
(set-face-foreground face (face-attribute 'default :background)))
(set-face-background 'fringe (face-attribute 'default :background))
(setq
;; Edit settings
org-auto-align-tags nil
org-tags-column 0
org-catch-invisible-edits 'show-and-error
org-insert-heading-respect-content t
;; Org styling, hide markup etc.
org-hide-emphasis-markers t
org-pretty-entities t
org-ellipsis ""
;; Agenda styling
org-agenda-tags-column 0
org-agenda-block-separator ?─
org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string
"⌚ now ─────────────────────────────────────────────────")
(global-org-modern-mode)
(setq-default org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
(add-hook 'write-file-hooks 'time-stamp)
(add-hook 'org-mode-hook
(lambda ()
;; yasnippet
;;disabled; (make-variable-buffer-local 'yas/trigger-key)
;;disabled; (org-set-local 'yas/trigger-key [tab])
;;disabled; (define-key yas/keymap [tab] 'yas/next-field-group)
;; flyspell mode for spell checking everywhere
;;disabled; (flyspell-mode 1)
;; auto-fill mode on
(auto-fill-mode 1)))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ch" 'counsel-org-link)
(global-set-key "\C-cne" 'elgantt-open)
(global-set-key "\C-cnn" 'org-capture)
(global-set-key "\C-cia" '(lambda ()(interactive)
(org-time-stamp '(16))))
(global-set-key "\C-cii" '(lambda () (interactive)
(org-time-stamp-inactive '(16))))
(setq org-todo-keywords
'((sequence
"INBOX(i)"
"TASK(t)" ; A task that needs doing & is ready to do
"PROJ(p)" ; A project, which usually contains other tasks
"LOOP(r)" ; A recurring task
"WAIT(w)" ; Something external is holding up this task
"HOLD(h)" ; This task is paused/on hold because of me
"|"
"DONE(d)" ; Task successfully completed
"KILL(k)") ; Task was cancelled, aborted or is no longer applicable
(sequence
"DECIDE()" ; for making decisions
"|"
"OKAY(o)" ; okay as-is
"YES(y)" ; take action
"NO(n)")) ; don't take action
org-todo-keyword-faces
'(
("INBOX" :foreground "cyan" :weight bold)
("TASK" :foreground "purple" :weight bold)
("PROJ" :foreground "violet" :weight bold)
("LOOP" :foreground "magenta" :weight bold)
("WAIT" :foreground "yellow" :weight bold)
("HOLD" :foreground "orange" :weight bold)
("DONE" :foreground "green" :weight bold)
("KILL" :foreground "grey" :weight bold)))
(add-hook 'org-insert-heading-hook
(lambda ()
(if
(or
(string-match "journal.org" buffer-file-name)
(string-match "money" buffer-file-name)
(string-match "therapy.org" buffer-file-name))
((lambda ()
(interactive)
(org-time-stamp-inactive '(16))
(newline)))
(setq org-insert-heading-hook nil)
)))
(setq org-capture-templates '(("t" "inbox" entry (file+headline "~/enc/org/phil.org" "Inbox") "* TODO %i%?")
("i" "idea" entry (file+headline "~/enc/org/phil.org" "Ideas") "* %?")
("d" "reminder" entry (file+headline "~/enc/org/phil.org" "Reminders") "* %i%? \n %U")
("p" "person" entry (file+headline "~/enc/org/people.org" "People")
"* %(org-contacts-template-name)
:PROPERTIES:
:EMAIL: %(org-contacts-template-email)
:PHONE: %(org-contacts-template-phone)
:ALIAS:
:NICKNAME:
:IGNORE:
:ICON:
:NOTE:
:ADDRESS:
:BIRTHDAY:
:END:")))
(use-package! org-transclusion
:after org
:init
(map!
:map global-map "<F12>" #'org-transclusion-add
:leader
:prefix "n"
:desc "Org Transclusion Mode" "t" #'org-transclusion-mode))
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
'("memoir"
"\\documentclass{memoir}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
(defun org-super-links-quick-related ()
(interactive)
(let ((org-super-links-link-prefix "\nrelated: "))
(org-super-links-link)))
(setq org-super-links-related-into-drawer t)
(setq org-super-links-related-drawer-default-name "RELATED"
org-super-links-link-prefix 'org-super-links-link-prefix-timestamp)
(setq org-export-with-broken-links t) ;; avoiding error on export
(global-unset-key (kbd "C-c l"))
(global-set-key (kbd "C-c l l") 'org-super-links-link)
(global-set-key (kbd "C-c l s") 'org-super-links-store-link)
(global-set-key (kbd "C-c l i") 'org-super-links-insert-drawer-link)
(global-set-key (kbd "C-c l r") 'org-super-links-quick-related)
(global-set-key (kbd "C-c l d") 'org-super-links-delete-link)
(org-wild-notifier-mode)
(setq org-wild-notifier-alert-time '(10))
(setq org-wild-notifier-notification-title "Emacs org-mode agenda")
(setq org-wild-notifier-keyword-whitelist '("TODO"))
(setq org-refile-targets '((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9)))
(setq org-outline-path-complete-in-steps nil)
(setq org-refile-use-outline-path t)
(setq org-contacts-files '("~/enc/org/people.org"))
(define-prefix-command 'org-roam-map)
(global-set-key "\C-r" 'org-roam-map)
(define-key org-roam-map "o" 'org-roam-buffer-toggle)
(define-key org-roam-map "f" 'org-roam-node-find)
(define-key org-roam-map "i" 'org-roam-node-insert)
(define-key org-roam-map "n" 'org-roam-capture)
(setq org-roam-v2-ack t)
(setq org-roam-completion-everywhere t)
(setq org-roam-directory
(file-truename "~/enc/org/roam"))
(org-roam-db-autosync-mode)
(org-roam-db-autosync-enable)
(setq org-roam-capture-templates
'(("n" "default" plain
"%?"
:if-new (file+head "${slug}.org" "#+title: ${title}\n#+category: ${title}\n#+filetags: \n")
:empty-lines 1
:unnarrowed t)
("j" "journal" plain
"%?"
:if-new (file+head "journal/journal-${slug}.org" "#+title: ${title}\n#+category: 📔${title}\n#+filetags: 📔\n")
:empty-lines 1
:unnarrowed t)
("t" "Therapy" plain
"#+title: ${title}\n"
:if-new (file+head "therapy/therapy-${slug}.org" "#+title: ${title}\n#+category: 📗 ${title}\n#+filetags: 📗\n")
:empty-lines 1
:unnarrowed)))
(global-set-key "\C-ca" 'org-agenda)
(define-prefix-command 'org-agenda-map)
(global-set-key "\C-a" 'org-agenda-map)
(define-key org-agenda-map "n" 'org-agenda-capture)
(define-key org-agenda-map "a" 'org-agenda)
(setq org-agenda-start-day nil
org-agenda-span '14
org-agenda-dim-blocked-tasks 'invisible
org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
(todo priority-down category-keep)
(search category-keep))
org-deadline-warning-days 3
org-agenda-insert-diary-extract-time t
org-log-into-drawer t
org-clock-into-drawer t
org-agenda-log-mode-items '(closed clock state)
org-agenda-prefix-format "%l %i %c %s %t")
(setq org-agenda-compact-blocks t)
(setq org-agenda-use-tag-inheritance (quote (agenda)));; agenda performance
(setq org-agenda-span 1)
(add-hook 'org-agenda-mode-hook '(lambda () (hl-line-mode 1)))
(setq org-agenda-custom-commands
(quote (("x" "Phil's view" agenda ""
((org-agenda-prefix-format " %i %-12:c %s %t "))))))
(setq org-agenda-skip-deadline-if-done t)
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-text-search-extra-files (quote (agenda-archives)))
(setq org-agenda-log-mode-items (quote (state)))
(setq org-agenda-search-headline-for-time nil)
(setq org-agenda-include-diary t)
(setq org-agenda-repeating-timestamp-show-all t)
(setq org-agenda-show-all-dates t)
(setq org-agenda-sorting-strategy
(quote ((agenda habit-down time-up user-defined-up priority-down category-keep)
(todo priority-down category-keep)
(tags priority-down category-keep)
(search category-keep))))
(setq org-agenda-start-on-weekday nil)
(setq org-agenda-skip-timestamp-if-deadline-is-shown t)
(define-key org-agenda-mode-map (kbd "C-p") 'my-scroll-down-half)
(define-key org-agenda-mode-map (kbd "C-n") 'my-scroll-up-half)
(setq org-agenda-format-date (lambda (date) (concat "\n"
(make-string (window-width) 9472)
"\n"
(org-agenda-format-date-aligned date))))
(setq org-export-with-broken-links t)
(defun my-org-copy-region-as-markdown ()
"Copy the region (in Org) to the system clipboard as Markdown."
(interactive)
(if (use-region-p)
(let* ((region
(buffer-substring-no-properties
(region-beginning)
(region-end)))
(markdown
(org-export-string-as region 'md t '(:with-toc nil))))
(gui-set-selection 'CLIPBOARD markdown))))
(setq doom-snippets-enable-short-helpers t)
(setq dired-open-extensions '(("gif" . "sxiv")
("jpg" . "sxiv")
("png" . "sxiv")
("mkv" . "mpv")
("mp4" . "mpv")))
(mode-icons-mode)
(add-hook 'dired-mode-hook #'mode-icons--mode-disable) ;; with mode-icons, visiting a dir with dired takes up *lots* of CPU for =mode-icons-reset= (performance-issue)
(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode))
(autoload 'csv-mode "csv-mode"
"Major mode for editing comma-separated value files." t)
;; To open files with .journal extension in hledger-mode
(add-to-list 'auto-mode-alist '("\\.journal\\'" . hledger-mode))
;; Provide the path to you journal file.
;; The default location is too opinionated.
(setq hledger-jfile "~/enc/org/hledger/2023.journal")
;;; Auto-completion for account names
;; For company-mode users,
(add-to-list 'company-backends 'hledger-company)