annotate lisp/mel/mel-u.el @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents fe104dbd9147
children 6075d714658b
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
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 110
diff changeset
7 ;; Version: $Id: mel-u.el,v 1.4 1997/07/13 22:41:32 steve Exp $
110
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))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 110
diff changeset
87 ;; The previous line causes the buffer to be made read-only, I
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 110
diff changeset
88 ;; do not pretend to understand the control flow leading to this
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 110
diff changeset
89 ;; but suspect it has something to do with image-mode. -slb
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 110
diff changeset
90 (setq buffer-read-only nil)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (delete-file filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 ))
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 (defalias 'uuencode-encode-region 'uuencode-external-encode-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (defalias 'uuencode-decode-region 'uuencode-external-decode-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 ;;; @ uuencode encoder/decoder for file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (defun uuencode-insert-encoded-file (filename)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
103 "Insert file encoded by unofficial uuencode format.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
104 This function uses external uuencode encoder which is specified by
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 76
diff changeset
105 variable `uuencode-external-encoder'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 (interactive (list (read-file-name "Insert encoded file: ")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (call-process (car uuencode-external-encoder) filename t nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (file-name-nondirectory filename))
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (provide 'mel-u)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 ;;; mel-u.el ends here