]> git.eshelyaron.com Git - emacs.git/commitdiff
Make newline-and-indent take a numeric prefix
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 17 Aug 2019 23:47:16 +0000 (16:47 -0700)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 17 Aug 2019 23:47:16 +0000 (16:47 -0700)
* lisp/simple.el (newline-and-indent): Take a prefix argument to
say how many times to perform its action (bug#10927).

etc/NEWS
lisp/simple.el

index 53408a871e7734eaac5f306bcf5b715ecc3d6ea1..25c5ce658f06ea6f5d87e84e199f1c4f90217419 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -417,6 +417,11 @@ RGB triplets with a single hexadecimal digit per component.
 \f
 * Editing Changes in Emacs 27.1
 
+---
+** The 'newline-and-indent' command (commonly bound to 'RET' in many
+modes) now takes an optional numeric argument to specify how many
+times is should insert newlines (and indent).
+
 +++
 ** New command 'make-empty-file'.
 
index fdf7d893cde7e1c799a97d7ae5995f5301877a2e..84497c31b254863ef5176f07daf52c86a78b11bb 100644 (file)
@@ -745,16 +745,21 @@ buffer if the variable `delete-trailing-lines' is non-nil."
   ;; Return nil for the benefit of `write-file-functions'.
   nil)
 
-(defun newline-and-indent ()
+(defun newline-and-indent (&optional arg)
   "Insert a newline, then indent according to major mode.
 Indentation is done using the value of `indent-line-function'.
 In programming language modes, this is the same as TAB.
 In some text modes, where TAB inserts a tab, this command indents to the
-column specified by the function `current-left-margin'."
-  (interactive "*")
+column specified by the function `current-left-margin'.
+
+With ARG, perform this action that many times."
+  (interactive "*p")
   (delete-horizontal-space t)
-  (newline nil t)
-  (indent-according-to-mode))
+  (unless arg
+    (setq arg 1))
+  (dotimes (_ arg)
+    (newline nil t)
+    (indent-according-to-mode)))
 
 (defun reindent-then-newline-and-indent ()
   "Reindent current line, insert newline, then indent the new line.