From 3694b0d4111554244c0bed7d786d6d4d6035f8a4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 21 Jan 2019 22:07:31 -0500 Subject: [PATCH] Standardize M-RET/M-S-RET as an "add new item" key --- modules/config/default/autoload/default.el | 19 +++++++++++++++++++ modules/config/default/config.el | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/config/default/autoload/default.el b/modules/config/default/autoload/default.el index 9d9bbd56f..c84a295fa 100644 --- a/modules/config/default/autoload/default.el +++ b/modules/config/default/autoload/default.el @@ -91,3 +91,22 @@ If ARG (universal argument), runs `compile' from the current directory." (interactive) (cond ((featurep! :completion ivy) (+ivy/tasks) (featurep! :completion helm) (+helm/tasks)))) + +;;;###autoload +(defun +default/newline-above () + "Insert an indented new line before the current one." + (interactive) + (if (featurep 'evil) + (call-interactively 'evil-open-above) + (beginning-of-line) + (save-excursion (newline)) + (indent-according-to-mode))) + +;;;###autoload +(defun +default/newline-below () + "Insert an indented new line after the current one." + (interactive) + (if (featurep 'evil) + (call-interactively 'evil-open-below) + (end-of-line) + (newline-and-indent))) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index 7f6c9a765..df3fb9c8b 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -147,7 +147,11 @@ ;; Pressing it again will send you to the true bol. Same goes for C-e, except ;; it will ignore comments+trailing whitespace before jumping to eol. (map! :gi "C-a" #'doom/backward-to-bol-or-indent - :gi "C-e" #'doom/forward-to-last-non-comment-or-eol) + :gi "C-e" #'doom/forward-to-last-non-comment-or-eol + ;; Standardize the behavior of M-RET/M-S-RET as a "add new item + ;; below/above" key. + :gi [M-return] #'+default/newline-below + :gi [M-S-return] #'+default/newline-above) (if (featurep 'evil) (load! "+evil-bindings")