From d7c1c75c86592d998f53dbc42c10ff664b79a329 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 18 Nov 2024 12:13:23 +0100 Subject: emacs: Move text --- .config/emacs/modules/mm-editing.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '.config/emacs/modules') diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index 5072366..c32776f 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -225,6 +225,24 @@ forces that to not happen." ("C-c i d" . #'decrement-number-at-point)) :commands (increment-number-at-point decrement-number-at-point)) + +;;; Move Line or Region + +(defun mm-move-text-indent (&rest _) + (let ((deactivate deactivate-mark)) + (if (region-active-p) + (indent-region (region-beginning) (region-end)) + (indent-region (line-beginning-position) (line-end-position))) + (setq deactivate-mark deactivate))) + +(use-package move-text + :ensure t + :bind (("M-n" . move-text-down) + ("M-p" . move-text-up)) + :config + (dolist (command #'(move-text-up move-text-down)) + (advice-add command :after #'mm-move-text-indent))) + ;;; Surround With Delimeters -- cgit v1.2.3