Add wrap-region and modify expand-region to match

This commit is contained in:
Case Duckworth 2022-01-05 11:23:26 -06:00
parent 1b12caa6b8
commit 710dfe7cd5
2 changed files with 41 additions and 1 deletions

18
init.el
View File

@ -944,7 +944,10 @@ See also `crux-reopen-as-root-mode'."
(exec-path-from-shell-initialize))
(setup (:straight expand-region)
(:+key "C-=" #'er/expand-region))
(:also-load +expand-region)
(:option expand-region-fast-keys-enabled nil)
(:+key "C-=" #'er/expand-region
"C--" #'+er/contract-or-negative-argument))
(setup (:straight (fill-sentences-correctly
:host github
@ -1303,6 +1306,19 @@ See also `crux-reopen-as-root-mode'."
whitespace-cleanup-mode-only-if-initially-clean nil)
(global-whitespace-cleanup-mode +1))
(setup (:straight wrap-region)
(:require wrap-region)
(wrap-region-add-wrappers
'(("*" "*" nil org-mode)
("~" "~" nil org-mode)
("/" "/" nil org-mode)
("=" "=" nil org-mode)
("+" "+" nil org-mode)
("_" "_" nil org-mode)
("$" "$" nil (org-mode latex-mode))))
(:hook-into org-mode
latex-mode))
(setup (:straight zoom-frm))
(setup (:straight zzz-to-char)

24
lisp/+expand-region.el Normal file
View File

@ -0,0 +1,24 @@
;;; +expand-region.el -*- lexical-binding: t; -*-
;;; Commentary:
;;
;;; Code:
;; Because of `wrap-region', I can't use `expand-region-fast-keys-enabled'. So
;; instead of that, I'm adding this to the binding to C--, but I also want to be
;; able to use the negative argument. So there's this.
(defun +er/contract-or-negative-argument (arg)
"Contract the region if the last command expanded it.
Otherwise, pass the ARG as a negative argument."
(interactive "p")
(cond ((memq last-command '(er/expand-region
er/contract-region
+er/contract-or-negative-argument))
(er/contract-region arg))
(t (call-interactively #'negative-argument))))
(provide '+expand-region)
;;; +expand-region.el ends here