From: okada Date: Mon, 12 Apr 2004 04:51:49 +0000 (+0000) Subject: mel-u.el (mime-write-decoded-region): Use temporary filename. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b4fd0d6a66ab3f08ca9cb9116753846194db0ce;p=elisp%2Fflim.git mel-u.el (mime-write-decoded-region): Use temporary filename. --- diff --git a/ChangeLog b/ChangeLog index 9707427..4151ea0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-04-12 Kenichi Okada + + * mel-u.el (mime-write-decoded-region): Use temporary filename. + 2004-03-05 Jesper Harder * sha1-el.el (sha1-maximum-internal-length): Doc fix. diff --git a/mel-u.el b/mel-u.el index ead3efb..e6612cd 100644 --- 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 ;;;