emacs/lisp/+expand-region.el

25 lines
814 B
EmacsLisp

;;; +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