From 1effee8ec18d810ba21c208c42cd8ba6b3c24391 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 19 Oct 2024 17:06:43 +0200 Subject: emacs: Add e/open-line --- .config/emacs/editing.el | 12 ++++++++++++ .config/emacs/modules/mm-keybindings.el | 25 +++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.config/emacs/editing.el b/.config/emacs/editing.el index 1920c91..f635705 100644 --- a/.config/emacs/editing.el +++ b/.config/emacs/editing.el @@ -144,4 +144,16 @@ screen after scrolling." (interactive) (mm-do-and-center #'cua-scroll-up)) +(defun e/open-line (arg) + "Insert and move to a new empty line after point. +With prefix argument ARG, inserts and moves to a new empty line before +point." + (interactive "P") + (end-of-line) + (newline-and-indent) + (when arg + (transpose-lines 1) + (previous-line 2) + (end-of-line))) + (provide 'editing) diff --git a/.config/emacs/modules/mm-keybindings.el b/.config/emacs/modules/mm-keybindings.el index dc49261..1cadcb8 100644 --- a/.config/emacs/modules/mm-keybindings.el +++ b/.config/emacs/modules/mm-keybindings.el @@ -63,28 +63,33 @@ the first command is remapped to the second command." ;;; Enable Repeat Bindings +(defun mm-enable-repeat-mode () + "Enable `repeat-mode' without polluting the echo area." + (mm-with-suppressed-output + (repeat-mode))) + (use-package repeat - :init - (repeat-mode)) + :hook (after-init . mm-enable-repeat-mode) + :custom + (repeat-exit-timeout 5)) ;;; Remap Existing Bindings (mm-keymap-remap global-map backward-delete-char-untabify backward-delete-char - kill-ring-save e/kill-ring-save-dwim capitalize-word capitalize-dwim downcase-word downcase-dwim upcase-word upcase-dwim - mark-word e/mark-entire-word - mark-sexp e/mark-entire-sexp - - transpose-chars e/transpose-previous-chars - transpose-lines e/transpose-current-and-next-lines - - delete-indentation e/join-current-and-next-line) + delete-indentation e/join-current-and-next-line + kill-ring-save e/kill-ring-save-dwim + mark-sexp e/mark-entire-sexp + mark-word e/mark-entire-word + open-line e/open-line + transpose-chars e/transpose-previous-chars + transpose-lines e/transpose-current-and-next-lines) (with-eval-after-load 'cc-vars (setopt c-backspace-function #'backward-delete-char)) -- cgit v1.2.3