2 ;;; mel-u.el: uuencode encoder/decoder for GNU Emacs
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; Created: 1995/10/25
11 ;;; $Id: mel-u.el,v 3.2 1996/01/09 18:19:25 morioka Exp $
12 ;;; Keywords: uuencode
14 ;;; This file is part of MEL (MIME Encoding Library).
16 ;;; This program is free software; you can redistribute it and/or
17 ;;; modify it under the terms of the GNU General Public License as
18 ;;; published by the Free Software Foundation; either version 2, or
19 ;;; (at your option) any later version.
21 ;;; This program is distributed in the hope that it will be useful,
22 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 ;;; General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with This program. If not, write to the Free Software
28 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
35 (defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
37 (defvar uuencode-external-encoder '("uuencode" "-")
38 "*list of uuencode encoder program name and its arguments.")
40 (defvar uuencode-external-decoder
41 (list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir))
42 "*list of uuencode decoder program name and its arguments.")
45 ;;; @ external encoder
49 (define-program-coding-system
50 nil (car uuencode-external-encoder) *noconv*)
51 (define-program-coding-system
52 nil (car uuencode-external-decoder) *noconv*)
55 (define-program-kanji-code
56 nil (car uuencode-external-encoder) 0)
57 (define-program-kanji-code
58 nil (car uuencode-external-decoder) 0)
61 (defun uuencode-external-encode-region (beg end)
64 (let (selective-display ; Disable ^M to nl translation.
66 kanji-flag) ; for NEmacs
67 (apply (function call-process-region)
68 beg end (car uuencode-external-encoder)
69 t t nil (cdr uuencode-external-encoder))
72 (defun uuencode-external-decode-region (beg end)
75 (let (selective-display ; Disable ^M to nl translation.
77 kanji-flag ; for NEmacs
78 (filename (save-excursion
80 (narrow-to-region beg end)
82 (if (re-search-forward "^begin [0-9]+ " nil t)
83 (if (looking-at ".+$")
84 (buffer-substring (match-beginning 0)
91 (apply (function call-process-region)
92 beg end (car uuencode-external-decoder)
93 t nil nil (cdr uuencode-external-decoder))
94 (setq filename (expand-file-name filename mime/tmp-dir))
95 (let ((file-coding-system-for-read
96 (if (boundp 'MULE) *noconv*)) ; for Mule
97 kanji-fileio-code ; for NEmacs
98 (emx-binary-mode t) ; for OS/2
99 jka-compr-compression-info-list ; for jka-compr
100 jam-zcat-filename-list ; for jam-zcat
101 require-final-newline)
102 (insert-file-contents filename)
104 (delete-file filename)
108 (defalias 'uuencode-encode-region 'uuencode-external-encode-region)
109 (defalias 'uuencode-decode-region 'uuencode-external-decode-region)