diff --git a/lisp/subr.el b/lisp/subr.el index aded02c4f79..ad3494a2fa7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -6748,7 +6748,9 @@ If OMIT-NULLS, empty lines will be removed from the results. If KEEP-NEWLINES, don't strip trailing newlines from the result lines." (if (equal string "") - (list "") + (if omit-nulls + nil + (list "")) (let ((lines nil) (start 0)) (while (< start (length string)) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index f4676793ff2..62cf2266d61 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1030,6 +1030,7 @@ final or penultimate step during initialization.")) (ert-deftest test-string-lines () (should (equal (string-lines "") '(""))) + (should (equal (string-lines "" t) '())) (should (equal (string-lines "foo") '("foo"))) (should (equal (string-lines "foo\n") '("foo")))