annotate lisp/mel/mel-u.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents c0c698873ce1
children 8eaf7971accc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; mel-u.el: uuencode encoder/decoder for GNU Emacs
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
2
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
4
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
6 ;; Created: 1995/10/25
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
7 ;; Version: $Id: mel-u.el,v 1.3 1997/03/16 03:05:15 steve Exp $
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
8 ;; Keywords: uuencode
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
9
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
10 ;; This file is part of MEL (MIME Encoding Library).
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
11
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
12 ;; This program is free software; you can redistribute it and/or
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
13 ;; modify it under the terms of the GNU General Public License as
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
14 ;; published by the Free Software Foundation; either version 2, or (at
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
15 ;; your option) any later version.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
16
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
17 ;; This program is distributed in the hope that it will be useful, but
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
20 ;; General Public License for more details.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
21
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
22 ;; You should have received a copy of the GNU General Public License
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
25 ;; Boston, MA 02111-1307, USA.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
26
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 (require 'emu)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
30 (require 'mel)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;;; @ variables
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 (defvar uuencode-external-encoder '("uuencode" "-")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 "*list of uuencode encoder program name and its arguments.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 (defvar uuencode-external-decoder
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
40 (list "sh" "-c" (format "(cd %s; uudecode)" mime-temp-directory))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 "*list of uuencode decoder program name and its arguments.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44 ;;; @ uuencode encoder/decoder for region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
47 (defun uuencode-external-encode-region (start end)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
48 "Encode current region by unofficial uuencode format.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
49 This function uses external uuencode encoder which is specified by
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
50 variable `uuencode-external-encoder'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 (as-binary-process (apply (function call-process-region)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
54 start end (car uuencode-external-encoder)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 t t nil (cdr uuencode-external-encoder))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 ;; for OS/2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 ;; regularize line break code
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 (while (re-search-forward "\r$" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
65 (defun uuencode-external-decode-region (start end)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
66 "Decode current region by unofficial uuencode format.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
67 This function uses external uuencode decoder which is specified by
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
68 variable `uuencode-external-decoder'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (let ((filename (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (save-restriction
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
73 (narrow-to-region start end)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
74 (goto-char start)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 (if (re-search-forward "^begin [0-9]+ " nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (if (looking-at ".+$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 (buffer-substring (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 ))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (if filename
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (as-binary-process
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (apply (function call-process-region)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
83 start end (car uuencode-external-decoder)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 t nil nil (cdr uuencode-external-decoder))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
85 (setq filename (expand-file-name filename mime-temp-directory))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
86 (as-binary-input-file (insert-file-contents filename))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (delete-file filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (defalias 'uuencode-encode-region 'uuencode-external-encode-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (defalias 'uuencode-decode-region 'uuencode-external-decode-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 ;;; @ uuencode encoder/decoder for file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (defun uuencode-insert-encoded-file (filename)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
99 "Insert file encoded by unofficial uuencode format.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
100 This function uses external uuencode encoder which is specified by
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
101 variable `uuencode-external-encoder'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (interactive (list (read-file-name "Insert encoded file: ")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (call-process (car uuencode-external-encoder) filename t nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 (file-name-nondirectory filename))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (provide 'mel-u)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 ;;; mel-u.el ends here