X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/dc294483af221066724f1007a595016b47fb5814..7c6317a0498b6690ea668909ac012cb45e6f809b:/lisp/simple.el diff --git a/lisp/simple.el b/lisp/simple.el index 3fa23ff947..37f6d5000e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -607,9 +607,10 @@ buffer if the variable `delete-trailing-lines' is non-nil." (with-syntax-table (make-syntax-table (syntax-table)) ;; Don't delete formfeeds, even if they are considered whitespace. (modify-syntax-entry ?\f "_") - (while (re-search-forward "\\s-$" end-marker t) - (skip-syntax-backward "-" (line-beginning-position)) - (delete-region (point) (match-end 0)))) + ;; Treating \n as non-whitespace makes things easier. + (modify-syntax-entry ?\n "_") + (while (re-search-forward "\\s-+$" end-marker t) + (delete-region (match-beginning 0) (match-end 0)))) ;; Delete trailing empty lines. (goto-char end-marker) (when (and (not end)