From 44325c98d87645858f5f71eddfe8f6b12525d37c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 16 Oct 2024 22:28:56 +0200 Subject: emacs: Rework ‘e/join-current-and-next-line’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/emacs/editing.el | 16 +++++++++++----- .config/emacs/modules/mm-keybindings.el | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to '.config/emacs') diff --git a/.config/emacs/editing.el b/.config/emacs/editing.el index 67d73eb..1920c91 100644 --- a/.config/emacs/editing.el +++ b/.config/emacs/editing.el @@ -16,12 +16,18 @@ This function wraps `align-regexp' and implicitly prepends REGEXP with (end (max (mark) (point)))) (align-regexp start end regexp 1 1 repeat))) -(defun e/join-current-and-next-line () +(defun e/join-current-and-next-line (&optional arg beg end) "Join the current- and next lines. -Join the next line after point to the line point is currently on. This -is in effect the reverse of `join-line'." - (interactive) - (delete-indentation 1)) +This function is identical to `join-line' but it joins the current line +with the next one instead of the previous one." + (interactive + (progn (barf-if-buffer-read-only) + (cons current-prefix-arg + (and (use-region-p) + (list (region-beginning) (region-end)))))) + (delete-indentation + (unless (or beg end) (not arg)) + beg end)) (defun e/transpose-previous-chars () "Transpose the two characters preceeding point. diff --git a/.config/emacs/modules/mm-keybindings.el b/.config/emacs/modules/mm-keybindings.el index d01b447..3eab35c 100644 --- a/.config/emacs/modules/mm-keybindings.el +++ b/.config/emacs/modules/mm-keybindings.el @@ -69,7 +69,9 @@ the first command is remapped to the second command." mark-sexp e/mark-entire-sexp transpose-chars e/transpose-previous-chars - transpose-lines e/transpose-current-and-next-lines) + transpose-lines e/transpose-current-and-next-lines + + delete-indentation e/join-current-and-next-line) (with-eval-after-load 'cc-vars (setopt c-backspace-function #'backward-delete-char)) @@ -96,9 +98,7 @@ the first command is remapped to the second command." "C-c d" #'duplicate-dwim "C-c t a" #'e/align-regexp "C-c t f" #'fill-paragraph - "C-c t s" #'sort-lines - "C-c j" #'e/join-current-and-next-line - "C-c J" #'join-line) + "C-c t s" #'sort-lines) (mm-keymap-set-repeating global-map "j" #'e/join-current-and-next-line -- cgit v1.2.3