Mercurial > hg > xemacs-beta
diff lisp/mel/mel-u.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 7e54bd776075 |
children | c0c698873ce1 |
line wrap: on
line diff
--- a/lisp/mel/mel-u.el Mon Aug 13 09:00:04 2007 +0200 +++ b/lisp/mel/mel-u.el Mon Aug 13 09:02:59 2007 +0200 @@ -1,57 +1,58 @@ +;;; ;;; mel-u.el: uuencode encoder/decoder for GNU Emacs - -;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. - -;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> -;; Created: 1995/10/25 -;; Version: $Id: mel-u.el,v 1.4 1997/03/22 05:29:07 steve Exp $ -;; Keywords: uuencode - -;; This file is part of MEL (MIME Encoding Library). - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2, or (at -;; your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - +;;; +;;; Copyright (C) 1995 Free Software Foundation, Inc. +;;; Copyright (C) 1995,1996 MORIOKA Tomohiko +;;; +;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> +;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp> +;;; Created: 1995/10/25 +;;; Version: +;;; $Id: mel-u.el,v 1.1.1.1 1996/12/18 22:43:39 steve Exp $ +;;; Keywords: uuencode +;;; +;;; This file is part of MEL (MIME Encoding Library). +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 2, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with This program. If not, write to the Free Software +;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +;;; ;;; Code: (require 'emu) -(require 'mel) ;;; @ variables ;;; +(defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/")) + (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)) + (list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir)) "*list of uuencode decoder program name and its arguments.") ;;; @ uuencode encoder/decoder for region ;;; -(defun uuencode-external-encode-region (start end) - "Encode current region by unofficial uuencode format. -This function uses external uuencode encoder which is specified by -variable `uuencode-external-encoder'." +(defun uuencode-external-encode-region (beg end) (interactive "*r") (save-excursion (as-binary-process (apply (function call-process-region) - start end (car uuencode-external-encoder) + beg end (car uuencode-external-encoder) t t nil (cdr uuencode-external-encoder)) ) ;; for OS/2 @@ -62,16 +63,13 @@ ) )) -(defun uuencode-external-decode-region (start end) - "Decode current region by unofficial uuencode format. -This function uses external uuencode decoder which is specified by -variable `uuencode-external-decoder'." +(defun uuencode-external-decode-region (beg end) (interactive "*r") (save-excursion (let ((filename (save-excursion (save-restriction - (narrow-to-region start end) - (goto-char start) + (narrow-to-region beg end) + (goto-char beg) (if (re-search-forward "^begin [0-9]+ " nil t) (if (looking-at ".+$") (buffer-substring (match-beginning 0) @@ -80,10 +78,17 @@ (if filename (as-binary-process (apply (function call-process-region) - start end (car uuencode-external-decoder) + beg 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)) + (setq filename (expand-file-name filename mime/tmp-dir)) + (let ((file-coding-system-for-read *noconv*) ; for Mule + kanji-fileio-code ; for NEmacs + (emx-binary-mode t) ; for OS/2 + jka-compr-compression-info-list ; for jka-compr + jam-zcat-filename-list ; for jam-zcat + require-final-newline) + (insert-file-contents filename) + ) (delete-file filename) )) ))) @@ -96,9 +101,6 @@ ;;; (defun uuencode-insert-encoded-file (filename) - "Insert file encoded by unofficial uuencode format. -This function uses external uuencode encoder which is specified by -variable `uuencode-external-encoder'." (interactive (list (read-file-name "Insert encoded file: "))) (call-process (car uuencode-external-encoder) filename t nil (file-name-nondirectory filename))