From d68e189a96918b113f565d5ce46257c7e9bc963c Mon Sep 17 00:00:00 2001 From: "Peter J. Weisberg" Date: Fri, 23 Sep 2011 10:56:00 -0400 Subject: [PATCH] * lisp/simple.el (delete-trailing-whitespace): Also delete extra newlines at the end of the buffer. --- lisp/ChangeLog | 3 +++ lisp/simple.el | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8c52d626c02..f17ba200815 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2011-09-23 Peter J. Weisberg + * simple.el (delete-trailing-whitespace): Also delete + extra newlines at the end of the buffer. + * textmodes/picture.el: Make motion commands obey shift-select-mode. (picture-newline): Use forward-line so as to ignore fields. diff --git a/lisp/simple.el b/lisp/simple.el index 35193135396..c828584c17f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -586,6 +586,12 @@ If the region is active, only delete whitespace within the region." (if (looking-at ".*\f") (goto-char (match-end 0)))) (delete-region (point) (match-end 0))) + (save-restriction + (goto-char end-marker) + (widen) + (if (and (eobp) + (looking-back "\n\n+" nil t)) + (replace-match "\n"))) (set-marker end-marker nil)))) ;; Return nil for the benefit of `write-file-functions'. nil) -- 2.39.5