summaryrefslogtreecommitdiff
path: root/.config/emacs
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-19 23:20:04 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-19 23:20:04 +0200
commitb37ed033f65b56d9ec249b25bbfdf27aaef6bc9a (patch)
treedea015983bdb5ea4f039f0241c0eb0072ca2928c /.config/emacs
parent2b46ba373d475c2da8e16d89899977da56ea6718 (diff)
emacs: Implement e/split-line
Diffstat (limited to '.config/emacs')
-rw-r--r--.config/emacs/editing.el17
-rw-r--r--.config/emacs/modules/mm-keybindings.el1
2 files changed, 18 insertions, 0 deletions
diff --git a/.config/emacs/editing.el b/.config/emacs/editing.el
index f635705..951a774 100644
--- a/.config/emacs/editing.el
+++ b/.config/emacs/editing.el
@@ -156,4 +156,21 @@ point."
(previous-line 2)
(end-of-line)))
+(defun e/split-line (&optional above)
+ "Split the line at point.
+Place the contents after point on a new line, indenting the new line
+according to the current major mode. With prefix argument ABOVE the
+contents after point are placed on a new line before point."
+ (interactive "P")
+ (save-excursion
+ (let* ((start (point))
+ (end (pos-eol))
+ (string (buffer-substring start end)))
+ (delete-region start end)
+ (when above
+ (goto-char (1- (pos-bol))))
+ (newline)
+ (insert string)
+ (indent-according-to-mode))))
+
(provide 'editing)
diff --git a/.config/emacs/modules/mm-keybindings.el b/.config/emacs/modules/mm-keybindings.el
index 2bc0971..c1dee93 100644
--- a/.config/emacs/modules/mm-keybindings.el
+++ b/.config/emacs/modules/mm-keybindings.el
@@ -111,6 +111,7 @@ the first command is remapped to the second command."
"C-<prior>" #'backward-page
"C-." #'repeat
+ "C-^" #'e/split-line
"C-/" #'e/mark-line-dwim
"C-c d" #'duplicate-dwim