From 5155cc349be9ef07f765a5976e7b6bb495d68057 Mon Sep 17 00:00:00 2001 From: okada Date: Mon, 12 Apr 2004 04:51:34 +0000 Subject: [PATCH] mel-u.el (mime-write-decoded-region): Use temporary filename. --- ChangeLog | 4 ++++ mel-u.el | 40 ++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 559bb1b..2bb6eea 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 ;;; -- 1.7.10.4