about summary refs log tree commit diff stats
path: root/lisp/+expand-region.el
blob: 8aac3cecda8faa9b6e98ec224d3d08c969c8ba0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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