changeset 95366:52e3cee99f90

* 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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 28 May 2008 17:35:34 +0000
parents 40ae7108af0a
children 380e5a5c73ea
files lisp/ChangeLog lisp/arc-mode.el lisp/ediff-util.el lisp/files.el lisp/jka-compr.el lisp/progmodes/flymake.el lisp/shadowfile.el lisp/subr.el
diffstat 8 files changed, 25 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/ChangeLog	Wed May 28 17:35:34 2008 +0000
@@ -1,5 +1,12 @@
 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.
 
--- a/lisp/arc-mode.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/arc-mode.el	Wed May 28 17:35:34 2008 +0000
@@ -1171,7 +1171,7 @@
 	  ;; 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
--- a/lisp/ediff-util.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/ediff-util.el	Wed May 28 17:35:34 2008 +0000
@@ -2715,7 +2715,7 @@
       (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))
--- a/lisp/files.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/files.el	Wed May 28 17:35:34 2008 +0000
@@ -4145,9 +4145,8 @@
 	     (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)
--- a/lisp/jka-compr.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/jka-compr.el	Wed May 28 17:35:34 2008 +0000
@@ -257,16 +257,12 @@
 	 (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
@@ -277,9 +273,10 @@
 		       (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))
--- a/lisp/progmodes/flymake.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/progmodes/flymake.el	Wed May 28 17:35:34 2008 +0000
@@ -562,10 +562,8 @@
 	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)
--- a/lisp/shadowfile.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/shadowfile.el	Wed May 28 17:35:34 2008 +0000
@@ -573,13 +573,11 @@
 	 (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.
--- a/lisp/subr.el	Wed May 28 16:13:20 2008 +0000
+++ b/lisp/subr.el	Wed May 28 17:35:34 2008 +0000
@@ -2562,8 +2562,7 @@
 	       (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))))))