(uuencode-write-decoded-region): New function.
authormorioka <morioka>
Wed, 11 Mar 1998 16:28:07 +0000 (16:28 +0000)
committermorioka <morioka>
Wed, 11 Mar 1998 16:28:07 +0000 (16:28 +0000)
mel-u.el

index fda849f..a2efb09 100644 (file)
--- a/mel-u.el
+++ b/mel-u.el
@@ -1,10 +1,9 @@
 ;;; mel-u.el: uuencode encoder/decoder for GNU Emacs
 
-;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1995/10/25
-;; Version: $Id: mel-u.el,v 5.10 1997/07/14 21:47:48 morioka Exp $
 ;; Keywords: uuencode
 
 ;; This file is part of MEL (MIME Encoding Library).
@@ -111,6 +110,31 @@ variable `uuencode-external-encoder'."
                (file-name-nondirectory filename))
   )
 
+(defun uuencode-write-decoded-region (start end filename)
+  "Decode and write current region encoded by uuencode into FILENAME.
+START and END are buffer positions."
+  (interactive
+   (list (region-beginning) (region-end)
+        (read-file-name "Write 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 (or (getenv "TMP")(getenv "TEMP") "/tmp")))
+      (if file
+         (as-binary-process
+          (apply (function call-process-region)
+                 start end (car uuencode-external-decoder)
+                 nil nil nil (cdr uuencode-external-decoder))
+          (rename-file file filename 'overwrites)
+          )))))
+
 
 ;;; @ end
 ;;;