summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-10-04 13:15:41 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-10-04 13:23:22 +0200
commit8b4a6a722a3982024fc87b26dbc7ef7e2043f6e1 (patch)
tree8a0c19130d8b9c3a89467b497c853fbc2b9adfbb /test/lisp/emacs-lisp
parent909f2a4b926ccc1b86d60341e44ca83c4d24fa0f (diff)
downloademacs-8b4a6a722a3982024fc87b26dbc7ef7e2043f6e1.tar.gz
emacs-8b4a6a722a3982024fc87b26dbc7ef7e2043f6e1.tar.bz2
emacs-8b4a6a722a3982024fc87b26dbc7ef7e2043f6e1.zip
Add new command 'ensure-empty-lines'.
* doc/lispref/text.texi (Commands for Insertion): Document it. * lisp/emacs-lisp/subr-x.el (ensure-empty-lines): New command.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/subr-x-tests.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el
index 1d19496ba44..f9cfea888c7 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -638,5 +638,43 @@
(should (equal (string-chop-newline "foo\nbar\n") "foo\nbar"))
(should (equal (string-chop-newline "foo\nbar") "foo\nbar")))
+(ert-deftest subr-ensure-empty-lines ()
+ (should
+ (equal
+ (with-temp-buffer
+ (insert "foo")
+ (goto-char (point-min))
+ (ensure-empty-lines 2)
+ (buffer-string))
+ "\n\nfoo"))
+ (should
+ (equal
+ (with-temp-buffer
+ (insert "foo")
+ (ensure-empty-lines 2)
+ (buffer-string))
+ "foo\n\n\n"))
+ (should
+ (equal
+ (with-temp-buffer
+ (insert "foo\n")
+ (ensure-empty-lines 2)
+ (buffer-string))
+ "foo\n\n\n"))
+ (should
+ (equal
+ (with-temp-buffer
+ (insert "foo\n\n\n\n\n")
+ (ensure-empty-lines 2)
+ (buffer-string))
+ "foo\n\n\n"))
+ (should
+ (equal
+ (with-temp-buffer
+ (insert "foo\n\n\n")
+ (ensure-empty-lines 0)
+ (buffer-string))
+ "foo\n")))
+
(provide 'subr-x-tests)
;;; subr-x-tests.el ends here