tweak(default): use electric-indent instead of remapping RET

This is experimental. electric-indent was initially avoided to sidestep
breaking indentation in whitespace-significant major modes with naive
indent logic. Switching to electric-indent will resurface that issue,
but since electric-indent-mode is on by default, I'll leave that to the
modes and modules to deal with on a per-mode basis.
This commit is contained in:
Henrik Lissner 2026-01-17 15:37:42 -05:00
parent d9711a9094
commit 7d0f2032ea
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 6 additions and 12 deletions

View file

@ -1,8 +1,5 @@
;;; config/default/autoload/text.el -*- lexical-binding: t; -*-
;;;###autoload
(defalias '+default/newline #'electric-indent-just-newline)
;;;###autoload
(defun +default/newline-above ()
"Insert an indented new line before the current one."

View file

@ -544,9 +544,9 @@ Continues comments if executed from a commented line."
:gi "TAB" cmds-tab
:gi [tab] cmds-tab))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
;; 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.
;; Smarter readline keybinds (C-a/C-e) for both Emacs and Evil. Changes C-a to
;; also cycle between true BOL and BOI (indentation). Same for C-e, but with
;; EOL and EOI (ignoring comments+trailing whitespace).
(map! :gi "C-a" #'doom/backward-to-bol-or-indent
:gi "C-e" #'doom/forward-to-last-non-comment-or-eol
;; Standardizes the behavior of modified RET to match the behavior of
@ -559,12 +559,9 @@ Continues comments if executed from a commented line."
;; C-<mouse-scroll-down> = text scale decrease
[C-down-mouse-2] (cmd! (text-scale-set 0))
;; auto-indent on newline by default
:gi [remap newline] #'newline-and-indent
;; insert literal newline
:i "S-RET" #'+default/newline
:i [S-return] #'+default/newline
:i "C-j" #'+default/newline
;; Do opposite of `electric-indent-mode'
:i "S-RET" #'electric-newline-and-maybe-indent
:i [S-return] #'electric-newline-and-maybe-indent
;; Add new item below current (without splitting current line).
:gi "C-RET" #'+default/newline-below