init.el (36642B)
1 ;; (setq use-package-compute-statistics t ;; use-package-report 2 ;; garbage-collection-messages t) 3 4 (setq auto-save-interval 24 5 delete-by-moving-to-trash t 6 echo-keystrokes 0.1 7 enable-recursive-minibuffers t 8 frame-inhibit-implied-resize t 9 gc-cons-percentage (* gc-cons-percentage 2) 10 history-length t 11 next-screen-context-lines 5 12 load-prefer-newer t 13 read-process-output-max (* 1024 1024) 14 scroll-conservatively 10000 15 use-dialog-box nil 16 user-full-name "David Wen Riccardi-Zhu" 17 ring-bell-function 'ignore 18 x-stretch-cursor t) 19 20 ;; Default variables that may be overwritten in a buffer. 21 (setq-default fill-column 80 22 tab-width 8 23 truncate-lines nil) 24 25 ;; Startup 26 (setq blink-cursor-mode nil 27 inhibit-splash-screen t 28 inhibit-startup-message t 29 initial-major-mode 'org-mode 30 initial-scratch-message nil 31 user-mail-address "dwrz@dwrz.net") 32 33 (put 'downcase-region 'disabled nil) 34 (put 'upcase-region 'disabled nil) 35 36 ;; Custom 37 (setq custom-file "~/.cache/custom.el") 38 39 ;; Functions 40 (defun dwrz-copy-filepath () 41 "Copy the current buffer file path to the clipboard." 42 (interactive) 43 (let ((filename (if (equal major-mode 'dired-mode) 44 default-directory (buffer-file-name)))) 45 (when filename (kill-new filename) 46 (message "Copied buffer path '%s' to the clipboard." filename)))) 47 48 (defun dwrz-copy-filename () 49 "Get the filename of the current buffer without the directory." 50 (interactive) 51 (when buffer-file-name 52 (let ((filename (file-name-nondirectory buffer-file-name))) 53 (when filename (kill-new filename) 54 (message "Copied buffer name '%s' to the clipboard." filename))))) 55 56 (defun dwrz-highlight-keywords () 57 "Highlight keywords." 58 (font-lock-add-keywords 59 nil '(("\\<\\(FIX\\|TODO\\|NB\\)" 1 font-lock-warning-face t)))) 60 61 (defun dwrz-insert-date () 62 "Insert date at point." 63 (interactive) 64 (insert (format-time-string "%Y%m%d"))) 65 66 (defun dwrz-insert-timestamp () 67 "Insert timestamp at point." 68 (interactive) 69 (insert (format-time-string "%FT%T%z"))) 70 71 (defun dwrz-org-capture-at-point () 72 "Insert an org capture template at point." 73 (interactive) 74 (org-capture 0)) 75 76 (defun dwrz-vterm-in-current-directory () 77 "Create or switch to a vterm buffer for the current directory." 78 (interactive) 79 (let* ((default-directory (if (buffer-file-name) 80 (file-name-directory (buffer-file-name)) 81 default-directory)) 82 (dir-path (expand-file-name default-directory)) 83 (vterm-buffer-name (concat "*vterm:" dir-path "*")) 84 (existing-vterm-buffer (get-buffer vterm-buffer-name))) 85 (if existing-vterm-buffer 86 (switch-to-buffer existing-vterm-buffer) 87 (vterm (generate-new-buffer-name vterm-buffer-name))))) 88 89 (defun dwrz-split-window-two-thirds () 90 "Split the current window into two, with a 2/3 and 1/3 vertical split." 91 (interactive) 92 (select-window (split-window-vertically 93 (floor (* 0.666 (window-total-height)))))) 94 95 (defun dwrz-unfill-region-or-paragraph (&optional beg end) 96 "Unfill paragraph or active region. If region is active, join all lines delimited by BEG and END, while respecting empty lines as paragraph delimiters. If no region is active, operate on the paragraph." 97 (interactive "r") 98 (let ((fill-column most-positive-fixnum)) 99 (if (use-region-p) (fill-region beg end) (fill-paragraph)))) 100 101 ;; Packages 102 (require 'package) 103 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) 104 105 (use-package abbrev :ensure nil :init (setq-default abbrev-mode t)) 106 107 (use-package autorevert 108 :config (setq auto-revert-verbose nil 109 global-auto-revert-non-file-buffers t) 110 :init (global-auto-revert-mode t) 111 :ensure nil) 112 113 (use-package avy 114 :config (setq avy-all-windows 'all-frames 115 avy-background t 116 avy-case-fold-search nil 117 avy-keys '(?a ?o ?e ?u ?h ?t ?n ?s) 118 avy-style 'at-full) 119 :defer t 120 :ensure t) 121 122 (use-package base16-theme 123 :ensure t 124 :init (setq base16-theme-256-color-source 'colors) 125 (load-theme 'base16-tomorrow t) 126 (set-face-attribute 'fringe nil :background "#ffffff")) 127 128 (use-package bookmark :config (setq bookmark-save-flag 1) :ensure nil) 129 130 (use-package calendar 131 :config (setq calendar-chinese-all-holidays-flag t 132 calendar-week-start-day 1 133 diary-file "~/org/diary.org") 134 (calendar-set-date-style 'iso) 135 :ensure nil) 136 137 (use-package cape 138 :init 139 (add-to-list 'completion-at-point-functions #'cape-abbrev) 140 (add-to-list 'completion-at-point-functions #'cape-dabbrev) 141 (add-to-list 'completion-at-point-functions #'cape-emoji) 142 (add-to-list 'completion-at-point-functions #'cape-dict) 143 (add-to-list 'completion-at-point-functions #'cape-file) 144 (add-to-list 'completion-at-point-functions #'cape-keyword) 145 (add-to-list 'completion-at-point-functions #'cape-history) 146 :ensure t) 147 148 (use-package cc-vars 149 :config (setq-default c-basic-offset 8) 150 :defer t 151 :ensure nil) 152 153 (use-package comp 154 :config (setq native-comp-async-report-warnings-errors nil) 155 :ensure nil) 156 157 (use-package compile 158 :config (setq compilation-message-face 'default) 159 :defer t 160 :ensure nil) 161 162 (use-package conf-mode :ensure nil) 163 164 (use-package consult 165 :bind (("C-h i" . consult-info) 166 ("C-r" . consult-ripgrep) 167 ("C-s" . consult-line) 168 ("C-x 4 b" . consult-buffer-other-window) 169 ("C-x 5 b" . consult-buffer-other-frame) 170 ("C-x b" . consult-buffer) 171 ("C-x p b" . consult-project-buffer) 172 ("C-x r b" . consult-bookmark) 173 ("C-y" . consult-yank-pop) 174 ([remap yank-pop] . consult-yank-pop) 175 ("M-g I" . consult-imenu-multi) 176 ("M-g M-g" . consult-goto-line) 177 ("M-g g" . consult-goto-line) 178 ("M-g i" . consult-imenu) 179 ("M-y" . yank) 180 :map minibuffer-local-map 181 ("M-s" . consult-history) 182 ("M-r" . consult-history)) 183 :hook (completion-list-mode . consult-preview-at-point-mode) 184 :config 185 (setq register-preview-delay 0 186 register-preview-function #'consult-register-format) 187 (advice-add #'register-preview :override #'consult-register-window) 188 (setq xref-show-xrefs-function #'consult-xref 189 xref-show-definitions-function #'consult-xref) 190 (consult-customize 191 consult-theme :preview-key '(:debounce 0.2 any) 192 consult-ripgrep consult-git-grep consult-grep 193 consult-bookmark consult-recent-file consult-xref 194 consult--source-bookmark consult--source-file-register 195 consult--source-recent-file consult--source-project-recent-file 196 :preview-key '(:debounce 0.4 any)) 197 (setq consult-narrow-key "<") 198 (define-key consult-narrow-map (vconcat consult-narrow-key "?") 199 #'consult-narrow-help) 200 :ensure t) 201 202 (use-package consult-lsp :defer t :ensure t) 203 204 (use-package consult-notmuch :defer t :ensure t) 205 206 (use-package corfu 207 :bind (:map corfu-map 208 ("<tab>" . corfu-complete) 209 ("RET" . nil) 210 ;; ("C-<tab>" . corfu-quit) 211 ;; ("<end>" . corfu-quit) 212 ;; ("<escape>" . corfu-quit) 213 ) 214 :custom 215 (corfu-auto t) 216 (corfu-auto-delay 0.1) 217 (corfu-auto-prefix 2) 218 (corfu-cycle t) 219 (corfu-history-mode 1) 220 (corfu-on-exact-match 'show) 221 (corfu-popupinfo-delay '(1.25 . 0.5)) 222 (corfu-quit-no-match t) 223 (corfu-scroll-margin 0) 224 :ensure t 225 :hook (corfu-mode . corfu-popupinfo-mode) 226 :init (global-corfu-mode) 227 (setq tab-always-indent 'complete)) 228 229 (use-package corfu-terminal 230 :init (unless (display-graphic-p) (corfu-terminal-mode +1)) 231 :ensure t) 232 233 (use-package csv-mode :mode "\\.csv\\'" :ensure t) 234 235 (use-package css-mode 236 :config (setq css-indent-offset 2) 237 :mode "\\.css\\'" 238 :ensure nil) 239 240 (use-package delsel :ensure nil :init (delete-selection-mode t)) 241 242 (use-package dired 243 :config (setq dired-listing-switches "-alh" 244 dired-recursive-copies 'always) 245 (put 'dired-find-alternate-file 'disabled nil) 246 :defer t 247 :ensure nil) 248 249 (use-package dired-hide-dotfiles 250 :after dired 251 :bind (:map dired-mode-map ("." . dired-hide-dotfiles-mode)) 252 :ensure t) 253 254 (use-package dired-x 255 :config (setq dired-omit-verbose nil 256 dired-omit-files (concat dired-omit-files "\\|^\\..+$") 257 dired-clean-up-buffers-too t) 258 :defer t 259 :ensure nil) 260 261 (use-package doc-view 262 :config (setq doc-view-resolution 300) 263 :defer t 264 :ensure nil) 265 266 (use-package dockerfile-mode 267 :defer t 268 :ensure t 269 :mode (("Dockerfile\\'" . dockerfile-mode) 270 ("Containerfile\\'" . dockerfile-mode))) 271 272 (use-package doom-modeline 273 :defer t 274 :hook (after-init . doom-modeline-mode) 275 :ensure t) 276 277 (use-package elisp-mode 278 :config (setq-local indent-tabs-mode nil) 279 :hook (emacs-lisp-mode . eldoc-mode) 280 :ensure nil) 281 282 (use-package embark 283 :bind 284 (("C-." . embark-act) 285 ("C-," . embark-dwim) 286 ("C-'" . embark-bindings) 287 :map minibuffer-local-map 288 ("C-<" . embark-collect) 289 ("C->" . embark-export)) 290 :config 291 (setq prefix-help-command #'embark-prefix-help-command) 292 :ensure t) 293 294 (use-package embark-consult 295 :ensure t 296 :hook 297 (embark-collect-mode . consult-preview-at-point-mode)) 298 299 (use-package eshell 300 :config 301 (setq eshell-banner-message "" 302 eshell-mv-interactive-query t) 303 (defvar eshell-command-start-time nil 304 "Holds the start time of the last Eshell command.") 305 306 (defun eshell-record-command-start-time () 307 "Record the start time of the current Eshell command." 308 (setq eshell-command-start-time (float-time))) 309 310 (defun eshell-format-duration (elapsed) 311 "Format ELAPSED time into a human readable string." 312 (cond 313 ((> elapsed 3600) 314 (format "%.0fh %.0fm" (/ elapsed 3600) (% (/ elapsed 60) 60))) 315 ((> elapsed 60) 316 (format "%.0fm %.0fs" (/ elapsed 60) (mod elapsed 60))) 317 ((> elapsed 1) 318 (format "%.2fs" elapsed)) 319 (t 320 (format "%.2fms" (* elapsed 1000))))) 321 322 (defun eshell-calculate-command-duration () 323 "Calculate the elapsed time of the last Eshell command." 324 (when eshell-command-start-time 325 (let* ((end-time (float-time)) 326 (elapsed (float-time (time-subtract end-time eshell-command-start-time))) 327 (elapsed-time-str (eshell-format-duration elapsed))) 328 (propertize elapsed-time-str 'face 'font-lock-comment-face)))) 329 330 (setq eshell-prompt-function 331 (lambda () 332 "Custom Eshell prompt using colors from the active theme." 333 (let* ((user-face (if (= (user-uid) 0) 'error 'success)) 334 (host-face (if (getenv "SSH_CONNECTION") 'warning 335 'font-lock-keyword-face)) 336 (path-face 'font-lock-type-face) 337 (time-face 'font-lock-comment-face) 338 (success-p (zerop eshell-last-command-status)) 339 (checkmark (if success-p "✔" "✘")) 340 (checkmark-face (if success-p 'success 'error)) 341 (command-duration (eshell-calculate-command-duration)) 342 (utc-time (propertize (format-time-string "%H:%M:%S " 343 (current-time) t) 344 'face time-face))) 345 (concat 346 utc-time 347 (propertize (user-login-name) 'face user-face) 348 (propertize "@" 'face host-face) 349 (propertize (system-name) 'face host-face) 350 " " (propertize checkmark 'face checkmark-face) 351 " (" (or command-duration "0.00s") ") " 352 (propertize (abbreviate-file-name (eshell/pwd)) 'face path-face) 353 " $ ")))) 354 355 (add-hook 'eshell-pre-command-hook #'eshell-record-command-start-time) 356 (add-hook 'eshell-post-command-hook #'eshell-calculate-command-duration) 357 358 :hook 359 ((eshell-mode . (lambda () 360 (keymap-unset eshell-hist-mode-map "<up>" t) 361 (keymap-unset eshell-hist-mode-map "<down>" t) 362 (local-set-key (kbd "C-a") 'eshell-bol) 363 (local-set-key (kbd "<up>") 'previous-line) 364 (local-set-key (kbd "<down>") 'next-line))) 365 (eshell-pre-command . eshell-record-command-start-time)) 366 :ensure nil) 367 368 (use-package eshell-vterm 369 :demand t 370 :after eshell 371 :config 372 (eshell-vterm-mode) 373 (add-to-list 'eshell-visual-commands "mg") 374 (add-to-list 'eshell-visual-commands "ssh")) 375 376 (use-package faces 377 :config 378 (let ((font "DejaVu Sans Mono-16")) 379 (set-face-attribute 'default nil :font font) 380 (add-to-list 'default-frame-alist `(font . ,font))) 381 :custom (face-font-family-alternatives 382 '(("hans" "adobe-source-han-sans-cn-font")))) 383 384 (use-package files 385 :config (setq auto-save-file-name-transforms 386 `((".*" ,temporary-file-directory t)) 387 auto-save-visited-mode t 388 backup-directory-alist `((".*" .,temporary-file-directory)) 389 confirm-kill-emacs 'y-or-n-p) 390 (setq-default require-final-newline t) 391 :ensure nil) 392 393 (use-package flycheck :defer t :ensure t) 394 395 (use-package flyspell 396 :bind (:map flyspell-mode-map ("C-;" . nil)) 397 :defer t 398 :hook ((text-mode . flyspell-mode) 399 (prog-mode . flyspell-prog-mode)) 400 :ensure nil) 401 402 (use-package frame :config (window-divider-mode -1) :ensure nil) 403 404 (use-package gnutls 405 :config (setq gnutls-verify-error t) 406 :defer t 407 :ensure nil) 408 409 (use-package go-mode 410 :bind (:map go-mode-map 411 ("C-c C-b" . pop-tag-mark) 412 ("C-c t" . go-tag-add) 413 ("C-c T" . go-tag-remove)) 414 :defer t 415 :ensure t 416 :hook ((go-mode . lsp) 417 (go-mode . (lambda () 418 (add-hook 'before-save-hook #'lsp-organize-imports nil t) 419 (add-hook 'before-save-hook #'lsp-format-buffer nil t)))) 420 :mode "\\.go\\'") 421 422 (use-package go-playground 423 :config (setq go-playground-ask-file-name nil 424 go-playground-basedir "~/.local/share/go/src/playground/" 425 go-playground-init-command "go mod init") 426 :defer t 427 :ensure t) 428 429 (use-package go-tag 430 :after go-mode 431 :config (setq go-tag-args (list "-transform" "camelcase")) 432 :defer t 433 :ensure t) 434 435 (use-package gptel 436 :commands (gptel gtpel-send gptel-send-region gptel-send-buffer) 437 :config 438 (setq gptel-api-key (password-store-get "open-ai/emacs") 439 gptel-default-mode 'org-mode 440 gptel-prompt-prefix-alist 441 '((markdown-mode . "# ") (org-mode . "* ") (text-mode . "🤖: "))) 442 (gptel-make-ollama "Ollama" 443 :host "localhost:11434" 444 :stream t 445 :models '(llama3.2:latest codeqwen:latest)) 446 (gptel-make-openai "OpenRouter" 447 :host "openrouter.ai" 448 :endpoint "/api/v1/chat/completions" 449 :stream t 450 :key (password-store-get "openrouter.ai/keys/emacs") 451 :models '(openai/gpt-4o-2024-08-06 452 meta-llama/llama-3.1-70b-instruct 453 meta-llama/llama-3.1-70b-instruct:nitro 454 meta-llama/llama-3.1-405b-instruct 455 meta-llama/llama-3.1-405b-instruct:nitro 456 anthropic/claude-3.5-sonnet 457 anthropic/claude-3-5-haiku)) 458 :defer t 459 :ensure t) 460 461 (use-package hl-line 462 :config (global-hl-line-mode t) 463 :ensure nil) 464 465 (use-package hideshow 466 :hook (go-mode . hs-minor-mode) 467 :ensure nil) 468 469 (use-package ispell 470 :config (setq ispell-program-name "/usr/bin/aspell" 471 ispell-dictionary "en_US" 472 ispell-extra-args '("--sug-mode=ultra" "--lang=en_US") 473 ;; ispell-list-command "--list" 474 ispell-dictionary-alist 475 '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "['‘’]" 476 t ("-d" "en_US") nil utf-8))) 477 :defer t 478 :ensure t) 479 480 (use-package jka-cmpr-hook :init (auto-compression-mode t) :ensure nil) 481 482 (use-package js 483 :config (setq js-indent-level 2) 484 :defines js-indent-level 485 :hook ((js-mode . lsp) 486 (js-mode . (lambda () (setq indent-tabs-mode nil)))) 487 :ensure nil) 488 489 (use-package ledger-mode :defer t :ensure t) 490 491 (use-package lsp-mode :defer t :ensure t) 492 493 (use-package magit 494 :bind ("C-x g" . magit-status) 495 :config (setq git-commit-summary-max-length 50) 496 :ensure t) 497 498 (use-package marginalia 499 :custom (marginalia-align 'right) 500 :config (marginalia-mode t) 501 :defer t 502 :ensure t) 503 504 (use-package markdown-mode :defer t :ensure t) 505 506 (use-package menu-bar :config (menu-bar-mode -1) :ensure nil) 507 508 (use-package message 509 :config (setq message-directory "drafts" 510 message-kill-buffer-on-exit t 511 message-sendmail-envelope-from 'header 512 message-sendmail-f-is-evil nil) 513 :hook (message-mode . (lambda () (corfu-mode -1))) 514 :defer t 515 :ensure nil) 516 517 (use-package move-text 518 :bind 519 (("<M-up>" . move-text-up) 520 ("<M-down>" . move-text-down)) 521 :defer nil 522 :ensure t) 523 524 (use-package mule 525 :config 526 (prefer-coding-system 'utf-8) 527 (set-default-coding-systems 'utf-8) 528 (set-terminal-coding-system 'utf-8) 529 (set-keyboard-coding-system 'utf-8) 530 :ensure nil) 531 532 (use-package mule-cmds 533 :preface (provide 'mule-cmds) 534 :config 535 (set-language-environment 'UTF-8) 536 :ensure nil) 537 538 (use-package mwheel 539 :custom (mouse-wheel-scroll-amount '(1 ((shift) .1))) 540 :ensure nil) 541 542 (use-package nerd-icons :defer t :ensure t) 543 544 (use-package notmuch 545 :bind (("C-x m" . notmuch) 546 :map notmuch-search-mode-map 547 ("D" . (lambda () "mark message as deleted" (interactive) 548 (notmuch-search-tag (list "-new" "-unread" "-inbox" 549 "+deleted")) 550 (forward-line))) 551 ("S" . (lambda () "mark message as spam" (interactive) 552 (notmuch-search-tag (list "-new" "-unread" "-inbox" "+spam")) 553 (forward-line))) 554 ("N" . (lambda () "unmark message as new and unread" (interactive) 555 (notmuch-search-tag (list "-new" "-unread")) 556 (forward-line))) 557 ("r" . notmuch-search-reply-to-thread) 558 ("R" . notmuch-search-reply-to-thread-sender) 559 :map notmuch-show-mode-map 560 ("D" . (lambda () "mark message as deleted" (interactive) 561 (notmuch-show-tag 562 (list "-new" "-unread" "-inbox" "+deleted")))) 563 ("S" . (lambda () "mark message as spam" (interactive) 564 (notmuch-show-tag (list "-new" "-unread" "-inbox" "+spam")))) 565 ("N" . (lambda () "unmark message as new and unread" (interactive) 566 (notmuch-show-tag (list "-new" "-unread")))) 567 ("r" . notmuch-show-reply) 568 ("R" . notmuch-show-reply-sender)) 569 :config (customize-set-variable 'notmuch-search-oldest-first nil) 570 (setq notmuch-address-command 'internal 571 notmuch-address-internal-completion '(sent nil) 572 notmuch-address-save-filename "~/org/contacts/notmuch-contacts" 573 notmuch-crypto-process-mime t 574 notmuch-fcc-dirs "sent" 575 notmuch-hello-hide-tags '("spam") 576 notmuch-show-all-tags-list t) 577 (setq notmuch-saved-searches 578 '((:name "inbox" :query "tag:inbox" :key "i") 579 (:name "unread" :query "tag:unread" :key "u") 580 (:name "new" :query "tag:new" :key "n") 581 (:name "sent" :query "tag:sent" :key "e") 582 (:name "drafts" :query "tag:draft" :key "d") 583 (:name "all mail" :query "*" :key "a") 584 (:name "todo" :query "tag:todo" :key "t"))) 585 :defer t 586 :functions notmuch-search-tag notmuch-show-tag) 587 588 (use-package novice :disabled t :ensure nil) 589 590 (use-package ol 591 :config (setq org-link-frame-setup 592 '((vm . vm-visit-folder-other-frame) 593 (vm-imap . vm-visit-imap-folder-other-frame) 594 (gnus . org-gnus-no-new-news) 595 (file . find-file) 596 (wl . wl-other-frame))) 597 :defer t 598 :ensure nil) 599 600 (use-package ol-notmuch :defer t :ensure t) 601 602 (use-package orderless 603 :ensure t 604 :custom 605 (orderless-matching-styles 'orderless-regexp) 606 (completion-styles '(orderless basic)) 607 (completion-category-overrides '((file (styles basic partial-completion))))) 608 609 (use-package org 610 :bind (:map org-mode-map 611 ("<M-right>" . nil) 612 ("<M-left>" . nil)) 613 :config (setq org-adapt-indentation nil 614 org-export-backends '(ascii html icalendar latex md odt) 615 org-fold-catch-invisible-edits 'show 616 org-fontify-done-headline t 617 org-default-priority 1 618 org-enforce-todo-dependencies t 619 org-hide-emphasis-markers t 620 org-highest-priority 1 621 org-image-actual-width '(800) 622 org-list-demote-modify-bullet nil 623 org-log-into-drawer t 624 org-lowest-priority 3 625 org-src-fontify-natively t 626 org-startup-with-inline-images t 627 org-tags-column 0 628 org-todo-keywords '((sequence "|" "MAYBE(m)") 629 (sequence "|" "EVENT(v)") 630 (sequence "NEXT(n)" 631 "IN-PROGRESS(i)" 632 "WAITING(w)" 633 "|" 634 "DELEGATED(e)" 635 "CANCELED(c)" 636 "DONE(d)"))) 637 (org-babel-do-load-languages 638 'org-babel-load-languages 639 '((awk .t ) (calc . t) (C . t) (emacs-lisp . t) (gnuplot . t) (js . t) 640 (makefile .t )(org . t) (python . t) (plantuml . t) 641 (shell . t) (sed .t) (sql . t) (sqlite . t))) 642 :defer t 643 :functions org-redisplay-inline-images 644 :hook ((org-mode . flyspell-mode) 645 (org-mode . (lambda () (electric-indent-local-mode -1))) 646 (org-babel-after-execute . (lambda () 647 (when org-inline-image-overlays 648 (org-redisplay-inline-images))))) 649 :ensure nil) 650 651 (use-package org-agenda 652 :config 653 (setq chimerical-agenda-files '("~/projects/chimerical/chimerical.org") 654 dwrz-agenda-files '("~/org/dwrz.org" 655 "~/projects/career/career.org" 656 "~/projects/chinese/chinese.org" 657 "~/projects/community/community.org" 658 "~/projects/finances/finances.org" 659 "~/projects/health/health.org" 660 "~/projects/home/home.org" 661 "~/projects/net/net.org" 662 "~/projects/rz/rz.org" 663 "~/projects/rz/elrz/elrz.org" 664 "~/projects/rz/mwb/mwb.org" 665 "~/projects/src/src.org") 666 eti-agenda-files '("~/projects/eti/eti.org")) 667 668 (defun dwrz-switch-org-ctx (ctx) 669 "Switch org agenda context." 670 (cond ((string= ctx "") (setq org-agenda-files (append 671 chimerical-agenda-files 672 dwrz-agenda-files 673 eti-agenda-files))) 674 ((string= ctx "chimerical") (setq org-agenda-files 675 chimerical-agenda-files)) 676 ((string= ctx "dwrz") (setq org-agenda-files 677 dwrz-agenda-files)) 678 ((string= ctx "eti") (setq org-agenda-files eti-agenda-files)))) 679 680 ;; Set the default context. 681 (dwrz-switch-org-ctx "") 682 683 (setq org-agenda-follow-indirect nil 684 org-agenda-include-diary t 685 org-agenda-prefix-format '((agenda . " %i %?-12t% s") 686 (timeline . " % s") 687 (todo . " %i") 688 (tags . " %i") 689 (search . " %i")) 690 org-agenda-span 'month 691 org-agenda-tags-column 'auto 692 org-agenda-use-time-grid nil 693 org-agenda-window-setup 'current-window 694 org-archive-location "~/org/archive.org::" 695 org-agenda-show-all-dates nil) 696 :defer t 697 :defines chimerical-agenda-files dwrz-agenda-files eti-agenda-files 698 :functions dwrz-switch-org-ctx 699 :ensure nil) 700 701 (use-package org-capture 702 :config (setq org-capture-templates 703 '(("e" "log entry" plain 704 (file "") 705 (file "~/org/templates/log-entry.org") 706 :jump-to-captured t) 707 ("l" "log" entry 708 (file "") 709 (file "~/org/templates/log.org") 710 :prepend t 711 :jump-to-captured t 712 :empty-lines-after 1) 713 ("n" "note" entry 714 (file "") 715 (file "~/org/templates/note.org") 716 :prepend t 717 :jump-to-captured t 718 :empty-lines-before 1 719 :empty-lines-after 1))) 720 :defer t 721 :ensure nil) 722 723 (use-package org-faces 724 :config (setq org-priority-faces 725 '((?1 . (:foreground "#c82829")) 726 (?2 . (:foreground "#eab700")) 727 (?3 . (:foreground "#718c00")))) 728 (setq org-todo-keyword-faces 729 '(("NEXT" . (:foreground "#c82829" :weight bold)) 730 ("IN-PROGRESS" . (:foreground "#718c00" :weight bold)) 731 ("WAITING" . (:foreground "#eab700" :weight bold)) 732 ("DONE" . (:foreground "#4271ae" :weight bold)) 733 ("EVENT" . (:foreground "#3e999f" :weight bold)) 734 ("DELEGATED" . (:foreground "#969896" :weight bold)) 735 ("CANCELED" . (:foreground "#a3685a" :weight bold)) 736 ("MAYBE" . (:foreground "#8959a8" :weight bold)))) 737 :defer t 738 :ensure nil) 739 740 (use-package org-src 741 :config (setq org-src-preserve-indentation t 742 org-src-tab-acts-natively t) 743 :defer t 744 :ensure nil) 745 746 (use-package osm :defer t :ensure t) 747 748 (use-package paragraphs 749 :config (setq sentence-end-double-space nil) 750 :ensure nil 751 :preface (provide 'paragraphs)) 752 753 (use-package paren :config (show-paren-mode t) :ensure nil) 754 755 (use-package password-store :defer t :ensure t) 756 757 (use-package pdf-tools 758 :config (setq pdf-view-display-size 'fit-page) 759 :ensure t 760 :hook (pdf-view-mode . (lambda () 761 (unless (featurep 'pdf-tools) 762 (pdf-tools-install)))) 763 :mode ("\\.pdf\\'" . pdf-view-mode)) 764 765 (use-package plantuml-mode 766 :config (setq org-plantuml-jar-path (expand-file-name 767 "/usr/share/java/plantuml/plantuml.jar")) 768 :defer t 769 :defines org-plantuml-jar-path 770 :ensure t) 771 772 (use-package proced 773 :commands proced 774 :custom 775 (proced-auto-update-flag t) 776 (proced-enable-color-flag t) 777 (proced-format 'custom) 778 (proced-goal-attribute nil) 779 (proced-show-remote-processes t) 780 :config 781 (add-to-list 782 'proced-format-alist 783 '(custom pid user pcpu pmem rss pri nice start time tree state (args comm))) 784 :ensure nil) 785 786 (use-package prog-mode 787 :hook ((prog-mode . flycheck-mode) 788 (prog-mode . flyspell-prog-mode) 789 (prog-mode . visual-line-mode) 790 (prog-mode . (lambda () (dwrz-highlight-keywords)))) 791 :ensure nil) 792 793 (use-package project 794 :config (add-to-list 'project-switch-commands 795 '(project-shell "Shell" "s") t) 796 :ensure nil) 797 798 (use-package rainbow-mode 799 :defer t 800 :hook ((conf-mode . rainbow-mode) 801 (prog-mode . rainbow-mode) 802 (text-mode . rainbow-mode)) 803 :ensure t) 804 805 (use-package recentf 806 :config (recentf-mode t) 807 :init (setq recentf-max-menu-items 100 808 recentf-max-saved-items 100) 809 :ensure nil) 810 811 (use-package register 812 :config (set-register ?c '(file . "~/.config/")) 813 (set-register ?d '(file . "~/org/diary.org")) 814 (set-register ?e '(file . "~/projects/eti/")) 815 (set-register ?f '(file . "~/projects/finances/")) 816 (set-register ?g '(file . "~/org/gtd.org")) 817 (set-register ?h '(file . "~/projects/home/")) 818 (set-register ?i '(file . "~/.config/emacs/init.el")) 819 (set-register ?j '(file . "~/journal/2024/2024.org")) 820 (set-register ?k '(file . "~/projects/chimerical/")) 821 (set-register ?n '(file . "~/projects/net/")) 822 (set-register ?o '(file . "~/org/")) 823 (set-register ?p '(file . "~/projects/"))) 824 825 (use-package repeat :config (repeat-mode) :ensure nil) 826 827 (use-package scroll-bar :config (scroll-bar-mode -1) :ensure nil) 828 829 (use-package select 830 :config (setq select-enable-primary t 831 select-enable-clipboard t) 832 :ensure nil) 833 834 (use-package savehist 835 :init (savehist-mode t) 836 :ensure nil) 837 838 (use-package sendmail 839 :after corfu 840 :config (setq mail-specify-envelope-from t 841 mail-envelope-from 'header 842 mail-specify-envelope-from t 843 send-mail-function 'sendmail-send-it) 844 (add-to-list 'savehist-additional-variables 'corfu-history) 845 :defer t 846 :ensure nil) 847 848 (use-package sh-script :config (setq sh-basic-offset 2) :defer t :ensure nil) 849 850 (use-package simple 851 :config (setq async-shell-command-buffer "new-buffer" 852 backward-delete-char-untabify-method nil 853 mail-user-agent 'message-user-agent 854 shift-select-mode nil) 855 (setq-default indent-tabs-mode t) 856 (column-number-mode t) 857 (size-indication-mode t) 858 :ensure nil) 859 860 (use-package sql 861 :config (setq sql-linter-program "pg_format") 862 :hook (sql-mode . sqlind-minor-mode) 863 :ensure nil) 864 865 (use-package sql-indent :config (setq sqlind-basic-offset 4) :defer t :ensure t) 866 867 (use-package subword :init (global-subword-mode t) :ensure nil) 868 869 (use-package subr 870 :hook (before-save . delete-trailing-whitespace) 871 :ensure nil) 872 873 (use-package subr-x :init (defalias 'yes-or-no-p 'y-or-n-p) :ensure nil) 874 875 (use-package text-mode 876 :hook ((text-mode . flyspell-mode) 877 (text-mode . visual-line-mode)) 878 :ensure nil) 879 880 (use-package textsize 881 :config (setq textsize-default-points 20) 882 :ensure t 883 :init (textsize-mode)) 884 885 (use-package time 886 :config 887 (setq world-clock-list '(("America/Los_Angeles" "Los Angeles") 888 ("America/New_York" "New York") 889 ("UTC" "UTC") 890 ("Europe/Rome" "Napoli") 891 ("Asia/Shanghai" "Shanghai") 892 ("Australia/Sydney" "Sydney")) 893 world-clock-time-format "%Y-%m-%d %u/7 %H:%M %Z") 894 :init (setq display-time-mode nil) 895 :ensure nil) 896 897 (use-package toc-org :defer t :ensure t) 898 899 (use-package tool-bar :config (tool-bar-mode -1) :ensure nil) 900 901 (use-package tramp 902 :config (setq tramp-default-method "rsync") 903 :defer t 904 :ensure nil) 905 906 (use-package vertico 907 :config 908 (setq vertico-cycle t 909 vertico-resize t) 910 :init (vertico-mode) 911 :ensure t) 912 913 (use-package vundo 914 :config 915 (setq vundo-glyph-alist vundo-unicode-symbols 916 vundo-compact-display t) 917 :defer t 918 :ensure t) 919 920 (use-package visual-fill-column 921 :config (setq split-window-preferred-function 922 'visual-fill-column-split-window-sensibly) 923 :ensure t 924 :hook (visual-line-mode . visual-fill-column-mode)) 925 926 (use-package vterm 927 :bind (:map vterm-mode-map 928 ("C-q" . vterm-send-next-key) 929 ("C-y" . vterm-yank)) 930 :config 931 (setq vterm-max-scrollback 32767) 932 (defun project-vterm () 933 (interactive) 934 (defvar vterm-buffer-name) 935 (let* ((default-directory (project-root (project-current t))) 936 (vterm-buffer-name (project-prefixed-buffer-name "vterm")) 937 (vterm-buffer (get-buffer vterm-buffer-name))) 938 (if (and vterm-buffer (not current-prefix-arg)) 939 (pop-to-buffer vterm-buffer 940 (bound-and-true-p display-comint-buffer-action)) 941 (vterm)))) 942 (add-to-list 'project-switch-commands '(project-vterm "Terminal" "t") t) 943 :defer t 944 :ensure t) 945 946 (use-package web-mode 947 :config (setq web-mode-code-indent-offset 2 948 web-mode-css-indent-offset 2 949 web-mode-engines-alist '(("go" . "\\.gohtml\\'")) 950 web-mode-indent-style 2 951 web-mode-markup-indent-offset 2) 952 :hook ((web-mode . (lambda () 953 (setq indent-tabs-mode nil) 954 (when (string-equal 955 "gohtml" (file-name-extension buffer-file-name)) 956 (web-mode-set-engine "go"))))) 957 :mode (("\\.html?\\'" . web-mode) 958 ("\\.gohtml\\'" . web-mode)) 959 :ensure t) 960 961 (use-package wgrep :defer t :ensure t) 962 963 (use-package which-key 964 :init (setq which-key-idle-delay 0.25) 965 :config (which-key-mode) 966 :ensure t) 967 968 (use-package window 969 :config (setq split-height-threshold nil 970 split-width-threshold 160) 971 :ensure nil) 972 973 (use-package xref :defer t :ensure nil) 974 975 (use-package yaml-mode :ensure t) 976 977 (use-package yasnippet :config (yas-global-mode 1) :ensure t) 978 979 (use-package yasnippet-capf 980 :after cape 981 :config 982 (add-to-list 'completion-at-point-functions #'yasnippet-capf) 983 :ensure t) 984 985 ;; Keymaps 986 (defvar-keymap dwrz-buffer-map 987 :doc "Prefix keymap for buffers." 988 :name "Buffer" 989 "R" #'revert-buffer 990 "b" #'consult-buffer 991 "i" #'ibuffer 992 "n" #'next-buffer 993 "p" #'previous-buffer 994 "r" #'rename-buffer) 995 996 (defvar-keymap dwrz-cape-map 997 :doc "Prefix keymap for cape." 998 :name "Cape" 999 "&" #'cape-sgml 1000 ":" #'cape-emoji 1001 "a" #'cape-abbrev 1002 "d" #'cape-dabbrev 1003 "e" #'cape-elisp-block 1004 "f" #'cape-file 1005 "h" #'cape-history 1006 "k" #'cape-keyword 1007 "l" #'cape-line 1008 "r" #'cape-rfc1345 1009 "s" #'cape-elisp-symbol 1010 "w" #'cape-dict) 1011 1012 (defvar-keymap dwrz-file-map 1013 :doc "Prefix keymaps for files." 1014 :name "File" 1015 "f" #'find-file 1016 "F" #'find-file-other-window 1017 "d" #'dired) 1018 1019 (defvar-keymap dwrz-highlight-map 1020 :doc "Prefix keymap for highlight." 1021 :name "Highlight" 1022 "l" #'highlight-lines-matching-regexp 1023 "p" #'highlight-phrase 1024 "r" #'highlight-regexp 1025 "s" #'highlight-symbol-at-point 1026 "u" #'unhighlight-regexp) 1027 1028 (defvar-keymap dwrz-macro-map 1029 :doc "Prefix keymap for macros." 1030 :name "Macro" 1031 "c" #'kmacro-set-counter 1032 "s" #'kmacro-start-macro-or-insert-counter 1033 "t" #'kmacro-end-or-call-macro) 1034 1035 (defvar-keymap dwrz-movement-map 1036 :doc "Prefix keymap for movement." 1037 :name "Move" 1038 "a" #'avy-goto-char 1039 "l" #'avy-goto-line 1040 "<up>" #'windmove-swap-states-up 1041 "<down>" #'windmove-swap-states-down 1042 "<left>" #'windmove-swap-states-left 1043 "<right>" #'windmove-swap-states-right) 1044 1045 (defvar-keymap dwrz-org-ctx-map 1046 :doc "Prefix keymap for org-mode context." 1047 :name "Org Context" 1048 "a" (cons "all" 1049 #'(lambda () (interactive) (dwrz-switch-org-ctx "all"))) 1050 "c" (cons "chimerical" 1051 #'(lambda () (interactive) (dwrz-switch-org-ctx "chimerical"))) 1052 "d" (cons "dwrz" #'(lambda () (interactive) (dwrz-switch-org-ctx "dwrz"))) 1053 "e" (cons "eti" #'(lambda () (interactive) (dwrz-switch-org-ctx "eti")))) 1054 1055 (defvar-keymap dwrz-org-map 1056 :doc "Prefix keymap for org-mode." 1057 :name "Org" 1058 "L" #'org-insert-link 1059 "a" #'org-agenda 1060 "b" #'org-toggle-archive-tag 1061 "B" #'org-archive-subtree-default 1062 "c" #'dwrz-org-capture-at-point 1063 "i" #'org-insert-structure-template 1064 "l" #'org-store-link 1065 "n" #'org-add-note 1066 "o" #'org-open-at-point 1067 "t" #'org-todo 1068 "x" dwrz-org-ctx-map) 1069 1070 (defvar-keymap dwrz-password-map 1071 :doc "Prefix keymap for password-store." 1072 :name "Password" 1073 "c" (cons "copy" #'password-store-copy) 1074 "e" (cons "edit" #'password-store-edit) 1075 "g" (cons "generate" #'password-store-generate) 1076 "i" (cons "insert" #'password-store-insert) 1077 "n" (cons "rename" #'password-store-rename) 1078 "r" (cons "remove" #'password-store-remove)) 1079 1080 (defvar-keymap dwrz-hideshow-map 1081 :doc "Prefix keymap for hideshow." 1082 :name "Transpose" 1083 "h" #'hs-hide-all 1084 "s" #'hs-show-all 1085 "H" #'hs-hide-block 1086 "S" #'hs-show-block) 1087 1088 (defvar-keymap dwrz-insert-map 1089 :doc "Prefix keymap for insertion and point." 1090 :name "Insert" 1091 "d" (cons "date" #'dwrz-insert-date) 1092 "e" #'emoji-search 1093 "h" #'hippie-expand 1094 "l" #'emoji-list 1095 "q" #'quoted-insert 1096 "t" (cons "timestamp" #'dwrz-insert-timestamp)) 1097 1098 (defvar-keymap dwrz-region-map 1099 :doc "Prefix keymap for region." 1100 :name "Region" 1101 "U" #'dwrz-unfill-region-or-paragraph 1102 "c" #'rot13-region 1103 "d" #'downcase-region 1104 "f" #'fill-region 1105 "o" #'comment-or-uncomment-region 1106 "r" #'reverse-region 1107 "s" #'sort-lines 1108 "u" #'upcase-region) 1109 1110 (defvar-keymap dwrz-search-map 1111 :doc "Prefix keymap for search." 1112 :name "Search" 1113 "a" (cons "address" 1114 #'(lambda () (interactive) (consult-notmuch-address t nil))) 1115 "c" #'consult-mark 1116 "f" #'consult-find 1117 "g" #'consult-grep 1118 "i" #'consult-imenu-multi 1119 "k" #'consult-global-mark 1120 "m" #'consult-line-multi 1121 "n" #'consult-notmuch 1122 "o" #'consult-org-heading 1123 "r" #'consult-ripgrep 1124 "t" #'consult-outline 1125 "v" #'consult-git-grep) 1126 1127 (defvar-keymap dwrz-spell-map 1128 "b" #'ispell-buffer 1129 "r" #'ispell-region 1130 "w" #'ispell-word) 1131 1132 (defvar-keymap dwrz-terminal-map 1133 :doc "Prefix keymap for terminal." 1134 :name "Terminal" 1135 "c" #'vterm-copy-mode 1136 "t" #'term 1137 "v" #'dwrz-vterm-in-current-directory) 1138 1139 (defvar-keymap dwrz-time-map 1140 :doc "Prefix keymap for date and time." 1141 :name "Time" 1142 "c" #'calendar 1143 "w" #'world-clock) 1144 1145 (defvar-keymap dwrz-transpose-map 1146 :doc "Prefix keymap for transposition." 1147 :name "Transpose" 1148 "c" #'transpose-chars 1149 "l" #'transpose-lines 1150 "p" #'transpose-paragraphs 1151 "s" #'transpose-sentences 1152 "w" #'transpose-words 1153 "x" #'transpose-sexps) 1154 1155 (defvar-keymap dwrz-windows-map 1156 :doc "Prefix keymap for windows." 1157 :name "Window" 1158 "0" #'delete-window 1159 "1" #'delete-other-windows 1160 "2" #'split-window-below 1161 "3" #'split-window-right 1162 "9" #'dwrz-split-window-two-thirds 1163 "<down>" #'windmove-swap-states-down 1164 "<left>" #'windmove-swap-states-left 1165 "<right>" #'windmove-swap-states-right 1166 "<up>" #'windmove-swap-states-up 1167 "B" #'balance-windows-area 1168 "E" #'enlarge-window-horizontally 1169 "S" #'shrink-window-horizontally 1170 "b" #'balance-windows 1171 "e" #'enlarge-window 1172 "o" #'other-window 1173 "s" #'shrink-window 1174 "t" #'tear-off-window) 1175 1176 (defvar-keymap dwrz-zoom-map 1177 :doc "Prefix keymap for text scale." 1178 :name "Zoom" 1179 :repeat t 1180 "+" #'text-scale-increase 1181 "-" #'text-scale-decrease 1182 "=" (cons "reset" #'(lambda () (interactive) (text-scale-increase 0)))) 1183 1184 (defvar-keymap dwrz-prefix-map 1185 :doc "Prefix keymap with multiple subkeymaps." 1186 :name "dwrz prefix" 1187 ;; :repeat (:exit (ignore)) 1188 "#" #'display-line-numbers-mode 1189 "&" #'async-shell-command 1190 "-" #'negative-argument 1191 ":" #'eval-expression 1192 ";" (cons "terminal" dwrz-terminal-map) 1193 "<" #'undo 1194 "<down>" #'windmove-down 1195 "<left>" #'windmove-left 1196 "<right>" #'windmove-right 1197 "<up>" #'windmove-up 1198 ">" #'undo-redo 1199 "?" (cons "help" help-map) 1200 "@" (cons "time" dwrz-time-map) 1201 "A" #'gptel-menu 1202 "E" #'hippie-expand 1203 "F" #'consult-find 1204 "H" (cons "highlight" dwrz-highlight-map) 1205 "M" (cons "macro" dwrz-macro-map) 1206 "P" (cons "project" project-prefix-map) 1207 "Q" #'save-buffers-kill-emacs 1208 "R" (cons "replace" #'query-replace) 1209 "S" (cons "spell" dwrz-spell-map) 1210 "_" (cons "hideshow" dwrz-hideshow-map) 1211 "a" #'avy-goto-char 1212 "b" (cons "buffer" dwrz-buffer-map) 1213 "c" (cons "cape" dwrz-cape-map) 1214 "e" (cons "exec" #'execute-extended-command) 1215 "f" (cons "file" dwrz-file-map) 1216 "h" #'hippie-expand 1217 "i" (cons "insert" dwrz-insert-map) 1218 "j" (cons "jump" #'jump-to-register) 1219 "l" (cons "line" #'consult-goto-line) 1220 "m" (cons "move" dwrz-movement-map) 1221 "n" (cons "narrow" narrow-map) 1222 "o" (cons "org" dwrz-org-map) 1223 "p" (cons "password" dwrz-password-map) 1224 "q" #'ignore 1225 "r" (cons "region" dwrz-region-map) 1226 "s" (cons "search" dwrz-search-map) 1227 "t" (cons "transpose" dwrz-transpose-map) 1228 "u" #'universal-argument 1229 "v" #'vundo 1230 "w" (cons "window" dwrz-windows-map) 1231 "y" #'yasnippet-capf 1232 "z" (cons "zoom" dwrz-zoom-map) 1233 "|" #'shell-command-on-region) 1234 1235 ;; KEYBINDINGS 1236 (global-set-key (kbd "C-z") dwrz-prefix-map) 1237 (global-set-key (kbd "C-;") dwrz-prefix-map)