From 710dfe7cd5620d6bec2ddc7b776cddacf2c640a1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 5 Jan 2022 11:23:26 -0600 Subject: Add wrap-region and modify expand-region to match --- lisp/+expand-region.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lisp/+expand-region.el (limited to 'lisp/+expand-region.el') 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 @@ +;;; +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 -- cgit 1.4.1-21-gabe81