From 2243b1e4effdeda0cec9cde4a49fd9ac8a5f9271 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 16 Jan 2022 23:13:11 -0600 Subject: Dammit, lots of changes --- init.el | 90 ++++++++++++++++++++++++++++++++++++++++----------------- lisp/+eshell.el | 20 +++++++++++++ lisp/+mwim.el | 42 +++++++++++++++++++++++++++ lisp/+setup.el | 26 ++++++++++++----- lisp/+sly.el | 18 ++++++++++++ lisp/+vterm.el | 19 ++++++++++++ 6 files changed, 181 insertions(+), 34 deletions(-) create mode 100644 lisp/+mwim.el create mode 100644 lisp/+sly.el create mode 100644 lisp/+vterm.el diff --git a/init.el b/init.el index 4136271..9f4d2fe 100644 --- a/init.el +++ b/init.el @@ -295,23 +295,25 @@ eshell-scroll-to-bottom-on-input 'all eshell-smart-space-goes-to-end t eshell-where-to-jump 'begin) - (add-hook 'eshell-mode-hook - (defun +eshell@setup () - "Eshell improperly does loading. Gah." - (interactive) - (dolist (setting `((outline-regexp . ,eshell-prompt-regexp) - (page-delimiter . ,eshell-prompt-regexp) - (imenu-generic-expression - . ,`(("Prompt" - ,(concat eshell-prompt-regexp - "\\(.*\\)") - 1))))) - (set (make-local-variable (car setting)) (cdr setting))) - (dolist (binding `(("C-d" . +eshell-quit-or-delete-char))) - (define-key eshell-mode-map + (setf (alist-get 'eshell-mode mwim-beginning-of-line-function) + #'eshell-bol) + (+eshell-eval-after-load + ;; Set local settings + (dolist (setting (list (cons 'outline-regexp eshell-prompt-regexp) + (cons 'page-delimiter eshell-prompt-regexp) + (cons 'imenu-generic-expression + (list "Prompt" + (concat eshell-prompt-regexp + "\\(.*\\)") + 1)))) + (set (make-local-variable (car setting)) (cdr setting))) + ;; Bind keys + (dolist (binding '(("C-d" . +eshell-quit-or-delete-char))) + (define-key eshell-mode-map (kbd (car binding)) (cdr binding))) - (dolist (environment `(("PAGER" . "cat"))) - (setenv (car environment) (cdr environment)))))) + ;; Environment variables + (dolist (environment '(("PAGER" . "cat"))) + (setenv (car environment) (cdr environment))))) (setup eww (:also-load +eww) @@ -560,6 +562,10 @@ (with-eval-after-load 'user-save (advice-add 'org-export-dispatch :before 'user-save-run-hooks))) +(setup password-cache + (:option password-cache t + password-cache-expiry (* 60 60))) + (setup prog (:local-set comment-auto-fill-only-comments t) (:hook #'prettify-symbols-mode @@ -591,7 +597,8 @@ (setup time (:option display-time-format "%H:%M" - display-time-default-load-average nil) + display-time-default-load-average nil + display-time-mail-file :disable) (display-time-mode +1)) (setup (:straight 0x0) @@ -663,12 +670,6 @@ ;;cape-dict)) (add-to-list 'completion-at-point-functions fn :append))))) -(setup (:straight (capf-autosuggest - :host nil - :repo "https://repo.or.cz/emacs-capf-autosuggest.git")) - (:hook-into eshell-mode - comint-mode)) - (setup (:straight circe) (:require _circe +circe) @@ -842,6 +843,8 @@ (add-hook 'modus-themes-after-load-theme-hook #'circe-nick-color-reset)) (add-hook 'kill-emacs-hook #'+circe-quit-all@kill-emacs)) +(setup (:straight clhs)) + (setup (:straight consult) (:also-load +consult) ;; from Consult wiki @@ -1062,6 +1065,11 @@ See also `crux-reopen-as-root-mode'." (setup (:straight eshell-syntax-highlighting) (:hook-into eshell-mode)) +(setup (:straight eshell-vterm) + (:load-after eshell) + (defalias 'eshell/v 'eshell-exec-visual) + (eshell-vterm-mode +1)) + (setup (:straight-when exec-path-from-shell (eq system-system 'linux)) (require 'exec-path-from-shell) @@ -1130,7 +1138,7 @@ See also `crux-reopen-as-root-mode'." (let (schemes) (dolist (scheme '(("scheme" . geiser-chez) ; chez ("petite" . geiser-chez) ; petite - ("csi" . geiser-chicken) ; chicken + ("csi" . geiser-chicken) ; chicken ("gsi" . geiser-gambit) ("gosh" . geiser-gauche) ("guile" . geiser-guile) @@ -1276,8 +1284,12 @@ See also `crux-reopen-as-root-mode'." (+sunrise-sunset 'modus-themes-load-operandi 'modus-themes-load-vivendi)) (setup (:straight mwim) - (:+key "C-a" #'mwim-beginning - "C-e" #'mwim-end)) + (:require +mwim) + (:option +mwim-passthrough-modes '(comint-mode + eshell-mode + vterm-mode)) + (:+key "C-a" #'+mwim-beginning-maybe + "C-e" #'+mwim-end-maybe)) (setup (:straight orderless) (:also-load +orderless) @@ -1392,6 +1404,17 @@ See also `crux-reopen-as-root-mode'." +modeline-position))) (simple-modeline-mode +1)) +(setup (:straight-when sly + (defvar +lisp-bin (executable-find "sbcl"))) + (:also-load sly-autoloads + +sly) + (:option inferior-lisp-program +lisp-bin + sly-kill-without-query-p t) + (:with-feature sly-mrepl + (dolist (key '("RET" "")) + (:bind key #'sly-mrepl-return-at-end)) + (:bind "C-c C-c" #'sly-mrepl-return))) + (setup (:straight smartscan) (:with-map smartscan-map (:bind "M-'" nil)) @@ -1423,6 +1446,10 @@ See also `crux-reopen-as-root-mode'." (auto-save-visited-mode -1) (super-save-mode +1)) +(setup (:straight-when systemd + (executable-find "systemd")) + (:option systemd-man-function 'woman)) + (setup (:straight (titlecase :host github :repo "duckwork/titlecase.el" @@ -1541,6 +1568,17 @@ See also `crux-reopen-as-root-mode'." (setup (:straight vlf) (:require vlf-setup)) +(setup (:straight-when vterm + (and module-file-suffix + (executable-find "cmake"))) + (:also-load +vterm) + (:option vterm-always-compile-module t + vterm-buffer-name-string "vterm: %s" + vterm-max-scrollback 100000 ; max allowed by vterm-module.h + ) + (advice-add 'counsel-yank-pop-action :around + #'+vterm-counsel-yank-pop-action)) + (setup (:straight web-mode) (setf (alist-get (rx "." (or "htm" "html" "phtml" "tpl.php" "asp" "gsp" "jsp" "ascx" "aspx" diff --git a/lisp/+eshell.el b/lisp/+eshell.el index bd92b03..1f8677c 100644 --- a/lisp/+eshell.el +++ b/lisp/+eshell.el @@ -76,5 +76,25 @@ any directory proferred by `consult-dir'." (add-hook 'eshell-post-command-hook #'eshell-record-args nil t) (remove-hook 'eshell-post-command-hook #'eshell-record-args t))) +;;;###autoload +(defmacro +eshell-eval-after-load (&rest forms) + "Execute FORMS after Eshell is loaded. +If Eshell is already loaded in the session, immediately execute +forms. + +I wrote this because Eshell doesn't properly do loading or +something, it's really annoying to work with." + (declare (indent 0)) + `(progn + (defun +eshell@setup () + "Setup the Eshell session." + ,@forms) + (when (featurep 'eshell) + `(dolist (buf (buffer-list)) + (with-current-buffer buf + (when (derived-mode-p 'eshell-mode) + (+eshell@setup))))) + '(add-hook 'eshell-mode-hook #'+eshell@setup))) + (provide '+eshell) ;;; +eshell.el ends here diff --git a/lisp/+mwim.el b/lisp/+mwim.el new file mode 100644 index 0000000..1c8ef5c --- /dev/null +++ b/lisp/+mwim.el @@ -0,0 +1,42 @@ +;;; +mwim.el --- Extras -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(require 'seq) + +(defgroup +mwim nil + "Extra `mwim' customizations." + :group 'mwim) + +(defcustom +mwim-passthrough-modes nil + "Modes to not move-where-I-mean." + :type '(repeat function)) + +(defun +mwim-beginning-maybe (&optional arg) + "Perform `mwim-beginning', maybe. +Will just do \\[beginning-of-line] in one of +`+mwim-passthrough-modes'." + (interactive) + (if (apply #'derived-mode-p +mwim-passthrough-modes) + (let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode)))) + (key "C-a")) + (funcall (or (keymap-lookup this-mode-map key t t) + (keymap-lookup (current-global-map) key t t)))) + (call-interactively #'mwim-beginning))) + +(defun +mwim-end-maybe (&optional arg) + "Perform `mwim-beginning', maybe. +Will just do \\[end-of-line] in one of +`+mwim-passthrough-modes'." + (interactive) + (if (apply #'derived-mode-p +mwim-passthrough-modes) + (let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode)))) + (key "C-e")) + (funcall (or (keymap-lookup this-mode-map key t t) + (keymap-lookup (current-global-map) key t t)))) + (call-interactively #'mwim-end))) + +(provide '+mwim) +;;; +mwim.el ends here diff --git a/lisp/+setup.el b/lisp/+setup.el index 6c8e31e..367fb01 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el @@ -49,6 +49,11 @@ :repeatable t :after-loaded t) +(defun +setup-straight-shorthand (sexp) + "Shorthand for `:straight' and other local macros." + (let ((recipe (cadr sexp))) + (or (car-safe recipe) recipe))) + (setup-define :straight (lambda (recipe) `(unless (ignore-errors (straight-use-package ',recipe) t) @@ -59,11 +64,18 @@ This macro can be used as HEAD, and will replace itself with the first RECIPE's package." :repeatable t - :shorthand (lambda (sexp) - (let ((recipe (cadr sexp))) - (if (consp recipe) - (car recipe) - recipe)))) + :shorthand #'+setup-straight-shorthand) + +(setup-define :straight-after + (lambda (recipe feature) + `(with-eval-after-load ,feature + (setup (:straight ,recipe)))) + :indent 1 + :documentation + "Install RECIPE with `straight-use-package', after FEATURE. +This macro can be used as HEAD, and will replace itself with the +first RECIPE's package." + :shorthand #'+setup-straight-shorthand) (setup-define :straight-when (lambda (recipe condition) @@ -80,9 +92,7 @@ evaluating the body. This macro can be used as HEAD, and will replace itself with the RECIPE's package." :repeatable 2 :indent 1 - :shorthand (lambda (sexp) - (let ((recipe (cadr sexp))) - (if (consp recipe) (car recipe) recipe)))) + :shorthand #'+setup-straight-shorthand) (provide '+setup) ;;; +setup.el ends here diff --git a/lisp/+sly.el b/lisp/+sly.el new file mode 100644 index 0000000..8d8fd6a --- /dev/null +++ b/lisp/+sly.el @@ -0,0 +1,18 @@ +;;; +sly.el --- Sly customizations -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(require 'sly) + +(defun sly-mrepl-return-at-end () + (interactive) + (if (<= (point-max) (point)) + (sly-mrepl-return) + (if (bound-and-true-p paredit-mode) + (paredit-newline) + (electric-newline-and-maybe-indent)))) + +(provide '+sly) +;;; +sly.el ends here diff --git a/lisp/+vterm.el b/lisp/+vterm.el new file mode 100644 index 0000000..66e226b --- /dev/null +++ b/lisp/+vterm.el @@ -0,0 +1,19 @@ +;;; +vterm.el --- Vterm extras -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(require +vterm) + +(defun +vterm-counsel-yank-pop-action (orig-fun &rest args) + (if (equal major-mode 'vterm-mode) + (let ((inhibit-read-only t) + (yank-undo-function (lambda (_start _end) (vterm-undo)))) + (cl-letf (((symbol-function 'insert-for-yank) + (lambda (str) (vterm-send-string str t)))) + (apply orig-fun args))) + (apply orig-fun args))) + +(provide '+vterm) +;;; +vterm.el ends here -- cgit 1.4.1-21-gabe81