4
|
1 ;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs
|
30
|
2
|
|
3 ;; Copyright (C) 1995,1996,1997 MORIOKA Tomohiko
|
|
4 ;; Copyright (C) 1996 Shuhei KOBAYASHI
|
|
5
|
|
6 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
7 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
8 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
9 ;; Created: 1995/10/25
|
32
|
10 ;; Version: $Id: mel-g.el,v 1.6 1997/03/16 05:55:17 steve Exp $
|
30
|
11 ;; Keywords: Gzip64, base64, gzip, MIME
|
|
12
|
|
13 ;; This file is not part of MEL (MIME Encoding Library) yet.
|
|
14
|
|
15 ;; This program is free software; you can redistribute it and/or
|
|
16 ;; modify it under the terms of the GNU General Public License as
|
|
17 ;; published by the Free Software Foundation; either version 2, or (at
|
|
18 ;; your option) any later version.
|
|
19
|
|
20 ;; This program is distributed in the hope that it will be useful, but
|
|
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
23 ;; General Public License for more details.
|
|
24
|
|
25 ;; You should have received a copy of the GNU General Public License
|
|
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
28 ;; Boston, MA 02111-1307, USA.
|
|
29
|
4
|
30 ;;; Code:
|
|
31
|
|
32 (require 'emu)
|
30
|
33 (require 'file-detect)
|
4
|
34
|
|
35
|
|
36 ;;; @ variables
|
|
37 ;;;
|
|
38
|
30
|
39 (defvar gzip64-external-encoder
|
32
|
40 (let ((file (exec-installed-p "mmencode")))
|
30
|
41 (and file
|
|
42 (` ("sh" "-c" (, (concat "gzip -c | " file))))
|
|
43 ))
|
4
|
44 "*list of gzip64 encoder program name and its arguments.")
|
|
45
|
30
|
46 (defvar gzip64-external-decoder
|
32
|
47 (let ((file (exec-installed-p "mmencode")))
|
30
|
48 (and file
|
|
49 (` ("sh" "-c" (, (concat file " -u | gzip -dc"))))
|
|
50 ))
|
4
|
51 "*list of gzip64 decoder program name and its arguments.")
|
|
52
|
|
53
|
|
54 ;;; @ encoder/decoder for region
|
|
55 ;;;
|
|
56
|
|
57 (defun gzip64-external-encode-region (beg end)
|
|
58 (interactive "*r")
|
|
59 (save-excursion
|
|
60 (as-binary-process (apply (function call-process-region)
|
|
61 beg end (car gzip64-external-encoder)
|
|
62 t t nil (cdr gzip64-external-encoder))
|
|
63 )
|
|
64 ;; for OS/2
|
|
65 ;; regularize line break code
|
|
66 (goto-char (point-min))
|
|
67 (while (re-search-forward "\r$" nil t)
|
|
68 (replace-match "")
|
|
69 )
|
|
70 ))
|
|
71
|
|
72 (defun gzip64-external-decode-region (beg end)
|
|
73 (interactive "*r")
|
|
74 (save-excursion
|
|
75 (as-binary-process (apply (function call-process-region)
|
|
76 beg end (car gzip64-external-decoder)
|
|
77 t t nil (cdr gzip64-external-decoder))
|
|
78 )
|
|
79 ))
|
|
80
|
|
81 (defalias 'gzip64-encode-region 'gzip64-external-encode-region)
|
|
82 (defalias 'gzip64-decode-region 'gzip64-external-decode-region)
|
|
83
|
|
84
|
|
85 ;;; @ encoder/decoder for file
|
|
86 ;;;
|
|
87
|
|
88 (defun gzip64-insert-encoded-file (filename)
|
|
89 (interactive (list (read-file-name "Insert encoded file: ")))
|
|
90 (apply (function call-process) (car gzip64-external-encoder)
|
|
91 filename t nil
|
|
92 (cdr gzip64-external-encoder))
|
|
93 )
|
|
94
|
|
95
|
|
96 ;;; @ end
|
|
97 ;;;
|
|
98
|
|
99 (provide 'mel-g)
|
|
100
|
|
101 ;;; mel-g.el ends here.
|