mel-u.el (mime-write-decoded-region): Use temporary filename.
authorokada <okada>
Mon, 12 Apr 2004 04:55:57 +0000 (04:55 +0000)
committerokada <okada>
Mon, 12 Apr 2004 04:55:57 +0000 (04:55 +0000)
ChangeLog
mel-u.el

index b1e9f06..fc73802 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-12  Kenichi Okada  <okada@opaopa.org>
+
+       * mel-u.el (mime-write-decoded-region): Use temporary filename.
+
 2004-03-05  Jesper Harder  <harder@ifa.au.dk>
 
        * sha1-el.el (sha1-maximum-internal-length): Doc fix.
index ead3efb..e6612cd 100644 (file)
--- a/mel-u.el
+++ b/mel-u.el
@@ -134,24 +134,28 @@ variable `uuencode-external-encoder'."
 START and END are buffer positions."
   (interactive "*r\nFWrite decoded region to file: ")
   (save-excursion
-    (let ((file (save-excursion
-                 (save-restriction
-                   (narrow-to-region start end)
-                   (goto-char start)
-                   (if (re-search-forward "^begin [0-9]+ " nil t)
-                       (if (looking-at ".+$")
-                           (buffer-substring (match-beginning 0)
-                                             (match-end 0)))))))
-         (default-directory temporary-file-directory))
-      (if file
-         (let ((coding-system-for-read  'binary)
-               (coding-system-for-write 'binary))
-           (apply (function call-process-region)
-                  start end (car uuencode-external-decoder)
-                  nil nil nil
-                  (cdr uuencode-external-decoder))
-           (rename-file file filename 'overwrites))))))
-
+    (let ((the-buf (current-buffer))
+         (clone-buf (clone-buffer " *x-uue*"))
+         (file (make-temp-name "x-uue")))
+      (save-excursion
+       (save-restriction
+         (set-buffer clone-buf)
+         (narrow-to-region start end)
+         (setq buffer-read-only nil)
+         (goto-char start)
+         (when (and (re-search-forward "^begin [0-9]+ " nil t)
+                  (looking-at ".+$"))
+           (replace-match file)
+           (let ((coding-system-for-read  'binary)
+                 (coding-system-for-write 'binary)
+                 (default-directory temporary-file-directory))
+             (apply (function call-process-region)
+                    (point-min) (point-max) (car uuencode-external-decoder)
+                    nil nil nil
+                    (cdr uuencode-external-decoder))
+             (rename-file file filename 'overwrites)
+             (message (concat "Wrote " filename))))))
+      (kill-buffer clone-buf))))
 
 ;;; @ end
 ;;;