X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mel-g.el;h=16a37fd48ee5a759bc59983d0f12d95ca8913d3f;hb=9c4d56623323910c0f8eed8a2f6dc128705f6694;hp=8f25b5309445390e8778448ef832b3175b6f5c38;hpb=abe34b4f5cb2f125b94b4047d288076d02173dbe;p=elisp%2Fflim.git diff --git a/mel-g.el b/mel-g.el index 8f25b53..16a37fd 100644 --- a/mel-g.el +++ b/mel-g.el @@ -1,16 +1,15 @@ -;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs +;;; mel-g.el --- Gzip64 encoder/decoder. -;; Copyright (C) 1995,1996,1997 MORIOKA Tomohiko -;; Copyright (C) 1996,1997 Shuhei KOBAYASHI +;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko +;; Copyright (C) 1996,1997,1999 Shuhei KOBAYASHI -;; Author: Shuhei KOBAYASHI -;; modified by MORIOKA Tomohiko -;; Maintainer: Shuhei KOBAYASHI +;; Author: Shuhei KOBAYASHI +;; MORIOKA Tomohiko +;; Maintainer: Shuhei KOBAYASHI ;; Created: 1995/10/25 -;; Version: $Id: mel-g.el,v 6.2 1997/09/20 15:09:36 shuhei-k Exp $ ;; Keywords: Gzip64, base64, gzip, MIME -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -23,7 +22,7 @@ ;; 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 +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -34,8 +33,8 @@ ;;; Code: -(require 'emu) -(require 'file-detect) +(require 'mime-def) +(require 'path-util) ;;; @ variables @@ -44,15 +43,13 @@ (defvar gzip64-external-encoder (let ((file (exec-installed-p "mmencode"))) (and file - (` ("sh" "-c" (, (concat "gzip -c | " file)))) - )) + (` ("sh" "-c" (, (concat "gzip -c | " file)))))) "*list of gzip64 encoder program name and its arguments.") (defvar gzip64-external-decoder (let ((file (exec-installed-p "mmencode"))) (and file - (` ("sh" "-c" (, (concat file " -u | gzip -dc")))) - )) + (` ("sh" "-c" (, (concat file " -u | gzip -dc")))))) "*list of gzip64 decoder program name and its arguments.") @@ -62,40 +59,70 @@ (defun gzip64-external-encode-region (beg end) (interactive "*r") (save-excursion - (as-binary-process (apply (function call-process-region) - beg end (car gzip64-external-encoder) - t t nil (cdr gzip64-external-encoder)) - ) + (as-binary-process + (apply (function call-process-region) + beg end (car gzip64-external-encoder) + t t nil + (cdr gzip64-external-encoder))) ;; for OS/2 ;; regularize line break code (goto-char (point-min)) (while (re-search-forward "\r$" nil t) - (replace-match "") - ) - )) + (replace-match "")))) (defun gzip64-external-decode-region (beg end) (interactive "*r") (save-excursion - (as-binary-process (apply (function call-process-region) - beg end (car gzip64-external-decoder) - t t nil (cdr gzip64-external-decoder)) - ) - )) + (as-binary-process + (apply (function call-process-region) + beg end (car gzip64-external-decoder) + t t nil + (cdr gzip64-external-decoder))))) -(defalias 'gzip64-encode-region 'gzip64-external-encode-region) -(defalias 'gzip64-decode-region 'gzip64-external-decode-region) +(mel-define-method-function (mime-encode-region start end (nil "x-gzip64")) + 'gzip64-external-encode-region) +(mel-define-method-function (mime-decode-region start end (nil "x-gzip64")) + 'gzip64-external-decode-region) + + +;;; @ encoder/decoder for string +;;; + +(mel-define-method mime-encode-string (string (nil "x-gzip64")) + (with-temp-buffer + (insert string) + (gzip64-external-encode-region (point-min)(point-max)) + (buffer-string))) + +(mel-define-method mime-decode-string (string (nil "x-gzip64")) + (with-temp-buffer + (insert string) + (gzip64-external-decode-region (point-min)(point-max)) + (buffer-string))) ;;; @ encoder/decoder for file ;;; -(defun gzip64-insert-encoded-file (filename) - (interactive (list (read-file-name "Insert encoded file: "))) - (apply (function call-process) (car gzip64-external-encoder) +(mel-define-method mime-insert-encoded-file (filename (nil "x-gzip64")) + (interactive "*fInsert encoded file: ") + (apply (function call-process) + (car gzip64-external-encoder) filename t nil - (cdr gzip64-external-encoder)) - ) + (cdr gzip64-external-encoder))) + +(mel-define-method mime-write-decoded-region (start end filename + (nil "x-gzip64")) + "Decode and write current region encoded by gzip64 into FILENAME. +START and END are buffer positions." + (interactive "*r\nFWrite decoded region to file: ") + (as-binary-process + (apply (function call-process-region) + start end (car gzip64-external-decoder) + nil nil nil + (let ((args (cdr gzip64-external-decoder))) + (append (butlast args) + (list (concat (car (last args)) ">" filename))))))) ;;; @ end