diff options
author | Case Duckworth | 2022-01-05 11:23:26 -0600 |
---|---|---|
committer | Case Duckworth | 2022-01-05 11:23:26 -0600 |
commit | 710dfe7cd5620d6bec2ddc7b776cddacf2c640a1 (patch) | |
tree | 73f43b788d589361460e36de7f0c1a998854e2c3 | |
parent | Changes (diff) | |
download | emacs-710dfe7cd5620d6bec2ddc7b776cddacf2c640a1.tar.gz emacs-710dfe7cd5620d6bec2ddc7b776cddacf2c640a1.zip |
Add wrap-region and modify expand-region to match
-rw-r--r-- | init.el | 18 | ||||
-rw-r--r-- | lisp/+expand-region.el | 24 |
2 files changed, 41 insertions, 1 deletions
diff --git a/init.el b/init.el index 13284d1..49e549e 100644 --- a/init.el +++ b/init.el | |||
@@ -944,7 +944,10 @@ See also `crux-reopen-as-root-mode'." | |||
944 | (exec-path-from-shell-initialize)) | 944 | (exec-path-from-shell-initialize)) |
945 | 945 | ||
946 | (setup (:straight expand-region) | 946 | (setup (:straight expand-region) |
947 | (:+key "C-=" #'er/expand-region)) | 947 | (:also-load +expand-region) |
948 | (:option expand-region-fast-keys-enabled nil) | ||
949 | (:+key "C-=" #'er/expand-region | ||
950 | "C--" #'+er/contract-or-negative-argument)) | ||
948 | 951 | ||
949 | (setup (:straight (fill-sentences-correctly | 952 | (setup (:straight (fill-sentences-correctly |
950 | :host github | 953 | :host github |
@@ -1303,6 +1306,19 @@ See also `crux-reopen-as-root-mode'." | |||
1303 | whitespace-cleanup-mode-only-if-initially-clean nil) | 1306 | whitespace-cleanup-mode-only-if-initially-clean nil) |
1304 | (global-whitespace-cleanup-mode +1)) | 1307 | (global-whitespace-cleanup-mode +1)) |
1305 | 1308 | ||
1309 | (setup (:straight wrap-region) | ||
1310 | (:require wrap-region) | ||
1311 | (wrap-region-add-wrappers | ||
1312 | '(("*" "*" nil org-mode) | ||
1313 | ("~" "~" nil org-mode) | ||
1314 | ("/" "/" nil org-mode) | ||
1315 | ("=" "=" nil org-mode) | ||
1316 | ("+" "+" nil org-mode) | ||
1317 | ("_" "_" nil org-mode) | ||
1318 | ("$" "$" nil (org-mode latex-mode)))) | ||
1319 | (:hook-into org-mode | ||
1320 | latex-mode)) | ||
1321 | |||
1306 | (setup (:straight zoom-frm)) | 1322 | (setup (:straight zoom-frm)) |
1307 | 1323 | ||
1308 | (setup (:straight zzz-to-char) | 1324 | (setup (:straight zzz-to-char) |
diff --git a/lisp/+expand-region.el b/lisp/+expand-region.el new file mode 100644 index 0000000..8aac3ce --- /dev/null +++ b/lisp/+expand-region.el | |||
@@ -0,0 +1,24 @@ | |||
1 | ;;; +expand-region.el -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;; | ||
6 | |||
7 | ;;; Code: | ||
8 | |||
9 | ;; Because of `wrap-region', I can't use `expand-region-fast-keys-enabled'. So | ||
10 | ;; instead of that, I'm adding this to the binding to C--, but I also want to be | ||
11 | ;; able to use the negative argument. So there's this. | ||
12 | (defun +er/contract-or-negative-argument (arg) | ||
13 | "Contract the region if the last command expanded it. | ||
14 | Otherwise, pass the ARG as a negative argument." | ||
15 | (interactive "p") | ||
16 | (cond ((memq last-command '(er/expand-region | ||
17 | er/contract-region | ||
18 | +er/contract-or-negative-argument)) | ||
19 | |||
20 | (er/contract-region arg)) | ||
21 | (t (call-interactively #'negative-argument)))) | ||
22 | |||
23 | (provide '+expand-region) | ||
24 | ;;; +expand-region.el ends here | ||