emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3efe59a: Make newline-and-indent take a numeric pre


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 3efe59a: Make newline-and-indent take a numeric prefix
Date: Sat, 17 Aug 2019 19:47:25 -0400 (EDT)

branch: master
commit 3efe59a8dd81e71597542e83eefc33fc6faab9a1
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make newline-and-indent take a numeric prefix
    
    * lisp/simple.el (newline-and-indent): Take a prefix argument to
    say how many times to perform its action (bug#10927).
---
 etc/NEWS       |  5 +++++
 lisp/simple.el | 15 ++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 53408a8..25c5ce6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -417,6 +417,11 @@ RGB triplets with a single hexadecimal digit per component.
 
 * 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'.
 
diff --git a/lisp/simple.el b/lisp/simple.el
index fdf7d89..84497c3 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]