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 --- lisp/+eshell.el | 20 ++++++++++++++++++++ lisp/+mwim.el | 42 ++++++++++++++++++++++++++++++++++++++++++ lisp/+setup.el | 26 ++++++++++++++++++-------- lisp/+sly.el | 18 ++++++++++++++++++ lisp/+vterm.el | 19 +++++++++++++++++++ 5 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 lisp/+mwim.el create mode 100644 lisp/+sly.el create mode 100644 lisp/+vterm.el (limited to 'lisp') 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