mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-22 10:26:20 +00:00
Don’t create unnecessary marker in ‘delete-trailing-whitespace’
* lisp/simple.el (delete-trailing-whitespace): If END argument is nil, there is no need for the end-marker to be created.
This commit is contained in:
parent
7c6317a049
commit
dcefd2bbc0
@ -602,7 +602,7 @@ buffer if the variable `delete-trailing-lines' is non-nil."
|
||||
(list nil nil))))
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(let ((end-marker (copy-marker (or end (point-max)))))
|
||||
(let ((end-marker (and end (copy-marker end))))
|
||||
(goto-char (or start (point-min)))
|
||||
(with-syntax-table (make-syntax-table (syntax-table))
|
||||
;; Don't delete formfeeds, even if they are considered whitespace.
|
||||
@ -611,15 +611,14 @@ buffer if the variable `delete-trailing-lines' is non-nil."
|
||||
(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)
|
||||
delete-trailing-lines
|
||||
;; Really the end of buffer.
|
||||
(= (point-max) (1+ (buffer-size)))
|
||||
(<= (skip-chars-backward "\n") -2))
|
||||
(delete-region (1+ (point)) end-marker))
|
||||
(set-marker end-marker nil))))
|
||||
(if end
|
||||
(set-marker end-marker nil)
|
||||
;; Delete trailing empty lines.
|
||||
(and delete-trailing-lines
|
||||
;; Really the end of buffer.
|
||||
(= (goto-char (point-max)) (1+ (buffer-size)))
|
||||
(<= (skip-chars-backward "\n") -2)
|
||||
(delete-region (1+ (point)) (point-max)))))))
|
||||
;; Return nil for the benefit of `write-file-functions'.
|
||||
nil)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user