2008-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
+ * progmodes/flymake.el (flymake-save-buffer-in-file):
+ * shadowfile.el (shadow-copy-file):
+ * arc-mode.el (archive-*-write-file-member):
+ * files.el (diff-buffer-with-file):
+ * subr.el (with-temp-file): Pass nil to write-region.
+ * jka-compr.el (jka-compr-write-region): Preserve `start's nullness.
+
* doc-view.el (doc-view-mode-map): Bind `q' to quit-window, as is
the custom.
;; the dired-like listing we created.
(if (eq major-mode 'archive-mode)
(archive-write-file tmpfile)
- (write-region (point-min) (point-max) tmpfile nil 'nomessage))
+ (write-region nil nil tmpfile nil 'nomessage))
;; basic-save-buffer needs last-coding-system-used to have
;; the value used to write the file, so save it before any
;; further processing clobbers it (we restore it in
(if (or (not (file-exists-p file))
(y-or-n-p (format "File %s exists, overwrite? " file)))
(progn
- ;;(write-region (point-min) (point-max) file)
+ ;;(write-region nil nil file)
(ediff-with-current-buffer buf
(set-visited-file-name file)
(save-buffer))
(file-exists-p buffer-file-name))
(let ((tempfile (make-temp-file "buffer-content-")))
(unwind-protect
- (save-restriction
- (widen)
- (write-region (point-min) (point-max) tempfile nil 'nomessage)
+ (progn
+ (write-region nil nil tempfile nil 'nomessage)
(diff buffer-file-name tempfile nil t)
(sit-for 0))
(when (file-exists-p tempfile)
(info (jka-compr-get-compression-info visit-file))
(magic (and info (jka-compr-info-file-magic-bytes info))))
- ;; If START is nil, use the whole buffer.
- (if (null start)
- (setq start 1 end (1+ (buffer-size))))
-
;; If we uncompressed this file when visiting it,
;; then recompress it when writing it
;; even if the contents look compressed already.
(if (and jka-compr-really-do-compress
- (eq start 1)
- (eq end (1+ (buffer-size))))
+ (or (null start)
+ (= (- end start) (buffer-size))))
(setq magic nil))
(if (and info
(equal (if (stringp start)
(substring start 0 (min (length start)
(length magic)))
- (buffer-substring start
- (min end
- (+ start (length magic)))))
+ (let ((from (or start (point-min)))
+ (to (min (or end (point-max))
+ (+ from (length magic)))))
+ (buffer-substring from to)))
magic))))
(let ((can-append (jka-compr-info-can-append info))
(compress-program (jka-compr-info-compress-program info))
nil))))
(defun flymake-save-buffer-in-file (file-name)
- (save-restriction
- (widen)
- (make-directory (file-name-directory file-name) 1)
- (write-region (point-min) (point-max) file-name nil 566))
+ (make-directory (file-name-directory file-name) 1)
+ (write-region nil nil file-name nil 566)
(flymake-log 3 "saved buffer %s in file %s" (buffer-name) file-name))
(defun flymake-save-string-to-file (file-name data)
(to (shadow-expand-cluster-in-file-name (cdr s))))
(when buffer
(set-buffer buffer)
- (save-restriction
- (widen)
- (condition-case i
- (progn
- (write-region (point-min) (point-max) to)
- (shadow-remove-from-todo s))
- (error (message "Shadow %s not updated!" (cdr s))))))))
+ (condition-case i
+ (progn
+ (write-region nil nil to)
+ (shadow-remove-from-todo s))
+ (error (message "Shadow %s not updated!" (cdr s)))))))
(defun shadow-shadows-of (file)
"Return copy operations needed to update FILE.
(with-current-buffer ,temp-buffer
,@body)
(with-current-buffer ,temp-buffer
- (widen)
- (write-region (point-min) (point-max) ,temp-file nil 0)))
+ (write-region nil nil ,temp-file nil 0)))
(and (buffer-name ,temp-buffer)
(kill-buffer ,temp-buffer))))))