X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mel-u.el;h=d004d60e3d15fa3fe74cda441172af449cce5a51;hb=refs%2Fheads%2Fchao-1_7_0;hp=fda849f90e43a1b87a53dda63f8178f3ce4da678;hpb=29c99d4d25875784e45b274690dc6bf463ab864b;p=elisp%2Fflim.git diff --git a/mel-u.el b/mel-u.el index fda849f..d004d60 100644 --- 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 ;; 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). @@ -27,7 +26,7 @@ ;;; Code: (require 'emu) -(require 'mel) +(require 'mime-def) ;;; @ variables @@ -36,8 +35,7 @@ (defvar uuencode-external-encoder '("uuencode" "-") "*list of uuencode encoder program name and its arguments.") -(defvar uuencode-external-decoder - (list "sh" "-c" (format "(cd %s; uudecode)" mime-temp-directory)) +(defvar uuencode-external-decoder '("sh" "-c" "uudecode") "*list of uuencode decoder program name and its arguments.") @@ -76,13 +74,13 @@ variable `uuencode-external-decoder'." (if (looking-at ".+$") (buffer-substring (match-beginning 0) (match-end 0)) - )))))) + ))))) + (default-directory mime-temp-directory)) (if filename (as-binary-process (apply (function call-process-region) start end (car uuencode-external-decoder) t nil nil (cdr uuencode-external-decoder)) - (setq filename (expand-file-name filename mime-temp-directory)) (as-binary-input-file (insert-file-contents filename)) ;; The previous line causes the buffer to be made read-only, I ;; do not pretend to understand the control flow leading to this @@ -111,6 +109,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 mime-temp-directory)) + (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 ;;;