aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-01-22 16:56:57 -0500
committerStefan Monnier2021-01-22 16:56:57 -0500
commitb9d0cdcacbd3da93b4ebfa10d778efb618881ccc (patch)
treeb64f3e1e9bd26c5d3843714714ac8ef348551385
parentba25a82855a2c03c25fec83f3056c166b692e94f (diff)
downloademacs-b9d0cdcacbd3da93b4ebfa10d778efb618881ccc.tar.gz
emacs-b9d0cdcacbd3da93b4ebfa10d778efb618881ccc.zip
* lisp/simple.el (newline-and-indent): Disable `electric-indent-mode`
With `electric-indent-mode` enabled, `newline-and-indent` ends up indenting 3 times: once for the original line and twice on the new line. `reindent-then-newline-and-indent` is even worse, indenting twice both lines. None of those commands should be affected by `electric-indent-mode` since they even explicitly say in their name when and how they do indentation. (reindent-then-newline-and-indent): Temporarily disable `electric-indent-mode` as well.
-rw-r--r--lisp/simple.el10
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 2c6e3916cd4..8d4e4a7a6bb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -820,9 +820,10 @@ With ARG, perform this action that many times."
820 (delete-horizontal-space t) 820 (delete-horizontal-space t)
821 (unless arg 821 (unless arg
822 (setq arg 1)) 822 (setq arg 1))
823 (dotimes (_ arg) 823 (let ((electric-indent-mode nil))
824 (newline nil t) 824 (dotimes (_ arg)
825 (indent-according-to-mode))) 825 (newline nil t)
826 (indent-according-to-mode))))
826 827
827(defun reindent-then-newline-and-indent () 828(defun reindent-then-newline-and-indent ()
828 "Reindent current line, insert newline, then indent the new line. 829 "Reindent current line, insert newline, then indent the new line.
@@ -832,7 +833,8 @@ In programming language modes, this is the same as TAB.
832In some text modes, where TAB inserts a tab, this indents to the 833In some text modes, where TAB inserts a tab, this indents to the
833column specified by the function `current-left-margin'." 834column specified by the function `current-left-margin'."
834 (interactive "*") 835 (interactive "*")
835 (let ((pos (point))) 836 (let ((pos (point))
837 (electric-indent-mode nil))
836 ;; Be careful to insert the newline before indenting the line. 838 ;; Be careful to insert the newline before indenting the line.
837 ;; Otherwise, the indentation might be wrong. 839 ;; Otherwise, the indentation might be wrong.
838 (newline) 840 (newline)