* progmodes/flymake.el (flymake-save-buffer-in-file):
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 May 2008 17:35:34 +0000 (17:35 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 May 2008 17:35:34 +0000 (17:35 +0000)
* 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.

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

index 6a395dc..b3e2660 100644 (file)
@@ -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.
 
index 8070e95..1f54b32 100644 (file)
@@ -1171,7 +1171,7 @@ using `make-temp-file', and the generated name is returned."
          ;; 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
index 2622d46..9aef531 100644 (file)
@@ -2715,7 +2715,7 @@ only if this merge job is part of a group, i.e., was invoked from within
       (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))
index 1475275..0fcbcb2 100644 (file)
@@ -4145,9 +4145,8 @@ This requires the external program `diff' to be in your `exec-path'."
             (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)
index ada7606..a5792ed 100644 (file)
@@ -257,16 +257,12 @@ There should be no more than seven characters after the final `/'."
         (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 @@ There should be no more than seven characters after the final `/'."
                       (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))
index 5412e2b..c6c58ef 100644 (file)
@@ -562,10 +562,8 @@ Find master file, patch and save it."
        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)
index 29eb04e..5481bba 100644 (file)
@@ -573,13 +573,11 @@ site."
         (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.
index 8264055..10edc54 100644 (file)
@@ -2562,8 +2562,7 @@ See also `with-temp-buffer'."
               (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))))))