(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.
(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)