Emacs 30.1!!!

This commit is contained in:
Alexander Rosenberg 2025-02-21 17:42:54 -08:00
parent 226ea54105
commit 89e010474f
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
3 changed files with 152 additions and 1158 deletions

View File

@ -61,7 +61,8 @@ appear at most once to denote \"all remaining modules\"."
:type 'boolean)
(defcustom eshell-starship-overridden-remote-methods
'("docker" "podman" "kubernetes" "doas" "su" "sudo" "sudoedit")
'("docker" "podman" "kubernetes" "doas" "su" "sudo" "sudoedit" "dockercp"
"podmancp" "toolbox" "distrobox" "flatpak" "apptainer" "nspawn" "run0")
"List of `file-remote-p' mwthods that should NOT be considered remote.
Any eshell buffer with a `default-directory' managed by one of these methods
will not be considered remote and all modules that would be disabled because of
@ -430,7 +431,7 @@ should be as for `eshell-starship--git-interpret-branch-status'."
(not (zerop behind)))
(when merge-conflicts "=")
(when stash "$")
(apply 'string (sort (seq-uniq status-chars) #'<)))))
(apply 'string (sort (seq-uniq status-chars))))))
(defun eshell-starship--git-current-operation ()
"Return the current git operation.
@ -758,7 +759,7 @@ This does not mean anything if pyenv-mode is not installed.")
:predicate
(lambda ()
(member (file-remote-p default-directory 'method)
'("doas" "sudo" "su" "sudoedit")))
'("doas" "sudo" "su" "sudoedit" "run0")))
:action
(lambda ()
(format "%s in"
@ -769,7 +770,7 @@ This does not mean anything if pyenv-mode is not installed.")
(eshell-starship-defmodule newline
:predicate 'always
:action (lambda () (propertize "\n" 'read-only t 'rear-nonsticky t))
:action (lambda () (progn "\n"))
:doc "A newline in the prompt.")
(eshell-starship-defmodule container
@ -777,7 +778,8 @@ This does not mean anything if pyenv-mode is not installed.")
:color "firebrick"
:predicate (lambda ()
(member (file-remote-p default-directory 'method)
'("docker" "podman" "kubernetes")))
'("docker" "podman" "kubernetes" "dockercp" "podmancp"
"toolbox" "distrobox" "flatpak" "apptainer" "nspawn")))
:action (lambda ()
(format "[%s]" (file-remote-p default-directory 'host)))
:reload-on 'cwd
@ -791,8 +793,7 @@ This does not mean anything if pyenv-mode is not installed.")
" " 'face `(:foreground
,(if (= eshell-last-command-status 0)
"lime green"
"red"))
'rear-nonsticky t))
"red"))))
:doc "An arrow that appears next to where you type.")
@ -989,7 +990,9 @@ Return a hash table mapping module names to their output."
(concat
(unless (<= (line-number-at-pos) 3)
"\n")
(eshell-starship--build-module-string)))
(let ((mods (eshell-starship--build-module-string)))
(add-face-text-property 0 (length mods) 'default t mods)
mods)))
(defvar-local eshell-starship--last-prompt-info nil
"A list of the last prompt and the time it took to render it.")
@ -1020,11 +1023,7 @@ Return a hash table mapping module names to their output."
"Enable eshell-starship."
(setq-local eshell-starship--restore-state
(buffer-local-set-state
eshell-prompt-function
'eshell-starship--prompt-function
;; temporary fix until the next version where eshell uses fields
eshell-prompt-regexp (rx bol (? "⬢ [" (+ any) "] ") " ")
eshell-highlight-prompt nil)
eshell-prompt-function 'eshell-starship--prompt-function)
eshell-starship--module-cache (make-hash-table :test 'equal))
(add-hook 'eshell-pre-command-hook
#'eshell-starship--run-module-precmd-actions nil t)

File diff suppressed because it is too large Load Diff

209
init.el
View File

@ -60,7 +60,8 @@
:hook (;;(emacs-lisp-mode . my/-emacs-lisp-mode-setup-evil-lookup)
;;(prog-mode . electric-pair-local-mode)
((text-mode tex-mode prog-mode) . auto-fill-mode)
((text-mode tex-mode prog-mode) . my/-enable-show-trailing-whitespace))
((text-mode tex-mode prog-mode) . my/-enable-show-trailing-whitespace)
((tex-mode prog-mode) . kill-ring-deindent-mode))
:init
(with-eval-after-load 'find-func
(when (and (file-directory-p "~/src/emacs/src/"))
@ -79,8 +80,34 @@
(describe-symbol (cadr form))
(describe-symbol form))))
;; Trusted buffer stuff
(defun my/temp-trust-buffer ()
"Set the current buffers local value of `trusted-content' to \\=:all."
(interactive)
(setq-local trusted-content :all)
(cond
((and (buffer-modified-p) (y-or-n-p "Save and reload buffer?"))
(save-buffer)
(revert-buffer-quick))
((y-or-n-p "Revert buffer?")
(revert-buffer-quick))))
(put 'trusted-content 'permanent-local t)
(defun my/-trusted-content-segment ()
(when (and (derived-mode-p 'prog-mode)
(not buffer-read-only))
(cond
((and (local-variable-p 'trusted-content)
(equal trusted-content :all)
buffer-file-name)
(propertize "[Temp. Trusted]" 'face 'warning))
((not (trusted-content-p))
(propertize "[Untrusted]" 'face 'error)))))
(add-to-list 'mode-line-misc-info
'(:eval (my/-trusted-content-segment)))
;; Increase responsiveness
(setq gc-cons-threshold 80000000
inhibit-compacting-font-caches t
read-process-output-max (* 1024 1024)) ;; 1mb
(global-so-long-mode 1)
@ -138,6 +165,9 @@
;; Visual line mode
(global-visual-line-mode 1)
;; Better line wrapping
(global-visual-wrap-prefix-mode 1)
;; Make some commands easier to enter multiple times
(repeat-mode 1)
@ -226,35 +256,27 @@ Interactively, force the recompile if called with a prefix."
:custom
(auth-sources '("~/.authinfo.gpg")))
(setopt remote-file-name-access-timeout 10)
(use-package tramp
:ensure nil
:custom
(tramp-file-name-with-method "doas")
:config
(add-to-list 'tramp-connection-properties
(list (rx bos "/" (or "podman" "docker") ":")
"direct-async-process" t))
(add-to-list 'tramp-connection-properties
(list (rx bos "/" (or "ssh" "sshx") ":")
"direct-async-process" t))
(add-to-list 'tramp-connection-properties
(list (rx bos "/" (or "sudo" "su" "doas"
"sudoedit")
":")
"direct-async-process" t))
(connection-local-set-profile-variables
'direct-async
'((tramp-direct-async-process . t)))
(connection-local-set-profile-variables
'error-only
'((tramp-verbose . 1)))
(connection-local-set-profiles
'(:method "sudo")
'error-only)
(connection-local-set-profiles
'(:method "doas")
'error-only)
(connection-local-set-profiles
'(:method "su")
'error-only)
(connection-local-set-profiles
'(:method "sudoedit")
'error-only))
(dolist (method '("podman" "docker" "ssh" "sshx" "sudo" "su" "doas"
"sudoedit" "run0" "kubernetes" "dockercp" "podmancp"
"distrobox" "toolbox" "flatpak" "apptainer" "nspawn"))
(let ((inhibit-message t)
(message-log-max nil))
(tramp-enable-method (intern method)))
(connection-local-set-profiles
`(:method ,method)
'error-only 'direct-async)))
(use-package midnight
:ensure nil
@ -757,11 +779,6 @@ With NO-EDGE, return nil if beg or end fall on the edge of the range."
(advice-add 'sp-region-ok-p :around 'my/-evil-cp-region-ok-p-no-string)
(advice-add 'evil-cp--balanced-block-p :around 'my/-evil-cp-block-ok-p-no-string))
;; be (hopefully) safer
(require 'trusted-files)
(keymap-global-set "C-c t" 'trusted-files-map)
(trusted-files-modeline-mode)
;; better lisp editing
(use-package adjust-parens
:hook (prog-mode . adjust-parens-mode)
@ -911,7 +928,11 @@ visual states."
;; better `replace-regexp'
(use-package visual-regexp
:bind (("C-c q" . vr/replace)
("C-M-%" . vr/query-replace)))
("C-M-%" . vr/query-replace))
:init
(let ((val minibuffer-regexp-prompts))
(cl-pushnew "Replace" val :test 'equal)
(setopt minibuffer-regexp-prompts val)))
;; better `align-regexp'
(use-package ialign
@ -975,15 +996,15 @@ visual states."
(defun my/-setup-text-mode-completion-styles ()
(setq-local completion-styles '(basic)))
(orderless-define-completion-style my/orderless-with-initialism
(orderless-matching-styles '(orderless-initialism
orderless-regexp)))
(orderless-matching-styles '(orderless-initialism orderless-regexp)))
(setq orderless-matching-styles '(orderless-regexp)
completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file
(styles basic partial-completion))
(command
(styles my/orderless-with-initialism basic)))))
(styles my/orderless-with-initialism
basic)))))
;; marginalia
(use-package marginalia
@ -1068,6 +1089,15 @@ visual states."
(use-package embark-consult
:hook (embark-collect-mode . consult-preview-at-point-mode))
(use-package completion-preview
:ensure nil
:defer nil
;; adjust parens can shadow this if it is not bound to <tab>
:bind (:map completion-preview-active-mode-map
("<tab>" . #'completion-preview-insert))
:config
(global-completion-preview-mode 1))
;; corfu (autocomplete)
(use-package corfu
:bind (("M-<tab>" . completion-at-point)
@ -1084,7 +1114,7 @@ visual states."
(completion-cycle-threshold completion-cycling))
(apply #'consult-completion-in-region completion-in-region--data))))
(setq corfu-cycle t
corfu-auto t
corfu-auto nil
corfu-on-exact-match nil
corfu-popupinfo-delay '(1.0 . 0.5)
completion-cycle-threshold nil
@ -1187,15 +1217,20 @@ to `posframe-show' if the display is graphical."
;; flymake
(use-package flymake
:config
(require 'consult-flymake))
(require 'consult-flymake)
:custom
(flymake-indicator-type 'margins))
;; flycheck
(use-package flycheck
:hook ((sh-mode emacs-lisp-mode) . trusted-files-flycheck-mode-if-safe)
:hook ((sh-mode emacs-lisp-mode) . my/flycheck-if-trusted)
:custom
(flycheck-indication-mode 'left-margin)
:init
(setq flycheck-display-errors-function nil))
(setq flycheck-display-errors-function nil)
(defun my/flycheck-if-trusted ()
(when (trusted-content-p)
(flycheck-mode))))
(use-package consult-flycheck)
(defun my/sly-notes-at-point (&optional pos buffer)
@ -1337,7 +1372,10 @@ With PROJECT, give diagnostics for all buffers in the current project."
:init
;; (defun my/eglot-in-text-mode-only ()
;; (when (eq major-mode 'text-mode)
;; (trusted-files-eglot-ensure-if-safe)))
;; (eglot-ensure)))
(defun my/eglot-if-trusted ()
(when (trusted-content-p)
(eglot-ensure)))
(defvar my/-eglot-documentation-buffer nil
"Buffer for showing documentation for `my/eglot-documentation-at-point'.")
(define-derived-mode my/eglot-documentation-mode special-mode "Eglot-Doc"
@ -1432,6 +1470,8 @@ With PROJECT, give diagnostics for all buffers in the current project."
:after (project evil)
:bind (:map project-prefix-map
("U" . my/project-gdb))
:custom
(gud-highlight-current-line t)
:config
(setq gdb-debuginfod-enable-setting t)
(defvar my/project-gdb-command nil
@ -1527,11 +1567,13 @@ With PROJECT, give diagnostics for all buffers in the current project."
;; project.el
(use-package project
:defer nil
:bind (([remap project-compile] . my/project-compile-or-default)
:map project-prefix-map
("s" . my/project-eshell)
("u" . my/project-run))
:init
(setq uniquify-dirname-transform #'project-uniquify-dirname-transform)
(defvar eshell-buffer-name)
(defun my/project-eshell (prompt &optional arg)
"Switch to or create an eshell buffer in the current projects root."
@ -1615,6 +1657,13 @@ COMMAND and COMINT are like `compile'."
:config
(evil-set-initial-state 'comint-mode 'normal))
;; editorconfig
(use-package editorconfig
:demand t
:ensure nil
:init
(editorconfig-mode 1))
;; nxml
(use-package nxml-mode
:ensure nil
@ -1718,7 +1767,8 @@ otherwise, call `bibtex-find-text'."
:hook ((LaTeX-mode . turn-on-reftex)
(LaTeX-mode . LaTeX-math-mode)
(LaTeX-mode . my/-setup-LaTeX-mode)
(LaTeX-mode . trusted-files-flycheck-mode-if-safe))
(LaTeX-mode . my/flycheck-if-trusted)
(TeX-mode . kill-ring-deindent-mode))
:bind (:map TeX-mode-map
("C-c ?" . latex-help))
:init
@ -1771,13 +1821,13 @@ otherwise, call `bibtex-find-text'."
;; blueprint
(use-package blueprint-ts-mode
:hook (blueprint-ts-mode . trusted-files-eglot-ensure-if-safe)
:hook (blueprint-ts-mode . my/eglot-if-trusted)
:after eglot)
;; python-ts-mode
(use-package python-ts-mode
:ensure nil
:hook (python-ts-mode . trusted-files-eglot-ensure-if-safe))
:hook (python-ts-mode . my/eglot-if-trusted))
;; python virtual environments
(use-package pyvenv)
(use-package pyenv-mode)
@ -1787,7 +1837,7 @@ otherwise, call `bibtex-find-text'."
;; java-ts-mode
(use-package java-ts-mode
:hook ((java-ts-mode . trusted-files-eglot-ensure-if-safe)
:hook ((java-ts-mode . my/eglot-if-trusted)
(java-ts-mode . my/-setup-java-ts-mode))
:config
(defun my/-setup-java-ts-mode ()
@ -1801,7 +1851,7 @@ otherwise, call `bibtex-find-text'."
;; c-ts-mode
(use-package c-ts-mode
:after evil
:hook ((c-ts-mode c++-ts-mode) . trusted-files-eglot-ensure-if-safe)
:hook ((c-ts-mode c++-ts-mode) . my/eglot-if-trusted)
:init
(setq-default c-ts-mode-indent-offset 4)
:config
@ -1819,12 +1869,13 @@ otherwise, call `bibtex-find-text'."
(use-package glsl-mode)
;; php-mode
(use-package php-mode
:hook (php-mode . trusted-files-eglot-ensure-if-safe))
(use-package php-ts-mode
:ensure nil
:hook (php-mode . my/eglot-if-trusted))
;; web-mode
(use-package web-mode
:hook (web-mode . trusted-files-eglot-ensure-if-safe)
:hook (web-mode . my/eglot-if-trusted)
:init
(add-to-list 'eglot-server-programs
'(web-mode . ("vscode-html-language-server" "--stdio"))))
@ -1832,7 +1883,7 @@ otherwise, call `bibtex-find-text'."
;; JavaScript
(use-package js
:ensure nil
:hook (js-ts-mode . trusted-files-eglot-ensure-if-safe))
:hook (js-ts-mode . my/eglot-if-trusted))
(use-package js-comint
:bind (:map js-ts-mode-map
("C-x C-e" . js-send-last-sexp)
@ -1853,7 +1904,7 @@ otherwise, call `bibtex-find-text'."
;; TypeScript
(use-package typescript-ts-mode
:ensure nil
:hook (typescript-ts-mode . trusted-files-eglot-ensure-if-safe)
:hook (typescript-ts-mode . my/eglot-if-trusted)
:init
(add-to-list 'auto-mode-alist `(,(rx ".ts" eos) . typescript-ts-mode)))
@ -1863,7 +1914,7 @@ otherwise, call `bibtex-find-text'."
(define-hostmode my/poly-web-hostmode
:mode 'web-mode)
(define-innermode my/poly-php-innermode
:mode 'php-mode
:mode 'php-ts-mode
:head-matcher (regexp-quote "<?php")
:tail-matcher (regexp-quote "?>")
:head-mode 'body
@ -1884,24 +1935,24 @@ otherwise, call `bibtex-find-text'."
;; go mode
(use-package go-mode
:defer nil
:hook (go-mode . trusted-files-eglot-ensure-if-safe))
:hook (go-mode . my/eglot-if-trusted))
(use-package go-ts-mode
:ensure nil
:hook (go-ts-mode . trusted-files-eglot-ensure-if-safe))
:hook (go-ts-mode . my/eglot-if-trusted))
;; rust
(use-package rust-mode)
(use-package rust-ts-mode
:ensure nil
:hook (rust-ts-mode . trusted-files-eglot-ensure-if-safe))
:hook (rust-ts-mode . my/eglot-if-trusted))
;; zig
(use-package zig-mode
:hook (zig-mode . trusted-files-eglot-ensure-if-safe))
:hook (zig-mode . my/eglot-if-trusted))
;; lua
(use-package lua-mode
:hook (lua-mode . trusted-files-eglot-ensure-if-safe))
:hook (lua-mode . my/eglot-if-trusted))
;; markdown
(use-package markdown-mode
@ -1923,7 +1974,7 @@ otherwise, call `bibtex-find-text'."
;; json
(use-package json-ts-mode
:hook (json-ts-mode . trusted-files-eglot-ensure-if-safe)
:hook (json-ts-mode . my/eglot-if-trusted)
:custom
(json-ts-mode-indent-offset 4)
:init
@ -1938,7 +1989,7 @@ otherwise, call `bibtex-find-text'."
;; yaml
(use-package yaml-ts-mode
:hook (;; (yaml-ts-mode . trusted-files-eglot-ensure-if-safe)
:hook (;; (yaml-ts-mode . my/eglot-if-trusted)
(yaml-ts-mode . my/-setup-yaml-ts-mode))
:init
(add-to-list 'auto-mode-alist `("\\.clangd\\'" . yaml-ts-mode))
@ -2027,7 +2078,7 @@ line in the block and manually deal with indentation."
:init
(defun my/-lisp-mode-autoconnect-sly ()
(unless (sly-connected-p)
(trusted-files-sly-if-safe)))
(sly)))
(setq inferior-lisp-program "/usr/bin/sbcl")
(defun my/-sly-fix-special-buffers ()
(when (string-match-p (rx bos "*" (* any) "*" eos) (buffer-name))
@ -2309,7 +2360,15 @@ current buffer is a Jupyter buffer, just use that."
(visual-line-mode -1)
(display-line-numbers-mode -1)
(toggle-truncate-lines 1))
(setq mode-line-right-align-edge 'right-margin)
:config
(defun my/-window-dedicated-modeline-segment ()
(let ((dedicated (window-dedicated-p)))
(cond
((eq dedicated t) "[SD]")
(dedicated "[D]"))))
(add-to-list 'mode-line-misc-info
'(:eval (my/-window-dedicated-modeline-segment)))
(evil-define-key '(normal visual motion) calc-edit-mode-map
(kbd "RET") 'calc-edit-return
(kbd "<return>") 'calc-edit-return)
@ -2406,14 +2465,18 @@ argument."
(use-package gnuplot)
(defun my/dir-container-p (&optional dir)
"Return non-nil if DIR is a remote directory that is a container."
(member (file-remote-p default-directory 'method)
'("docker" "podman")))
"Return non-nil if DIR is a remote directory that is a container.
Actually, return the method name."
(car (member (file-remote-p default-directory 'method)
'("docker" "podman" "kubernetes" "dockercp" "podmancp"
"toolbox" "distrobox" "flatpak" "apptainer" "nspawn"))))
(defun my/dir-distrobox-p (&optional dir)
"Return non-nil if DIR is a remote directory that is a distrobox container."
(and (my/dir-container-p dir)
(let ((default-directory (or dir default-directory)))
(executable-find "distrobox-host-exec" t))))
(let ((method (my/dir-container-p dir)))
(or (equal method "distrobox")
(and method
(let ((default-directory (or dir default-directory)))
(executable-find "distrobox-host-exec" t))))))
(defun my/dir-sudo-p (&optional dir)
"Return non-nil if DIR is a remote directory that is sudo, doas, etc.."
(member (file-remote-p (or dir default-directory) 'method)
@ -2495,6 +2558,8 @@ argument."
:bind (:map eshell-mode-map
("TAB" . completion-at-point)
("<tab>" . completion-at-point))
:custom
(eshell-history-append t)
:init
(defun my/-eshell-filter-alias-list ()
(cl-remove-if-not (lambda (elt)
@ -2751,9 +2816,7 @@ ARG is the same as for either of the above functions."
(let (out)
(dolist (bme bookmarks
(append my/-dirvish-base-quick-access-entries
(sort out
(lambda (elt1 elt2)
(string< (car elt1) (car elt2))))))
(sort out :key 'car)))
(let ((name (car bme)))
(let-alist (cdr bme)
(when (and (file-directory-p .filename)
@ -2917,7 +2980,7 @@ R is rest of the arguments to OLDFUN."
;; ledger
(use-package ledger-mode)
(use-package flycheck-ledger
:hook (ledger-mode . trusted-files-flycheck-mode-if-safe))
:hook (ledger-mode . my/flycheck-if-trusted))
;; khard contacts
(require 'khard)
@ -3073,7 +3136,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
;; "Setup up stuff in `org-mu4e-compose' buffers."
;; (setq-local ltex-eglot-variable-save-method 'file)
;; ;; this should come last so it can pick up the above
;; ;; (trusted-files-eglot-ensure-if-safe)
;; ;; (my/eglot-if-trusted)
;; )
;; (add-hook 'org-mu4e-compose-mode-hook #'my/-setup-org-mu4e-compose-mode)
@ -3098,7 +3161,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
("f" . helpful-callable)
("v" . helpful-variable)
("k" . helpful-key)
("o" . helpful-symbol)
("O" . helpful-symbol)
("x" . helpful-command)
("F" . helpful-function)
:map helpful-mode-map
@ -3399,6 +3462,14 @@ one of the normal rainbow-delimiters-depth-N-face faces."
("Europe/Paris" "Paris")
("Asia/Calcutta" "Bangalore")))
;; dictionaries
(use-package dictionary
:defer t
:ensure nil
:custom
(dictionary-read-word-function . #'dictionary-completing-read-word)
(dictionary-read-dictionary-function . #'dictionary-completing-read-dictionary))
;; page break lines
(use-package page-break-lines
:config