diff options
| author | Lars Ingebrigtsen | 2019-08-17 16:47:16 -0700 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-08-17 16:47:16 -0700 |
| commit | 3efe59a8dd81e71597542e83eefc33fc6faab9a1 (patch) | |
| tree | 391023e7360aac2ba19f6f1545a1085d765e4917 | |
| parent | 2b9145312c4cebfd95d2d0e78ba93dbbbc9019c4 (diff) | |
| download | emacs-3efe59a8dd81e71597542e83eefc33fc6faab9a1.tar.gz emacs-3efe59a8dd81e71597542e83eefc33fc6faab9a1.zip | |
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).
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 15 |
2 files changed, 15 insertions, 5 deletions
| @@ -417,6 +417,11 @@ RGB triplets with a single hexadecimal digit per component. | |||
| 417 | 417 | ||
| 418 | * Editing Changes in Emacs 27.1 | 418 | * Editing Changes in Emacs 27.1 |
| 419 | 419 | ||
| 420 | --- | ||
| 421 | ** The 'newline-and-indent' command (commonly bound to 'RET' in many | ||
| 422 | modes) now takes an optional numeric argument to specify how many | ||
| 423 | times is should insert newlines (and indent). | ||
| 424 | |||
| 420 | +++ | 425 | +++ |
| 421 | ** New command 'make-empty-file'. | 426 | ** New command 'make-empty-file'. |
| 422 | 427 | ||
diff --git a/lisp/simple.el b/lisp/simple.el index fdf7d893cde..84497c31b25 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -745,16 +745,21 @@ buffer if the variable `delete-trailing-lines' is non-nil." | |||
| 745 | ;; Return nil for the benefit of `write-file-functions'. | 745 | ;; Return nil for the benefit of `write-file-functions'. |
| 746 | nil) | 746 | nil) |
| 747 | 747 | ||
| 748 | (defun newline-and-indent () | 748 | (defun newline-and-indent (&optional arg) |
| 749 | "Insert a newline, then indent according to major mode. | 749 | "Insert a newline, then indent according to major mode. |
| 750 | Indentation is done using the value of `indent-line-function'. | 750 | Indentation is done using the value of `indent-line-function'. |
| 751 | In programming language modes, this is the same as TAB. | 751 | In programming language modes, this is the same as TAB. |
| 752 | In some text modes, where TAB inserts a tab, this command indents to the | 752 | In some text modes, where TAB inserts a tab, this command indents to the |
| 753 | column specified by the function `current-left-margin'." | 753 | column specified by the function `current-left-margin'. |
| 754 | (interactive "*") | 754 | |
| 755 | With ARG, perform this action that many times." | ||
| 756 | (interactive "*p") | ||
| 755 | (delete-horizontal-space t) | 757 | (delete-horizontal-space t) |
| 756 | (newline nil t) | 758 | (unless arg |
| 757 | (indent-according-to-mode)) | 759 | (setq arg 1)) |
| 760 | (dotimes (_ arg) | ||
| 761 | (newline nil t) | ||
| 762 | (indent-according-to-mode))) | ||
| 758 | 763 | ||
| 759 | (defun reindent-then-newline-and-indent () | 764 | (defun reindent-then-newline-and-indent () |
| 760 | "Reindent current line, insert newline, then indent the new line. | 765 | "Reindent current line, insert newline, then indent the new line. |