From 308ab86c18112ae122540afe3790c371b623cc83 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Tue, 30 Jan 2024 09:35:15 -0500 Subject: move emacs config --- emacs/.config/chemacs/profiles.el | 5 - emacs/.config/doom-staging/config.el | 365 -------- emacs/.config/doom-staging/init.el | 184 ---- emacs/.config/doom-staging/packages.el | 61 -- emacs/.config/doom/config.el | 365 -------- emacs/.config/doom/init.el | 185 ---- emacs/.config/doom/packages.el | 59 -- emacs/.config/emacs-kj/early-init.el | 21 - emacs/.config/emacs-kj/init.el | 911 -------------------- emacs/.config/emacs-kj/lisp/kj-bindings.el | 34 - emacs/.config/emacs-kj/lisp/kj-defaults.el | 49 -- emacs/.config/emacs-kj/lisp/kj-development.el | 93 -- emacs/.config/emacs-kj/lisp/kj-email.el | 97 --- emacs/.config/emacs-kj/lisp/kj-eshell.el | 83 -- emacs/.config/emacs-kj/lisp/kj-history.el | 65 -- emacs/.config/emacs-kj/lisp/kj-lib.el | 11 - emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el | 20 - emacs/.config/emacs-kj/lisp/kj-org.el | 251 ------ emacs/.config/emacs-kj/lisp/kj-popup.el | 95 --- emacs/.config/emacs-v2/early-init.el | 32 - emacs/.config/emacs-v2/elpaca-installer.el | 38 - emacs/.config/emacs-v2/emacs-custom.el | 19 - emacs/.config/emacs-v2/init.el | 40 - emacs/.config/emacs-v2/lisp/kj-bindings.el | 34 - emacs/.config/emacs-v2/lisp/kj-defaults.el | 50 -- emacs/.config/emacs-v2/lisp/kj-development.el | 116 --- emacs/.config/emacs-v2/lisp/kj-email.el | 86 -- emacs/.config/emacs-v2/lisp/kj-eshell.el | 83 -- emacs/.config/emacs-v2/lisp/kj-history.el | 66 -- emacs/.config/emacs-v2/lisp/kj-init.el | 944 --------------------- emacs/.config/emacs-v2/lisp/kj-lib.el | 11 - emacs/.config/emacs-v2/lisp/kj-multiple-cursors.el | 20 - emacs/.config/emacs-v2/lisp/kj-org.el | 251 ------ emacs/.config/emacs-v2/templates | 29 - emacs/.config/emacs/early-init.el | 32 + emacs/.config/emacs/elpaca-installer.el | 38 + emacs/.config/emacs/emacs-custom.el | 19 + emacs/.config/emacs/init.el | 40 + emacs/.config/emacs/lisp/kj-bindings.el | 34 + emacs/.config/emacs/lisp/kj-defaults.el | 50 ++ emacs/.config/emacs/lisp/kj-development.el | 116 +++ emacs/.config/emacs/lisp/kj-email.el | 86 ++ emacs/.config/emacs/lisp/kj-eshell.el | 83 ++ emacs/.config/emacs/lisp/kj-history.el | 66 ++ emacs/.config/emacs/lisp/kj-init.el | 944 +++++++++++++++++++++ emacs/.config/emacs/lisp/kj-lib.el | 11 + emacs/.config/emacs/lisp/kj-multiple-cursors.el | 20 + emacs/.config/emacs/lisp/kj-org.el | 251 ++++++ emacs/.config/emacs/templates | 29 + 49 files changed, 1819 insertions(+), 4773 deletions(-) delete mode 100644 emacs/.config/chemacs/profiles.el delete mode 100644 emacs/.config/doom-staging/config.el delete mode 100644 emacs/.config/doom-staging/init.el delete mode 100644 emacs/.config/doom-staging/packages.el delete mode 100644 emacs/.config/doom/config.el delete mode 100644 emacs/.config/doom/init.el delete mode 100644 emacs/.config/doom/packages.el delete mode 100644 emacs/.config/emacs-kj/early-init.el delete mode 100644 emacs/.config/emacs-kj/init.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-bindings.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-defaults.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-development.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-email.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-eshell.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-history.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-lib.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-org.el delete mode 100644 emacs/.config/emacs-kj/lisp/kj-popup.el delete mode 100644 emacs/.config/emacs-v2/early-init.el delete mode 100644 emacs/.config/emacs-v2/elpaca-installer.el delete mode 100644 emacs/.config/emacs-v2/emacs-custom.el delete mode 100644 emacs/.config/emacs-v2/init.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-bindings.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-defaults.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-development.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-email.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-eshell.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-history.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-init.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-lib.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-multiple-cursors.el delete mode 100644 emacs/.config/emacs-v2/lisp/kj-org.el delete mode 100644 emacs/.config/emacs-v2/templates create mode 100644 emacs/.config/emacs/early-init.el create mode 100644 emacs/.config/emacs/elpaca-installer.el create mode 100644 emacs/.config/emacs/emacs-custom.el create mode 100644 emacs/.config/emacs/init.el create mode 100644 emacs/.config/emacs/lisp/kj-bindings.el create mode 100644 emacs/.config/emacs/lisp/kj-defaults.el create mode 100644 emacs/.config/emacs/lisp/kj-development.el create mode 100644 emacs/.config/emacs/lisp/kj-email.el create mode 100644 emacs/.config/emacs/lisp/kj-eshell.el create mode 100644 emacs/.config/emacs/lisp/kj-history.el create mode 100644 emacs/.config/emacs/lisp/kj-init.el create mode 100644 emacs/.config/emacs/lisp/kj-lib.el create mode 100644 emacs/.config/emacs/lisp/kj-multiple-cursors.el create mode 100644 emacs/.config/emacs/lisp/kj-org.el create mode 100644 emacs/.config/emacs/templates (limited to 'emacs/.config') diff --git a/emacs/.config/chemacs/profiles.el b/emacs/.config/chemacs/profiles.el deleted file mode 100644 index 473c2b5..0000000 --- a/emacs/.config/chemacs/profiles.el +++ /dev/null @@ -1,5 +0,0 @@ -(("default" . ((user-emacs-directory . "~/.config/emacs-v2"))) - ("doom" . ((user-emacs-directory . "~/build/doom-emacs") - (env . (("DOOMDIR" . "~/.config/doom"))))) - ("kj" . ((user-emacs-directory . "~/.config/emacs-kj"))) - ("v2" . ((user-emacs-directory . "~/.config/emacs-v2")))) diff --git a/emacs/.config/doom-staging/config.el b/emacs/.config/doom-staging/config.el deleted file mode 100644 index 34e66b5..0000000 --- a/emacs/.config/doom-staging/config.el +++ /dev/null @@ -1,365 +0,0 @@ -;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- - -;; Place your private configuration here! Remember, you do not need to run 'doom -;; sync' after modifying this file! - -;; Some functionality uses this to identify you, e.g. GPG configuration, email -;; clients, file templates and snippets. -(setq user-full-name "KJ Orbekk" - user-mail-address "kj@orbekk.com") - -(defmacro system-specific-config (system-regex &rest code) - "Run CODE on systems that match SYSTEM-REGEX." - `(when (string-match ,system-regex (system-name)) - ,@code)) - -(setq kj/font-size 16) -(setq doom-theme 'modus-operandi) -(after! modus-themes - (modus-themes-load-themes)) - -;; Completion gets in the way more often than being useful. -(setq company-idle-delay nil) -(setq lsp-ui-doc-enable nil) - -(setq display-line-numbers-type nil) - -;; Scratch buffers are often for lisp stuff. -(setq doom-scratch-initial-major-mode 'lisp-interaction-mode) - -(setq math-additional-units - '((ZiB "1024 * EiB" "Zebibyte") - (EiB "1024 * PiB" "Exbibyte") - (PiB "1024 * TiB" "Pebibyte") - (TiB "1024 * GiB" "Tebibyte") - (GiB "1024 * MiB" "Gibibyte") - (MiB "1024 * KiB" "Mebibyte") - (KiB "1024 * B" "Kibibyte") - (B nil "Byte") - (Zib "1024 * ZiB" "Zebibit") - (Eib "1024 * PiB" "Exbibit") - (Pib "1024 * TiB" "Pebibit") - (Tib "1024 * GiB" "Tebibit") - (Gib "1024 * Mib" "Gibibit") - (Mib "1024 * Kib" "Mebibit") - (Kib "1024 * b" "Kibibit") - (b "B / 8" "Bit"))) - -(system-specific-config - "pincer" - (setq kj/font-size 18) - (setq doom-theme 'doom-one)) - -(system-specific-config - "orbekk" - (setq doom-theme 'doom-solarized-light)) - -(system-specific-config - "^siofra\." - (setq kj/font-size 20) - (setq doom-theme 'doom-one-light)) - -(setq doom-font (font-spec :family "iosevka" :size kj/font-size)) -(setq doom-variable-pitch-font (font-spec :family "Noto Serif" :size kj/font-size)) - -;; If you use `org' and don't want your org files in the default location below, -;; change `org-directory'. It must be set before org loads! -(setq org-directory "~/org/") -(setq org-todo-keywords - '((sequence - "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))) -(setq org-refile-use-outline-path nil) -(setq org-refile-targets '((nil . (:maxlevel . 2)))) -(setq org-log-into-drawer t) -(setq org-agenda-log-mode-items '(closed clock state)) -(setq org-agenda-start-day nil) -(setq org-agenda-block-separator nil) -(setq org-agenda-compact-blocks t) -(setq org-agenda-start-with-log-mode nil) -(setq org-habit-show-all-today t) -(setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------")) -(setq org-roam-directory (concat org-directory "roam/")) -(setq-default org-agenda-files '()) -(dolist (file '("tasks.org" - "running-2022.org")) - (add-to-list 'org-agenda-files (concat org-roam-directory file))) -(setq org-roam-db-location (concat org-roam-directory "/org-roam.db")) -(setq org-export-with-toc nil) -(setq deft-directory org-directory) -(setq deft-recursive t) -;; Org html export -(setq org-html-htmlize-output-type 'css) -;; Website publish settings. -(defvar kj/publish-tag "publish") -(defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") -(add-to-list 'org-modules 'org-habit) - -; (setq org-appear-autolinks t) -; (use-package! org-appear -; :hook (org-mode . org-appear-mode)) - -(setq org-log-done 'time) -(setq org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "LOOP(r)" ; A recurring task - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "IDEA(i)" ; An unconfirmed and unapproved task or notion - "|" - "DONE(d!)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)") ; Task was completed - (sequence - "|" - "OKAY(o)" - "YES(y)" - "NO(n)"))) - -;;(use-package! org-super-agenda -;; :after org-agenda -;; :init -;; -;; (setq org-agenda-custom-commands -;; '(("d" "Daily KJ agenda" -;; ((agenda "" ((org-agenda-span 'day) -;; (org-agenda-start-day nil) -;; (org-super-agenda-groups -;; '((:name "Habits" -;; :habit t -;; :order 2) -;; (:name "Past & Overdue" -;; :scheduled past -;; :deadline past) -;; (:name "Today" -;; :time-grid t -;; :date today) -;; (:name "Due Soon" -;; :scheduled future -;; :deadline future))))) -;; (alltodo "" ((org-agenda-overriding-header "") -;; (org-super-agenda-groups -;; '((:name "Important" -;; :priority "A" -;; :priority "B") -;; (:discard (:habit t)))))))))) -;; -;; :config -;; (org-super-agenda-mode 1)) - -(setq org-journal-file-type 'weekly) -(setq org-journal-dir org-roam-directory) -(setq org-journal-file-format "journal-%Y-%m-%d.org") -(setq org-journal-enable-agenda-integration t) -(defun kj/org-journal-init () - (interactive) - (save-excursion - (goto-char (point-min)) - (org-id-get-create) - (org-set-property "category" "journal"))) - -(defun kj/org-journal-file-header (time) - (format-time-string "#+title: Week of %F (%W)\n" - (org-journal--convert-time-to-file-type-time time))) -(setq org-journal-file-header #'kj/org-journal-file-header) -(add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init) - -;; Allow more keys when navigating with avy. -(setq avy-keys '(?a ?o ?e ?u ?d ?h ?n ?s ?l ?, ?. ?p ?r)) -(setq avy-timeout-seconds 0.4) - -;; Low menu delay. -(setq which-key-idle-delay .5) - -;; Allow longer output in compilation buffer. -(setq comint-buffer-maximum-size 10000) - -;; Replace values in an alist from a list of replacements. -;; -;; Example: -;; (kj/assq-replace '((:a . 1)) '((:a . 2))) -(defun kj/assq-replace (replacements alist) - (let ((replace1 (lambda (aelem alist) - (cons aelem (assq-delete-all (car aelem) alist))))) - (if replacements - (kj/assq-replace (cdr replacements) - (funcall replace1 (car replacements) alist)) - alist))) - -(server-start) -(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode) -(add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode)) - -;; Make ace window more visible -(custom-set-faces! - '(aw-leading-char-face - :foreground "white" :background "red" - :weight bold :height 2.5 :box (:line-width 10 :color "red"))) - -(after! racket-mode - (remove-hook! 'racket-mode #'racket-smart-open-bracket-mode)) - -(after! org - (add-hook 'org-mode-hook 'mixed-pitch-mode) - (setq org-roam-mode-section-functions - (list #'org-roam-backlinks-section - #'org-roam-reflinks-section - #'org-roam-unlinked-references-section)) - - (add-to-list 'org-structure-template-alist - '("se" . "src emacs-lisp")) - - (setq org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export") - (:output-dir . "static/data/")) - org-babel-default-header-args)) - - (defun kj/org-journal-find-location () - ;; Open today's journal, but specify a non-nil prefix argument in order to - ;; inhibit inserting the heading; org-capture will insert the heading. - (org-journal-new-entry t)) - ;; (unless (eq org-journal-file-type 'daily) - ;; (org-narrow-to-subtree)) - ;; (goto-char (point-max))) - - (defun kj/org-journal-narrowed-location () - ;; Open today's journal, but specify a non-nil prefix argument in order to - ;; inhibit inserting the heading; org-capture will insert the heading. - (org-journal-new-entry t) - (unless (eq org-journal-file-type 'daily) - (org-narrow-to-subtree)) - (goto-char (point-max))) - - (setq org-capture-templates - `(("g" "Go to current journal entry" plain (function kj/org-journal-find-location) - "%i%?" :jump-to-captured t :immediate-finish t) - ("t" "Create a TODO" entry (file+headline "~/org/roam/tasks.org" "Inbox") - "** TODO %?\n%i\n%a") - ("w" "Log bodyweight" table-line - (file+headline ,(concat org-roam-directory "bodyweight.org") - "Body weight log") - "| %t | %^{Weight} | |" - :prepend t :immediate-finish t))) - - (defun kj/find-agenda-files-containing-tag (tag) - (setq org-agenda-archives-mode nil) - (let* ((org-agenda-archives-mode nil) - (candidates (org-agenda-files nil 'ifmode)) - (matcher (cdr (org-make-tags-matcher tag))) - (files)) - ;; (message "Results:") - (dolist (file candidates files) - (org-check-agenda-file file) - (with-current-buffer (org-get-agenda-file-buffer file) - ;; (message "%S" (org-scan-tags 'agenda matcher nil)) - (when (org-scan-tags 'agenda matcher nil) - (push file files)))))) - - (setq kj/inbox-path "/ssh:dragon.orbekk.com:/storage/srv/kj.orbekk.com/dav/Inbox.org") - - (defun kj/fetch-inbox () - (interactive) - (let ((content (with-current-buffer (find-file-noselect kj/inbox-path) - (buffer-string)))) - (kj/org-journal-find-location) - (when (not (string-empty-p content)) - (org-paste-subtree nil content))) - (with-current-buffer (find-file-noselect kj/inbox-path) - (erase-buffer) - (save-buffer) - (kill-buffer))) - - (defvar org-publish-project-alist) - (defun kj/org-publish (&optional project force) - (interactive) - (setq project (or project "all")) - (setq force (or force current-prefix-arg)) - (setq org-agenda-files (list org-roam-directory)) - (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) - (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) - ;; Disable org babel exports during publish entirely to speed up publish. - ;; This messes up babel output handling. - ;; (org-export-use-babel nil) - (org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export")) - org-babel-default-header-args)) - (org-publish-project-alist - `( - ("static" - :base-directory ,(concat org-roam-directory "/static") - :base-extension ,static-files-re - :recursive t - :publishing-directory ,(concat kj/publish-directory "/static") - :publishing-function org-publish-attachment) - ("source" - :base-directory ,org-roam-directory - :base-extension "org" - :exclude ".*" - :include ,files-to-include - :recursive t - :publishing-directory ,kj/publish-directory - :publishing-function org-publish-attachment) - ("html" - :base-directory ,org-roam-directory - :base-extension "org" - :recursive t - :exclude ".*" - :include ,files-to-include - :publishing-directory ,kj/publish-directory - :publishing-function org-html-publish-to-html - - :with-broken-links t - :with-toc nil - :with-latex t - :with-drawers t - :with-title t - :section-numbers nil - - ;; HTML options - :html-toplevel-hlevel 2 - :html-preamble "" - :html-postamble "" - :html-html5-fancy t - :html-doctype "html5" - :html-head "" - :html-head-include-scripts nil - :html-head-include-default-style nil - :html-container article) - - ("all" :components ("static" "source" "html"))))) - - (org-publish project force)))) - -(setq aw-dispatch-always t) - -;;; Keybindings -(map! (:after evil-org - :leader "n P" #'kj/org-publish) - - (:leader - :desc "window" "e" evil-window-map) - - (:map evil-window-map - "e" #'ace-window)) - -(add-hook 'eshell-mode-hook - (lambda () - (setenv "PAGER" "cat")) - (setenv "EDITOR" "emacsclient")) - -(after! evil-embrace - (evil-embrace-enable-evil-surround-integration) - (setq evil-embrace-show-help-p t)) - -(let ((local-config "~/.doom.d/config.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) diff --git a/emacs/.config/doom-staging/init.el b/emacs/.config/doom-staging/init.el deleted file mode 100644 index 0e8a2ef..0000000 --- a/emacs/.config/doom-staging/init.el +++ /dev/null @@ -1,184 +0,0 @@ -;;; init.el -*- lexical-binding: t; -*- - -;; This file controls what Doom modules are enabled and what order they load -;; in. Remember to run 'doom sync' after modifying it! - -;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's -;; documentation. There you'll find information about all of Doom's -;; modules and what flags they support. - -;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or -;; 'C-c g k' for non-vim users) to view its documentation. This works on -;; flags as well (those symbols that start with a plus). -;; -;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its -;; directory (for easy access to its source code). -(let ((local-config "~/.doom.d/init.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) - -(doom! :input - ;;chinese - ;;japanese - - :completion - company ; the ultimate code completion backend - ;;helm ; the *other* search engine for love and life - ;;ido ; the other *other* search engine... - ;;ivy ; a search engine for love and life - vertico ; the search engine of the future - - :ui - ;;deft ; notational velocity for Emacs - doom ; what makes DOOM look the way it does - doom-dashboard ; a nifty splash screen for Emacs - ;;doom-quit ; DOOM quit-message prompts when you quit Emacs - ;;fill-column ; a `fill-column' indicator - hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW - ;;hydra - ;;indent-guides ; highlighted indent columns - ;;minimap ; show a map of the code on the side - (modeline +light) ; snazzy, Atom-inspired modeline, plus API - ;;nav-flash ; blink cursor line after big motions - ;;neotree ; a project drawer, like NERDTree for vim - ophints ; highlight the region an operation acts on - (popup +defaults) ; tame sudden yet inevitable temporary windows - ;;pretty-code ; ligatures or substitute text with pretty symbols - ;;tabs ; an tab bar for Emacs - treemacs ; a project drawer, like neotree but cooler - ;;unicode ; extended unicode support for various languages - vc-gutter ; vcs diff in the fringe - vi-tilde-fringe ; fringe tildes to mark beyond EOB - (window-select +numbers) ; visually switch windows - ;;workspaces ; tab emulation, persistence & separate workspaces - zen ; distraction-free coding or writing - ;; (emoji +unicode) ; 😇 - - :editor - ;;(evil +everywhere); come to the dark side, we have cookies - file-templates ; auto-snippets for empty files - fold ; (nigh) universal code folding - format ; automated prettiness - ;;god ; run Emacs commands without modifier keys - ;;lispy ; vim for lisp, for people who don't like vim - multiple-cursors ; editing in many places at once - ;;objed ; text object editing for the innocent - ;;parinfer ; turn lisp into python, sort of - ;;rotate-text ; cycle region at point between text candidates - snippets ; my elves. They type so I don't have to - ;;word-wrap ; soft wrapping with language-aware indent - - :emacs - dired ; making dired pretty [functional] - electric ; smarter, keyword-based electric-indent - ;;ibuffer ; interactive buffer management - undo ; persistent, smarter undo for your inevitable mistakes - vc ; version-control and Emacs, sitting in a tree - - :term - eshell ; the elisp shell that works everywhere - shell ; simple shell REPL for Emacs - ;;term ; basic terminal emulator for Emacs - ;;vterm ; the best terminal emulation in Emacs - - :checkers - ;;syntax ; tasing you for every semicolon you forget - ;;spell ; tasing you for misspelling mispelling - ;;grammar ; tasing grammar mistake every you make - - :tools - ;;ansible - ;;debugger ; FIXME stepping through code, to help you add bugs - direnv - ;;docker - editorconfig ; let someone else argue about tabs vs spaces - ;;ein ; tame Jupyter notebooks with emacs - (eval +overlay) ; run code, run (also, repls) - ;;gist ; interacting with github gists - lookup ; navigate your code and its documentation - lsp - ;;macos ; MacOS-specific commands - magit ; a git porcelain for Emacs - ;;make ; run make tasks from Emacs - pass ; password manager for nerds - ;;pdf ; pdf enhancements - ;;prodigy ; FIXME managing external services & code builders - rgb ; creating color strings - ;;taskrunner ; taskrunner for all your projects - ;;terraform ; infrastructure as code - ;;tmux ; an API for interacting with tmux - ;;upload ; map local to remote projects via ssh/ftp - - :lang - ;;agda ; types of types of types of types... - (cc +lsp) ; C/C++/Obj-C madness - clojure ; java with a lisp - ;;common-lisp ; if you've seen one lisp, you've seen them all - ;;coq ; proofs-as-programs - ;;crystal ; ruby at the speed of c - ;;csharp ; unity, .NET, and mono shenanigans - data ; config/data formats - ;;(dart +flutter) ; paint ui and not much else - ;;elixir ; erlang done right - ;;elm ; care for a cup of TEA? - emacs-lisp ; drown in parentheses - ;;erlang ; an elegant language for a more civilized age - (ess +lsp) ; emacs speaks statistics - ;;faust ; dsp, but you get to keep your soul - ;;fsharp ; ML stands for Microsoft's Language - ;;fstar ; (dependent) types and (monadic) effects and Z3 - ;;(go +lsp) ; the hipster dialect - (haskell +dante) ; a language that's lazier than I am - ;;hy ; readability of scheme w/ speed of python - ;;idris ; - ;;json ; At least it ain't XML - ;;(java +meghanada) ; the poster child for carpal tunnel syndrome - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) - ;;julia ; a better, faster MATLAB - ;;kotlin ; a better, slicker Java(Script) - ;;latex ; writing papers in Emacs has never been so fun - ;;lean - ;;factor - ledger ; an accounting system in Emacs - ;;lua ; one-based indices? one-based indices - markdown ; writing docs for people to ignore - ;;nim ; python + lisp at the speed of c - nix ; I hereby declare "nix geht mehr!" - ;;ocaml ; an objective camel - (org +journal +roam2) ; organize your plain life in plain text - ;;perl ; write code no one else can comprehend - ;;php ; perl's insecure younger brother - ;;plantuml ; diagrams for confusing people more - ;;purescript ; javascript, but functional - python ; beautiful is better than ugly - ;;qt ; the 'cutest' gui framework ever - racket ; a DSL for DSLs - ;;rest ; Emacs as a REST client - ;;rst ; ReST in peace - ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - (rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() - ;;scala ; java, but good - ;;scheme ; a fully conniving family of lisps - sh ; she sells {ba,z,fi}sh shells on the C xor - ;;sml - ;;solidity ; do you need a blockchain? No. - ;;swift ; who asked for emoji variables? - ;;terra ; Earth and Moon in alignment for performance. - web ; the tubes - ;;yaml ; JSON, but readable - - :email - ;;mu4e - ;;notmuch - ;;(wanderlust +gmail) - - :app - everywhere - ;;calendar - ;;irc ; how neckbeards socialize - ;;(rss +org) ; emacs as an RSS reader - ;;twitter ; twitter client https://twitter.com/vnought - - :config - ;;literate - (default +bindings)) diff --git a/emacs/.config/doom-staging/packages.el b/emacs/.config/doom-staging/packages.el deleted file mode 100644 index 477cf1a..0000000 --- a/emacs/.config/doom-staging/packages.el +++ /dev/null @@ -1,61 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; $DOOMDIR/packages.el - -;; To install a package with Doom you must declare them here, run 'doom sync' on -;; the command line, then restart Emacs for the changes to take effect. -;; Alternatively, use M-x doom/reload. - - -;; Doom's packages are pinned to a specific commit and updated from release to -;; release. The `unpin!' macro allows you to unpin single packages... -;(unpin! pinned-package) -;; ...or multiple packages -;(unpin! pinned-package another-pinned-package) -;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) -;(unpin! t) - - -;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: -;(package! some-package) - -;; To install a package directly from a particular repo, you'll need to specify -;; a `:recipe'. You'll find documentation on what `:recipe' accepts here: -;; https://github.com/raxod502/straight.el#the-recipe-format -;(package! another-package -; :recipe (:host github :repo "username/repo")) - -;; If the package you are trying to install does not contain a PACKAGENAME.el -;; file, or is located in a subdirectory of the repo, you'll need to specify -;; `:files' in the `:recipe': -;(package! this-package -; :recipe (:host github :repo "username/repo" -; :files ("some-file.el" "src/lisp/*.el"))) - -;; If you'd like to disable a package included with Doom, for whatever reason, -;; you can do so here with the `:disable' property: -;(package! builtin-package :disable t) - -;; You can override the recipe of a built in package without having to specify -;; all the properties for `:recipe'. These will inherit the rest of its recipe -;; from Doom or MELPA/ELPA/Emacsmirror: -;(package! builtin-package :recipe (:nonrecursive t)) -;(package! builtin-package-2 :recipe (:repo "myfork/package")) - -;; Specify a `:branch' to install a package from a particular branch or tag. -;; This is required for some packages whose default branch isn't 'master' (which -;; our package manager can't deal with; see raxod502/straight.el#279) -;(package! builtin-package :recipe (:branch "develop")) - -;; (package! hledger-mode) - -;; Enabled for AoC 2021. -(package! heap) - -(package! modus-themes) - -; (package! org-appear) -; (package! org-super-agenda) - -(let ((local-config "~/.doom.d/packages.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) diff --git a/emacs/.config/doom/config.el b/emacs/.config/doom/config.el deleted file mode 100644 index 25a762a..0000000 --- a/emacs/.config/doom/config.el +++ /dev/null @@ -1,365 +0,0 @@ -;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- - -;; Place your private configuration here! Remember, you do not need to run 'doom -;; sync' after modifying this file! - -;; Some functionality uses this to identify you, e.g. GPG configuration, email -;; clients, file templates and snippets. -(setq user-full-name "KJ Orbekk" - user-mail-address "kj@orbekk.com") - -(defmacro system-specific-config (system-regex &rest code) - "Run CODE on systems that match SYSTEM-REGEX." - `(when (string-match ,system-regex (system-name)) - ,@code)) - -(setq kj/font-size 16) -(setq doom-theme 'modus-operandi) -(after! modus-themes - (modus-themes-load-themes)) - -;; Completion gets in the way more often than being useful. -(setq company-idle-delay nil) -(setq lsp-ui-doc-enable nil) - -(setq display-line-numbers-type nil) - -;; Scratch buffers are often for lisp stuff. -(setq doom-scratch-initial-major-mode 'lisp-interaction-mode) - -(setq math-additional-units - '((ZiB "1024 * EiB" "Zebibyte") - (EiB "1024 * PiB" "Exbibyte") - (PiB "1024 * TiB" "Pebibyte") - (TiB "1024 * GiB" "Tebibyte") - (GiB "1024 * MiB" "Gibibyte") - (MiB "1024 * KiB" "Mebibyte") - (KiB "1024 * B" "Kibibyte") - (B nil "Byte") - (Zib "1024 * ZiB" "Zebibit") - (Eib "1024 * PiB" "Exbibit") - (Pib "1024 * TiB" "Pebibit") - (Tib "1024 * GiB" "Tebibit") - (Gib "1024 * Mib" "Gibibit") - (Mib "1024 * Kib" "Mebibit") - (Kib "1024 * b" "Kibibit") - (b "B / 8" "Bit"))) - -(system-specific-config - "pincer" - (setq kj/font-size 18) - (setq doom-theme 'doom-one)) - -(system-specific-config - "orbekk" - (setq doom-theme 'doom-solarized-light)) - -(system-specific-config - "^siofra\." - (setq kj/font-size 20) - (setq doom-theme 'doom-one-light)) - -(setq doom-font (font-spec :family "iosevka" :size kj/font-size)) -(setq doom-variable-pitch-font (font-spec :family "Noto Serif" :size kj/font-size)) - -;; If you use `org' and don't want your org files in the default location below, -;; change `org-directory'. It must be set before org loads! -(setq org-directory "~/org/") -(setq org-todo-keywords - '((sequence - "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))) -(setq org-refile-use-outline-path nil) -(setq org-refile-targets '((nil . (:maxlevel . 2)))) -(setq org-log-into-drawer t) -(setq org-agenda-log-mode-items '(closed clock state)) -(setq org-agenda-start-day nil) -(setq org-agenda-block-separator nil) -(setq org-agenda-compact-blocks t) -(setq org-agenda-start-with-log-mode nil) -(setq org-habit-show-all-today t) -(setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------")) -(setq org-roam-directory (concat org-directory "roam/")) -(setq-default org-agenda-files '()) -(dolist (file '("tasks.org" - "running-2022.org")) - (add-to-list 'org-agenda-files (concat org-roam-directory file))) -(setq org-roam-db-location (concat org-roam-directory "/org-roam.db")) -(setq org-export-with-toc nil) -(setq deft-directory org-directory) -(setq deft-recursive t) -;; Org html export -(setq org-html-htmlize-output-type 'css) -;; Website publish settings. -(defvar kj/publish-tag "publish") -(defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") -(add-to-list 'org-modules 'org-habit) - -; (setq org-appear-autolinks t) -; (use-package! org-appear -; :hook (org-mode . org-appear-mode)) - -(setq org-log-done 'time) -(setq org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "LOOP(r)" ; A recurring task - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "IDEA(i)" ; An unconfirmed and unapproved task or notion - "|" - "DONE(d!)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)") ; Task was completed - (sequence - "|" - "OKAY(o)" - "YES(y)" - "NO(n)"))) - -;;(use-package! org-super-agenda -;; :after org-agenda -;; :init -;; -;; (setq org-agenda-custom-commands -;; '(("d" "Daily KJ agenda" -;; ((agenda "" ((org-agenda-span 'day) -;; (org-agenda-start-day nil) -;; (org-super-agenda-groups -;; '((:name "Habits" -;; :habit t -;; :order 2) -;; (:name "Past & Overdue" -;; :scheduled past -;; :deadline past) -;; (:name "Today" -;; :time-grid t -;; :date today) -;; (:name "Due Soon" -;; :scheduled future -;; :deadline future))))) -;; (alltodo "" ((org-agenda-overriding-header "") -;; (org-super-agenda-groups -;; '((:name "Important" -;; :priority "A" -;; :priority "B") -;; (:discard (:habit t)))))))))) -;; -;; :config -;; (org-super-agenda-mode 1)) - -(setq org-journal-file-type 'weekly) -(setq org-journal-dir org-roam-directory) -(setq org-journal-file-format "journal-%Y-%m-%d.org") -(setq org-journal-enable-agenda-integration t) -(defun kj/org-journal-init () - (interactive) - (save-excursion - (goto-char (point-min)) - (org-id-get-create) - (org-set-property "category" "journal"))) - -(defun kj/org-journal-file-header (time) - (format-time-string "#+title: Week of %F (%W)\n" - (org-journal--convert-time-to-file-type-time time))) -(setq org-journal-file-header #'kj/org-journal-file-header) -(add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init) - -;; Allow more keys when navigating with avy. -(setq avy-keys '(?a ?o ?e ?u ?d ?h ?n ?s ?l ?, ?. ?p ?r)) -(setq avy-timeout-seconds 0.4) - -;; Low menu delay. -(setq which-key-idle-delay .5) - -;; Allow longer output in compilation buffer. -(setq comint-buffer-maximum-size 10000) - -;; Replace values in an alist from a list of replacements. -;; -;; Example: -;; (kj/assq-replace '((:a . 1)) '((:a . 2))) -(defun kj/assq-replace (replacements alist) - (let ((replace1 (lambda (aelem alist) - (cons aelem (assq-delete-all (car aelem) alist))))) - (if replacements - (kj/assq-replace (cdr replacements) - (funcall replace1 (car replacements) alist)) - alist))) - -(server-start) -(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode) -(add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode)) - -;; Make ace window more visible -(custom-set-faces! - '(aw-leading-char-face - :foreground "white" :background "red" - :weight bold :height 2.5 :box (:line-width 10 :color "red"))) - -(after! racket-mode - (remove-hook! 'racket-mode #'racket-smart-open-bracket-mode)) - -(after! org - (add-hook 'org-mode-hook 'mixed-pitch-mode) - (setq org-roam-mode-section-functions - (list #'org-roam-backlinks-section - #'org-roam-reflinks-section - #'org-roam-unlinked-references-section)) - - (add-to-list 'org-structure-template-alist - '("se" . "src emacs-lisp")) - - (setq org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export") - (:output-dir . "static/data/")) - org-babel-default-header-args)) - - (defun kj/org-journal-find-location () - ;; Open today's journal, but specify a non-nil prefix argument in order to - ;; inhibit inserting the heading; org-capture will insert the heading. - (org-journal-new-entry t)) - ;; (unless (eq org-journal-file-type 'daily) - ;; (org-narrow-to-subtree)) - ;; (goto-char (point-max))) - - (defun kj/org-journal-narrowed-location () - ;; Open today's journal, but specify a non-nil prefix argument in order to - ;; inhibit inserting the heading; org-capture will insert the heading. - (org-journal-new-entry t) - (unless (eq org-journal-file-type 'daily) - (org-narrow-to-subtree)) - (goto-char (point-max))) - - (setq org-capture-templates - `(("g" "Go to current journal entry" plain (function kj/org-journal-find-location) - "%i%?" :jump-to-captured t :immediate-finish t) - ("t" "Create a TODO" entry (file+headline "~/org/roam/tasks.org" "Inbox") - "** TODO %?\n%i\n%a") - ("w" "Log bodyweight" table-line - (file+headline ,(concat org-roam-directory "bodyweight.org") - "Body weight log") - "| %t | %^{Weight} | |" - :prepend t :immediate-finish t))) - - (defun kj/find-agenda-files-containing-tag (tag) - (setq org-agenda-archives-mode nil) - (let* ((org-agenda-archives-mode nil) - (candidates (org-agenda-files nil 'ifmode)) - (matcher (cdr (org-make-tags-matcher tag))) - (files)) - ;; (message "Results:") - (dolist (file candidates files) - (org-check-agenda-file file) - (with-current-buffer (org-get-agenda-file-buffer file) - ;; (message "%S" (org-scan-tags 'agenda matcher nil)) - (when (org-scan-tags 'agenda matcher nil) - (push file files)))))) - - (setq kj/inbox-path "/ssh:dragon.orbekk.com:/storage/srv/kj.orbekk.com/dav/Inbox.org") - - (defun kj/fetch-inbox () - (interactive) - (let ((content (with-current-buffer (find-file-noselect kj/inbox-path) - (buffer-string)))) - (kj/org-journal-find-location) - (when (not (string-empty-p content)) - (org-paste-subtree nil content))) - (with-current-buffer (find-file-noselect kj/inbox-path) - (erase-buffer) - (save-buffer) - (kill-buffer))) - - (defvar org-publish-project-alist) - (defun kj/org-publish (&optional project force) - (interactive) - (setq project (or project "all")) - (setq force (or force current-prefix-arg)) - (setq org-agenda-files (list org-roam-directory)) - (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) - (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) - ;; Disable org babel exports during publish entirely to speed up publish. - ;; This messes up babel output handling. - ;; (org-export-use-babel nil) - (org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export")) - org-babel-default-header-args)) - (org-publish-project-alist - `( - ("static" - :base-directory ,(concat org-roam-directory "/static") - :base-extension ,static-files-re - :recursive t - :publishing-directory ,(concat kj/publish-directory "/static") - :publishing-function org-publish-attachment) - ("source" - :base-directory ,org-roam-directory - :base-extension "org" - :exclude ".*" - :include ,files-to-include - :recursive t - :publishing-directory ,kj/publish-directory - :publishing-function org-publish-attachment) - ("html" - :base-directory ,org-roam-directory - :base-extension "org" - :recursive t - :exclude ".*" - :include ,files-to-include - :publishing-directory ,kj/publish-directory - :publishing-function org-html-publish-to-html - - :with-broken-links t - :with-toc nil - :with-latex t - :with-drawers t - :with-title t - :section-numbers nil - - ;; HTML options - :html-toplevel-hlevel 2 - :html-preamble "" - :html-postamble "" - :html-html5-fancy t - :html-doctype "html5" - :html-head "" - :html-head-include-scripts nil - :html-head-include-default-style nil - :html-container article) - - ("all" :components ("static" "source" "html"))))) - - (org-publish project force)))) - -(setq aw-dispatch-always t) - -;;; Keybindings -(map! (:after evil-org - :leader "n P" #'kj/org-publish) - - (:leader - :desc "window" "e" evil-window-map) - - (:map evil-window-map - "e" #'ace-window)) - -(add-hook 'eshell-mode-hook - (lambda () - (setenv "PAGER" "cat")) - (setenv "EDITOR" "emacsclient")) - -(after! evil-embrace - (evil-embrace-enable-evil-surround-integration) - (setq evil-embrace-show-help-p t)) - -(let ((local-config "~/.config/doom/config.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) diff --git a/emacs/.config/doom/init.el b/emacs/.config/doom/init.el deleted file mode 100644 index ff2768b..0000000 --- a/emacs/.config/doom/init.el +++ /dev/null @@ -1,185 +0,0 @@ -;;; init.el -*- lexical-binding: t; -*- - -;; This file controls what Doom modules are enabled and what order they load -;; in. Remember to run 'doom sync' after modifying it! - -;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's -;; documentation. There you'll find information about all of Doom's -;; modules and what flags they support. - -;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or -;; 'C-c g k' for non-vim users) to view its documentation. This works on -;; flags as well (those symbols that start with a plus). -;; -;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its -;; directory (for easy access to its source code). -(let ((local-config "~/.config/doom/init.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) - -(doom! :input - ;;chinese - ;;japanese - - :completion - company ; the ultimate code completion backend - ;;helm ; the *other* search engine for love and life - ;;ido ; the other *other* search engine... - ;;ivy ; a search engine for love and life - vertico ; the search engine of the future - - :ui - ;;deft ; notational velocity for Emacs - doom ; what makes DOOM look the way it does - doom-dashboard ; a nifty splash screen for Emacs - ;;doom-quit ; DOOM quit-message prompts when you quit Emacs - ;;fill-column ; a `fill-column' indicator - hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW - ;;hydra - ;;indent-guides ; highlighted indent columns - ;;minimap ; show a map of the code on the side - (modeline +light) ; snazzy, Atom-inspired modeline, plus API - ;;nav-flash ; blink cursor line after big motions - ;;neotree ; a project drawer, like NERDTree for vim - ophints ; highlight the region an operation acts on - (popup +defaults) ; tame sudden yet inevitable temporary windows - ;;pretty-code ; ligatures or substitute text with pretty symbols - ;;tabs ; an tab bar for Emacs - treemacs ; a project drawer, like neotree but cooler - ;;unicode ; extended unicode support for various languages - vc-gutter ; vcs diff in the fringe - vi-tilde-fringe ; fringe tildes to mark beyond EOB - (window-select +numbers) ; visually switch windows - ;;workspaces ; tab emulation, persistence & separate workspaces - zen ; distraction-free coding or writing - ;; (emoji +unicode) ; 😇 - - :editor - ;(meow +dvorak +override +keypad) - (evil +everywhere); come to the dark side, we have cookies - file-templates ; auto-snippets for empty files - fold ; (nigh) universal code folding - format ; automated prettiness - ;;god ; run Emacs commands without modifier keys - ;;lispy ; vim for lisp, for people who don't like vim - multiple-cursors ; editing in many places at once - ;;objed ; text object editing for the innocent - ;;parinfer ; turn lisp into python, sort of - ;;rotate-text ; cycle region at point between text candidates - snippets ; my elves. They type so I don't have to - ;;word-wrap ; soft wrapping with language-aware indent - - :emacs - dired ; making dired pretty [functional] - electric ; smarter, keyword-based electric-indent - ;;ibuffer ; interactive buffer management - undo ; persistent, smarter undo for your inevitable mistakes - vc ; version-control and Emacs, sitting in a tree - - :term - eshell ; the elisp shell that works everywhere - shell ; simple shell REPL for Emacs - ;;term ; basic terminal emulator for Emacs - ;;vterm ; the best terminal emulation in Emacs - - :checkers - ;;syntax ; tasing you for every semicolon you forget - ;;spell ; tasing you for misspelling mispelling - ;;grammar ; tasing grammar mistake every you make - - :tools - ;;ansible - ;;debugger ; FIXME stepping through code, to help you add bugs - direnv - ;;docker - editorconfig ; let someone else argue about tabs vs spaces - ;;ein ; tame Jupyter notebooks with emacs - (eval +overlay) ; run code, run (also, repls) - ;;gist ; interacting with github gists - lookup ; navigate your code and its documentation - lsp - ;;macos ; MacOS-specific commands - magit ; a git porcelain for Emacs - ;;make ; run make tasks from Emacs - pass ; password manager for nerds - ;;pdf ; pdf enhancements - ;;prodigy ; FIXME managing external services & code builders - rgb ; creating color strings - ;;taskrunner ; taskrunner for all your projects - ;;terraform ; infrastructure as code - ;;tmux ; an API for interacting with tmux - ;;upload ; map local to remote projects via ssh/ftp - - :lang - ;;agda ; types of types of types of types... - (cc +lsp) ; C/C++/Obj-C madness - clojure ; java with a lisp - ;;common-lisp ; if you've seen one lisp, you've seen them all - ;;coq ; proofs-as-programs - ;;crystal ; ruby at the speed of c - ;;csharp ; unity, .NET, and mono shenanigans - data ; config/data formats - ;;(dart +flutter) ; paint ui and not much else - ;;elixir ; erlang done right - ;;elm ; care for a cup of TEA? - emacs-lisp ; drown in parentheses - ;;erlang ; an elegant language for a more civilized age - ;;(ess +lsp) ; emacs speaks statistics - ;;faust ; dsp, but you get to keep your soul - ;;fsharp ; ML stands for Microsoft's Language - ;;fstar ; (dependent) types and (monadic) effects and Z3 - ;;(go +lsp) ; the hipster dialect - (haskell +dante) ; a language that's lazier than I am - ;;hy ; readability of scheme w/ speed of python - ;;idris ; - ;;json ; At least it ain't XML - ;;(java +meghanada) ; the poster child for carpal tunnel syndrome - ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) - ;;julia ; a better, faster MATLAB - ;;kotlin ; a better, slicker Java(Script) - ;;latex ; writing papers in Emacs has never been so fun - ;;lean - ;;factor - ledger ; an accounting system in Emacs - ;;lua ; one-based indices? one-based indices - markdown ; writing docs for people to ignore - ;;nim ; python + lisp at the speed of c - nix ; I hereby declare "nix geht mehr!" - ;;ocaml ; an objective camel - (org +journal +roam2) ; organize your plain life in plain text - ;;perl ; write code no one else can comprehend - ;;php ; perl's insecure younger brother - ;;plantuml ; diagrams for confusing people more - ;;purescript ; javascript, but functional - python ; beautiful is better than ugly - ;;qt ; the 'cutest' gui framework ever - racket ; a DSL for DSLs - ;;rest ; Emacs as a REST client - ;;rst ; ReST in peace - ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} - (rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() - ;;scala ; java, but good - ;;scheme ; a fully conniving family of lisps - sh ; she sells {ba,z,fi}sh shells on the C xor - ;;sml - ;;solidity ; do you need a blockchain? No. - ;;swift ; who asked for emoji variables? - ;;terra ; Earth and Moon in alignment for performance. - web ; the tubes - ;;yaml ; JSON, but readable - - :email - ;;mu4e - ;;notmuch - ;;(wanderlust +gmail) - - :app - everywhere - ;;calendar - ;;irc ; how neckbeards socialize - ;;(rss +org) ; emacs as an RSS reader - ;;twitter ; twitter client https://twitter.com/vnought - - :config - ;;literate - (default +bindings)) diff --git a/emacs/.config/doom/packages.el b/emacs/.config/doom/packages.el deleted file mode 100644 index 136308b..0000000 --- a/emacs/.config/doom/packages.el +++ /dev/null @@ -1,59 +0,0 @@ -;; -*- no-byte-compile: t; -*- -;;; $DOOMDIR/packages.el - -;; To install a package with Doom you must declare them here, run 'doom sync' on -;; the command line, then restart Emacs for the changes to take effect. -;; Alternatively, use M-x doom/reload. - - -;; Doom's packages are pinned to a specific commit and updated from release to -;; release. The `unpin!' macro allows you to unpin single packages... -;(unpin! pinned-package) -;; ...or multiple packages -;(unpin! pinned-package another-pinned-package) -;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) -;(unpin! t) - - -;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: -;(package! some-package) - -;; To install a package directly from a particular repo, you'll need to specify -;; a `:recipe'. You'll find documentation on what `:recipe' accepts here: -;; https://github.com/raxod502/straight.el#the-recipe-format -;(package! another-package -; :recipe (:host github :repo "username/repo")) - -;; If the package you are trying to install does not contain a PACKAGENAME.el -;; file, or is located in a subdirectory of the repo, you'll need to specify -;; `:files' in the `:recipe': -;(package! this-package -; :recipe (:host github :repo "username/repo" -; :files ("some-file.el" "src/lisp/*.el"))) - -;; If you'd like to disable a package included with Doom, for whatever reason, -;; you can do so here with the `:disable' property: -;(package! builtin-package :disable t) - -;; You can override the recipe of a built in package without having to specify -;; all the properties for `:recipe'. These will inherit the rest of its recipe -;; from Doom or MELPA/ELPA/Emacsmirror: -;(package! builtin-package :recipe (:nonrecursive t)) -;(package! builtin-package-2 :recipe (:repo "myfork/package")) - -;; Specify a `:branch' to install a package from a particular branch or tag. -;; This is required for some packages whose default branch isn't 'master' (which -;; our package manager can't deal with; see raxod502/straight.el#279) -;(package! builtin-package :recipe (:branch "develop")) - -;; (package! hledger-mode) - -(package! modus-themes) -(package! meow) - -; (package! org-appear) -; (package! org-super-agenda) - -(let ((local-config "~/.config/doom/packages.local.el")) - (when (file-exists-p local-config) - (load-file local-config))) diff --git a/emacs/.config/emacs-kj/early-init.el b/emacs/.config/emacs-kj/early-init.el deleted file mode 100644 index fde5f3e..0000000 --- a/emacs/.config/emacs-kj/early-init.el +++ /dev/null @@ -1,21 +0,0 @@ -;;; early-init.el -*- lexical-binding: t; -*- - -;; Defer garbage collection further back in the startup process -(setq gc-cons-threshold most-positive-fixnum) -(setq-default inhibit-redisplay t - inhibit-message t) -;; These log messages are too annoying. -(setq native-comp-async-report-warnings-errors 'silent) -(add-hook 'window-setup-hook - (lambda () - (setq-default inhibit-redisplay nil - inhibit-message nil) - (redisplay))) - -(setq package-enable-at-startup nil) - -(setq default-frame-alist '((undecorated . t))) -(tool-bar-mode -1) -(scroll-bar-mode -1) -(tooltip-mode -1) -(menu-bar-mode -1) diff --git a/emacs/.config/emacs-kj/init.el b/emacs/.config/emacs-kj/init.el deleted file mode 100644 index 83a9353..0000000 --- a/emacs/.config/emacs-kj/init.el +++ /dev/null @@ -1,911 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(setq package-enable-at-startup nil) -(defvar bootstrap-version) -(let ((bootstrap-file - (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) - (bootstrap-version 6)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) - -(push (expand-file-name "lisp" user-emacs-directory) load-path) -(require 'kj-lib) - -(setq user-full-name "KJ Orbekk" - user-mail-address "kj@orbekk.com") - -(setq startup-time (current-time)) -(setq initial-scratch-message - (format ";; Emacs startup %s.\n\n" - (format-time-string "%F %T %z" startup-time))) -(setq inhibit-startup-message t) - -(setq custom-file (expand-file-name "emacs-custom.el" user-emacs-directory)) -(load custom-file :noerror t) - -(defalias 'yes-or-no-p 'y-or-n-p) - -(straight-use-package 'use-package) -(use-package straight - :custom (straight-use-package-by-default t)) - -(global-hl-line-mode 1) -(global-auto-revert-mode 1) - -(setq visible-bell t - ring-bell-function 'ignore) - -(use-package modus-themes) -(use-package doom-themes) - -(load-theme 'modus-vivendi-tinted) -(setq alert-default-style 'libnotify) - -(custom-theme-set-faces - 'modus-vivendi-tinted - '(avy-lead-face ((t :inherit (bold modus-themes-subtle-blue)))) - '(avy-lead-face-0 ((t :inherit (bold modus-themes-subtle-cyan)))) - '(avy-lead-face-1 ((t :inherit (bold modus-themes-subtle-green)))) - '(avy-lead-face-2 ((t :inherit (bold modus-themes-subtle-magenta))))) - -(use-package all-the-icons - :if (display-graphic-p)) -(setq inhibit-compacting-font-caches t) -(setq use-dialog-box nil) -(setq display-time-24hr-format t) - -(display-battery-mode 1) -(display-time-mode 1) - -(use-package doom-modeline - :ensure t - :init (doom-modeline-mode 1) - :config - (setq doom-modeline-buffer-encoding 'nondefault)) - -(use-package emojify - :bind - (("C-c C-i C-e" . emojify-insert-emoji)) - :hook (after-init . global-emojify-mode) - :config - (emojify-set-emoji-styles '(unicode))) - -(setq-default show-trailing-whitespace t) -(dolist (mode '(calendar-mode-hook - eshell-mode-hook - term-mode-hook - comint-mode-hook - completion-list-mode)) - (add-hook mode - (defun kj/disable-trailing-whitespace () - (setq show-trailing-whitespace nil)))) - -;; Deletes trailing whitespace on changed lines only. -(use-package ws-butler - :diminish ws-butler-mode - :hook (prog-mode . ws-butler-mode)) - -;; `M-x shell` settings -(setq shell-prompt-pattern "^[^#$%>\n]*[#$%>❯] *" - explicit-shell-file-name "zsh" - explicit-zsh-args '("--login" "--interactive")) -(defun kj/shell-buffer-name () - (concat "*shell:" default-directory "*")) - -(defun kj/shell-here () - (interactive) - (let ((buffer - (shell (kj/shell-buffer-name)))) - (with-current-buffer buffer - (let* ((proc (get-buffer-process (current-buffer))) - (sentinel (process-sentinel proc))) - (set-process-sentinel - proc - `(lambda (proc signal) - (funcall ',sentinel proc signal) - (and (memq (process-status proc) '(exit signal)) - (buffer-live-p (process-buffer proc)) - (message "Shell died, killing buffer %s" - (process-buffer proc)) - (kill-buffer (process-buffer proc))))))))) - -(use-package coterm - :config - (coterm-mode 1)) - -;; Update buffer name to reflect directory. -(advice-add 'cd :after - (defun kj/maybe-rename-shell (&rest args) - (and (derived-mode-p 'shell-mode) - (rename-buffer - (kj/shell-buffer-name))))) - -(use-package rainbow-delimiters - :defer t - :hook (prog-mode . rainbow-delimiters-mode) - ) - -(column-number-mode) -(set-fringe-mode 10) -(setq next-screen-context-lines 10) - -(use-package avy - :bind - (("C-c l" . avy-goto-char) - ("C-c n" . avy-goto-line)) - :config - (setq avy-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) - (defun avy-action-embark (pt) - (unwind-protect - (save-excursion - (goto-char pt) - (embark-act)) - (select-window - (cdr (ring-ref avy-ring 0)))) - t) - -(setf (alist-get ?. avy-dispatch-alist) 'avy-action-embark)) -(define-key isearch-mode-map (kbd "M-j") 'avy-isearch) - -(winner-mode +1) - -(use-package ace-window - :bind - (("C-c e" . ace-window)) - :config - (setq aw-dispatch-always t) - (setq aw-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) - ;; Make ace window more visible - ;; (custom-set-faces! - ;; '(aw-leading-char-face - ;; :foreground "white" :background "red" - ;; :weight bold :height 2.5 :box (:line-width 10 :color "red"))) - ) - -(defun kj/balance-main-window () - (balance-windows (window-main-window))) - -;; Prefer horizontal splits. -(setq split-height-threshold 100) - -(defun kj/split-window-below () - (interactive) - (split-window-below) - (kj/balance-main-window) - (other-window 1)) - -(defun kj/split-window-right () - (interactive) - (split-window-right) - (kj/balance-main-window) - (other-window 1)) - -(global-set-key (kbd "C-x 3") #'kj/split-window-right) -(global-set-key (kbd "C-x 2") #'kj/split-window-below) - -(use-package vertico - :init - (vertico-mode)) - -;; Rebind C-x? -(global-set-key (kbd "C-t") 'ctrl-x-map) -(define-key global-map (kbd "C-t") ctl-x-map) -;; (define-key key-translation-map "\C-t" "\C-t") -;; (define-key key-translation-map "\C-x" "\C-t") - -(use-package marginalia - :bind - (:map minibuffer-local-map - ("M-n" . marginalia-cycle)) - :init - (marginalia-mode)) - -(use-package embark - :ensure t - - :bind - (("C-." . embark-act) - ("C-;" . embark-dwim) - ("C-h C-b" . embark-bindings)) - - :init - (setq prefix-help-command #'embark-prefix-help-command) - - :config - - ;; Hide the mode line of the Embark live/completions buffers - (add-to-list 'display-buffer-alist - '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" - . - (window-parameters (mode-line-format . none))))) - -(use-package embark-consult - :ensure t - :after (embark consult) - :demand t - :hook (embark-mode . consult-preview-at-point-mode)) - -;; For editing grep buffers. -(use-package wgrep) -(use-package deadgrep - :bind ("M-s g" . deadgrep)) - -;; For recent files. -(setq recentf-max-saved-items 1000) -(setq recentf-auto-cleanup 'never) -(defun kj/recentf-keep (file) - (cond - ((file-remote-p file) t) - ((file-readable-p file)))) -(setq recentf-keep '(kj/recentf-keep)) -(setq recentf-save-file "~/.cache/emacs-recentf") -(recentf-mode 1) -(run-at-time nil (* 5 60) 'recentf-save-list) - -(setq global-mark-ring-max 500 - mark-ring-max 16) - -;; Example configuration for Consult -(use-package consult - ;; Replace bindings. Lazily loaded due by `use-package'. - :bind (;; C-c bindings (mode-specific-map) - ("C-c h" . kj/consult-history) - ;;("C-c m" . consult-mode-command) - ("C-c k" . consult-kmacro) - ;; C-x bindings (ctl-x-map) - ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command - ("C-x b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x C-b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window - ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame - ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump - ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer - ("C-c f r" . consult-recent-file) - ;; Custom M-# bindings for fast register access - ("M-#" . consult-register-load) - ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) - ("C-M-#" . consult-register) - ;; Other custom bindings - ("M-y" . consult-yank-pop) ;; orig. yank-pop - (" a" . consult-apropos) ;; orig. apropos-command - ;; M-g bindings (goto-map) - ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck - ("M-g g" . consult-goto-line) ;; orig. goto-line - ("M-g M-g" . consult-goto-line) ;; orig. goto-line - ("M-g o" . consult-outline) ;; Alternative: consult-org-heading - ("M-g m" . consult-mark) - ("M-g k" . consult-global-mark) - ("M-g i" . consult-imenu) - ("M-g I" . consult-imenu-multi) - ;; M-s bindings (search-map) - ("M-s d" . consult-find) - ("M-s D" . consult-locate) - ;; ("M-s g" . consult-grep) - ("M-s G" . consult-git-grep) - ("M-s r" . consult-ripgrep) - ("M-s l" . consult-line) - ("M-s L" . consult-line-multi) - ("M-s m" . consult-multi-occur) - ("M-s k" . consult-keep-lines) - ("M-s u" . consult-focus-lines) - ;; Isearch integration - ("M-s e" . consult-isearch-history) - :map isearch-mode-map - ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s l" . consult-line) ;; needed by consult-line to detect isearch - ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch - ;; Minibuffer history - :map minibuffer-local-map - ("M-s" . kj/consult-history) ;; orig. next-matching-history-element - ("M-r" . kj/consult-history)) ;; orig. previous-matching-history-element - - ;; Enable automatic preview at point in the *Completions* buffer. This is - ;; relevant when you use the default completion UI. - ;; :hook (completion-list-mode . consult-preview-at-point-mode) - - ;; The :init configuration is always executed (Not lazy) - :init - - ;; Optionally configure the register formatting. This improves the register - ;; preview for `consult-register', `consult-register-load', - ;; `consult-register-store' and the Emacs built-ins. - (setq register-preview-delay 0.5 - register-preview-function #'consult-register-format) - - ;; Optionally tweak the register preview window. - ;; This adds thin lines, sorting and hides the mode line of the window. - (advice-add #'register-preview :override #'consult-register-window) - - ;; Use Consult to select xref locations with preview - (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref) - - ;; Configure other variables and modes in the :config section, - ;; after lazily loading the package. - :config - - ;; Use consult for completion. - (setq completion-in-region-function #'consult-completion-in-region) - - ;; Optionally configure preview. The default value - ;; is 'any, such that any key triggers the preview. - (setq consult-preview-key '(:debounce 0.3 any)) - ;; (setq consult-preview-key (kbd "M-.")) - ;; (setq consult-preview-key (list (kbd "") (kbd ""))) - ;; For some commands and buffer sources it is useful to configure the - ;; :preview-key on a per-command basis using the `consult-customize' macro. - ;; (consult-customize - ;; consult-theme - ;; :preview-key '(:debounce 0.2 any) - ;; consult-ripgrep consult-git-grep consult-grep - ;; consult-bookmark consult-recent-file consult-xref - ;; consult--source-bookmark consult--source-recent-file - ;; consult--source-project-recent-file - ;; :preview-key (kbd "M-.")) - - ;; Optionally configure the narrowing key. - ;; Both < and C-+ work reasonably well. - (setq consult-narrow-key "<") ;; (kbd "C-+") - - (setq consult-ripgrep-args - "rg --null --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --with-filename --line-number --search-zip --hidden") - - ;; Optionally make narrowing help available in the minibuffer. - ;; You may want to use `embark-prefix-help-command' or which-key instead. - ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) - - ;; By default `consult-project-function' uses `project-root' from project.el. - ;; Optionally configure a different project root function. - ;; There are multiple reasonable alternatives to chose from. - ;;;; 1. project.el (the default) - ;;(setq consult-project-function #'consult--default-project-function) - ;;;; 2. projectile.el (projectile-project-root) - (autoload 'projectile-project-root "projectile") - (setq consult-project-function (lambda (_) (projectile-project-root))) - ;;;; 3. vc.el (vc-root-dir) - ;; (setq consult-project-function (lambda (_) (vc-root-dir))) - ;;;; 4. locate-dominating-file - ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) - ) - -(use-package orderless - :init - (setq completion-styles '(orderless basic) - completion-category-defaults nil - completion-category-overrides '((file (styles partial-completion))))) - -(use-package which-key - :init - (which-key-mode)) - -;; This is needed to fix an issue with magit transient dependencies. -(use-package transient) -(use-package magit) - -(use-package mixed-pitch - :hook - (text-mode . mixed-pitch-mode) - (org-mode . mixed-pitch-mode) - ) - -(when (string= (system-name) "fedora") - (setenv "SSH_AUTH_SOCK" (s-trim (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))) - -(setq kj/font-height - (cond ((string= (system-name) "fedora") 100) - (t 150))) - -(custom-set-faces - `(variable-pitch ((t (:family "Noto Serif" :height ,kj/font-height)))) - `(default ((t (:family "Iosevka" :height ,kj/font-height))))) - -;; (unless (equal system-name "minideck") -;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 150) -;; (set-face-attribute 'variable-pitch nil :font "Noto Serif")) - -;;; Compilation settings -(setq compilation-ask-about-save nil) -(setq compilation-scroll-output 'first-error) -;; Allow longer output in compilation buffer. -(add-to-list 'compilation-filter-hook #'comint-truncate-buffer) -(setq comint-buffer-maximum-size 10000) - -(use-package ob-async) - -(use-package direnv - :config - (setq direnv-always-show-summary nil) - (direnv-mode)) - -(use-package projectile - :ensure t - :init - (projectile-mode +1) - :bind (:map projectile-mode-map - ("C-x p" . projectile-command-map))) - -(use-package emacs - :init - (setq ediff-diff-options "-w" ; turn off whitespace checking - ediff-split-window-function #'split-window-horizontally - ediff-window-setup-function #'ediff-setup-windows-plain)) - -(use-package anzu - :config - (global-anzu-mode +1) - (global-set-key [remap query-replace] 'anzu-query-replace) - (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)) - -(defun meow-setup () - (setq meow-replace-state-name-list - '((normal . "N") - (motion . "M") - (keypad . "🖩") - (insert . "I") - (beacon . "📻"))) - (setq meow-cheatsheet-layout meow-cheatsheet-layout-dvorak) - (meow-leader-define-key - '("1" . meow-digit-argument) - '("2" . meow-digit-argument) - '("3" . meow-digit-argument) - '("4" . meow-digit-argument) - '("5" . meow-digit-argument) - '("6" . meow-digit-argument) - '("7" . meow-digit-argument) - '("8" . meow-digit-argument) - '("9" . meow-digit-argument) - '("0" . meow-digit-argument) - '("/" . meow-keypad-describe-key) - '("?" . meow-cheatsheet) - '("b" . consult-buffer) - ;;'("p" . projectile-command-map) - ) - (meow-motion-overwrite-define-key - ;; custom keybinding for motion state - '("" . ignore)) - (meow-normal-define-key - '("0" . meow-expand-0) - '("9" . meow-expand-9) - '("8" . meow-expand-8) - '("7" . meow-expand-7) - '("6" . meow-expand-6) - '("5" . meow-expand-5) - '("4" . meow-expand-4) - '("3" . meow-expand-3) - '("2" . meow-expand-2) - '("1" . meow-expand-1) - '("-" . negative-argument) - '(";" . meow-reverse) - '("," . meow-inner-of-thing) - '("." . meow-bounds-of-thing) - '("@" . er/expand-region) - '("<" . meow-beginning-of-thing) - '(">" . meow-end-of-thing) - '("a" . meow-append) - '("A" . meow-open-below) - '("b" . meow-back-word) - '("B" . meow-back-symbol) - '("c" . meow-change) - '("d" . meow-delete) - '("D" . meow-backward-delete) - '("e" . meow-line) - '("E" . meow-goto-line) - '("f" . meow-find) - '("g" . meow-cancel-selection) - '("G" . meow-grab) - '("h" . meow-left) - '("H" . meow-left-expand) - '("i" . meow-insert) - '("I" . meow-open-above) - '("j" . meow-join) - '("k" . meow-kill) - '("l" . meow-till) - '("m" . meow-mark-word) - '("M" . meow-mark-symbol) - '("n" . meow-next) - '("N" . meow-next-expand) - '("o" . meow-block) - '("O" . meow-to-block) - '("p" . meow-prev) - '("P" . meow-prev-expand) - '("q" . meow-quit) - '("Q" . meow-goto-line) - '("r" . meow-replace) - '("R" . meow-swap-grab) - '("s" . meow-search) - '("/" . isearch-forward) - '("?" . isearch-backward) - '("t" . meow-right) - '("T" . meow-right-expand) - '("u" . meow-undo) - '("U" . meow-undo-in-selection) - '("v" . meow-visit) - '("w" . meow-next-word) - '("W" . meow-next-symbol) - '("x" . meow-save) - '("X" . meow-sync-grab) - '("y" . meow-yank) - '("z" . meow-pop-selection) - '("P" . (lambda () (interactive) (forward-line -10))) - '("N" . (lambda () (interactive) (forward-line 10))) - '("'" . repeat) - '("" . ignore)) - - (add-hook 'git-commit-mode-hook #'meow-insert)) - -;; (use-package meow -;; :bind -;; :config -;; (meow-setup) -;; (meow-global-mode 1) -;; ;; (meow-setup-indicator) ; Not needed with doom-modeline. -;; (setq meow-use-clipboard t) -;; ;; (add-to-list 'meow-keypad-start-keys '(?t . ?x)) -;; ;; (add-to-list 'meow-keypad-start-keys '(?x . ?t)) -;; (define-key meow-insert-state-keymap "\C-[" #'meow-insert-exit) -;; ) - -(use-package emacs - :hook (dired-mode . dired-omit-mode) - :init - (setq dired-dwim-target t ; suggest a target for moving/copying intelligently - dired-hide-details-hide-symlink-targets nil - ;; don't prompt to revert, just do it - dired-auto-revert-buffer #'dired-buffer-stale-p - ;; Always copy/delete recursively - dired-recursive-copies 'always - dired-recursive-deletes 'top - ;; Ask whether destination dirs should get created when copying/removing files. - dired-create-destination-dirs 'ask)) - -;; (use-package dirvish -;; :init -;; (setq dirvish-hide-details nil) -;; (dirvish-override-dired-mode)) - -(use-package diredfl - :hook (dired-mode . diredfl-mode)) - -;; Tramp settings -(setq tramp-use-ssh-controlmaster-options nil - tramp-default-method "ssh") -;; Need 'eval-after-load' of 'tramp-sh' here because nixos has a -;; startup file that messes with this variable. -(with-eval-after-load 'tramp-sh - (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) - -(setq math-additional-units - '((ZiB "1024 * EiB" "Zebibyte") - (EiB "1024 * PiB" "Exbibyte") - (PiB "1024 * TiB" "Pebibyte") - (TiB "1024 * GiB" "Tebibyte") - (GiB "1024 * MiB" "Gibibyte") - (MiB "1024 * KiB" "Mebibyte") - (KiB "1024 * B" "Kibibyte") - (B nil "Byte") - (Zib "1024 * ZiB" "Zebibit") - (Eib "1024 * PiB" "Exbibit") - (Pib "1024 * TiB" "Pebibit") - (Tib "1024 * GiB" "Tebibit") - (Gib "1024 * Mib" "Gibibit") - (Mib "1024 * Kib" "Mebibit") - (Kib "1024 * b" "Kibibit") - (b "B / 8" "Bit"))) - - -;; Low menu delay. -(setq which-key-idle-delay .5) - -;; Replace values in an alist from a list of replacements. -;; -;; Example: -;; (kj/assq-replace '((:a . 1)) '((:a . 2))) -(defun kj/assq-replace (replacements alist) - (let ((replace1 (lambda (aelem alist) - (cons aelem (assq-delete-all (car aelem) alist))))) - (if replacements - (kj/assq-replace (cdr replacements) - (funcall replace1 (car replacements) alist)) - alist))) - - -(use-package idle-highlight-mode - :config - (setq idle-highlight-idle-time 0.2) - (set-face-attribute 'idle-highlight nil :inherit 'underline) - :hook ((prog-mode text-mode) . idle-highlight-mode)) - -(defun kj/smartparens-config () - (require 'smartparens-config) - (bind-keys :map smartparens-mode-map - ("C-M-a" . sp-beginning-of-sexp) - ("C-M-e" . sp-end-of-sexp) - - ("C-" . sp-down-sexp) - ("C-" . sp-up-sexp) - ("M-" . sp-backward-down-sexp) - ("M-" . sp-backward-up-sexp) - - ("C-M-f" . sp-forward-sexp) - ("C-M-b" . sp-backward-sexp) - - ("C-M-n" . sp-next-sexp) - ("C-M-p" . sp-previous-sexp) - - ("C-S-f" . sp-forward-symbol) - ("C-S-b" . sp-backward-symbol) - - ("C-" . sp-forward-slurp-sexp) - ("M-" . sp-forward-barf-sexp) - ("C-" . sp-backward-slurp-sexp) - ("M-" . sp-backward-barf-sexp) - - ("C-M-t" . sp-transpose-sexp) - ("C-M-k" . sp-kill-sexp) - ("C-k" . sp-kill-hybrid-sexp) - ("C-M-w" . sp-copy-sexp) - ("C-M-d" . delete-sexp) - - ("M-" . backward-kill-word) - ("C-" . sp-backward-kill-word) - ([remap sp-backward-kill-word] . backward-kill-word) - - ("M-[" . sp-backward-unwrap-sexp) - ("M-]" . sp-unwrap-sexp) - - ("C-x C-t" . sp-transpose-hybrid-sexp) - - ("C-c (" . wrap-with-parens) - ("C-c [" . wrap-with-brackets) - ("C-c {" . wrap-with-braces) - ("C-c '" . wrap-with-single-quotes) - ("C-c \"" . wrap-with-double-quotes) - ("C-c _" . wrap-with-underscores) - ("C-c `" . wrap-with-back-quotes) - - ("M-k" . sp-raise-sexp) - ("M-S" . sp-split-sexp) - ("M-I" . sp-splice-sexp)) - ) - -(use-package smartparens - :init - (kj/smartparens-config) - :hook ((prog-mode lisp-mode) . smartparens-strict-mode) - ) - -;; (use-package paredit -;; :hook ((lisp-mode emacs-lisp-mode) . paredit-mode) -;; :bind (:map paredit-mode-map -;; ("M-k" . paredit-raise-sexp) -;; ("M-I" . paredit-splice-sexp)) -;; :hook (paredit-mode -;; . (lambda () -;; (unbind-key "M-r" paredit-mode-map) -;; (unbind-key "M-s" paredit-mode-map)))) - -(define-key isearch-mode-map (kbd "C-RET") - #'isearch-exit-other-end) -;; Why does C-RET not always work? -(define-key isearch-mode-map (kbd "C-") - #'isearch-exit-other-end) -(defun isearch-exit-other-end () - "Exit isearch, at the opposite end of the string." - (interactive) - (isearch-exit) - (goto-char isearch-other-end)) -(define-key isearch-mode-map (kbd "M-z") - #'kj/isearch-zap) -(defun kj/isearch-zap () - "Zap to beginning of search" - (interactive) - (isearch-exit) - (goto-char isearch-other-end) - (kill-region (region-beginning) (region-end))) - -(setq case-fold-search t) -(setq case-replace t) - -(use-package expand-region - :bind (("C-@" . #'er/expand-region))) - -(use-package multiple-cursors) - -(use-package ace-mc - :bind (:map kj/leader-map - ("h" . ace-mc-add-multiple-cursors) - ("M-h" . ace-mc-add-single-cursor))) - -;; Disable VC over tramp. -;;(setq-default vc-handled-backends nil) -(defun kj/vc-off-if-remote () - (if (file-remote-p (buffer-file-name)) - (setq-local vc-handled-backends nil))) -(add-hook 'find-file-hook 'kj/vc-off-if-remote) - -(use-package selected - :demand t - :diminish selected-minor-mode - :bind (:map selected-keymap - ("[" . align-code) - ("f" . fill-region) - ("U" . unfill-region) - ("d" . downcase-region) - ("r" . reverse-region) - ("S" . sort-lines)) - :config - (selected-global-mode 1)) - -(setq kj/some-lines 6) -(defun kj/forward-some-lines () - (interactive) - (forward-line kj/some-lines)) -(defun kj/previous-some-lines () - (interactive) - (previous-line kj/some-lines)) - -;; Repeat commands (e.g., C-x o o o) -(repeat-mode 1) - -;; Disable the built-in repeat-mode hinting -;;(setq repeat-echo-function #'ignore) - -;; Spawn or hide a which-key popup -;; (advice-add 'repeat-post-hook :after -;; (defun repeat-help--which-key-popup () -;; (if-let ((cmd (or this-command real-this-command)) -;; (keymap (or repeat-map -;; (repeat--command-property 'repeat-map)))) -;; (run-at-time -;; 0 nil -;; (lambda () -;; (which-key--create-buffer-and-show -;; nil (symbol-value keymap)))) -;; (which-key--hide-popup)))) - -;; Calendar settings. -(setq calendar-week-start-day 1) -;; Show calendar week numbers. -(copy-face font-lock-constant-face 'calendar-iso-week-face) -(set-face-attribute 'calendar-iso-week-face nil - :height 0.7) -(setq calendar-intermonth-text - '(propertize - (format "%2d" - (car - (calendar-iso-from-absolute - (calendar-absolute-from-gregorian (list month day year))))) - 'font-lock-face 'calendar-iso-week-face)) - -;; (setq ispell-local-dictionary "en_US") -;; (add-hook 'text-mode-hook flyspell-mode) -;; (add-hook 'prog-mode-hook flyspell-prog-mode) - -;; Enabled commands -(put 'narrow-to-region 'disabled nil) -(put 'downcase-region 'disabled nil) -(put 'upcase-region 'disabled nil) - -(defun kj/modules (module-directory) - (cl-loop for path in (f-files module-directory) - if (string-match "\\([^/]*\\).el" path) - collect (intern (match-string 1 path)))) - -(dolist (module (kj/modules - (expand-file-name "lisp" user-emacs-directory))) - (require module)) - -(use-package embark - :config - - ;; Experimental - (defun find-file-keeping-default-directory (filename) - (let ((dir default-directory)) - (with-current-buffer (find-file filename) - (setq default-directory dir)))) - (define-key embark-file-map "@" 'find-file-keeping-default-directory)) - -;; Restore gc. -(setq gc-cons-threshold (* 16 1024 1024)) - -;; (use-package devil -;; :config -;; (global-devil-mode)) - -;;; Email settings -(setq message-kill-buffer-on-exit t) ;; After sending a message. - -(let ((google-config-file - (expand-file-name "google.el" user-emacs-directory))) - (when (file-exists-p google-config-file) - (load-file google-config-file))) - -;; Special symbols -(use-package emacs - :defer 1 - :config - (defvar kj/iso-transl-char-map - '( - ;; fractions that emacs doesn't include - ("1/3" . [?⅓]) - ("1/5" . [?⅕]) - ("1/6" . [?⅙]) - ("1/7" . [?⅐]) - ("1/8" . [?⅛]) - ("1/9" . [?⅑]) - ("1/10" . [?⅒]) - ("2/3" . [?⅔]) - ("2/5" . [?⅖]) - ("3/5" . [?⅗]) - ("3/8" . [?⅜]) - ("4/5" . [?⅘]) - ("5/6" . [?⅚]) - ("5/8" . [?⅝]) - ("7/8" . [?⅞]) - ;; add the emojis I commonly use - (":c" . [?✅]) - (":u" . [?👍]) - (":d" . [?👎]) - (":w" . [?🖐]) - ;; card suits - ("c" . [?♣]) - ("h" . [?♥]) - ("d" . [?♦]) - ("s" . [?♠]))) - (require 'iso-transl) - (iso-transl-define-keys kj/iso-transl-char-map) - :init - (require 'iso-transl)) - -(use-package pcre2el) -(use-package pdf-tools) - -(defvar kj/help-modes '(helpful-mode - help-mode - shortdoc-mode - Man-mode - woman-mode - Info-mode)) - -(defun kj/buffer-help-p (buf act) - "BUF is a help buffer, ignore ACT." - (member (buffer-local-value 'major-mode (get-buffer buf)) kj/help-modes)) - -(add-to-list 'display-buffer-alist - `(kj/help-modes ;predicate - (display-buffer-reuse-window - display-buffer-reuse-mode-window) ;functions to try - (mode . ,kj/help-modes) - (inhibit-same-window . nil))) - -(use-package helpful - :bind - (([remap describe-key] . 'helpful-key) - ([remap describe-variable] . 'helpful-variable) - ([remap describe-symbol] . 'helpful-symbol) - ([remap describe-command] . 'helpful-command) - ([remap describe-function] . 'helpful-callable))) - -;;; Picking a specific eglot action. -;; (defun my-replace-with-deduced-type (beg) -;; (interactive "*d") -;; (eglot-server-capable-or-lose :codeActionProvider) -;; (let* ((server (eglot--current-server-or-lose)) -;; (action-title "Replace with deduced type") -;; (available-actions (eglot-code-actions beg)) -;; (action (seq-find (lambda (a) -;; (equal (plist-get a :title) action-title)) -;; available-actions))) -;; (unless action -;; (error "Could not find '%s': %s" action-title available-actions)) -;; (eglot-execute server action))) - -;;(transient-insert-suffix 'magit-dispatch "J" -;; `("k" "KJ" kj/my-test)) diff --git a/emacs/.config/emacs-kj/lisp/kj-bindings.el b/emacs/.config/emacs-kj/lisp/kj-bindings.el deleted file mode 100644 index d82706f..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-bindings.el +++ /dev/null @@ -1,34 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package emacs - :bind - (("C-w" . kj/kill-word-or-region) - ("C-c s" . kj/shell-here) - ("C-c t" . eshell) - ("C-c ." . kj/eshell-here) - ("C-c c" . org-capture) - ("M-o" . other-window) - ("C-c a m" . notmuch) - ("C-c M" . smerge-ediff) - ("C-c b r" . revert-buffer) - ("C-c r l" . consult-flymake) - ("C-c r f" . eglot-format) - ("C-c r g" . recompile) - ("C-c r a" . eglot-code-actions) - ("C-c r r" . eglot-rename) - ("C-c r n" . flymake-goto-next-error) - ("C-c r p" . flymake-goto-prev-error) - ("C-c w u" . winner-undo) - ("C-c w U" . winner-redo) - ("C-" . completion-at-point) - ;; Replace downcase-word binding. - ("M-l" . iso-transl-ctl-x-8-map)) - - :config - (defvar kj/flymake-repeat-map (make-sparse-keymap "flymake")) - (define-repeating-key kj/flymake-repeat-map "n" flymake-goto-next-error "next error") - (define-repeating-key kj/flymake-repeat-map "p" flymake-goto-prev-error "prev error") - (define-key kj/flymake-repeat-map (kbd "C-g") '("quit" . ignore)) - ) - -(provide 'kj-bindings) diff --git a/emacs/.config/emacs-kj/lisp/kj-defaults.el b/emacs/.config/emacs-kj/lisp/kj-defaults.el deleted file mode 100644 index a5ced96..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-defaults.el +++ /dev/null @@ -1,49 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -;; Backups -(make-directory "~/.cache/emacs_backups/" t) -(make-directory "~/.cache/emacs_autosave/" t) -(setq backup-directory-alist '(("." . "~/.cache/emacs_backups/"))) -(setq auto-save-file-name-transforms '((".*" "~/.cache/emacs_autosave/" t))) - -;; Keep backups, but avoid same directory since it can be slow on tramp. -(setq version-control t - delete-old-versions -1 - vc-make-backup-files t - create-lockfiles nil - backup-by-copying t) - -(setq-default indent-tabs-mode nil) -(setq sentence-end-double-space nil) -(setq save-interprogram-paste-before-kill t) -(setq mouse-yank-at-point t) -(setq enable-recursive-minibuffers t) -(set-language-environment "utf-8") -(setq require-final-newline t) -;; Save bookmark list every time a bookmark is added. -(setq bookmark-save-flag 1) -(delete-selection-mode 1) - -(savehist-mode 1) - -;; Resize settings -(setq frame-inhibit-implied-resize t) -(setq pixel-scroll-precision-mode t) - -(setq kill-whole-line t) - -(defun kj/kill-word-or-region (arg) - (interactive "p") - (if (region-active-p) - (kill-region (region-beginning) (region-end)) - (backward-kill-word (or arg 1)))) -(global-set-key (kbd "C-w") 'kj/kill-word-or-region) - -(defun kj/open-line (n) - (interactive "*p") - (beginning-of-line) - (open-line n) - (indent-according-to-mode)) -(global-set-key (kbd "C-o") 'kj/open-line) - -(provide 'kj-defaults) diff --git a/emacs/.config/emacs-kj/lisp/kj-development.el b/emacs/.config/emacs-kj/lisp/kj-development.el deleted file mode 100644 index 397f0cc..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-development.el +++ /dev/null @@ -1,93 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(setq tab-stop-list (number-sequence 4 200 4)) - -(use-package eglot - :config - (setq eglot-events-buffer-size 0)) - -(add-hook 'prog-mode-hook 'subword-mode) - -;; Only used to get better eglot snippets. -(use-package yasnippet - :config - (add-to-list 'yas-snippet-dirs (expand-file-name "yasnippets" user-emacs-directory)) - (yas-global-mode)) - -(use-package rustic - :after eglot - :bind (("C-c C-r C-s" . rustic-popup) - ("C-c C-r C-n" . kj/rustic-nextest-all)) - :config - (defun kj/rustic-nextest-all () - (interactive) - (setq rustic-cargo-nextest-exec-command "nextest run --run-ignored all") - (rustic-cargo-run-nextest)) - (setq - ;; eglot seems to be the best option right now. - rustic-lsp-client 'eglot - rustic-format-on-save nil - ;; Prevent automatic syntax checking, which was causing lags and stutters. - ;; eglot-send-changes-idle-time (* 60 60) - ) - :hook - (rustic-mode . eglot-ensure) - ;; Disable the annoying doc popups in the minibuffer. - ;; (add-hook 'eglot-managed-mode-hook (lambda () (eldoc-mode -1))) - ) - -(use-package markdown-mode - :ensure t - :mode ("README\\.md\\'" . gfm-mode) - :init (setq markdown-command "multimarkdown")) - -(straight-use-package - '(nix-mode :type git :host github :repo "NixOS/nix-mode")) -(use-package nix-mode - :mode "\\.nix\\'") - -(use-package ledger-mode - :mode "\\.journal") -(use-package unobtrusive-magit-theme) - -(use-package editorconfig - :ensure t - :config - (editorconfig-mode 1)) - -(use-package tree-sitter - :config - (global-tree-sitter-mode) - (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)) - -(use-package tree-sitter-langs - :after tree-sitter) - -(use-package clojure-mode) - -;; Devicetree mode for keyboard configs. -(use-package dts-mode - :mode "\\.keymap\\'") - -(use-package yaml-mode - :mode "\\.\(yml|yaml\)\\'") - -(use-package ansi-color - :hook (compilation-filter . ansi-color-compilation-filter)) - -(use-package diff-hl - :config - (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) - (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) - (global-diff-hl-mode)) - -(use-package graphviz-dot-mode - :ensure t) - -(use-package haskell-mode) -(use-package tidal - :config - (setq tidal-boot-script-path "~/projects/audio/BootTidal.hs")) - -(use-package ess) - -(provide 'kj-development) diff --git a/emacs/.config/emacs-kj/lisp/kj-email.el b/emacs/.config/emacs-kj/lisp/kj-email.el deleted file mode 100644 index 6cfba74..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-email.el +++ /dev/null @@ -1,97 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(setq kj/fastmail-maildir (expand-file-name "~/Maildir/fastmail")) - -(when (file-exists-p (expand-file-name "~/Maildir")) - (with-eval-after-load 'message - (setq message-mail-user-agent 'notmuch-user-agent - message-cite-style 'message-cite-style-gmail - message-citation-line-function 'message-insert-formatted-citation-line - message-kill-buffer-on-exit t) - (add-hook 'message-mode-hook 'turn-off-auto-fill) - (add-hook 'message-mode-hook 'visual-line-mode)) - (use-package notmuch - :config - - (setq notmuch-show-all-tags-list t - notmuch-show-relative-dates t - notmuch-hello-tag-list-make-query "tag:unread" - notmuch-archive-tags '("-inbox" "-unread") - notmuch-fcc-dirs nil - notmuch-show-logo nil - notmuch-mua-cite-function 'message-cite-original-without-signature - notmuch-wash-citation-lines-prefix most-positive-fixnum - notmuch-wash-citation-lines-suffix most-positive-fixnum - notmuch-show-indent-messages-width 0) - (add-hook 'notmuch-show-hook 'kj/disable-trailing-whitespace) - - (defun kj/confirm-empty-subject () - "Allow user to quit when current message subject is empty." - (or (message-field-value "Subject") - (yes-or-no-p "Really send without Subject? ") - (keyboard-quit))) - (add-hook 'message-send-hook #'kj/confirm-empty-subject) - (advice-add - 'message-send :before (defun kj/notmuch-switch-to-local (&args) - (when (file-remote-p default-directory) - (cd (expand-file-name "~"))))) - (setq notmuch-saved-searches - '((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type tree) - (:name "unread" :query "tag:unread" :key "u" :search-type tree) - (:name "flagged" :query "tag:flagged" :key "f" :search-type tree) - (:name "sent" :query "tag:sent" :key "t" :search-type tree) - (:name "drafts" :query "tag:draft" :key "d" :search-type tree) - (:name "all mail" :query "*" :key "a" :search-type tree) - ))) - - (setq kj/notmuch-wash-citation-regexp "^\\(\\(>\\|[[:space:]]\\)+\\).*\n") - - ;;; XXX consider upstreaming this. - (defun kj/notmuch-wash-citations-by-depth (_msg _depth) - (goto-char (point-min)) - (beginning-of-line) - (let ((maxlevel 1)) - (while (intern-soft (format "message-cited-text-%d" maxlevel)) - (setq maxlevel (1+ maxlevel))) - (setq maxlevel (1- maxlevel)) - - (while (and (< (point) (point-max)) - (re-search-forward kj/notmuch-wash-citation-regexp nil t)) - (let* ((cite-start (match-beginning 0)) - (cite-end (match-end 0)) - (cite-level (seq-count (lambda (c) (eql c ?>)) (match-string 1))) - (face-level (1+ (% (1- cite-level) maxlevel))) - (cited-text-face (intern (format "message-cited-text-%d" face-level)))) - (overlay-put (make-overlay cite-start cite-end) - 'face cited-text-face))))) - ;; This doesn't seem to work that well... :( - ;;(add-hook 'notmuch-show-insert-text/plain-hook #'kj/notmuch-wash-citations-by-depth 90) - - (defun kj/notmuch-tree-by-tag (tag) - (interactive - (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) - (notmuch-tree (concat "tag:" tag))) - - (define-key notmuch-hello-mode-map "T" - 'kj/notmuch-tree-by-tag) - - (define-key notmuch-show-mode-map "!" - (lambda () - "mark message as spam" - (interactive) - (notmuch-show-tag (list "+_gz" "-inbox")))) - - (define-key notmuch-search-mode-map "!" - (lambda (&optional beg end) - "mark thread as spam" - (interactive (notmuch-interactive-region)) - (notmuch-search-tag (list "+_gz" "-inbox") beg end))) - ) - -(when (file-exists-p kj/fastmail-maildir) - (setq sendmail-program "mujmap" - message-send-mail-function 'message-send-mail-with-sendmail - message-signature "Kjetil" - message-sendmail-extra-arguments (list "-C" kj/fastmail-maildir "send"))) - -(provide 'kj-email) diff --git a/emacs/.config/emacs-kj/lisp/kj-eshell.el b/emacs/.config/emacs-kj/lisp/kj-eshell.el deleted file mode 100644 index 7004b1d..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-eshell.el +++ /dev/null @@ -1,83 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(use-package eshell - :bind - (:map eshell-mode-map - ("M-r" . consult-history)) - :hook ((eshell-first-time-mode . kj/eshell-on-load)) - :config - (add-hook 'eshell-mode-hook - (lambda () - (setenv "PAGER" "cat")) - (setenv "EDITOR" "emacsclient")) - (setq eshell-prefer-lisp-functions nil - eshell-scroll-to-bottom-on-input 'all - eshell-hist-ignoredups t - eshell-destroy-buffer-when-process-dies t - eshell-error-if-no-glob t) - (setq tramp-remote-path '(tramp-own-remote-path)) - - (defun kj/eshell-on-load () - (dolist (command '("htop" "tmux" "vim" "nvim" "watch")) - (add-to-list 'eshell-visual-commands - command)) - - ;; (define-key eshell-prompt-mode-map (kbd "C-d") 'eshell-life-is-too-much) - ) - - (add-to-list 'eshell-complex-commands "ssh") - - (add-to-list 'eshell-modules-list 'eshell-tramp) - (add-hook 'eshell-mode-hook 'visual-line-mode)) - -(use-package pcmpl-args) - -(use-package esh-help - :init - (setup-esh-help-eldoc)) - -(use-package eshell-syntax-highlighting - :hook (eshell-mode . eshell-syntax-highlighting-mode)) - -(defun eshell/ssh (&rest args) - (if (= 1 (length args)) - (throw 'eshell-replace-command - (eshell/cd - (format "/ssh:%s:" (car args)))) - (throw 'eshell-replace-command - (eshell-parse-command "*ssh" - (eshell-stringify-list (flatten-tree args)))))) - -(defvar kj/eshell-here-directory) - -(defun kj/eshell-buffer-name () - (let ((base (concat "*eshell:" default-directory))) - (cond - ((not (get-buffer base)) base) - (t (cl-loop for n from 2 - for name = (format "%s<%d>" base n) - until (not (get-buffer name)) - finally return name))))) - -(defun kj/eshell-update-buffer-name () - (interactive) - (rename-buffer (kj/eshell-buffer-name))) -(add-hook 'eshell-directory-change-hook 'kj/eshell-update-buffer-name) - -(defun kj/new-eshell-here () - (let ((default-directory kj/eshell-here-directory)) - (eshell t))) - -(defun kj/eshell-here () - (interactive) - (unless (eq last-command 'kj/eshell-here) - (setq kj/eshell-here-directory - (if (derived-mode-p 'eshell-mode) - (with-current-buffer (other-buffer (current-buffer) t) - default-directory) - default-directory))) - (if (derived-mode-p 'eshell-mode) - (kj/new-eshell-here) - (eshell)) - (kj/eshell-update-buffer-name)) - -(provide 'kj-eshell) diff --git a/emacs/.config/emacs-kj/lisp/kj-history.el b/emacs/.config/emacs-kj/lisp/kj-history.el deleted file mode 100644 index 31cd8c1..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-history.el +++ /dev/null @@ -1,65 +0,0 @@ -;; -*- lexical-binding: t; -*- - -(defvar kj/history-command "fc -R $HISTFILE && fc -l 1" - "History command used to get shell history.") - -(defvar kj/history-regexp - (rx bol (* " ") - ;; Index - (* digit) - (* " ") - ;; Command - (group (1+ (not "\n"))))) - -(use-package consult - :config - (defun kj/get-shell-history () - (with-temp-buffer - (unless (process-file - "zsh" - nil - (current-buffer) - nil - "-c" - kj/history-command) - (error "Getting history failed: %s" (buffer-string))) - (goto-char (point-min)) - (let ((result)) - (save-match-data - (while (re-search-forward kj/history-regexp nil t) - (let ((command - ;; Fix up multi-line commands. - (string-replace "\\\\n" "\\\n" (match-string-no-properties 1)))) - (push command result)))) - result))) - - (defun kj/consult-history () - (interactive) - (if (not - (or (and (minibufferp) - (eq minibuffer-history-variable 'shell-command-history)) - (derived-mode-p 'term-mode 'shell-mode) - )) - (call-interactively 'consult-history) - (pcase-let* ((bol - (cond ((derived-mode-p 'eshell-mode) 'eshell-bol) - ((derived-mode-p 'term-mode) 'term-bol) - ((derived-mode-p 'comint-mode) 'comint-bol))) - (`(,beg . ,end) - (cond ((minibufferp) - (cons (minibuffer-prompt-end) (point-max))) - (bol (save-excursion - (funcall bol) - (cons (point) (pos-eol)))) - (t (cons (point) (point))))) - (str (consult--read - (kj/get-shell-history) - :prompt "Shell history: " - :history t - :sort nil - :initial (buffer-substring-no-properties beg end) - :state (consult--insertion-preview beg end)))) - (delete-region beg end) - (insert (substring-no-properties str)))))) - -(provide 'kj-history) diff --git a/emacs/.config/emacs-kj/lisp/kj-lib.el b/emacs/.config/emacs-kj/lisp/kj-lib.el deleted file mode 100644 index 5df1822..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-lib.el +++ /dev/null @@ -1,11 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(defmacro define-repeating-key (keymap key cmd &optional desc) - `(let ((def - ,(if desc - `'(,desc . ,cmd) - `',cmd))) - (define-key ,keymap ,key def) - (put ',cmd 'repeat-map ',keymap))) - -(provide 'kj-lib) diff --git a/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el b/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el deleted file mode 100644 index 962193d..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el +++ /dev/null @@ -1,20 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package multiple-cursors - :config - (defvar kj/multiple-cursors-map (make-sparse-keymap "cursors")) - (define-repeating-key kj/multiple-cursors-map "." mc/mark-next-like-this "→ this") - (define-repeating-key kj/multiple-cursors-map "," mc/mark-previous-like-this "← this") - (define-repeating-key kj/multiple-cursors-map ">" mc/skip-to-next-like-this "⇥ this") - (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") - (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") - (define-repeating-key kj/multiple-cursors-map "*" mc/mark-all-like-this "all like this") - (define-repeating-key kj/multiple-cursors-map "w" mc/mark-next-like-this-word "word") - (define-repeating-key kj/multiple-cursors-map "s" mc/mark-next-like-this-symbol "symbol") - (define-repeating-key kj/multiple-cursors-map "(" mc/mark-all-symbols-like-this-in-defun "symbol defun") - (define-repeating-key kj/multiple-cursors-map (kbd "DEL") mc/unmark-next-like-this "DEL last") - (define-repeating-key kj/multiple-cursors-map (kbd "") mc/unmark-previous-like-this "DEL first") - (define-key kj/multiple-cursors-map (kbd "C-g") '("quit" . ignore)) - (global-set-key (kbd "C-c m") (cons "cursors" kj/multiple-cursors-map))) - -(provide 'kj-multiple-cursors) diff --git a/emacs/.config/emacs-kj/lisp/kj-org.el b/emacs/.config/emacs-kj/lisp/kj-org.el deleted file mode 100644 index b6fda9c..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-org.el +++ /dev/null @@ -1,251 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package org - :config - (org-babel-do-load-languages 'org-babel-load-languages - '((emacs-lisp . t) - (sql . t) - (shell . t))) - (setq org-confirm-babel-evaluate nil - org-return-follows-link t - ) - - ;; Install the link type - (org-add-link-type "notmuch" 'org-notmuch-open) - (add-hook 'org-store-link-functions 'org-notmuch-store-link) - - (defun org-notmuch-store-link () - "Store a link to a notmuch search or message." - (when (eq major-mode 'notmuch-show-mode) - (let* ((message-id (notmuch-show-get-prop :id)) - (subject (notmuch-show-get-subject)) - (to (notmuch-show-get-to)) - (from (notmuch-show-get-from)) - desc link) - (org-store-link-props :type "notmuch" :from from :to to - :subject subject :message-id message-id) - (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) - (org-add-link-props :link link :description desc) - link))) - - (defun org-notmuch-open (path) - "Follow a notmuch message link specified by PATH." - (org-notmuch-follow-link path)) - - (defun org-notmuch-follow-link (search) - "Follow a notmuch link to SEARCH. - -Can link to more than one message, if so all matching messages are shown." - (require 'notmuch) - (notmuch-show (org-link-unescape search))) - - (org-add-link-type "notmuch-search" 'org-notmuch-search-open) - (add-hook 'org-store-link-functions 'org-notmuch-search-store-link) - - (defun org-notmuch-search-store-link () - "Store a link to a notmuch search or message." - (when (eq major-mode 'notmuch-search-mode) - (let ((link (concat "notmuch-search:" - (org-link-escape notmuch-search-query-string))) - (desc (concat "Notmuch search: " notmuch-search-query-string))) - (org-store-link-props :type "notmuch-search" - :link link - :description desc) - link))) - - (defun org-notmuch-search-open (path) - "Follow a notmuch message link specified by PATH." - (message path) - (org-notmuch-search-follow-link path)) - - (defun org-notmuch-search-follow-link (search) - "Follow a notmuch link by displaying SEARCH in notmuch-search mode." - (require 'notmuch) - (notmuch-search (org-link-unescape search))) - - ;; If you use `org' and don't want your org files in the default location below, - ;; change `org-directory'. It must be set before org loads! - (setq org-directory "~/org/") - (setq org-todo-keywords - '((sequence - "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))) - (setq org-refile-use-outline-path nil) - (setq org-refile-targets '((nil . (:maxlevel . 2)))) - (setq org-log-into-drawer t) - (setq org-agenda-log-mode-items '(closed clock state)) - (setq org-agenda-start-day nil) - (setq org-agenda-block-separator nil) - (setq org-agenda-compact-blocks t) - (setq org-agenda-start-with-log-mode nil) - (setq org-habit-show-all-today t) - (setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------")) - (setq org-roam-directory (concat org-directory "roam/")) - (setq-default org-agenda-files '()) - (dolist (file '("tasks.org" - "running-2022.org")) - (add-to-list 'org-agenda-files (concat org-roam-directory file))) - (setq org-roam-db-location (concat org-roam-directory "/org-roam.db")) - (setq org-export-with-toc nil) - (setq deft-directory org-directory) - (setq deft-recursive t) - ;; Org html export - (setq org-html-htmlize-output-type 'css) - ;; Website publish settings. - (defvar kj/publish-tag "publish") - (defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") - (add-to-list 'org-modules 'org-habit) - - (defvar org-publish-project-alist) - (defun kj/find-agenda-files-containing-tag (tag) - (setq org-agenda-archives-mode nil) - (let* ((org-agenda-archives-mode nil) - (candidates (org-agenda-files nil 'ifmode)) - (matcher (cdr (org-make-tags-matcher tag))) - (files)) - ;; (message "Results:") - (dolist (file candidates files) - (org-check-agenda-file file) - (with-current-buffer (org-get-agenda-file-buffer file) - ;; (message "%S" (org-scan-tags 'agenda matcher nil)) - (when (org-scan-tags 'agenda matcher nil) - (push file files)))))) - - (defun kj/org-publish (&optional project force) - (interactive) - (setq project (or project "all")) - (setq force (or force current-prefix-arg)) - (setq org-agenda-files (list org-roam-directory)) - (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) - (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) - ;; Disable org babel exports during publish entirely to speed up publish. - ;; This messes up babel output handling. - ;; (org-export-use-babel nil) - (org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export")) - org-babel-default-header-args)) - (org-publish-project-alist - `( - ("static" - :base-directory ,(concat org-roam-directory "/static") - :base-extension ,static-files-re - :recursive t - :publishing-directory ,(concat kj/publish-directory "/static") - :publishing-function org-publish-attachment) - ("source" - :base-directory ,org-roam-directory - :base-extension "org" - :exclude ".*" - :include ,files-to-include - :recursive t - :publishing-directory ,kj/publish-directory - :publishing-function org-publish-attachment) - ("html" - :base-directory ,org-roam-directory - :base-extension "org" - :recursive t - :exclude ".*" - :include ,files-to-include - :publishing-directory ,kj/publish-directory - :publishing-function org-html-publish-to-html - - :with-broken-links t - :with-toc nil - :with-latex t - :with-drawers t - :with-title t - :section-numbers nil - - ;; HTML options - :html-toplevel-hlevel 2 - :html-preamble "" - :html-postamble "" - :html-html5-fancy t - :html-doctype "html5" - :html-head "" - :html-head-include-scripts nil - :html-head-include-default-style nil - :html-container article) - - ("all" :components ("static" "source" "html"))))) - - (org-publish project force))) - ; (setq org-appear-autolinks t) - ; (use-package! org-appear - ; :hook (org-mode . org-appear-mode)) - - (setq org-log-done 'time) - (setq org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "LOOP(r)" ; A recurring task - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "IDEA(i)" ; An unconfirmed and unapproved task or notion - "|" - "DONE(d!)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)") ; Task was completed - (sequence - "|" - "OKAY(o)" - "YES(y)" - "NO(n)"))) - - (setq org-journal-file-type 'weekly) - (setq org-journal-dir org-roam-directory) - (setq org-journal-file-format "journal-%Y-%m-%d.org") - (setq org-journal-enable-agenda-integration t) - (defun kj/org-journal-init () - (interactive) - (save-excursion - (goto-char (point-min)) - (org-id-get-create) - (org-set-property "category" "journal"))) - - (defun kj/org-journal-file-header (time) - (format-time-string "#+title: Week of %F (%W)\n" - (org-journal--convert-time-to-file-type-time time))) - (setq org-journal-file-header #'kj/org-journal-file-header) - (add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init) - - ;; Org - (add-to-list 'org-export-backends 'md) - - (require 'org-tempo)) - -(defun org-archive-done-tasks () - (interactive) - (org-map-entries - (lambda () - (org-archive-subtree) - (setq org-map-continue-from (org-element-property :begin (org-element-at-point)))) - "/DONE" 'file)) - -(use-package org-pomodoro - :ensure t - :after org - :commands (org-pomodoro) - :config - (setq - org-pomodoro-manual-break t - org-pomodoro-time-format "%m" - org-pomodoro-format "🍅%s" - org-pomodoro-play-sounds nil - alert-user-configuration (quote ((((:category . "org-pomodoro")) notifications nil)))) - :bind - (("C-c o p" . org-pomodoro))) - -(use-package org-tidy - :after org - :hook (org-mode . org-tidy-mode)) - -(provide 'kj-org) diff --git a/emacs/.config/emacs-kj/lisp/kj-popup.el b/emacs/.config/emacs-kj/lisp/kj-popup.el deleted file mode 100644 index 0ac99a5..0000000 --- a/emacs/.config/emacs-kj/lisp/kj-popup.el +++ /dev/null @@ -1,95 +0,0 @@ -;;; -*- lexical-binding: t; -*- -;;; Window placement -;;; TODO: Test popper.el. -;; (global-set-key (kbd "C-`") #'window-toggle-side-windows) -;; (global-set-key (kbd "M-`") #'kj/popup-toggle-override) -;; (setq window-sides-slots '(0 0 2 2)) ; 2 right side windows -(setq switch-to-buffer-obey-display-actions t) -(setq switch-to-buffer-in-dedicated-window 'pop) -(setq even-window-sizes 'width-only) -(defvar kj/popup-override nil) - -(defun kj/popup-clear-overrides () - (interactive) - (dolist (buffer (buffer-list)) - (with-current-buffer buffer - (kill-local-variable 'kj/popup-override)))) - -(defun kj/popup-toggle-override () - (interactive) - (if (local-variable-p 'kj/popup-override) - (kill-local-variable 'kj/popup-override) - (setq-local kj/popup-override - (not (kj/popup-buffer-base (buffer-name))))) - (let ((buffer (buffer-name))) - (switch-to-prev-buffer) - (switch-to-buffer buffer))) - -(defun kj/popup-buffer-base (buffer &optional condition) - (or - (s-matches-p - (rx (| "*Help*" - "*info*" - (seq "*Messages*") - (seq "*Warnings*") - (seq "*Backtrace*") - (seq "*eldoc " (* anything) "*") - (seq "*WoMan " (* anything) "*") - (seq "*man " (* anything) "*") - (seq "fig: " (* anything)) - (seq "*htop*" (* anything)) - (seq "*Proced*" (* anything)) - (seq "*eshell" (* anything)) - (seq "*shell" (* anything)) - "*Occur*")) buffer) - (with-current-buffer buffer - (apply #'derived-mode-p - '(magit-mode - compilation-mode - shell-mode - comint-mode - Custom-mode ; For customization - fig-commit-mode))))) - -(defun kj/popup-buffer (buffer &optional condition) - (with-current-buffer buffer - (if (local-variable-p 'kj/popup-override) - kj/popup-override - (kj/popup-buffer-base buffer condition)))) - -;; (setq transient-display-buffer-action -;; '(display-buffer-in-best-side -;; (slot . -1) -;; (inhibit-same-window . t) -;; (window-parameters -;; (no-other-window . t)))) - -(defun kj/display-new-popup (buffer alist) - (let ((popup-window - (display-buffer-in-direction - buffer - (append (if (> (frame-width) 160) - '((direction . rightmost) - (window-width . 80)) - '((direction . bottom))))))) - (set-window-parameter popup-window 'kj/popup t) - popup-window)) - -(defun kj/find-popup-window () - (seq-find - (lambda (w) - (window-parameter w 'kj/popup)) - (window-list))) - -(defun display-popup-buffer (buffer alist) - (let ((window (kj/find-popup-window))) - (if window - (window--display-buffer buffer window 'reuse alist) - (kj/display-new-popup buffer alist)))) - -;; (add-to-list 'display-buffer-alist -;; `(kj/popup-buffer -;; (display-popup-buffer) -;; (slot . 0))) - -(provide 'kj-popup) diff --git a/emacs/.config/emacs-v2/early-init.el b/emacs/.config/emacs-v2/early-init.el deleted file mode 100644 index 8184bbb..0000000 --- a/emacs/.config/emacs-v2/early-init.el +++ /dev/null @@ -1,32 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(setq package-enable-at-startup nil) - -;; Optimization: file name handlers not needed during startup. -(defvar kj/file-name-handler-alist--old file-name-handler-alist) -(setq file-name-handler-alist nil) -(defun kj/restore-file-name-handler-alist () - (if (not (boundp 'kj/file-name-handler-alist--old)) - (message "File name handler already restored") - (setq file-name-handler-alist kj/file-name-handler-alist--old) - (makunbound 'kj/file-name-handler-alist--old))) - -;; Optimization: avoid garbage collection during startup. -;; Reset by gcmh later. -(setq gc-cons-threshold most-positive-fixnum) - -;; Move native compilation cache out of the way. Should be set in -;; early-init so that package loding uses the updated value. -(startup-redirect-eln-cache "~/.cache/emacs/eln-cache") - -;; Early options that affect startup. -(setq - package-native-compile t - inhibit-startup-message t - native-comp-async-report-warnings-errors 'silent - default-frame-alist - '((tool-bar-lines . 0) - (menu-bar-lines . 0) - (undecorated . t) - (vertical-scroll-bars . nil) - (horizontal-scroll-bars . nil))) diff --git a/emacs/.config/emacs-v2/elpaca-installer.el b/emacs/.config/emacs-v2/elpaca-installer.el deleted file mode 100644 index 5a10886..0000000 --- a/emacs/.config/emacs-v2/elpaca-installer.el +++ /dev/null @@ -1,38 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(defvar elpaca-installer-version 0.6) -(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) -(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) -(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) -(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - :ref nil - :files (:defaults "elpaca-test.el" (:exclude "extensions")) - :build (:not elpaca--activate-package))) -(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - (order (cdr elpaca-order)) - (default-directory repo)) - (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - ((zerop (call-process "git" nil buffer t "clone" - (plist-get order :repo) repo))) - ((zerop (call-process "git" nil buffer t "checkout" - (or (plist-get order :ref) "--")))) - (emacs (concat invocation-directory invocation-name)) - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - ((require 'elpaca)) - ((elpaca-generate-autoloads "elpaca" repo))) - (progn (message "%s" (buffer-string)) (kill-buffer buffer)) - (error "%s" (with-current-buffer buffer (buffer-string)))) - ((error) (warn "%s" err) (delete-directory repo 'recursive)))) - (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) -(add-hook 'after-init-hook #'elpaca-process-queues) -(elpaca `(,@elpaca-order)) diff --git a/emacs/.config/emacs-v2/emacs-custom.el b/emacs/.config/emacs-v2/emacs-custom.el deleted file mode 100644 index 819655f..0000000 --- a/emacs/.config/emacs-v2/emacs-custom.el +++ /dev/null @@ -1,19 +0,0 @@ -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(custom-safe-themes - '("0340489fa0ccbfa05661bc5c8c19ee0ff95ab1d727e4cc28089b282d30df8fc8" - "e3999eba4f25d912d7d61cbaaed1b551957e61da047279da89499d3bd1f1d007" - "8d412c0ed46b865312d6df5c1dfd1821d349dd3cba00049cf88c4ad34403597e" - "88267200889975d801f6c667128301af0bc183f3450c4b86138bfb23e8a78fb1" - default)) - '(safe-local-variable-values '((checkdoc-package-keywords-flag)))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(default ((t (:family "Iosevka" :height 150)))) - '(variable-pitch ((t (:family "Noto Serif" :height 150))))) diff --git a/emacs/.config/emacs-v2/init.el b/emacs/.config/emacs-v2/init.el deleted file mode 100644 index ddc40f1..0000000 --- a/emacs/.config/emacs-v2/init.el +++ /dev/null @@ -1,40 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -;; NixOS emacs doesn't include a build time. Assume a recent version. -(setq elpaca-core-date 20240101) -(setq elpaca-directory "~/.cache/emacs/elpaca") -(load-file (expand-file-name "elpaca-installer.el" user-emacs-directory)) - -(add-hook 'emacs-startup-hook - (lambda () - (message "Emacs ready in %s with %d garbage collections." - (format "%.2f seconds" - (float-time - (time-subtract after-init-time before-init-time))) - gcs-done))) - -(add-hook 'elpaca-after-init-hook 'kj/restore-file-name-handler-alist) - -(elpaca elpaca-use-package - ;; Enable :elpaca use-package keyword. - (elpaca-use-package-mode) - ;; Assume :elpaca t unless otherwise specified. - (setq elpaca-use-package-by-default t)) -(elpaca-wait) - -(use-package gcmh - :hook - (elpaca-after-init . kj/enable-gcmh) - :config - (defun kj/enable-gcmh () - (message "Enabling gcmh") - (gcmh-mode 1))) - -;; Include user configuration. -(defvar kj/module-directory (expand-file-name "lisp" user-emacs-directory)) -(push kj/module-directory load-path) -(require 'kj-lib) -(require 'kj-init) -(cl-loop for path in (directory-files kj/module-directory) - if (string-match "\\([^/]*\\).el" path) - do (require (intern (match-string-no-properties 1 path)))) diff --git a/emacs/.config/emacs-v2/lisp/kj-bindings.el b/emacs/.config/emacs-v2/lisp/kj-bindings.el deleted file mode 100644 index e01b659..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-bindings.el +++ /dev/null @@ -1,34 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package emacs :elpaca nil - :bind - (("C-w" . kj/kill-word-or-region) - ("C-c s" . kj/shell-here) - ("C-c t" . eshell) - ("C-c ." . kj/eshell-here) - ("C-c c" . org-capture) - ("M-o" . other-window) - ("C-c a m" . notmuch) - ("C-c a g" . magit-list-repositories) - ("C-c M" . smerge-ediff) - ("C-c b r" . revert-buffer) - ("C-c r l" . consult-flymake) - ("C-c r f" . eglot-format) - ("C-c r g" . recompile) - ("C-c r a" . eglot-code-actions) - ("C-c r r" . eglot-rename) - ("C-c r n" . flymake-goto-next-error) - ("C-c r p" . flymake-goto-prev-error) - ("C-c w u" . winner-undo) - ("C-c w U" . winner-redo) - ("C-" . completion-at-point) - ;; Replace downcase-word binding. - ("M-l" . iso-transl-ctl-x-8-map)) - - :config - (defvar kj/flymake-repeat-map (make-sparse-keymap "flymake")) - (define-repeating-key kj/flymake-repeat-map "n" flymake-goto-next-error "next error") - (define-repeating-key kj/flymake-repeat-map "p" flymake-goto-prev-error "prev error") - (define-key kj/flymake-repeat-map (kbd "C-g") '("quit" . ignore))) - -(provide 'kj-bindings) diff --git a/emacs/.config/emacs-v2/lisp/kj-defaults.el b/emacs/.config/emacs-v2/lisp/kj-defaults.el deleted file mode 100644 index c2cf6fd..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-defaults.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -;; Backups -(make-directory "~/.cache/emacs_backups/" t) -(make-directory "~/.cache/emacs_autosave/" t) -(setq backup-directory-alist '(("." . "~/.cache/emacs_backups/"))) -(setq auto-save-file-name-transforms '((".*" "~/.cache/emacs_autosave/" t))) - -;; Keep backups, but avoid same directory since it can be slow on tramp. -(setq version-control t - delete-old-versions -1 - vc-make-backup-files t - create-lockfiles nil - backup-by-copying t) - -(setq-default indent-tabs-mode nil) -(setq sentence-end-double-space nil) -(setq save-interprogram-paste-before-kill t) -(setq mouse-yank-at-point t) -(setq enable-recursive-minibuffers t) -(set-language-environment "utf-8") -(setq require-final-newline t) -;; Save bookmark list every time a bookmark is added. -(setq bookmark-save-flag 1) -(delete-selection-mode 1) - -(setq savehist-file "~/.cache/emacs/savehist-history") -(savehist-mode 1) - -;; Resize settings -(setq frame-inhibit-implied-resize t) -(setq pixel-scroll-precision-mode t) - -(setq kill-whole-line t) - -(defun kj/kill-word-or-region (arg) - (interactive "p") - (if (region-active-p) - (kill-region (region-beginning) (region-end)) - (backward-kill-word (or arg 1)))) -(global-set-key (kbd "C-w") 'kj/kill-word-or-region) - -(defun kj/open-line (n) - (interactive "*p") - (beginning-of-line) - (open-line n) - (indent-according-to-mode)) -(global-set-key (kbd "C-o") 'kj/open-line) - -(provide 'kj-defaults) diff --git a/emacs/.config/emacs-v2/lisp/kj-development.el b/emacs/.config/emacs-v2/lisp/kj-development.el deleted file mode 100644 index 6eee3dd..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-development.el +++ /dev/null @@ -1,116 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(setq tab-stop-list (number-sequence 4 200 4)) - -(use-package eglot :elpaca nil - :config - (setq eglot-events-buffer-size 0)) - -(add-hook 'prog-mode-hook 'subword-mode) - -;; Only used to get better eglot snippets. -(use-package yasnippet - :config - (add-to-list 'yas-snippet-dirs (expand-file-name "yasnippets" user-emacs-directory)) - (yas-global-mode)) - -(use-package tempel - ;; Require trigger prefix before template name when completing. - ;; :custom - ;; (tempel-trigger-prefix "<") - - :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand - ("M-*" . tempel-insert)) - - :init - - ;; Setup completion at point - (defun tempel-setup-capf () - ;; Add the Tempel Capf to `completion-at-point-functions'. - ;; `tempel-expand' only triggers on exact matches. Alternatively use - ;; `tempel-complete' if you want to see all matches, but then you - ;; should also configure `tempel-trigger-prefix', such that Tempel - ;; does not trigger too often when you don't expect it. NOTE: We add - ;; `tempel-expand' *before* the main programming mode Capf, such - ;; that it will be tried first. - (setq-local completion-at-point-functions - (cons #'tempel-expand - completion-at-point-functions))) - - (add-hook 'conf-mode-hook 'tempel-setup-capf) - (add-hook 'prog-mode-hook 'tempel-setup-capf) - (add-hook 'text-mode-hook 'tempel-setup-capf) - - ;; Optionally make the Tempel templates available to Abbrev, - ;; either locally or globally. `expand-abbrev' is bound to C-x '. - ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode) - ;; (global-tempel-abbrev-mode) -) - -(use-package rustic - :after eglot - :bind (("C-c C-r C-s" . rustic-popup) - ("C-c C-r C-n" . kj/rustic-nextest-all)) - :config - (defun kj/rustic-nextest-all () - (interactive) - (setq rustic-cargo-nextest-exec-command "nextest run --run-ignored all") - (rustic-cargo-run-nextest)) - (setq - ;; eglot seems to be the best option right now. - rustic-lsp-client 'eglot - rustic-format-on-save nil - ;; Prevent automatic syntax checking, which was causing lags and stutters. - ;; eglot-send-changes-idle-time (* 60 60) - ) - :hook - (rustic-mode . eglot-ensure) - ;; Disable the annoying doc popups in the minibuffer. - ;; (add-hook 'eglot-managed-mode-hook (lambda () (eldoc-mode -1))) - ) - -(use-package markdown-mode - :ensure t - :mode ("README\\.md\\'" . gfm-mode) - :init (setq markdown-command "multimarkdown")) - -(use-package nix-mode - :mode "\\.nix\\'") - -(use-package ledger-mode - :mode "\\.journal") -(use-package unobtrusive-magit-theme) - -(use-package editorconfig - :ensure t - :config - (editorconfig-mode 1)) - -(use-package clojure-mode) - -;; Devicetree mode for keyboard configs. -(use-package dts-mode - :mode "\\.keymap\\'") - -(use-package yaml-mode - :mode "\\.\(yml|yaml\)\\'") - -;; (use-package ansi-color -;; :hook (compilation-filter . ansi-color-compilation-filter)) - -(use-package diff-hl - :config - (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) - (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) - (global-diff-hl-mode)) - -(use-package graphviz-dot-mode - :ensure t) - -(use-package haskell-mode) -(use-package tidal - :config - (setq tidal-boot-script-path "~/projects/audio/BootTidal.hs")) - -(use-package ess) - -(provide 'kj-development) diff --git a/emacs/.config/emacs-v2/lisp/kj-email.el b/emacs/.config/emacs-v2/lisp/kj-email.el deleted file mode 100644 index 721050b..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-email.el +++ /dev/null @@ -1,86 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(setq kj/fastmail-maildir (expand-file-name "~/Maildir/fastmail")) - -(when (file-exists-p (expand-file-name "~/Maildir")) - (use-package notmuch - :autoload compose-mail - :after seq - :bind - (:map notmuch-hello-mode-map - ;; ("T" . kj/notmuch-tree-by-tag) - ) - :config - (with-eval-after-load 'message - (setq message-mail-user-agent 'notmuch-user-agent - message-cite-style 'message-cite-style-gmail - message-citation-line-function 'message-insert-formatted-citation-line - message-kill-buffer-on-exit nil) - (add-hook 'message-mode-hook 'turn-off-auto-fill) - (add-hook 'message-mode-hook 'visual-line-mode)) - (setq notmuch-show-all-tags-list t - notmuch-show-relative-dates t - notmuch-hello-tag-list-make-query "tag:unread" - notmuch-archive-tags '("-inbox" "-unread") - notmuch-fcc-dirs nil - notmuch-show-logo nil - notmuch-mua-cite-function 'message-cite-original-without-signature - notmuch-wash-citation-lines-prefix most-positive-fixnum - notmuch-wash-citation-lines-suffix most-positive-fixnum - notmuch-show-indent-messages-width 0) - (add-hook 'notmuch-show-hook 'kj/disable-trailing-whitespace) - - (defun kj/confirm-empty-subject () - "Allow user to quit when current message subject is empty." - (or (message-field-value "Subject") - (yes-or-no-p "Really send without Subject? ") - (keyboard-quit))) - (add-hook 'message-send-hook #'kj/confirm-empty-subject) - (advice-add - 'message-send :before (defun kj/notmuch-switch-to-local (&args) - (when (file-remote-p default-directory) - (cd (expand-file-name "~"))))) - (setq notmuch-saved-searches - '((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type nil) - (:name "unread" :query "tag:unread" :key "u" :search-type nil) - (:name "flagged" :query "tag:flagged" :key "f" :search-type nil) - (:name "sent" :query "tag:sent" :key "t" :search-type nil) - (:name "drafts" :query "tag:draft" :key "d" :search-type nil) - (:name "all mail" :query "*" :key "a" :search-type nil) - ))) - - (setq kj/notmuch-wash-citation-regexp "^\\(\\(>\\|[[:space:]]\\)+\\).*\n") - - ;;; XXX consider upstreaming this. - (defun kj/notmuch-wash-citations-by-depth (_msg _depth) - (goto-char (point-min)) - (beginning-of-line) - (let ((maxlevel 1)) - (while (intern-soft (format "message-cited-text-%d" maxlevel)) - (setq maxlevel (1+ maxlevel))) - (setq maxlevel (1- maxlevel)) - - (while (and (< (point) (point-max)) - (re-search-forward kj/notmuch-wash-citation-regexp nil t)) - (let* ((cite-start (match-beginning 0)) - (cite-end (match-end 0)) - (cite-level (seq-count (lambda (c) (eql c ?>)) (match-string 1))) - (face-level (1+ (% (1- cite-level) maxlevel))) - (cited-text-face (intern (format "message-cited-text-%d" face-level)))) - (overlay-put (make-overlay cite-start cite-end) - 'face cited-text-face))))) - ;; This doesn't seem to work that well... :( - ;;(add-hook 'notmuch-show-insert-text/plain-hook #'kj/notmuch-wash-citations-by-depth 90) - - (defun kj/notmuch-tree-by-tag (tag) - (interactive - (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) - (notmuch-tree (concat "tag:" tag)))) - -(when (file-exists-p kj/fastmail-maildir) - (setq sendmail-program "mujmap" - message-send-mail-function 'message-send-mail-with-sendmail - message-signature "Kjetil" - message-sendmail-extra-arguments (list "-C" kj/fastmail-maildir "send"))) - -(provide 'kj-email) diff --git a/emacs/.config/emacs-v2/lisp/kj-eshell.el b/emacs/.config/emacs-v2/lisp/kj-eshell.el deleted file mode 100644 index 5617658..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-eshell.el +++ /dev/null @@ -1,83 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(use-package eshell :elpaca nil - :bind - (:map eshell-mode-map - ("M-r" . consult-history)) - :hook ((eshell-first-time-mode . kj/eshell-on-load)) - :config - (add-hook 'eshell-mode-hook - (lambda () - (setenv "PAGER" "cat")) - (setenv "EDITOR" "emacsclient")) - (setq eshell-prefer-lisp-functions nil - eshell-scroll-to-bottom-on-input 'all - eshell-hist-ignoredups t - eshell-destroy-buffer-when-process-dies t - eshell-error-if-no-glob t) - (setq tramp-remote-path '(tramp-own-remote-path)) - - (defun kj/eshell-on-load () - (dolist (command '("htop" "tmux" "vim" "nvim" "watch")) - (add-to-list 'eshell-visual-commands - command)) - - ;; (define-key eshell-prompt-mode-map (kbd "C-d") 'eshell-life-is-too-much) - ) - - (add-to-list 'eshell-complex-commands "ssh") - - (add-to-list 'eshell-modules-list 'eshell-tramp) - (add-hook 'eshell-mode-hook 'visual-line-mode)) - -(use-package pcmpl-args) - -(use-package esh-help - :init - (setup-esh-help-eldoc)) - -(use-package eshell-syntax-highlighting - :hook (eshell-mode . eshell-syntax-highlighting-mode)) - -(defun eshell/ssh (&rest args) - (if (= 1 (length args)) - (throw 'eshell-replace-command - (eshell/cd - (format "/ssh:%s:" (car args)))) - (throw 'eshell-replace-command - (eshell-parse-command "*ssh" - (eshell-stringify-list (flatten-tree args)))))) - -(defvar kj/eshell-here-directory) - -(defun kj/eshell-buffer-name () - (let ((base (concat "*eshell:" default-directory))) - (cond - ((not (get-buffer base)) base) - (t (cl-loop for n from 2 - for name = (format "%s<%d>" base n) - until (not (get-buffer name)) - finally return name))))) - -(defun kj/eshell-update-buffer-name () - (interactive) - (rename-buffer (kj/eshell-buffer-name))) -(add-hook 'eshell-directory-change-hook 'kj/eshell-update-buffer-name) - -(defun kj/new-eshell-here () - (let ((default-directory kj/eshell-here-directory)) - (eshell t))) - -(defun kj/eshell-here () - (interactive) - (unless (eq last-command 'kj/eshell-here) - (setq kj/eshell-here-directory - (if (derived-mode-p 'eshell-mode) - (with-current-buffer (other-buffer (current-buffer) t) - default-directory) - default-directory))) - (if (derived-mode-p 'eshell-mode) - (kj/new-eshell-here) - (eshell)) - (kj/eshell-update-buffer-name)) - -(provide 'kj-eshell) diff --git a/emacs/.config/emacs-v2/lisp/kj-history.el b/emacs/.config/emacs-v2/lisp/kj-history.el deleted file mode 100644 index 9805aa1..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-history.el +++ /dev/null @@ -1,66 +0,0 @@ -;; -*- lexical-binding: t; -*- - -(defvar kj/history-command "fc -R $HISTFILE && fc -l 1" - "History command used to get shell history.") - -(defvar kj/history-regexp - (rx bol (* " ") - ;; Index - (* digit) - (* " ") - ;; Command - (group (1+ (not "\n"))))) - -(use-package emacs :elpaca nil - :after consult - :config - (defun kj/get-shell-history () - (with-temp-buffer - (unless (process-file - "zsh" - nil - (current-buffer) - nil - "-c" - kj/history-command) - (error "Getting history failed: %s" (buffer-string))) - (goto-char (point-min)) - (let ((result)) - (save-match-data - (while (re-search-forward kj/history-regexp nil t) - (let ((command - ;; Fix up multi-line commands. - (string-replace "\\\\n" "\\\n" (match-string-no-properties 1)))) - (push command result)))) - result))) - - (defun kj/consult-history () - (interactive) - (if (not - (or (and (minibufferp) - (eq minibuffer-history-variable 'shell-command-history)) - (derived-mode-p 'term-mode 'shell-mode) - )) - (call-interactively 'consult-history) - (pcase-let* ((bol - (cond ((derived-mode-p 'eshell-mode) 'eshell-bol) - ((derived-mode-p 'term-mode) 'term-bol) - ((derived-mode-p 'comint-mode) 'comint-bol))) - (`(,beg . ,end) - (cond ((minibufferp) - (cons (minibuffer-prompt-end) (point-max))) - (bol (save-excursion - (funcall bol) - (cons (point) (pos-eol)))) - (t (cons (point) (point))))) - (str (consult--read - (kj/get-shell-history) - :prompt "Shell history: " - :history t - :sort nil - :initial (buffer-substring-no-properties beg end) - :state (consult--insertion-preview beg end)))) - (delete-region beg end) - (insert (substring-no-properties str)))))) - -(provide 'kj-history) diff --git a/emacs/.config/emacs-v2/lisp/kj-init.el b/emacs/.config/emacs-v2/lisp/kj-init.el deleted file mode 100644 index 298040a..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-init.el +++ /dev/null @@ -1,944 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(setq user-full-name "KJ Orbekk" - user-mail-address "kj@orbekk.com") - -(defvar kj/cache-dir "~/.cache/emacs") - -(setq initial-scratch-message nil) - -(setq switch-to-buffer-obey-display-actions t) -(setq switch-to-buffer-in-dedicated-window 'pop) -(setq even-window-sizes 'width-only) - -(setq custom-file (expand-file-name "emacs-custom.el" user-emacs-directory)) -(load custom-file :noerror t) - -(setq bookmark-file (expand-file-name "boomarks" kj/cache-dir)) - -(setq fast-but-imprecise-scrolling t) - -(setq use-short-answers t) - -(global-hl-line-mode 1) -(global-auto-revert-mode 1) - -(setq outline-minor-mode-cycle t - outline-minor-mode-highlight 'override) - -(setq visible-bell t - ring-bell-function 'ignore) - -(setq auto-save-list-file-prefix (expand-file-name "auto-save-list/.saves-" kj/cache-dir)) - -(use-package wombat-theme :elpaca nil - :disabled - :init - (load-theme 'wombat) - :config - (custom-theme-set-faces - 'wombat - '(default ((t :background "#111111"))) - '(ansi-color-black ((t :background "#000000"))) - '(hl-line ((t :inherit () :background "#242424"))))) - -(use-package modus-themes - :init - (load-theme 'modus-operandi-tinted) - (load-theme 'modus-vivendi-tinted t t) - :config - (custom-theme-set-faces - 'modus-vivendi-tinted - '(avy-lead-face ((t :inherit (bold modus-themes-subtle-blue)))) - '(avy-lead-face-0 ((t :inherit (bold modus-themes-subtle-cyan)))) - '(avy-lead-face-1 ((t :inherit (bold modus-themes-subtle-green)))) - '(avy-lead-face-2 ((t :inherit (bold modus-themes-subtle-magenta)))))) - -(use-package doom-themes) - -(setq alert-default-style 'libnotify) - -(use-package all-the-icons - :if (display-graphic-p)) -(setq inhibit-compacting-font-caches t) -(setq use-dialog-box nil) -(setq display-time-24hr-format t) - -(display-battery-mode 1) -(display-time-mode 1) - -(use-package doom-modeline - :ensure t - :init (doom-modeline-mode 1) - :config - (setq doom-modeline-buffer-encoding 'nondefault)) - -(use-package emojify - :bind - (("C-c C-i C-e" . emojify-insert-emoji)) - :hook (after-init . global-emojify-mode) - :config - (emojify-set-emoji-styles '(unicode))) - -(setq-default show-trailing-whitespace t) -(dolist (mode '(calendar-mode-hook - eshell-mode-hook - term-mode-hook - comint-mode-hook - completion-list-mode)) - (add-hook mode - (defun kj/disable-trailing-whitespace () - (setq show-trailing-whitespace nil)))) - -;; Deletes trailing whitespace on changed lines only. -(use-package ws-butler - :diminish ws-butler-mode - :hook (prog-mode . ws-butler-mode)) - -;; `M-x shell` settings -(setq shell-prompt-pattern "^[^#$%>\n]*[#$%>❯] *" - explicit-shell-file-name "zsh" - explicit-zsh-args '("--login" "--interactive")) -(defun kj/shell-buffer-name () - (concat "*shell:" default-directory "*")) - -(defun kj/shell-here () - (interactive) - (let ((buffer - (shell (kj/shell-buffer-name)))) - (with-current-buffer buffer - (let* ((proc (get-buffer-process (current-buffer))) - (sentinel (process-sentinel proc))) - (set-process-sentinel - proc - `(lambda (proc signal) - (funcall ',sentinel proc signal) - (and (memq (process-status proc) '(exit signal)) - (buffer-live-p (process-buffer proc)) - (message "Shell died, killing buffer %s" - (process-buffer proc)) - (kill-buffer (process-buffer proc))))))))) - -(use-package coterm - :config - (coterm-mode 1)) - -;; Update buffer name to reflect directory. -(advice-add 'cd :after - (defun kj/maybe-rename-shell (&rest args) - (and (derived-mode-p 'shell-mode) - (rename-buffer - (kj/shell-buffer-name))))) - -(use-package rainbow-delimiters - :defer t - :hook (prog-mode . rainbow-delimiters-mode) - ) - -(column-number-mode) -(set-fringe-mode 10) -(setq next-screen-context-lines 10) - -(use-package avy - :bind - (("C-c l" . avy-goto-char) - ("C-c n" . avy-goto-line)) - :config - (setq avy-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) - (defun avy-action-embark (pt) - (unwind-protect - (save-excursion - (goto-char pt) - (embark-act)) - (select-window - (cdr (ring-ref avy-ring 0)))) - t) - -(setf (alist-get ?. avy-dispatch-alist) 'avy-action-embark)) -(define-key isearch-mode-map (kbd "M-j") 'avy-isearch) - -(winner-mode +1) - -(use-package ace-window - :bind - (("C-c e" . ace-window)) - :config - (setq aw-dispatch-always t) - (setq aw-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) - ;; Make ace window more visible - ;; (custom-set-faces! - ;; '(aw-leading-char-face - ;; :foreground "white" :background "red" - ;; :weight bold :height 2.5 :box (:line-width 10 :color "red"))) - ) - -(defun kj/balance-main-window () - (balance-windows (window-main-window))) - -;; Prefer horizontal splits. -(setq split-height-threshold 100) - -(defun kj/split-window-below () - (interactive) - (split-window-below) - (kj/balance-main-window) - (other-window 1)) - -(defun kj/split-window-right () - (interactive) - (split-window-right) - (kj/balance-main-window) - (other-window 1)) - -(global-set-key (kbd "C-x 3") #'kj/split-window-right) -(global-set-key (kbd "C-x 2") #'kj/split-window-below) - -(use-package vertico - :init - (vertico-mode)) - -;; Rebind C-x? -(global-set-key (kbd "C-t") 'ctrl-x-map) -(define-key global-map (kbd "C-t") ctl-x-map) -;; (define-key key-translation-map "\C-t" "\C-t") -;; (define-key key-translation-map "\C-x" "\C-t") - -(use-package marginalia - :bind - (:map minibuffer-local-map - ("M-n" . marginalia-cycle)) - :init - (marginalia-mode)) - -(use-package embark - :ensure t - - :bind - (("C-." . embark-act) - ("C-;" . embark-dwim) - ("C-h C-b" . embark-bindings)) - - :init - (setq prefix-help-command #'embark-prefix-help-command) - - :config - (defun find-file-keeping-default-directory (filename) - (let ((dir default-directory)) - (with-current-buffer (find-file filename) - (setq-local default-directory dir)))) - (define-key embark-file-map "@" 'find-file-keeping-default-directory) - - ;; Hide the mode line of the Embark live/completions buffers - (add-to-list 'display-buffer-alist - '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" - . - (window-parameters (mode-line-format . none))))) - -(use-package embark-consult - :ensure t - :after (embark consult) - :demand t - :hook (embark-mode . consult-preview-at-point-mode)) - -;; For editing grep buffers. -(use-package wgrep) -(use-package deadgrep - :bind ("M-s g" . deadgrep)) - -;; For recent files. -(setq recentf-max-saved-items 1000) -(setq recentf-auto-cleanup 'never) -(defun kj/recentf-keep (file) - (cond - ((file-remote-p file) t) - ((file-readable-p file)))) -(setq recentf-keep '(kj/recentf-keep)) -(setq recentf-save-file (expand-file-name "emacs-recentf" kj/cache-dir)) -(recentf-mode 1) -(run-at-time nil (* 5 60) 'recentf-save-list) - -(setq global-mark-ring-max 500 - mark-ring-max 16) - -(defun kj/consult-ripgrep-here (&optional dir initial) - (interactive "P") - (unless dir - (setq dir default-directory)) - (consult-ripgrep dir initial)) - -;; Example configuration for Consult -(use-package consult - ;; Replace bindings. Lazily loaded due by `use-package'. - :bind (;; C-c bindings (mode-specific-map) - ("C-c h" . kj/consult-history) - ;;("C-c m" . consult-mode-command) - ("C-c k" . consult-kmacro) - ;; C-x bindings (ctl-x-map) - ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command - ("C-x b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x C-b" . consult-buffer) ;; orig. switch-to-buffer - ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window - ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame - ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump - ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer - ("C-c f r" . consult-recent-file) - ;; Custom M-# bindings for fast register access - ("M-#" . consult-register-load) - ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) - ("C-M-#" . consult-register) - ;; Other custom bindings - ("M-y" . consult-yank-pop) ;; orig. yank-pop - (" a" . consult-apropos) ;; orig. apropos-command - ;; M-g bindings (goto-map) - ("M-g e" . consult-compile-error) - ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck - ("M-g g" . consult-goto-line) ;; orig. goto-line - ("M-g M-g" . consult-goto-line) ;; orig. goto-line - ("M-g o" . consult-outline) ;; Alternative: consult-org-heading - ("M-g m" . consult-mark) - ("M-g k" . consult-global-mark) - ("M-g i" . consult-imenu) - ("M-g I" . consult-imenu-multi) - ;; M-s bindings (search-map) - ("M-s d" . consult-find) - ("M-s D" . consult-locate) - ;; ("M-s g" . consult-grep) - ("M-s G" . consult-git-grep) - ("M-s r" . consult-ripgrep) - ("M-s R" . kj/consult-ripgrep-here) - ("M-s l" . consult-line) - ("M-s L" . consult-line-multi) - ("M-s m" . consult-multi-occur) - ("M-s k" . consult-keep-lines) - ("M-s u" . consult-focus-lines) - ;; Isearch integration - ("M-s e" . consult-isearch-history) - :map isearch-mode-map - ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string - ("M-s l" . consult-line) ;; needed by consult-line to detect isearch - ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch - ;; Minibuffer history - :map minibuffer-local-map - ("M-s" . kj/consult-history) ;; orig. next-matching-history-element - ("M-r" . kj/consult-history)) ;; orig. previous-matching-history-element - - ;; Enable automatic preview at point in the *Completions* buffer. This is - ;; relevant when you use the default completion UI. - ;; :hook (completion-list-mode . consult-preview-at-point-mode) - - ;; The :init configuration is always executed (Not lazy) - :init - - ;; Optionally configure the register formatting. This improves the register - ;; preview for `consult-register', `consult-register-load', - ;; `consult-register-store' and the Emacs built-ins. - (setq register-preview-delay 0.5 - register-preview-function #'consult-register-format) - - ;; Optionally tweak the register preview window. - ;; This adds thin lines, sorting and hides the mode line of the window. - (advice-add #'register-preview :override #'consult-register-window) - - ;; Use Consult to select xref locations with preview - (setq xref-show-xrefs-function #'consult-xref - xref-show-definitions-function #'consult-xref) - - ;; Configure other variables and modes in the :config section, - ;; after lazily loading the package. - :config - - ;; Use consult for completion. - (setq completion-in-region-function #'consult-completion-in-region) - - ;; Optionally configure preview. The default value - ;; is 'any, such that any key triggers the preview. - (setq consult-preview-key '(:debounce 0.3 any)) - ;; (setq consult-preview-key (kbd "M-.")) - ;; (setq consult-preview-key (list (kbd "") (kbd ""))) - ;; For some commands and buffer sources it is useful to configure the - ;; :preview-key on a per-command basis using the `consult-customize' macro. - ;; (consult-customize - ;; consult-theme - ;; :preview-key '(:debounce 0.2 any) - ;; consult-ripgrep consult-git-grep consult-grep - ;; consult-bookmark consult-recent-file consult-xref - ;; consult--source-bookmark consult--source-recent-file - ;; consult--source-project-recent-file - ;; :preview-key (kbd "M-.")) - - ;; Optionally configure the narrowing key. - ;; Both < and C-+ work reasonably well. - (setq consult-narrow-key "<") ;; (kbd "C-+") - - (setq consult-ripgrep-args - "rg --null --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --with-filename --line-number --search-zip --hidden") - - ;; Optionally make narrowing help available in the minibuffer. - ;; You may want to use `embark-prefix-help-command' or which-key instead. - ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) - - ;; By default `consult-project-function' uses `project-root' from project.el. - ;; Optionally configure a different project root function. - ;; There are multiple reasonable alternatives to chose from. - ;;;; 1. project.el (the default) - ;;(setq consult-project-function #'consult--default-project-function) - ;;;; 2. projectile.el (projectile-project-root) - (autoload 'projectile-project-root "projectile") - (setq consult-project-function (lambda (_) (projectile-project-root))) - ;;;; 3. vc.el (vc-root-dir) - ;; (setq consult-project-function (lambda (_) (vc-root-dir))) - ;;;; 4. locate-dominating-file - ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) - ) - -(use-package orderless - :init - (setq completion-styles '(orderless basic) - completion-category-defaults nil - completion-category-overrides '((file (styles partial-completion))))) - -(use-package which-key - :init - (which-key-mode)) - -(use-package seq) - -(use-package transient - :config - (setq transient-levels-file (expand-file-name "transient/levels.el" kj/cache-dir) - transient-values-file (expand-file-name "transient/values.el" kj/cache-dir) - transient-history-file (expand-file-name "transient/history.el" kj/cache-dir))) - -(defconst kj/git-directory (expand-file-name "~/git")) -(defun kj/read-repository () - (let ((repos - (thread-last - (directory-files "/ssh:dragon.orbekk.com:/storage/projects") - (seq-filter (lambda (f) (not (string-match (rx bol (or "." "..") eol) f))))))) - (thread-last - (completing-read "Repository: " repos) - (concat "ssh://dragon.orbekk.com:/storage/projects/")))) - -(use-package magit - :bind (:map magit-repolist-mode-map - ("c" . magit-clone) - ("i" . magit-init) - ("C" . kj/clone-project)) - :custom - (magit-repository-directories `((,kj/git-directory . 1)) "My git repositories") - (magit-repolist-columns '(("Name" 25 magit-repolist-column-ident nil) - ("Version" 25 magit-repolist-column-version - ((:sort magit-repolist-version<))) - ("BU" 3 magit-repolist-column-unpushed-to-upstream - ((:right-align t) (:sort <))) - ("F" 3 magit-repolist-column-flag - ((:right-align t) (:sort <))) - ("Path" 99 magit-repolist-column-path nil))) - :config - (defun kj/clone-project () - (interactive) - (let ((magit-clone-set-remote.pushDefault t)) - (magit-clone-regular (kj/read-repository) kj/git-directory nil)))) - -(use-package mixed-pitch - :hook - (text-mode . mixed-pitch-mode) - (org-mode . mixed-pitch-mode) - ) - -(when (string= (system-name) "fedora") - (setenv "SSH_AUTH_SOCK" (string-trim (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))) - -(setq kj/font-height - (cond ((string= (system-name) "fedora") 100) - (t 150))) - -(custom-set-faces - `(variable-pitch ((t (:family "Noto Serif" :height ,kj/font-height)))) - `(default ((t (:family "Iosevka" :height ,kj/font-height))))) - -;; (unless (equal system-name "minideck") -;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 150) -;; (set-face-attribute 'variable-pitch nil :font "Noto Serif")) - -;;; Compilation settings -(use-package compile :elpaca nil - :config - (setq compilation-ask-about-save nil) - (setq compilation-scroll-output 'first-error) - ;; Allow longer output in compilation buffer. - (add-to-list 'compilation-filter-hook #'comint-truncate-buffer) - (setq comint-buffer-maximum-size 10000)) - -(use-package ob-async) - -(use-package direnv - :config - (setq direnv-always-show-summary nil) - (direnv-mode)) - -(use-package projectile - :ensure t - :defer 1 - :init - (setq projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld" kj/cache-dir)) - (projectile-mode +1) - :bind (:map projectile-mode-map - ("C-x p" . projectile-command-map))) - -(use-package emacs :elpaca nil - :config - (setq ediff-diff-options "-w" ; turn off whitespace checking - ediff-split-window-function #'split-window-horizontally - ediff-window-setup-function #'ediff-setup-windows-plain)) - -(use-package anzu - :config - (global-anzu-mode +1) - (global-set-key [remap query-replace] 'anzu-query-replace) - (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)) - -(defun meow-setup () - (setq meow-replace-state-name-list - '((normal . "N") - (motion . "M") - (keypad . "🖩") - (insert . "I") - (beacon . "📻"))) - (setq meow-cheatsheet-layout meow-cheatsheet-layout-dvorak) - (meow-leader-define-key - '("1" . meow-digit-argument) - '("2" . meow-digit-argument) - '("3" . meow-digit-argument) - '("4" . meow-digit-argument) - '("5" . meow-digit-argument) - '("6" . meow-digit-argument) - '("7" . meow-digit-argument) - '("8" . meow-digit-argument) - '("9" . meow-digit-argument) - '("0" . meow-digit-argument) - '("/" . meow-keypad-describe-key) - '("?" . meow-cheatsheet) - '("b" . consult-buffer) - ;;'("p" . projectile-command-map) - ) - (meow-motion-overwrite-define-key - ;; custom keybinding for motion state - '("" . ignore)) - (meow-normal-define-key - '("0" . meow-expand-0) - '("9" . meow-expand-9) - '("8" . meow-expand-8) - '("7" . meow-expand-7) - '("6" . meow-expand-6) - '("5" . meow-expand-5) - '("4" . meow-expand-4) - '("3" . meow-expand-3) - '("2" . meow-expand-2) - '("1" . meow-expand-1) - '("-" . negative-argument) - '(";" . meow-reverse) - '("," . meow-inner-of-thing) - '("." . meow-bounds-of-thing) - '("@" . er/expand-region) - '("<" . meow-beginning-of-thing) - '(">" . meow-end-of-thing) - '("a" . meow-append) - '("A" . meow-open-below) - '("b" . meow-back-word) - '("B" . meow-back-symbol) - '("c" . meow-change) - '("d" . meow-delete) - '("D" . meow-backward-delete) - '("e" . meow-line) - '("E" . meow-goto-line) - '("f" . meow-find) - '("g" . meow-cancel-selection) - '("G" . meow-grab) - '("h" . meow-left) - '("H" . meow-left-expand) - '("i" . meow-insert) - '("I" . meow-open-above) - '("j" . meow-join) - '("k" . meow-kill) - '("l" . meow-till) - '("m" . meow-mark-word) - '("M" . meow-mark-symbol) - '("n" . meow-next) - '("N" . meow-next-expand) - '("o" . meow-block) - '("O" . meow-to-block) - '("p" . meow-prev) - '("P" . meow-prev-expand) - '("q" . meow-quit) - '("Q" . meow-goto-line) - '("r" . meow-replace) - '("R" . meow-swap-grab) - '("s" . meow-search) - '("/" . isearch-forward) - '("?" . isearch-backward) - '("t" . meow-right) - '("T" . meow-right-expand) - '("u" . meow-undo) - '("U" . meow-undo-in-selection) - '("v" . meow-visit) - '("w" . meow-next-word) - '("W" . meow-next-symbol) - '("x" . meow-save) - '("X" . meow-sync-grab) - '("y" . meow-yank) - '("z" . meow-pop-selection) - '("P" . (lambda () (interactive) (forward-line -10))) - '("N" . (lambda () (interactive) (forward-line 10))) - '("'" . repeat) - '("" . ignore)) - - (add-hook 'git-commit-mode-hook #'meow-insert)) - -;; (use-package meow -;; :bind -;; :config -;; (meow-setup) -;; (meow-global-mode 1) -;; ;; (meow-setup-indicator) ; Not needed with doom-modeline. -;; (setq meow-use-clipboard t) -;; ;; (add-to-list 'meow-keypad-start-keys '(?t . ?x)) -;; ;; (add-to-list 'meow-keypad-start-keys '(?x . ?t)) -;; (define-key meow-insert-state-keymap "\C-[" #'meow-insert-exit) -;; ) - -(use-package emacs :elpaca nil - :hook (dired-mode . dired-omit-mode) - :init - (setq dired-dwim-target t ; suggest a target for moving/copying intelligently - dired-hide-details-hide-symlink-targets nil - ;; don't prompt to revert, just do it - dired-auto-revert-buffer #'dired-buffer-stale-p - ;; Always copy/delete recursively - dired-recursive-copies 'always - dired-recursive-deletes 'top - ;; Ask whether destination dirs should get created when copying/removing files. - dired-create-destination-dirs 'ask)) - -;; (use-package dirvish -;; :init -;; (setq dirvish-hide-details nil) -;; (dirvish-override-dired-mode)) - -(use-package diredfl - :hook (dired-mode . diredfl-mode)) - -;; Tramp settings -(setq tramp-use-ssh-controlmaster-options nil - tramp-default-method "ssh") -;; Need 'eval-after-load' of 'tramp-sh' here because nixos has a -;; startup file that messes with this variable. -(with-eval-after-load 'tramp-sh - (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) - -;; Calc settings. -(setq calc-make-windows-dedicated t - calc-kill-line-numbering nil - calc-display-trail nil) -(setq math-additional-units - '((ZiB "1024 * EiB" "Zebibyte") - (EiB "1024 * PiB" "Exbibyte") - (PiB "1024 * TiB" "Pebibyte") - (TiB "1024 * GiB" "Tebibyte") - (GiB "1024 * MiB" "Gibibyte") - (MiB "1024 * KiB" "Mebibyte") - (KiB "1024 * B" "Kibibyte") - (B nil "Byte") - (Zib "1024 * ZiB" "Zebibit") - (Eib "1024 * PiB" "Exbibit") - (Pib "1024 * TiB" "Pebibit") - (Tib "1024 * GiB" "Tebibit") - (Gib "1024 * Mib" "Gibibit") - (Mib "1024 * Kib" "Mebibit") - (Kib "1024 * b" "Kibibit") - (b "B / 8" "Bit"))) - -;; Low menu delay. -(setq which-key-idle-delay .5) - -;; Replace values in an alist from a list of replacements. -;; -;; Example: -;; (kj/assq-replace '((:a . 1)) '((:a . 2))) -(defun kj/assq-replace (replacements alist) - (let ((replace1 (lambda (aelem alist) - (cons aelem (assq-delete-all (car aelem) alist))))) - (if replacements - (kj/assq-replace (cdr replacements) - (funcall replace1 (car replacements) alist)) - alist))) - - -(use-package idle-highlight-mode - :config - (setq idle-highlight-idle-time 0.2) - (set-face-attribute 'idle-highlight nil :inherit 'underline) - :hook ((prog-mode text-mode) . idle-highlight-mode)) - -(defun kj/smartparens-config () - (require 'smartparens-config) - (bind-keys :map smartparens-mode-map - ("C-M-a" . sp-beginning-of-sexp) - ("C-M-e" . sp-end-of-sexp) - - ("C-" . sp-down-sexp) - ("C-" . sp-up-sexp) - ("M-" . sp-backward-down-sexp) - ("M-" . sp-backward-up-sexp) - - ("C-M-f" . sp-forward-sexp) - ("C-M-b" . sp-backward-sexp) - - ("C-M-n" . sp-next-sexp) - ("C-M-p" . sp-previous-sexp) - - ("C-S-f" . sp-forward-symbol) - ("C-S-b" . sp-backward-symbol) - - ("C-" . sp-forward-slurp-sexp) - ("M-" . sp-forward-barf-sexp) - ("C-" . sp-backward-slurp-sexp) - ("M-" . sp-backward-barf-sexp) - - ("C-M-t" . sp-transpose-sexp) - ("C-M-k" . sp-kill-sexp) - ("C-k" . sp-kill-hybrid-sexp) - ("C-M-w" . sp-copy-sexp) - ("C-M-d" . delete-sexp) - - ("M-" . backward-kill-word) - ("C-" . sp-backward-kill-word) - ([remap sp-backward-kill-word] . backward-kill-word) - - ("M-[" . sp-backward-unwrap-sexp) - ("M-]" . sp-unwrap-sexp) - - ("C-x C-t" . sp-transpose-hybrid-sexp) - - ("C-c (" . wrap-with-parens) - ("C-c [" . wrap-with-brackets) - ("C-c {" . wrap-with-braces) - ("C-c '" . wrap-with-single-quotes) - ("C-c \"" . wrap-with-double-quotes) - ("C-c _" . wrap-with-underscores) - ("C-c `" . wrap-with-back-quotes) - - ("M-k" . sp-raise-sexp) - ("M-S" . sp-split-sexp) - ("M-I" . sp-splice-sexp)) - ) - -(use-package smartparens - :init - (kj/smartparens-config) - :hook ((prog-mode lisp-mode) . smartparens-strict-mode) - ) - -;; (use-package paredit -;; :hook ((lisp-mode emacs-lisp-mode) . paredit-mode) -;; :bind (:map paredit-mode-map -;; ("M-k" . paredit-raise-sexp) -;; ("M-I" . paredit-splice-sexp)) -;; :hook (paredit-mode -;; . (lambda () -;; (unbind-key "M-r" paredit-mode-map) -;; (unbind-key "M-s" paredit-mode-map)))) - - -(define-key isearch-mode-map (kbd "C-RET") - #'isearch-exit-other-end) -;; Why does C-RET not always work? -(define-key isearch-mode-map (kbd "C-") - #'isearch-exit-other-end) - -(defun isearch-exit-other-end () - "Exit isearch, at the opposite end of the string." - (interactive) - (isearch-exit) - (goto-char isearch-other-end)) -(define-key isearch-mode-map (kbd "M-z") - #'kj/isearch-zap) -(defun kj/isearch-zap () - "Zap to beginning of search" - (interactive) - (isearch-exit) - (goto-char isearch-other-end) - (kill-region (region-beginning) (region-end))) - -(setq case-fold-search t - case-replace t - char-fold-symmetric t - isearch-lax-whitespace t - search-default-mode 'char-fold-to-regexp) -(use-package char-fold :elpaca nil - :config - (setopt char-fold-include - (cons '(?- "_" "-") char-fold-include))) - -(use-package expand-region - :bind (("C-@" . #'er/expand-region))) - -(use-package ace-mc - :bind (:map kj/leader-map - ("h" . ace-mc-add-multiple-cursors) - ("M-h" . ace-mc-add-single-cursor))) - -;; Disable VC over tramp. -;;(setq-default vc-handled-backends nil) -(defun kj/vc-off-if-remote () - (if (file-remote-p (buffer-file-name)) - (setq-local vc-handled-backends nil))) -(add-hook 'find-file-hook 'kj/vc-off-if-remote) - -(use-package selected - :demand t - :diminish selected-minor-mode - :bind (:map selected-keymap - ("[" . align-code) - ("f" . fill-region) - ("U" . unfill-region) - ("d" . downcase-region) - ("r" . reverse-region) - ("S" . sort-lines)) - :config - (selected-global-mode 1)) - -(setq kj/some-lines 6) -(defun kj/forward-some-lines () - (interactive) - (forward-line kj/some-lines)) -(defun kj/previous-some-lines () - (interactive) - (previous-line kj/some-lines)) - -;; Repeat commands (e.g., C-x o o o) -(use-package repeat-help - :custom - (repeat-help-key "?" "The default `C-h' tends to interfere.") - :init - (repeat-help-mode 1)) -(repeat-mode 1) - -;; Disable the built-in repeat-mode hinting -;;(setq repeat-echo-function #'ignore) - -;; Spawn or hide a which-key popup -;; (advice-add 'repeat-post-hook :after -;; (defun repeat-help--which-key-popup () -;; (if-let ((cmd (or this-command real-this-command)) -;; (keymap (or repeat-map -;; (repeat--command-property 'repeat-map)))) -;; (run-at-time -;; 0 nil -;; (lambda () -;; (which-key--create-buffer-and-show -;; nil (symbol-value keymap)))) -;; (which-key--hide-popup)))) - -;; Calendar settings. -(setq calendar-week-start-day 1) -;; Show calendar week numbers. -(copy-face font-lock-constant-face 'calendar-iso-week-face) -(set-face-attribute 'calendar-iso-week-face nil - :height 0.7) -(setq calendar-intermonth-text - '(propertize - (format "%2d" - (car - (calendar-iso-from-absolute - (calendar-absolute-from-gregorian (list month day year))))) - 'font-lock-face 'calendar-iso-week-face)) - -;; (setq ispell-local-dictionary "en_US") -;; (add-hook 'text-mode-hook flyspell-mode) -;; (add-hook 'prog-mode-hook flyspell-prog-mode) - -;;; Email settings -(setq message-kill-buffer-on-exit t) ;; After sending a message. - -(let ((google-config-file - (expand-file-name "google.el" user-emacs-directory))) - (when (file-exists-p google-config-file) - (load-file google-config-file))) - -;; Special symbols -(use-package emacs :elpaca nil - :defer 1 - :config - (defvar kj/iso-transl-char-map - '( - ;; fractions that emacs doesn't include - ("1/3" . [?⅓]) - ("1/5" . [?⅕]) - ("1/6" . [?⅙]) - ("1/7" . [?⅐]) - ("1/8" . [?⅛]) - ("1/9" . [?⅑]) - ("1/10" . [?⅒]) - ("2/3" . [?⅔]) - ("2/5" . [?⅖]) - ("3/5" . [?⅗]) - ("3/8" . [?⅜]) - ("4/5" . [?⅘]) - ("5/6" . [?⅚]) - ("5/8" . [?⅝]) - ("7/8" . [?⅞]) - ;; add the emojis I commonly use - (":c" . [?✅]) - (":u" . [?👍]) - (":d" . [?👎]) - (":w" . [?🖐]) - ;; card suits - ("c" . [?♣]) - ("h" . [?♥]) - ("d" . [?♦]) - ("s" . [?♠]))) - (require 'iso-transl) - (iso-transl-define-keys kj/iso-transl-char-map) - :init - (require 'iso-transl)) - -(use-package pcre2el) -(use-package pdf-tools) - -(defvar kj/help-modes '(helpful-mode - help-mode - shortdoc-mode - Man-mode - woman-mode - Info-mode)) - -(defun kj/buffer-help-p (buf act) - "BUF is a help buffer, ignore ACT." - (with-current-buffer buf - (apply 'derived-mode-p kj/help-modes))) - -(add-to-list 'display-buffer-alist - `(kj/buffer-help-p - (display-buffer-reuse-window - display-buffer-reuse-mode-window) - (mode . ,kj/help-modes) - (inhibit-same-window . nil))) - -(use-package helpful - :bind - (([remap describe-key] . 'helpful-key) - ([remap describe-variable] . 'helpful-variable) - ([remap describe-symbol] . 'helpful-symbol) - ([remap describe-command] . 'helpful-command) - ([remap describe-function] . 'helpful-callable))) - -;; Enabled commands -(put 'narrow-to-region 'disabled nil) -(put 'downcase-region 'disabled nil) -(put 'upcase-region 'disabled nil) - -(provide 'kj-init) diff --git a/emacs/.config/emacs-v2/lisp/kj-lib.el b/emacs/.config/emacs-v2/lisp/kj-lib.el deleted file mode 100644 index 5df1822..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-lib.el +++ /dev/null @@ -1,11 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(defmacro define-repeating-key (keymap key cmd &optional desc) - `(let ((def - ,(if desc - `'(,desc . ,cmd) - `',cmd))) - (define-key ,keymap ,key def) - (put ',cmd 'repeat-map ',keymap))) - -(provide 'kj-lib) diff --git a/emacs/.config/emacs-v2/lisp/kj-multiple-cursors.el b/emacs/.config/emacs-v2/lisp/kj-multiple-cursors.el deleted file mode 100644 index 962193d..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-multiple-cursors.el +++ /dev/null @@ -1,20 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package multiple-cursors - :config - (defvar kj/multiple-cursors-map (make-sparse-keymap "cursors")) - (define-repeating-key kj/multiple-cursors-map "." mc/mark-next-like-this "→ this") - (define-repeating-key kj/multiple-cursors-map "," mc/mark-previous-like-this "← this") - (define-repeating-key kj/multiple-cursors-map ">" mc/skip-to-next-like-this "⇥ this") - (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") - (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") - (define-repeating-key kj/multiple-cursors-map "*" mc/mark-all-like-this "all like this") - (define-repeating-key kj/multiple-cursors-map "w" mc/mark-next-like-this-word "word") - (define-repeating-key kj/multiple-cursors-map "s" mc/mark-next-like-this-symbol "symbol") - (define-repeating-key kj/multiple-cursors-map "(" mc/mark-all-symbols-like-this-in-defun "symbol defun") - (define-repeating-key kj/multiple-cursors-map (kbd "DEL") mc/unmark-next-like-this "DEL last") - (define-repeating-key kj/multiple-cursors-map (kbd "") mc/unmark-previous-like-this "DEL first") - (define-key kj/multiple-cursors-map (kbd "C-g") '("quit" . ignore)) - (global-set-key (kbd "C-c m") (cons "cursors" kj/multiple-cursors-map))) - -(provide 'kj-multiple-cursors) diff --git a/emacs/.config/emacs-v2/lisp/kj-org.el b/emacs/.config/emacs-v2/lisp/kj-org.el deleted file mode 100644 index b6fda9c..0000000 --- a/emacs/.config/emacs-v2/lisp/kj-org.el +++ /dev/null @@ -1,251 +0,0 @@ -;;; -*- lexical-binding: t; -*- - -(use-package org - :config - (org-babel-do-load-languages 'org-babel-load-languages - '((emacs-lisp . t) - (sql . t) - (shell . t))) - (setq org-confirm-babel-evaluate nil - org-return-follows-link t - ) - - ;; Install the link type - (org-add-link-type "notmuch" 'org-notmuch-open) - (add-hook 'org-store-link-functions 'org-notmuch-store-link) - - (defun org-notmuch-store-link () - "Store a link to a notmuch search or message." - (when (eq major-mode 'notmuch-show-mode) - (let* ((message-id (notmuch-show-get-prop :id)) - (subject (notmuch-show-get-subject)) - (to (notmuch-show-get-to)) - (from (notmuch-show-get-from)) - desc link) - (org-store-link-props :type "notmuch" :from from :to to - :subject subject :message-id message-id) - (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) - (org-add-link-props :link link :description desc) - link))) - - (defun org-notmuch-open (path) - "Follow a notmuch message link specified by PATH." - (org-notmuch-follow-link path)) - - (defun org-notmuch-follow-link (search) - "Follow a notmuch link to SEARCH. - -Can link to more than one message, if so all matching messages are shown." - (require 'notmuch) - (notmuch-show (org-link-unescape search))) - - (org-add-link-type "notmuch-search" 'org-notmuch-search-open) - (add-hook 'org-store-link-functions 'org-notmuch-search-store-link) - - (defun org-notmuch-search-store-link () - "Store a link to a notmuch search or message." - (when (eq major-mode 'notmuch-search-mode) - (let ((link (concat "notmuch-search:" - (org-link-escape notmuch-search-query-string))) - (desc (concat "Notmuch search: " notmuch-search-query-string))) - (org-store-link-props :type "notmuch-search" - :link link - :description desc) - link))) - - (defun org-notmuch-search-open (path) - "Follow a notmuch message link specified by PATH." - (message path) - (org-notmuch-search-follow-link path)) - - (defun org-notmuch-search-follow-link (search) - "Follow a notmuch link by displaying SEARCH in notmuch-search mode." - (require 'notmuch) - (notmuch-search (org-link-unescape search))) - - ;; If you use `org' and don't want your org files in the default location below, - ;; change `org-directory'. It must be set before org loads! - (setq org-directory "~/org/") - (setq org-todo-keywords - '((sequence - "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))) - (setq org-refile-use-outline-path nil) - (setq org-refile-targets '((nil . (:maxlevel . 2)))) - (setq org-log-into-drawer t) - (setq org-agenda-log-mode-items '(closed clock state)) - (setq org-agenda-start-day nil) - (setq org-agenda-block-separator nil) - (setq org-agenda-compact-blocks t) - (setq org-agenda-start-with-log-mode nil) - (setq org-habit-show-all-today t) - (setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------")) - (setq org-roam-directory (concat org-directory "roam/")) - (setq-default org-agenda-files '()) - (dolist (file '("tasks.org" - "running-2022.org")) - (add-to-list 'org-agenda-files (concat org-roam-directory file))) - (setq org-roam-db-location (concat org-roam-directory "/org-roam.db")) - (setq org-export-with-toc nil) - (setq deft-directory org-directory) - (setq deft-recursive t) - ;; Org html export - (setq org-html-htmlize-output-type 'css) - ;; Website publish settings. - (defvar kj/publish-tag "publish") - (defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") - (add-to-list 'org-modules 'org-habit) - - (defvar org-publish-project-alist) - (defun kj/find-agenda-files-containing-tag (tag) - (setq org-agenda-archives-mode nil) - (let* ((org-agenda-archives-mode nil) - (candidates (org-agenda-files nil 'ifmode)) - (matcher (cdr (org-make-tags-matcher tag))) - (files)) - ;; (message "Results:") - (dolist (file candidates files) - (org-check-agenda-file file) - (with-current-buffer (org-get-agenda-file-buffer file) - ;; (message "%S" (org-scan-tags 'agenda matcher nil)) - (when (org-scan-tags 'agenda matcher nil) - (push file files)))))) - - (defun kj/org-publish (&optional project force) - (interactive) - (setq project (or project "all")) - (setq force (or force current-prefix-arg)) - (setq org-agenda-files (list org-roam-directory)) - (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) - (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) - ;; Disable org babel exports during publish entirely to speed up publish. - ;; This messes up babel output handling. - ;; (org-export-use-babel nil) - (org-babel-default-header-args - (kj/assq-replace '((:exports . "both") - (:eval . "never-export")) - org-babel-default-header-args)) - (org-publish-project-alist - `( - ("static" - :base-directory ,(concat org-roam-directory "/static") - :base-extension ,static-files-re - :recursive t - :publishing-directory ,(concat kj/publish-directory "/static") - :publishing-function org-publish-attachment) - ("source" - :base-directory ,org-roam-directory - :base-extension "org" - :exclude ".*" - :include ,files-to-include - :recursive t - :publishing-directory ,kj/publish-directory - :publishing-function org-publish-attachment) - ("html" - :base-directory ,org-roam-directory - :base-extension "org" - :recursive t - :exclude ".*" - :include ,files-to-include - :publishing-directory ,kj/publish-directory - :publishing-function org-html-publish-to-html - - :with-broken-links t - :with-toc nil - :with-latex t - :with-drawers t - :with-title t - :section-numbers nil - - ;; HTML options - :html-toplevel-hlevel 2 - :html-preamble "" - :html-postamble "" - :html-html5-fancy t - :html-doctype "html5" - :html-head "" - :html-head-include-scripts nil - :html-head-include-default-style nil - :html-container article) - - ("all" :components ("static" "source" "html"))))) - - (org-publish project force))) - ; (setq org-appear-autolinks t) - ; (use-package! org-appear - ; :hook (org-mode . org-appear-mode)) - - (setq org-log-done 'time) - (setq org-todo-keywords - '((sequence - "TODO(t)" ; A task that needs doing & is ready to do - "PROJ(p)" ; A project, which usually contains other tasks - "LOOP(r)" ; A recurring task - "STRT(s)" ; A task that is in progress - "WAIT(w)" ; Something external is holding up this task - "HOLD(h)" ; This task is paused/on hold because of me - "IDEA(i)" ; An unconfirmed and unapproved task or notion - "|" - "DONE(d!)" ; Task successfully completed - "KILL(k)") ; Task was cancelled, aborted or is no longer applicable - (sequence - "[ ](T)" ; A task that needs doing - "[-](S)" ; Task is in progress - "[?](W)" ; Task is being held up or paused - "|" - "[X](D)") ; Task was completed - (sequence - "|" - "OKAY(o)" - "YES(y)" - "NO(n)"))) - - (setq org-journal-file-type 'weekly) - (setq org-journal-dir org-roam-directory) - (setq org-journal-file-format "journal-%Y-%m-%d.org") - (setq org-journal-enable-agenda-integration t) - (defun kj/org-journal-init () - (interactive) - (save-excursion - (goto-char (point-min)) - (org-id-get-create) - (org-set-property "category" "journal"))) - - (defun kj/org-journal-file-header (time) - (format-time-string "#+title: Week of %F (%W)\n" - (org-journal--convert-time-to-file-type-time time))) - (setq org-journal-file-header #'kj/org-journal-file-header) - (add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init) - - ;; Org - (add-to-list 'org-export-backends 'md) - - (require 'org-tempo)) - -(defun org-archive-done-tasks () - (interactive) - (org-map-entries - (lambda () - (org-archive-subtree) - (setq org-map-continue-from (org-element-property :begin (org-element-at-point)))) - "/DONE" 'file)) - -(use-package org-pomodoro - :ensure t - :after org - :commands (org-pomodoro) - :config - (setq - org-pomodoro-manual-break t - org-pomodoro-time-format "%m" - org-pomodoro-format "🍅%s" - org-pomodoro-play-sounds nil - alert-user-configuration (quote ((((:category . "org-pomodoro")) notifications nil)))) - :bind - (("C-c o p" . org-pomodoro))) - -(use-package org-tidy - :after org - :hook (org-mode . org-tidy-mode)) - -(provide 'kj-org) diff --git a/emacs/.config/emacs-v2/templates b/emacs/.config/emacs-v2/templates deleted file mode 100644 index cb4219c..0000000 --- a/emacs/.config/emacs-v2/templates +++ /dev/null @@ -1,29 +0,0 @@ -;; ~/.config/emacs/templates -*- mode: lisp-data; -*- - -fundamental-mode - -(today (format-time-string "%Y-%m-%d")) - -text-mode - -(cut "--8<---------------cut here---------------start------------->8---" n r n - "--8<---------------cut here---------------end--------------->8---" n) - -emacs-lisp-mode - -(header ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) - " -- " p " -*- lexical-binding: t -*-" n - ";;; Commentary:" n ";;; Code:" n n) -(provide "(provide '" (file-name-base (or (buffer-file-name) (buffer-name))) ")" n - ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) - " ends here" n) - -c++-mode - -(ns "namespace " (s ns) "{" n r n "} // namespace " (s ns)) -(namespace "namespace " (s ns) "{" n r n "} // namespace " (s ns)) - -;; Local Variables: -;; outline-regexp: "[a-z]" -;; eval: (outline-minor-mode 1) -;; End: diff --git a/emacs/.config/emacs/early-init.el b/emacs/.config/emacs/early-init.el new file mode 100644 index 0000000..8184bbb --- /dev/null +++ b/emacs/.config/emacs/early-init.el @@ -0,0 +1,32 @@ +;;; -*- lexical-binding: t; -*- + +(setq package-enable-at-startup nil) + +;; Optimization: file name handlers not needed during startup. +(defvar kj/file-name-handler-alist--old file-name-handler-alist) +(setq file-name-handler-alist nil) +(defun kj/restore-file-name-handler-alist () + (if (not (boundp 'kj/file-name-handler-alist--old)) + (message "File name handler already restored") + (setq file-name-handler-alist kj/file-name-handler-alist--old) + (makunbound 'kj/file-name-handler-alist--old))) + +;; Optimization: avoid garbage collection during startup. +;; Reset by gcmh later. +(setq gc-cons-threshold most-positive-fixnum) + +;; Move native compilation cache out of the way. Should be set in +;; early-init so that package loding uses the updated value. +(startup-redirect-eln-cache "~/.cache/emacs/eln-cache") + +;; Early options that affect startup. +(setq + package-native-compile t + inhibit-startup-message t + native-comp-async-report-warnings-errors 'silent + default-frame-alist + '((tool-bar-lines . 0) + (menu-bar-lines . 0) + (undecorated . t) + (vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil))) diff --git a/emacs/.config/emacs/elpaca-installer.el b/emacs/.config/emacs/elpaca-installer.el new file mode 100644 index 0000000..5a10886 --- /dev/null +++ b/emacs/.config/emacs/elpaca-installer.el @@ -0,0 +1,38 @@ +;;; -*- lexical-binding: t; -*- + +(defvar elpaca-installer-version 0.6) +(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) +(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) +(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) +(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) +(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (< emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (call-process "git" nil buffer t "clone" + (plist-get order :repo) repo))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) +(add-hook 'after-init-hook #'elpaca-process-queues) +(elpaca `(,@elpaca-order)) diff --git a/emacs/.config/emacs/emacs-custom.el b/emacs/.config/emacs/emacs-custom.el new file mode 100644 index 0000000..819655f --- /dev/null +++ b/emacs/.config/emacs/emacs-custom.el @@ -0,0 +1,19 @@ +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(custom-safe-themes + '("0340489fa0ccbfa05661bc5c8c19ee0ff95ab1d727e4cc28089b282d30df8fc8" + "e3999eba4f25d912d7d61cbaaed1b551957e61da047279da89499d3bd1f1d007" + "8d412c0ed46b865312d6df5c1dfd1821d349dd3cba00049cf88c4ad34403597e" + "88267200889975d801f6c667128301af0bc183f3450c4b86138bfb23e8a78fb1" + default)) + '(safe-local-variable-values '((checkdoc-package-keywords-flag)))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(default ((t (:family "Iosevka" :height 150)))) + '(variable-pitch ((t (:family "Noto Serif" :height 150))))) diff --git a/emacs/.config/emacs/init.el b/emacs/.config/emacs/init.el new file mode 100644 index 0000000..ddc40f1 --- /dev/null +++ b/emacs/.config/emacs/init.el @@ -0,0 +1,40 @@ +;;; -*- lexical-binding: t; -*- + +;; NixOS emacs doesn't include a build time. Assume a recent version. +(setq elpaca-core-date 20240101) +(setq elpaca-directory "~/.cache/emacs/elpaca") +(load-file (expand-file-name "elpaca-installer.el" user-emacs-directory)) + +(add-hook 'emacs-startup-hook + (lambda () + (message "Emacs ready in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) + +(add-hook 'elpaca-after-init-hook 'kj/restore-file-name-handler-alist) + +(elpaca elpaca-use-package + ;; Enable :elpaca use-package keyword. + (elpaca-use-package-mode) + ;; Assume :elpaca t unless otherwise specified. + (setq elpaca-use-package-by-default t)) +(elpaca-wait) + +(use-package gcmh + :hook + (elpaca-after-init . kj/enable-gcmh) + :config + (defun kj/enable-gcmh () + (message "Enabling gcmh") + (gcmh-mode 1))) + +;; Include user configuration. +(defvar kj/module-directory (expand-file-name "lisp" user-emacs-directory)) +(push kj/module-directory load-path) +(require 'kj-lib) +(require 'kj-init) +(cl-loop for path in (directory-files kj/module-directory) + if (string-match "\\([^/]*\\).el" path) + do (require (intern (match-string-no-properties 1 path)))) diff --git a/emacs/.config/emacs/lisp/kj-bindings.el b/emacs/.config/emacs/lisp/kj-bindings.el new file mode 100644 index 0000000..e01b659 --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-bindings.el @@ -0,0 +1,34 @@ +;;; -*- lexical-binding: t; -*- + +(use-package emacs :elpaca nil + :bind + (("C-w" . kj/kill-word-or-region) + ("C-c s" . kj/shell-here) + ("C-c t" . eshell) + ("C-c ." . kj/eshell-here) + ("C-c c" . org-capture) + ("M-o" . other-window) + ("C-c a m" . notmuch) + ("C-c a g" . magit-list-repositories) + ("C-c M" . smerge-ediff) + ("C-c b r" . revert-buffer) + ("C-c r l" . consult-flymake) + ("C-c r f" . eglot-format) + ("C-c r g" . recompile) + ("C-c r a" . eglot-code-actions) + ("C-c r r" . eglot-rename) + ("C-c r n" . flymake-goto-next-error) + ("C-c r p" . flymake-goto-prev-error) + ("C-c w u" . winner-undo) + ("C-c w U" . winner-redo) + ("C-" . completion-at-point) + ;; Replace downcase-word binding. + ("M-l" . iso-transl-ctl-x-8-map)) + + :config + (defvar kj/flymake-repeat-map (make-sparse-keymap "flymake")) + (define-repeating-key kj/flymake-repeat-map "n" flymake-goto-next-error "next error") + (define-repeating-key kj/flymake-repeat-map "p" flymake-goto-prev-error "prev error") + (define-key kj/flymake-repeat-map (kbd "C-g") '("quit" . ignore))) + +(provide 'kj-bindings) diff --git a/emacs/.config/emacs/lisp/kj-defaults.el b/emacs/.config/emacs/lisp/kj-defaults.el new file mode 100644 index 0000000..c2cf6fd --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-defaults.el @@ -0,0 +1,50 @@ +;;; -*- lexical-binding: t; -*- + +;; Backups +(make-directory "~/.cache/emacs_backups/" t) +(make-directory "~/.cache/emacs_autosave/" t) +(setq backup-directory-alist '(("." . "~/.cache/emacs_backups/"))) +(setq auto-save-file-name-transforms '((".*" "~/.cache/emacs_autosave/" t))) + +;; Keep backups, but avoid same directory since it can be slow on tramp. +(setq version-control t + delete-old-versions -1 + vc-make-backup-files t + create-lockfiles nil + backup-by-copying t) + +(setq-default indent-tabs-mode nil) +(setq sentence-end-double-space nil) +(setq save-interprogram-paste-before-kill t) +(setq mouse-yank-at-point t) +(setq enable-recursive-minibuffers t) +(set-language-environment "utf-8") +(setq require-final-newline t) +;; Save bookmark list every time a bookmark is added. +(setq bookmark-save-flag 1) +(delete-selection-mode 1) + +(setq savehist-file "~/.cache/emacs/savehist-history") +(savehist-mode 1) + +;; Resize settings +(setq frame-inhibit-implied-resize t) +(setq pixel-scroll-precision-mode t) + +(setq kill-whole-line t) + +(defun kj/kill-word-or-region (arg) + (interactive "p") + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (backward-kill-word (or arg 1)))) +(global-set-key (kbd "C-w") 'kj/kill-word-or-region) + +(defun kj/open-line (n) + (interactive "*p") + (beginning-of-line) + (open-line n) + (indent-according-to-mode)) +(global-set-key (kbd "C-o") 'kj/open-line) + +(provide 'kj-defaults) diff --git a/emacs/.config/emacs/lisp/kj-development.el b/emacs/.config/emacs/lisp/kj-development.el new file mode 100644 index 0000000..6eee3dd --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-development.el @@ -0,0 +1,116 @@ +;;; -*- lexical-binding: t; -*- +(setq tab-stop-list (number-sequence 4 200 4)) + +(use-package eglot :elpaca nil + :config + (setq eglot-events-buffer-size 0)) + +(add-hook 'prog-mode-hook 'subword-mode) + +;; Only used to get better eglot snippets. +(use-package yasnippet + :config + (add-to-list 'yas-snippet-dirs (expand-file-name "yasnippets" user-emacs-directory)) + (yas-global-mode)) + +(use-package tempel + ;; Require trigger prefix before template name when completing. + ;; :custom + ;; (tempel-trigger-prefix "<") + + :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand + ("M-*" . tempel-insert)) + + :init + + ;; Setup completion at point + (defun tempel-setup-capf () + ;; Add the Tempel Capf to `completion-at-point-functions'. + ;; `tempel-expand' only triggers on exact matches. Alternatively use + ;; `tempel-complete' if you want to see all matches, but then you + ;; should also configure `tempel-trigger-prefix', such that Tempel + ;; does not trigger too often when you don't expect it. NOTE: We add + ;; `tempel-expand' *before* the main programming mode Capf, such + ;; that it will be tried first. + (setq-local completion-at-point-functions + (cons #'tempel-expand + completion-at-point-functions))) + + (add-hook 'conf-mode-hook 'tempel-setup-capf) + (add-hook 'prog-mode-hook 'tempel-setup-capf) + (add-hook 'text-mode-hook 'tempel-setup-capf) + + ;; Optionally make the Tempel templates available to Abbrev, + ;; either locally or globally. `expand-abbrev' is bound to C-x '. + ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode) + ;; (global-tempel-abbrev-mode) +) + +(use-package rustic + :after eglot + :bind (("C-c C-r C-s" . rustic-popup) + ("C-c C-r C-n" . kj/rustic-nextest-all)) + :config + (defun kj/rustic-nextest-all () + (interactive) + (setq rustic-cargo-nextest-exec-command "nextest run --run-ignored all") + (rustic-cargo-run-nextest)) + (setq + ;; eglot seems to be the best option right now. + rustic-lsp-client 'eglot + rustic-format-on-save nil + ;; Prevent automatic syntax checking, which was causing lags and stutters. + ;; eglot-send-changes-idle-time (* 60 60) + ) + :hook + (rustic-mode . eglot-ensure) + ;; Disable the annoying doc popups in the minibuffer. + ;; (add-hook 'eglot-managed-mode-hook (lambda () (eldoc-mode -1))) + ) + +(use-package markdown-mode + :ensure t + :mode ("README\\.md\\'" . gfm-mode) + :init (setq markdown-command "multimarkdown")) + +(use-package nix-mode + :mode "\\.nix\\'") + +(use-package ledger-mode + :mode "\\.journal") +(use-package unobtrusive-magit-theme) + +(use-package editorconfig + :ensure t + :config + (editorconfig-mode 1)) + +(use-package clojure-mode) + +;; Devicetree mode for keyboard configs. +(use-package dts-mode + :mode "\\.keymap\\'") + +(use-package yaml-mode + :mode "\\.\(yml|yaml\)\\'") + +;; (use-package ansi-color +;; :hook (compilation-filter . ansi-color-compilation-filter)) + +(use-package diff-hl + :config + (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) + (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) + (global-diff-hl-mode)) + +(use-package graphviz-dot-mode + :ensure t) + +(use-package haskell-mode) +(use-package tidal + :config + (setq tidal-boot-script-path "~/projects/audio/BootTidal.hs")) + +(use-package ess) + +(provide 'kj-development) diff --git a/emacs/.config/emacs/lisp/kj-email.el b/emacs/.config/emacs/lisp/kj-email.el new file mode 100644 index 0000000..721050b --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-email.el @@ -0,0 +1,86 @@ +;;; -*- lexical-binding: t; -*- + +(setq kj/fastmail-maildir (expand-file-name "~/Maildir/fastmail")) + +(when (file-exists-p (expand-file-name "~/Maildir")) + (use-package notmuch + :autoload compose-mail + :after seq + :bind + (:map notmuch-hello-mode-map + ;; ("T" . kj/notmuch-tree-by-tag) + ) + :config + (with-eval-after-load 'message + (setq message-mail-user-agent 'notmuch-user-agent + message-cite-style 'message-cite-style-gmail + message-citation-line-function 'message-insert-formatted-citation-line + message-kill-buffer-on-exit nil) + (add-hook 'message-mode-hook 'turn-off-auto-fill) + (add-hook 'message-mode-hook 'visual-line-mode)) + (setq notmuch-show-all-tags-list t + notmuch-show-relative-dates t + notmuch-hello-tag-list-make-query "tag:unread" + notmuch-archive-tags '("-inbox" "-unread") + notmuch-fcc-dirs nil + notmuch-show-logo nil + notmuch-mua-cite-function 'message-cite-original-without-signature + notmuch-wash-citation-lines-prefix most-positive-fixnum + notmuch-wash-citation-lines-suffix most-positive-fixnum + notmuch-show-indent-messages-width 0) + (add-hook 'notmuch-show-hook 'kj/disable-trailing-whitespace) + + (defun kj/confirm-empty-subject () + "Allow user to quit when current message subject is empty." + (or (message-field-value "Subject") + (yes-or-no-p "Really send without Subject? ") + (keyboard-quit))) + (add-hook 'message-send-hook #'kj/confirm-empty-subject) + (advice-add + 'message-send :before (defun kj/notmuch-switch-to-local (&args) + (when (file-remote-p default-directory) + (cd (expand-file-name "~"))))) + (setq notmuch-saved-searches + '((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type nil) + (:name "unread" :query "tag:unread" :key "u" :search-type nil) + (:name "flagged" :query "tag:flagged" :key "f" :search-type nil) + (:name "sent" :query "tag:sent" :key "t" :search-type nil) + (:name "drafts" :query "tag:draft" :key "d" :search-type nil) + (:name "all mail" :query "*" :key "a" :search-type nil) + ))) + + (setq kj/notmuch-wash-citation-regexp "^\\(\\(>\\|[[:space:]]\\)+\\).*\n") + + ;;; XXX consider upstreaming this. + (defun kj/notmuch-wash-citations-by-depth (_msg _depth) + (goto-char (point-min)) + (beginning-of-line) + (let ((maxlevel 1)) + (while (intern-soft (format "message-cited-text-%d" maxlevel)) + (setq maxlevel (1+ maxlevel))) + (setq maxlevel (1- maxlevel)) + + (while (and (< (point) (point-max)) + (re-search-forward kj/notmuch-wash-citation-regexp nil t)) + (let* ((cite-start (match-beginning 0)) + (cite-end (match-end 0)) + (cite-level (seq-count (lambda (c) (eql c ?>)) (match-string 1))) + (face-level (1+ (% (1- cite-level) maxlevel))) + (cited-text-face (intern (format "message-cited-text-%d" face-level)))) + (overlay-put (make-overlay cite-start cite-end) + 'face cited-text-face))))) + ;; This doesn't seem to work that well... :( + ;;(add-hook 'notmuch-show-insert-text/plain-hook #'kj/notmuch-wash-citations-by-depth 90) + + (defun kj/notmuch-tree-by-tag (tag) + (interactive + (list (notmuch-select-tag-with-completion "Notmuch search tag: "))) + (notmuch-tree (concat "tag:" tag)))) + +(when (file-exists-p kj/fastmail-maildir) + (setq sendmail-program "mujmap" + message-send-mail-function 'message-send-mail-with-sendmail + message-signature "Kjetil" + message-sendmail-extra-arguments (list "-C" kj/fastmail-maildir "send"))) + +(provide 'kj-email) diff --git a/emacs/.config/emacs/lisp/kj-eshell.el b/emacs/.config/emacs/lisp/kj-eshell.el new file mode 100644 index 0000000..5617658 --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-eshell.el @@ -0,0 +1,83 @@ +;;; -*- lexical-binding: t; -*- +(use-package eshell :elpaca nil + :bind + (:map eshell-mode-map + ("M-r" . consult-history)) + :hook ((eshell-first-time-mode . kj/eshell-on-load)) + :config + (add-hook 'eshell-mode-hook + (lambda () + (setenv "PAGER" "cat")) + (setenv "EDITOR" "emacsclient")) + (setq eshell-prefer-lisp-functions nil + eshell-scroll-to-bottom-on-input 'all + eshell-hist-ignoredups t + eshell-destroy-buffer-when-process-dies t + eshell-error-if-no-glob t) + (setq tramp-remote-path '(tramp-own-remote-path)) + + (defun kj/eshell-on-load () + (dolist (command '("htop" "tmux" "vim" "nvim" "watch")) + (add-to-list 'eshell-visual-commands + command)) + + ;; (define-key eshell-prompt-mode-map (kbd "C-d") 'eshell-life-is-too-much) + ) + + (add-to-list 'eshell-complex-commands "ssh") + + (add-to-list 'eshell-modules-list 'eshell-tramp) + (add-hook 'eshell-mode-hook 'visual-line-mode)) + +(use-package pcmpl-args) + +(use-package esh-help + :init + (setup-esh-help-eldoc)) + +(use-package eshell-syntax-highlighting + :hook (eshell-mode . eshell-syntax-highlighting-mode)) + +(defun eshell/ssh (&rest args) + (if (= 1 (length args)) + (throw 'eshell-replace-command + (eshell/cd + (format "/ssh:%s:" (car args)))) + (throw 'eshell-replace-command + (eshell-parse-command "*ssh" + (eshell-stringify-list (flatten-tree args)))))) + +(defvar kj/eshell-here-directory) + +(defun kj/eshell-buffer-name () + (let ((base (concat "*eshell:" default-directory))) + (cond + ((not (get-buffer base)) base) + (t (cl-loop for n from 2 + for name = (format "%s<%d>" base n) + until (not (get-buffer name)) + finally return name))))) + +(defun kj/eshell-update-buffer-name () + (interactive) + (rename-buffer (kj/eshell-buffer-name))) +(add-hook 'eshell-directory-change-hook 'kj/eshell-update-buffer-name) + +(defun kj/new-eshell-here () + (let ((default-directory kj/eshell-here-directory)) + (eshell t))) + +(defun kj/eshell-here () + (interactive) + (unless (eq last-command 'kj/eshell-here) + (setq kj/eshell-here-directory + (if (derived-mode-p 'eshell-mode) + (with-current-buffer (other-buffer (current-buffer) t) + default-directory) + default-directory))) + (if (derived-mode-p 'eshell-mode) + (kj/new-eshell-here) + (eshell)) + (kj/eshell-update-buffer-name)) + +(provide 'kj-eshell) diff --git a/emacs/.config/emacs/lisp/kj-history.el b/emacs/.config/emacs/lisp/kj-history.el new file mode 100644 index 0000000..9805aa1 --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-history.el @@ -0,0 +1,66 @@ +;; -*- lexical-binding: t; -*- + +(defvar kj/history-command "fc -R $HISTFILE && fc -l 1" + "History command used to get shell history.") + +(defvar kj/history-regexp + (rx bol (* " ") + ;; Index + (* digit) + (* " ") + ;; Command + (group (1+ (not "\n"))))) + +(use-package emacs :elpaca nil + :after consult + :config + (defun kj/get-shell-history () + (with-temp-buffer + (unless (process-file + "zsh" + nil + (current-buffer) + nil + "-c" + kj/history-command) + (error "Getting history failed: %s" (buffer-string))) + (goto-char (point-min)) + (let ((result)) + (save-match-data + (while (re-search-forward kj/history-regexp nil t) + (let ((command + ;; Fix up multi-line commands. + (string-replace "\\\\n" "\\\n" (match-string-no-properties 1)))) + (push command result)))) + result))) + + (defun kj/consult-history () + (interactive) + (if (not + (or (and (minibufferp) + (eq minibuffer-history-variable 'shell-command-history)) + (derived-mode-p 'term-mode 'shell-mode) + )) + (call-interactively 'consult-history) + (pcase-let* ((bol + (cond ((derived-mode-p 'eshell-mode) 'eshell-bol) + ((derived-mode-p 'term-mode) 'term-bol) + ((derived-mode-p 'comint-mode) 'comint-bol))) + (`(,beg . ,end) + (cond ((minibufferp) + (cons (minibuffer-prompt-end) (point-max))) + (bol (save-excursion + (funcall bol) + (cons (point) (pos-eol)))) + (t (cons (point) (point))))) + (str (consult--read + (kj/get-shell-history) + :prompt "Shell history: " + :history t + :sort nil + :initial (buffer-substring-no-properties beg end) + :state (consult--insertion-preview beg end)))) + (delete-region beg end) + (insert (substring-no-properties str)))))) + +(provide 'kj-history) diff --git a/emacs/.config/emacs/lisp/kj-init.el b/emacs/.config/emacs/lisp/kj-init.el new file mode 100644 index 0000000..298040a --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-init.el @@ -0,0 +1,944 @@ +;;; -*- lexical-binding: t; -*- + +(setq user-full-name "KJ Orbekk" + user-mail-address "kj@orbekk.com") + +(defvar kj/cache-dir "~/.cache/emacs") + +(setq initial-scratch-message nil) + +(setq switch-to-buffer-obey-display-actions t) +(setq switch-to-buffer-in-dedicated-window 'pop) +(setq even-window-sizes 'width-only) + +(setq custom-file (expand-file-name "emacs-custom.el" user-emacs-directory)) +(load custom-file :noerror t) + +(setq bookmark-file (expand-file-name "boomarks" kj/cache-dir)) + +(setq fast-but-imprecise-scrolling t) + +(setq use-short-answers t) + +(global-hl-line-mode 1) +(global-auto-revert-mode 1) + +(setq outline-minor-mode-cycle t + outline-minor-mode-highlight 'override) + +(setq visible-bell t + ring-bell-function 'ignore) + +(setq auto-save-list-file-prefix (expand-file-name "auto-save-list/.saves-" kj/cache-dir)) + +(use-package wombat-theme :elpaca nil + :disabled + :init + (load-theme 'wombat) + :config + (custom-theme-set-faces + 'wombat + '(default ((t :background "#111111"))) + '(ansi-color-black ((t :background "#000000"))) + '(hl-line ((t :inherit () :background "#242424"))))) + +(use-package modus-themes + :init + (load-theme 'modus-operandi-tinted) + (load-theme 'modus-vivendi-tinted t t) + :config + (custom-theme-set-faces + 'modus-vivendi-tinted + '(avy-lead-face ((t :inherit (bold modus-themes-subtle-blue)))) + '(avy-lead-face-0 ((t :inherit (bold modus-themes-subtle-cyan)))) + '(avy-lead-face-1 ((t :inherit (bold modus-themes-subtle-green)))) + '(avy-lead-face-2 ((t :inherit (bold modus-themes-subtle-magenta)))))) + +(use-package doom-themes) + +(setq alert-default-style 'libnotify) + +(use-package all-the-icons + :if (display-graphic-p)) +(setq inhibit-compacting-font-caches t) +(setq use-dialog-box nil) +(setq display-time-24hr-format t) + +(display-battery-mode 1) +(display-time-mode 1) + +(use-package doom-modeline + :ensure t + :init (doom-modeline-mode 1) + :config + (setq doom-modeline-buffer-encoding 'nondefault)) + +(use-package emojify + :bind + (("C-c C-i C-e" . emojify-insert-emoji)) + :hook (after-init . global-emojify-mode) + :config + (emojify-set-emoji-styles '(unicode))) + +(setq-default show-trailing-whitespace t) +(dolist (mode '(calendar-mode-hook + eshell-mode-hook + term-mode-hook + comint-mode-hook + completion-list-mode)) + (add-hook mode + (defun kj/disable-trailing-whitespace () + (setq show-trailing-whitespace nil)))) + +;; Deletes trailing whitespace on changed lines only. +(use-package ws-butler + :diminish ws-butler-mode + :hook (prog-mode . ws-butler-mode)) + +;; `M-x shell` settings +(setq shell-prompt-pattern "^[^#$%>\n]*[#$%>❯] *" + explicit-shell-file-name "zsh" + explicit-zsh-args '("--login" "--interactive")) +(defun kj/shell-buffer-name () + (concat "*shell:" default-directory "*")) + +(defun kj/shell-here () + (interactive) + (let ((buffer + (shell (kj/shell-buffer-name)))) + (with-current-buffer buffer + (let* ((proc (get-buffer-process (current-buffer))) + (sentinel (process-sentinel proc))) + (set-process-sentinel + proc + `(lambda (proc signal) + (funcall ',sentinel proc signal) + (and (memq (process-status proc) '(exit signal)) + (buffer-live-p (process-buffer proc)) + (message "Shell died, killing buffer %s" + (process-buffer proc)) + (kill-buffer (process-buffer proc))))))))) + +(use-package coterm + :config + (coterm-mode 1)) + +;; Update buffer name to reflect directory. +(advice-add 'cd :after + (defun kj/maybe-rename-shell (&rest args) + (and (derived-mode-p 'shell-mode) + (rename-buffer + (kj/shell-buffer-name))))) + +(use-package rainbow-delimiters + :defer t + :hook (prog-mode . rainbow-delimiters-mode) + ) + +(column-number-mode) +(set-fringe-mode 10) +(setq next-screen-context-lines 10) + +(use-package avy + :bind + (("C-c l" . avy-goto-char) + ("C-c n" . avy-goto-line)) + :config + (setq avy-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) + (defun avy-action-embark (pt) + (unwind-protect + (save-excursion + (goto-char pt) + (embark-act)) + (select-window + (cdr (ring-ref avy-ring 0)))) + t) + +(setf (alist-get ?. avy-dispatch-alist) 'avy-action-embark)) +(define-key isearch-mode-map (kbd "M-j") 'avy-isearch) + +(winner-mode +1) + +(use-package ace-window + :bind + (("C-c e" . ace-window)) + :config + (setq aw-dispatch-always t) + (setq aw-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) + ;; Make ace window more visible + ;; (custom-set-faces! + ;; '(aw-leading-char-face + ;; :foreground "white" :background "red" + ;; :weight bold :height 2.5 :box (:line-width 10 :color "red"))) + ) + +(defun kj/balance-main-window () + (balance-windows (window-main-window))) + +;; Prefer horizontal splits. +(setq split-height-threshold 100) + +(defun kj/split-window-below () + (interactive) + (split-window-below) + (kj/balance-main-window) + (other-window 1)) + +(defun kj/split-window-right () + (interactive) + (split-window-right) + (kj/balance-main-window) + (other-window 1)) + +(global-set-key (kbd "C-x 3") #'kj/split-window-right) +(global-set-key (kbd "C-x 2") #'kj/split-window-below) + +(use-package vertico + :init + (vertico-mode)) + +;; Rebind C-x? +(global-set-key (kbd "C-t") 'ctrl-x-map) +(define-key global-map (kbd "C-t") ctl-x-map) +;; (define-key key-translation-map "\C-t" "\C-t") +;; (define-key key-translation-map "\C-x" "\C-t") + +(use-package marginalia + :bind + (:map minibuffer-local-map + ("M-n" . marginalia-cycle)) + :init + (marginalia-mode)) + +(use-package embark + :ensure t + + :bind + (("C-." . embark-act) + ("C-;" . embark-dwim) + ("C-h C-b" . embark-bindings)) + + :init + (setq prefix-help-command #'embark-prefix-help-command) + + :config + (defun find-file-keeping-default-directory (filename) + (let ((dir default-directory)) + (with-current-buffer (find-file filename) + (setq-local default-directory dir)))) + (define-key embark-file-map "@" 'find-file-keeping-default-directory) + + ;; Hide the mode line of the Embark live/completions buffers + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + . + (window-parameters (mode-line-format . none))))) + +(use-package embark-consult + :ensure t + :after (embark consult) + :demand t + :hook (embark-mode . consult-preview-at-point-mode)) + +;; For editing grep buffers. +(use-package wgrep) +(use-package deadgrep + :bind ("M-s g" . deadgrep)) + +;; For recent files. +(setq recentf-max-saved-items 1000) +(setq recentf-auto-cleanup 'never) +(defun kj/recentf-keep (file) + (cond + ((file-remote-p file) t) + ((file-readable-p file)))) +(setq recentf-keep '(kj/recentf-keep)) +(setq recentf-save-file (expand-file-name "emacs-recentf" kj/cache-dir)) +(recentf-mode 1) +(run-at-time nil (* 5 60) 'recentf-save-list) + +(setq global-mark-ring-max 500 + mark-ring-max 16) + +(defun kj/consult-ripgrep-here (&optional dir initial) + (interactive "P") + (unless dir + (setq dir default-directory)) + (consult-ripgrep dir initial)) + +;; Example configuration for Consult +(use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings (mode-specific-map) + ("C-c h" . kj/consult-history) + ;;("C-c m" . consult-mode-command) + ("C-c k" . consult-kmacro) + ;; C-x bindings (ctl-x-map) + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x C-b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ("C-c f r" . consult-recent-file) + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + (" a" . consult-apropos) ;; orig. apropos-command + ;; M-g bindings (goto-map) + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-imenu-multi) + ;; M-s bindings (search-map) + ("M-s d" . consult-find) + ("M-s D" . consult-locate) + ;; ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s r" . consult-ripgrep) + ("M-s R" . kj/consult-ripgrep-here) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s m" . consult-multi-occur) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . kj/consult-history) ;; orig. next-matching-history-element + ("M-r" . kj/consult-history)) ;; orig. previous-matching-history-element + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + ;; :hook (completion-list-mode . consult-preview-at-point-mode) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Use consult for completion. + (setq completion-in-region-function #'consult-completion-in-region) + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + (setq consult-preview-key '(:debounce 0.3 any)) + ;; (setq consult-preview-key (kbd "M-.")) + ;; (setq consult-preview-key (list (kbd "") (kbd ""))) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + ;; (consult-customize + ;; consult-theme + ;; :preview-key '(:debounce 0.2 any) + ;; consult-ripgrep consult-git-grep consult-grep + ;; consult-bookmark consult-recent-file consult-xref + ;; consult--source-bookmark consult--source-recent-file + ;; consult--source-project-recent-file + ;; :preview-key (kbd "M-.")) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; (kbd "C-+") + + (setq consult-ripgrep-args + "rg --null --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --with-filename --line-number --search-zip --hidden") + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. + ;; There are multiple reasonable alternatives to chose from. + ;;;; 1. project.el (the default) + ;;(setq consult-project-function #'consult--default-project-function) + ;;;; 2. projectile.el (projectile-project-root) + (autoload 'projectile-project-root "projectile") + (setq consult-project-function (lambda (_) (projectile-project-root))) + ;;;; 3. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) + ;;;; 4. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) + ) + +(use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) + +(use-package which-key + :init + (which-key-mode)) + +(use-package seq) + +(use-package transient + :config + (setq transient-levels-file (expand-file-name "transient/levels.el" kj/cache-dir) + transient-values-file (expand-file-name "transient/values.el" kj/cache-dir) + transient-history-file (expand-file-name "transient/history.el" kj/cache-dir))) + +(defconst kj/git-directory (expand-file-name "~/git")) +(defun kj/read-repository () + (let ((repos + (thread-last + (directory-files "/ssh:dragon.orbekk.com:/storage/projects") + (seq-filter (lambda (f) (not (string-match (rx bol (or "." "..") eol) f))))))) + (thread-last + (completing-read "Repository: " repos) + (concat "ssh://dragon.orbekk.com:/storage/projects/")))) + +(use-package magit + :bind (:map magit-repolist-mode-map + ("c" . magit-clone) + ("i" . magit-init) + ("C" . kj/clone-project)) + :custom + (magit-repository-directories `((,kj/git-directory . 1)) "My git repositories") + (magit-repolist-columns '(("Name" 25 magit-repolist-column-ident nil) + ("Version" 25 magit-repolist-column-version + ((:sort magit-repolist-version<))) + ("BU" 3 magit-repolist-column-unpushed-to-upstream + ((:right-align t) (:sort <))) + ("F" 3 magit-repolist-column-flag + ((:right-align t) (:sort <))) + ("Path" 99 magit-repolist-column-path nil))) + :config + (defun kj/clone-project () + (interactive) + (let ((magit-clone-set-remote.pushDefault t)) + (magit-clone-regular (kj/read-repository) kj/git-directory nil)))) + +(use-package mixed-pitch + :hook + (text-mode . mixed-pitch-mode) + (org-mode . mixed-pitch-mode) + ) + +(when (string= (system-name) "fedora") + (setenv "SSH_AUTH_SOCK" (string-trim (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))) + +(setq kj/font-height + (cond ((string= (system-name) "fedora") 100) + (t 150))) + +(custom-set-faces + `(variable-pitch ((t (:family "Noto Serif" :height ,kj/font-height)))) + `(default ((t (:family "Iosevka" :height ,kj/font-height))))) + +;; (unless (equal system-name "minideck") +;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 150) +;; (set-face-attribute 'variable-pitch nil :font "Noto Serif")) + +;;; Compilation settings +(use-package compile :elpaca nil + :config + (setq compilation-ask-about-save nil) + (setq compilation-scroll-output 'first-error) + ;; Allow longer output in compilation buffer. + (add-to-list 'compilation-filter-hook #'comint-truncate-buffer) + (setq comint-buffer-maximum-size 10000)) + +(use-package ob-async) + +(use-package direnv + :config + (setq direnv-always-show-summary nil) + (direnv-mode)) + +(use-package projectile + :ensure t + :defer 1 + :init + (setq projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld" kj/cache-dir)) + (projectile-mode +1) + :bind (:map projectile-mode-map + ("C-x p" . projectile-command-map))) + +(use-package emacs :elpaca nil + :config + (setq ediff-diff-options "-w" ; turn off whitespace checking + ediff-split-window-function #'split-window-horizontally + ediff-window-setup-function #'ediff-setup-windows-plain)) + +(use-package anzu + :config + (global-anzu-mode +1) + (global-set-key [remap query-replace] 'anzu-query-replace) + (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)) + +(defun meow-setup () + (setq meow-replace-state-name-list + '((normal . "N") + (motion . "M") + (keypad . "🖩") + (insert . "I") + (beacon . "📻"))) + (setq meow-cheatsheet-layout meow-cheatsheet-layout-dvorak) + (meow-leader-define-key + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("b" . consult-buffer) + ;;'("p" . projectile-command-map) + ) + (meow-motion-overwrite-define-key + ;; custom keybinding for motion state + '("" . ignore)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("@" . er/expand-region) + '("<" . meow-beginning-of-thing) + '(">" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-line) + '("E" . meow-goto-line) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-join) + '("k" . meow-kill) + '("l" . meow-till) + '("m" . meow-mark-word) + '("M" . meow-mark-symbol) + '("n" . meow-next) + '("N" . meow-next-expand) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-prev) + '("P" . meow-prev-expand) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-search) + '("/" . isearch-forward) + '("?" . isearch-backward) + '("t" . meow-right) + '("T" . meow-right-expand) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-next-word) + '("W" . meow-next-symbol) + '("x" . meow-save) + '("X" . meow-sync-grab) + '("y" . meow-yank) + '("z" . meow-pop-selection) + '("P" . (lambda () (interactive) (forward-line -10))) + '("N" . (lambda () (interactive) (forward-line 10))) + '("'" . repeat) + '("" . ignore)) + + (add-hook 'git-commit-mode-hook #'meow-insert)) + +;; (use-package meow +;; :bind +;; :config +;; (meow-setup) +;; (meow-global-mode 1) +;; ;; (meow-setup-indicator) ; Not needed with doom-modeline. +;; (setq meow-use-clipboard t) +;; ;; (add-to-list 'meow-keypad-start-keys '(?t . ?x)) +;; ;; (add-to-list 'meow-keypad-start-keys '(?x . ?t)) +;; (define-key meow-insert-state-keymap "\C-[" #'meow-insert-exit) +;; ) + +(use-package emacs :elpaca nil + :hook (dired-mode . dired-omit-mode) + :init + (setq dired-dwim-target t ; suggest a target for moving/copying intelligently + dired-hide-details-hide-symlink-targets nil + ;; don't prompt to revert, just do it + dired-auto-revert-buffer #'dired-buffer-stale-p + ;; Always copy/delete recursively + dired-recursive-copies 'always + dired-recursive-deletes 'top + ;; Ask whether destination dirs should get created when copying/removing files. + dired-create-destination-dirs 'ask)) + +;; (use-package dirvish +;; :init +;; (setq dirvish-hide-details nil) +;; (dirvish-override-dired-mode)) + +(use-package diredfl + :hook (dired-mode . diredfl-mode)) + +;; Tramp settings +(setq tramp-use-ssh-controlmaster-options nil + tramp-default-method "ssh") +;; Need 'eval-after-load' of 'tramp-sh' here because nixos has a +;; startup file that messes with this variable. +(with-eval-after-load 'tramp-sh + (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) + +;; Calc settings. +(setq calc-make-windows-dedicated t + calc-kill-line-numbering nil + calc-display-trail nil) +(setq math-additional-units + '((ZiB "1024 * EiB" "Zebibyte") + (EiB "1024 * PiB" "Exbibyte") + (PiB "1024 * TiB" "Pebibyte") + (TiB "1024 * GiB" "Tebibyte") + (GiB "1024 * MiB" "Gibibyte") + (MiB "1024 * KiB" "Mebibyte") + (KiB "1024 * B" "Kibibyte") + (B nil "Byte") + (Zib "1024 * ZiB" "Zebibit") + (Eib "1024 * PiB" "Exbibit") + (Pib "1024 * TiB" "Pebibit") + (Tib "1024 * GiB" "Tebibit") + (Gib "1024 * Mib" "Gibibit") + (Mib "1024 * Kib" "Mebibit") + (Kib "1024 * b" "Kibibit") + (b "B / 8" "Bit"))) + +;; Low menu delay. +(setq which-key-idle-delay .5) + +;; Replace values in an alist from a list of replacements. +;; +;; Example: +;; (kj/assq-replace '((:a . 1)) '((:a . 2))) +(defun kj/assq-replace (replacements alist) + (let ((replace1 (lambda (aelem alist) + (cons aelem (assq-delete-all (car aelem) alist))))) + (if replacements + (kj/assq-replace (cdr replacements) + (funcall replace1 (car replacements) alist)) + alist))) + + +(use-package idle-highlight-mode + :config + (setq idle-highlight-idle-time 0.2) + (set-face-attribute 'idle-highlight nil :inherit 'underline) + :hook ((prog-mode text-mode) . idle-highlight-mode)) + +(defun kj/smartparens-config () + (require 'smartparens-config) + (bind-keys :map smartparens-mode-map + ("C-M-a" . sp-beginning-of-sexp) + ("C-M-e" . sp-end-of-sexp) + + ("C-" . sp-down-sexp) + ("C-" . sp-up-sexp) + ("M-" . sp-backward-down-sexp) + ("M-" . sp-backward-up-sexp) + + ("C-M-f" . sp-forward-sexp) + ("C-M-b" . sp-backward-sexp) + + ("C-M-n" . sp-next-sexp) + ("C-M-p" . sp-previous-sexp) + + ("C-S-f" . sp-forward-symbol) + ("C-S-b" . sp-backward-symbol) + + ("C-" . sp-forward-slurp-sexp) + ("M-" . sp-forward-barf-sexp) + ("C-" . sp-backward-slurp-sexp) + ("M-" . sp-backward-barf-sexp) + + ("C-M-t" . sp-transpose-sexp) + ("C-M-k" . sp-kill-sexp) + ("C-k" . sp-kill-hybrid-sexp) + ("C-M-w" . sp-copy-sexp) + ("C-M-d" . delete-sexp) + + ("M-" . backward-kill-word) + ("C-" . sp-backward-kill-word) + ([remap sp-backward-kill-word] . backward-kill-word) + + ("M-[" . sp-backward-unwrap-sexp) + ("M-]" . sp-unwrap-sexp) + + ("C-x C-t" . sp-transpose-hybrid-sexp) + + ("C-c (" . wrap-with-parens) + ("C-c [" . wrap-with-brackets) + ("C-c {" . wrap-with-braces) + ("C-c '" . wrap-with-single-quotes) + ("C-c \"" . wrap-with-double-quotes) + ("C-c _" . wrap-with-underscores) + ("C-c `" . wrap-with-back-quotes) + + ("M-k" . sp-raise-sexp) + ("M-S" . sp-split-sexp) + ("M-I" . sp-splice-sexp)) + ) + +(use-package smartparens + :init + (kj/smartparens-config) + :hook ((prog-mode lisp-mode) . smartparens-strict-mode) + ) + +;; (use-package paredit +;; :hook ((lisp-mode emacs-lisp-mode) . paredit-mode) +;; :bind (:map paredit-mode-map +;; ("M-k" . paredit-raise-sexp) +;; ("M-I" . paredit-splice-sexp)) +;; :hook (paredit-mode +;; . (lambda () +;; (unbind-key "M-r" paredit-mode-map) +;; (unbind-key "M-s" paredit-mode-map)))) + + +(define-key isearch-mode-map (kbd "C-RET") + #'isearch-exit-other-end) +;; Why does C-RET not always work? +(define-key isearch-mode-map (kbd "C-") + #'isearch-exit-other-end) + +(defun isearch-exit-other-end () + "Exit isearch, at the opposite end of the string." + (interactive) + (isearch-exit) + (goto-char isearch-other-end)) +(define-key isearch-mode-map (kbd "M-z") + #'kj/isearch-zap) +(defun kj/isearch-zap () + "Zap to beginning of search" + (interactive) + (isearch-exit) + (goto-char isearch-other-end) + (kill-region (region-beginning) (region-end))) + +(setq case-fold-search t + case-replace t + char-fold-symmetric t + isearch-lax-whitespace t + search-default-mode 'char-fold-to-regexp) +(use-package char-fold :elpaca nil + :config + (setopt char-fold-include + (cons '(?- "_" "-") char-fold-include))) + +(use-package expand-region + :bind (("C-@" . #'er/expand-region))) + +(use-package ace-mc + :bind (:map kj/leader-map + ("h" . ace-mc-add-multiple-cursors) + ("M-h" . ace-mc-add-single-cursor))) + +;; Disable VC over tramp. +;;(setq-default vc-handled-backends nil) +(defun kj/vc-off-if-remote () + (if (file-remote-p (buffer-file-name)) + (setq-local vc-handled-backends nil))) +(add-hook 'find-file-hook 'kj/vc-off-if-remote) + +(use-package selected + :demand t + :diminish selected-minor-mode + :bind (:map selected-keymap + ("[" . align-code) + ("f" . fill-region) + ("U" . unfill-region) + ("d" . downcase-region) + ("r" . reverse-region) + ("S" . sort-lines)) + :config + (selected-global-mode 1)) + +(setq kj/some-lines 6) +(defun kj/forward-some-lines () + (interactive) + (forward-line kj/some-lines)) +(defun kj/previous-some-lines () + (interactive) + (previous-line kj/some-lines)) + +;; Repeat commands (e.g., C-x o o o) +(use-package repeat-help + :custom + (repeat-help-key "?" "The default `C-h' tends to interfere.") + :init + (repeat-help-mode 1)) +(repeat-mode 1) + +;; Disable the built-in repeat-mode hinting +;;(setq repeat-echo-function #'ignore) + +;; Spawn or hide a which-key popup +;; (advice-add 'repeat-post-hook :after +;; (defun repeat-help--which-key-popup () +;; (if-let ((cmd (or this-command real-this-command)) +;; (keymap (or repeat-map +;; (repeat--command-property 'repeat-map)))) +;; (run-at-time +;; 0 nil +;; (lambda () +;; (which-key--create-buffer-and-show +;; nil (symbol-value keymap)))) +;; (which-key--hide-popup)))) + +;; Calendar settings. +(setq calendar-week-start-day 1) +;; Show calendar week numbers. +(copy-face font-lock-constant-face 'calendar-iso-week-face) +(set-face-attribute 'calendar-iso-week-face nil + :height 0.7) +(setq calendar-intermonth-text + '(propertize + (format "%2d" + (car + (calendar-iso-from-absolute + (calendar-absolute-from-gregorian (list month day year))))) + 'font-lock-face 'calendar-iso-week-face)) + +;; (setq ispell-local-dictionary "en_US") +;; (add-hook 'text-mode-hook flyspell-mode) +;; (add-hook 'prog-mode-hook flyspell-prog-mode) + +;;; Email settings +(setq message-kill-buffer-on-exit t) ;; After sending a message. + +(let ((google-config-file + (expand-file-name "google.el" user-emacs-directory))) + (when (file-exists-p google-config-file) + (load-file google-config-file))) + +;; Special symbols +(use-package emacs :elpaca nil + :defer 1 + :config + (defvar kj/iso-transl-char-map + '( + ;; fractions that emacs doesn't include + ("1/3" . [?⅓]) + ("1/5" . [?⅕]) + ("1/6" . [?⅙]) + ("1/7" . [?⅐]) + ("1/8" . [?⅛]) + ("1/9" . [?⅑]) + ("1/10" . [?⅒]) + ("2/3" . [?⅔]) + ("2/5" . [?⅖]) + ("3/5" . [?⅗]) + ("3/8" . [?⅜]) + ("4/5" . [?⅘]) + ("5/6" . [?⅚]) + ("5/8" . [?⅝]) + ("7/8" . [?⅞]) + ;; add the emojis I commonly use + (":c" . [?✅]) + (":u" . [?👍]) + (":d" . [?👎]) + (":w" . [?🖐]) + ;; card suits + ("c" . [?♣]) + ("h" . [?♥]) + ("d" . [?♦]) + ("s" . [?♠]))) + (require 'iso-transl) + (iso-transl-define-keys kj/iso-transl-char-map) + :init + (require 'iso-transl)) + +(use-package pcre2el) +(use-package pdf-tools) + +(defvar kj/help-modes '(helpful-mode + help-mode + shortdoc-mode + Man-mode + woman-mode + Info-mode)) + +(defun kj/buffer-help-p (buf act) + "BUF is a help buffer, ignore ACT." + (with-current-buffer buf + (apply 'derived-mode-p kj/help-modes))) + +(add-to-list 'display-buffer-alist + `(kj/buffer-help-p + (display-buffer-reuse-window + display-buffer-reuse-mode-window) + (mode . ,kj/help-modes) + (inhibit-same-window . nil))) + +(use-package helpful + :bind + (([remap describe-key] . 'helpful-key) + ([remap describe-variable] . 'helpful-variable) + ([remap describe-symbol] . 'helpful-symbol) + ([remap describe-command] . 'helpful-command) + ([remap describe-function] . 'helpful-callable))) + +;; Enabled commands +(put 'narrow-to-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(put 'upcase-region 'disabled nil) + +(provide 'kj-init) diff --git a/emacs/.config/emacs/lisp/kj-lib.el b/emacs/.config/emacs/lisp/kj-lib.el new file mode 100644 index 0000000..5df1822 --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-lib.el @@ -0,0 +1,11 @@ +;;; -*- lexical-binding: t; -*- + +(defmacro define-repeating-key (keymap key cmd &optional desc) + `(let ((def + ,(if desc + `'(,desc . ,cmd) + `',cmd))) + (define-key ,keymap ,key def) + (put ',cmd 'repeat-map ',keymap))) + +(provide 'kj-lib) diff --git a/emacs/.config/emacs/lisp/kj-multiple-cursors.el b/emacs/.config/emacs/lisp/kj-multiple-cursors.el new file mode 100644 index 0000000..962193d --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-multiple-cursors.el @@ -0,0 +1,20 @@ +;;; -*- lexical-binding: t; -*- + +(use-package multiple-cursors + :config + (defvar kj/multiple-cursors-map (make-sparse-keymap "cursors")) + (define-repeating-key kj/multiple-cursors-map "." mc/mark-next-like-this "→ this") + (define-repeating-key kj/multiple-cursors-map "," mc/mark-previous-like-this "← this") + (define-repeating-key kj/multiple-cursors-map ">" mc/skip-to-next-like-this "⇥ this") + (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") + (define-repeating-key kj/multiple-cursors-map "<" mc/skip-to-previous-like-this "⇤ this") + (define-repeating-key kj/multiple-cursors-map "*" mc/mark-all-like-this "all like this") + (define-repeating-key kj/multiple-cursors-map "w" mc/mark-next-like-this-word "word") + (define-repeating-key kj/multiple-cursors-map "s" mc/mark-next-like-this-symbol "symbol") + (define-repeating-key kj/multiple-cursors-map "(" mc/mark-all-symbols-like-this-in-defun "symbol defun") + (define-repeating-key kj/multiple-cursors-map (kbd "DEL") mc/unmark-next-like-this "DEL last") + (define-repeating-key kj/multiple-cursors-map (kbd "") mc/unmark-previous-like-this "DEL first") + (define-key kj/multiple-cursors-map (kbd "C-g") '("quit" . ignore)) + (global-set-key (kbd "C-c m") (cons "cursors" kj/multiple-cursors-map))) + +(provide 'kj-multiple-cursors) diff --git a/emacs/.config/emacs/lisp/kj-org.el b/emacs/.config/emacs/lisp/kj-org.el new file mode 100644 index 0000000..b6fda9c --- /dev/null +++ b/emacs/.config/emacs/lisp/kj-org.el @@ -0,0 +1,251 @@ +;;; -*- lexical-binding: t; -*- + +(use-package org + :config + (org-babel-do-load-languages 'org-babel-load-languages + '((emacs-lisp . t) + (sql . t) + (shell . t))) + (setq org-confirm-babel-evaluate nil + org-return-follows-link t + ) + + ;; Install the link type + (org-add-link-type "notmuch" 'org-notmuch-open) + (add-hook 'org-store-link-functions 'org-notmuch-store-link) + + (defun org-notmuch-store-link () + "Store a link to a notmuch search or message." + (when (eq major-mode 'notmuch-show-mode) + (let* ((message-id (notmuch-show-get-prop :id)) + (subject (notmuch-show-get-subject)) + (to (notmuch-show-get-to)) + (from (notmuch-show-get-from)) + desc link) + (org-store-link-props :type "notmuch" :from from :to to + :subject subject :message-id message-id) + (setq desc (org-email-link-description)) + (setq link (concat "notmuch:" "id:" message-id)) + (org-add-link-props :link link :description desc) + link))) + + (defun org-notmuch-open (path) + "Follow a notmuch message link specified by PATH." + (org-notmuch-follow-link path)) + + (defun org-notmuch-follow-link (search) + "Follow a notmuch link to SEARCH. + +Can link to more than one message, if so all matching messages are shown." + (require 'notmuch) + (notmuch-show (org-link-unescape search))) + + (org-add-link-type "notmuch-search" 'org-notmuch-search-open) + (add-hook 'org-store-link-functions 'org-notmuch-search-store-link) + + (defun org-notmuch-search-store-link () + "Store a link to a notmuch search or message." + (when (eq major-mode 'notmuch-search-mode) + (let ((link (concat "notmuch-search:" + (org-link-escape notmuch-search-query-string))) + (desc (concat "Notmuch search: " notmuch-search-query-string))) + (org-store-link-props :type "notmuch-search" + :link link + :description desc) + link))) + + (defun org-notmuch-search-open (path) + "Follow a notmuch message link specified by PATH." + (message path) + (org-notmuch-search-follow-link path)) + + (defun org-notmuch-search-follow-link (search) + "Follow a notmuch link by displaying SEARCH in notmuch-search mode." + (require 'notmuch) + (notmuch-search (org-link-unescape search))) + + ;; If you use `org' and don't want your org files in the default location below, + ;; change `org-directory'. It must be set before org loads! + (setq org-directory "~/org/") + (setq org-todo-keywords + '((sequence + "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))) + (setq org-refile-use-outline-path nil) + (setq org-refile-targets '((nil . (:maxlevel . 2)))) + (setq org-log-into-drawer t) + (setq org-agenda-log-mode-items '(closed clock state)) + (setq org-agenda-start-day nil) + (setq org-agenda-block-separator nil) + (setq org-agenda-compact-blocks t) + (setq org-agenda-start-with-log-mode nil) + (setq org-habit-show-all-today t) + (setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------")) + (setq org-roam-directory (concat org-directory "roam/")) + (setq-default org-agenda-files '()) + (dolist (file '("tasks.org" + "running-2022.org")) + (add-to-list 'org-agenda-files (concat org-roam-directory file))) + (setq org-roam-db-location (concat org-roam-directory "/org-roam.db")) + (setq org-export-with-toc nil) + (setq deft-directory org-directory) + (setq deft-recursive t) + ;; Org html export + (setq org-html-htmlize-output-type 'css) + ;; Website publish settings. + (defvar kj/publish-tag "publish") + (defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com") + (add-to-list 'org-modules 'org-habit) + + (defvar org-publish-project-alist) + (defun kj/find-agenda-files-containing-tag (tag) + (setq org-agenda-archives-mode nil) + (let* ((org-agenda-archives-mode nil) + (candidates (org-agenda-files nil 'ifmode)) + (matcher (cdr (org-make-tags-matcher tag))) + (files)) + ;; (message "Results:") + (dolist (file candidates files) + (org-check-agenda-file file) + (with-current-buffer (org-get-agenda-file-buffer file) + ;; (message "%S" (org-scan-tags 'agenda matcher nil)) + (when (org-scan-tags 'agenda matcher nil) + (push file files)))))) + + (defun kj/org-publish (&optional project force) + (interactive) + (setq project (or project "all")) + (setq force (or force current-prefix-arg)) + (setq org-agenda-files (list org-roam-directory)) + (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|")) + (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag)) + ;; Disable org babel exports during publish entirely to speed up publish. + ;; This messes up babel output handling. + ;; (org-export-use-babel nil) + (org-babel-default-header-args + (kj/assq-replace '((:exports . "both") + (:eval . "never-export")) + org-babel-default-header-args)) + (org-publish-project-alist + `( + ("static" + :base-directory ,(concat org-roam-directory "/static") + :base-extension ,static-files-re + :recursive t + :publishing-directory ,(concat kj/publish-directory "/static") + :publishing-function org-publish-attachment) + ("source" + :base-directory ,org-roam-directory + :base-extension "org" + :exclude ".*" + :include ,files-to-include + :recursive t + :publishing-directory ,kj/publish-directory + :publishing-function org-publish-attachment) + ("html" + :base-directory ,org-roam-directory + :base-extension "org" + :recursive t + :exclude ".*" + :include ,files-to-include + :publishing-directory ,kj/publish-directory + :publishing-function org-html-publish-to-html + + :with-broken-links t + :with-toc nil + :with-latex t + :with-drawers t + :with-title t + :section-numbers nil + + ;; HTML options + :html-toplevel-hlevel 2 + :html-preamble "" + :html-postamble "" + :html-html5-fancy t + :html-doctype "html5" + :html-head "" + :html-head-include-scripts nil + :html-head-include-default-style nil + :html-container article) + + ("all" :components ("static" "source" "html"))))) + + (org-publish project force))) + ; (setq org-appear-autolinks t) + ; (use-package! org-appear + ; :hook (org-mode . org-appear-mode)) + + (setq org-log-done 'time) + (setq org-todo-keywords + '((sequence + "TODO(t)" ; A task that needs doing & is ready to do + "PROJ(p)" ; A project, which usually contains other tasks + "LOOP(r)" ; A recurring task + "STRT(s)" ; A task that is in progress + "WAIT(w)" ; Something external is holding up this task + "HOLD(h)" ; This task is paused/on hold because of me + "IDEA(i)" ; An unconfirmed and unapproved task or notion + "|" + "DONE(d!)" ; Task successfully completed + "KILL(k)") ; Task was cancelled, aborted or is no longer applicable + (sequence + "[ ](T)" ; A task that needs doing + "[-](S)" ; Task is in progress + "[?](W)" ; Task is being held up or paused + "|" + "[X](D)") ; Task was completed + (sequence + "|" + "OKAY(o)" + "YES(y)" + "NO(n)"))) + + (setq org-journal-file-type 'weekly) + (setq org-journal-dir org-roam-directory) + (setq org-journal-file-format "journal-%Y-%m-%d.org") + (setq org-journal-enable-agenda-integration t) + (defun kj/org-journal-init () + (interactive) + (save-excursion + (goto-char (point-min)) + (org-id-get-create) + (org-set-property "category" "journal"))) + + (defun kj/org-journal-file-header (time) + (format-time-string "#+title: Week of %F (%W)\n" + (org-journal--convert-time-to-file-type-time time))) + (setq org-journal-file-header #'kj/org-journal-file-header) + (add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init) + + ;; Org + (add-to-list 'org-export-backends 'md) + + (require 'org-tempo)) + +(defun org-archive-done-tasks () + (interactive) + (org-map-entries + (lambda () + (org-archive-subtree) + (setq org-map-continue-from (org-element-property :begin (org-element-at-point)))) + "/DONE" 'file)) + +(use-package org-pomodoro + :ensure t + :after org + :commands (org-pomodoro) + :config + (setq + org-pomodoro-manual-break t + org-pomodoro-time-format "%m" + org-pomodoro-format "🍅%s" + org-pomodoro-play-sounds nil + alert-user-configuration (quote ((((:category . "org-pomodoro")) notifications nil)))) + :bind + (("C-c o p" . org-pomodoro))) + +(use-package org-tidy + :after org + :hook (org-mode . org-tidy-mode)) + +(provide 'kj-org) diff --git a/emacs/.config/emacs/templates b/emacs/.config/emacs/templates new file mode 100644 index 0000000..cb4219c --- /dev/null +++ b/emacs/.config/emacs/templates @@ -0,0 +1,29 @@ +;; ~/.config/emacs/templates -*- mode: lisp-data; -*- + +fundamental-mode + +(today (format-time-string "%Y-%m-%d")) + +text-mode + +(cut "--8<---------------cut here---------------start------------->8---" n r n + "--8<---------------cut here---------------end--------------->8---" n) + +emacs-lisp-mode + +(header ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) + " -- " p " -*- lexical-binding: t -*-" n + ";;; Commentary:" n ";;; Code:" n n) +(provide "(provide '" (file-name-base (or (buffer-file-name) (buffer-name))) ")" n + ";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) + " ends here" n) + +c++-mode + +(ns "namespace " (s ns) "{" n r n "} // namespace " (s ns)) +(namespace "namespace " (s ns) "{" n r n "} // namespace " (s ns)) + +;; Local Variables: +;; outline-regexp: "[a-z]" +;; eval: (outline-minor-mode 1) +;; End: -- cgit v1.2.3