annotate lisp/tm/tm-tar.el @ 73:e2d7a37b7c8d

Added tag r20-0b31 for changeset b9518feda344
author cvs
date Mon, 13 Aug 2007 09:03:47 +0200
parents 131b0175ea99
children c0c698873ce1
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 ;;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 10
diff changeset
2 ;;; $Id: tm-tar.el,v 1.1.1.1 1996/12/18 22:43:37 steve Exp $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4 ;;; tm-tar.el
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6 ;;; Internal viewer for
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;;; - application/x-tar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;;; - application/x-gzip, type="tar"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9 ;;; - aplication/octet-stream, type="tar"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;;; - aplication/octet-stream, type="tar+gzip"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;;; by Hiroshi Ueno <zodiac@ibm.net>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13 ;;; modified by Tomohiko Morioka <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;;; @ required modules
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 (require 'emu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 (require 'tm-view)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;;; @ constants
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 (defconst tm-tar/list-buffer "*tm-tar/List*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 (defconst tm-tar/view-buffer "*tm-tar/View*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 (defconst tm-tar/file-search-regexp "[0-9]+\:[0-9\:]+[ ]+[0-9]+[ ]+")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28 (defconst tm-tar/popup-menu-title "Action Menu")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 ;;; @ variables
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 (defvar tm-tar/tar-program "gtar")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 (defvar tm-tar/tar-decompress-arg '("-z"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 (defvar tm-tar/gzip-program "gzip")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 (defvar tm-tar/mmencode-program "mmencode")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 (defvar tm-tar/uudecode-program "uudecode")
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 tm-tar/popup-menu-items
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 '(("View File" . tm-tar/view-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 ("Key Help" . tm-tar/helpful-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 ("Quit tm-tar Mode" . exit-recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45 (cond ((string-match "XEmacs\\|Lucid" emacs-version)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 (defvar tm-tar/popup-menu
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 (cons tm-tar/popup-menu-title
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 (lambda (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 (vector (car item)(cdr item) t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 tm-tar/popup-menu-items)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 (defun tm-tar/mouse-button-2 (event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 (popup-menu tm-tar/popup-menu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 ((>= emacs-major-version 19)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 (defun tm-tar/mouse-button-2 (event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 (let ((menu
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 (cons tm-tar/popup-menu-title
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 (list (cons "Menu Items" tm-tar/popup-menu-items))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (let ((func (x-popup-menu event menu)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 (if func
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 (funcall func)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (defvar tm-tar/tar-mode-map nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (if tm-tar/tar-mode-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 (setq tm-tar/tar-mode-map (make-keymap))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 (suppress-keymap tm-tar/tar-mode-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (define-key tm-tar/tar-mode-map "\C-c" 'exit-recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 (define-key tm-tar/tar-mode-map "q" 'exit-recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 (define-key tm-tar/tar-mode-map "n" 'tm-tar/next-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (define-key tm-tar/tar-mode-map " " 'tm-tar/next-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (define-key tm-tar/tar-mode-map "\C-m" 'tm-tar/next-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (define-key tm-tar/tar-mode-map "p" 'tm-tar/previous-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (define-key tm-tar/tar-mode-map "\177" 'tm-tar/previous-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (define-key tm-tar/tar-mode-map "\C-\M-m" 'tm-tar/previous-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 (define-key tm-tar/tar-mode-map "v" 'tm-tar/view-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (define-key tm-tar/tar-mode-map "\C-h" 'Helper-help)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (define-key tm-tar/tar-mode-map "?" 'tm-tar/helpful-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (if mouse-button-2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (define-key tm-tar/tar-mode-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 mouse-button-2 'tm:button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 ;;; @@ tm-tar mode functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (defun tm-tar/tar-mode (&optional prev-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 "Major mode for listing the contents of a tar archive file."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (unwind-protect
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 (let ((buffer-read-only t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 (mode-name "tm-tar")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 (mode-line-buffer-identification '("%17b"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 (tm-tar/move-to-filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 (catch 'tm-tar/tar-mode (tm-tar/command-loop))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (if prev-buf
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (switch-to-buffer prev-buf)
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 (defun tm-tar/command-loop ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (let ((old-local-map (current-local-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (unwind-protect
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (use-local-map tm-tar/tar-mode-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (tm-tar/helpful-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 (recursive-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (use-local-map old-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (defun tm-tar/next-line ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (next-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (tm-tar/move-to-filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 (defun tm-tar/previous-line ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (previous-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (tm-tar/move-to-filename)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (defun tm-tar/view-file ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (let ((name (tm-tar/get-filename))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 (switch-to-buffer tm-tar/view-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 (setq buffer-read-only nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 (message "Reading a file from an archive. Please wait...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (apply 'call-process tm-tar/tar-program
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 nil t nil (append tm-tar/view-args (list name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (view-buffer tm-tar/view-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 (defun tm-tar/get-filename ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (let (eol)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (setq eol (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 (if (re-search-forward "^d" eol t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (error "Cannot view a directory"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (if (re-search-forward tm-tar/file-search-regexp eol t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (progn (let ((beg (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (skip-chars-forward "^ \n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (buffer-substring beg (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (error "No file on this line")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (defun tm-tar/move-to-filename ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 (let ((eol (progn (end-of-line) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 (beginning-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 (re-search-forward tm-tar/file-search-regexp eol t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 (defun tm-tar/set-properties ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 (if mouse-button-2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (let ((beg (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 (while (re-search-forward tm-tar/file-search-regexp end t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 (tm:add-button (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 (end-of-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 'tm-tar/view-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 (defun tm-tar/helpful-message ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (message "Type %s, %s, %s, %s, %s, %s."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 (substitute-command-keys "\\[Helper-help] for help")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 (substitute-command-keys "\\[tm-tar/helpful-message] for keys")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 (substitute-command-keys "\\[tm-tar/next-line] to next")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (substitute-command-keys "\\[tm-tar/previous-line] to prev")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 (substitute-command-keys "\\[tm-tar/view-file] to view")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 (substitute-command-keys "\\[exit-recursive-edit] to quit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 (defun tm-tar/y-or-n-p (prompt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 (prog1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 (y-or-n-p prompt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (message "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 ;;; @@ tar message decoder
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 (defun mime/decode-message/tar (beg end cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 (if (tm-tar/y-or-n-p "Do you want to enter tm-tar mode? ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 (let ((coding (cdr (assoc 'encoding cal)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 (cur-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 (tm-tar/tar-file-name (expand-file-name (concat (make-temp-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (expand-file-name "tm" mime/tmp-dir)) ".tar")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (tm-tar/tmp-file-name (expand-file-name (make-temp-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (expand-file-name "tm" mime/tmp-dir))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 new-buf
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (find-file tm-tar/tmp-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (setq new-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (setq buffer-read-only nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (set-buffer cur-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 (re-search-forward "^$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (append-to-buffer new-buf (+ (match-end 0) 1) end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (if (member coding mime-viewer/uuencode-encoding-name-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 (if (re-search-forward "^begin [0-9]+ " nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (kill-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (insert tm-tar/tar-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (set-buffer-modified-p nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (kill-buffer new-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (error "uuencode file signature was not found")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (save-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (kill-buffer new-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (message "Listing the contents of an archive. Please wait...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (cond ((string-equal coding "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (call-process tm-tar/mmencode-program nil nil nil "-u"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 "-o" tm-tar/tar-file-name tm-tar/tmp-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 ((string-equal coding "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 (call-process tm-tar/mmencode-program nil nil nil "-u" "-q"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 "-o" tm-tar/tar-file-name tm-tar/tmp-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 ((member coding mime-viewer/uuencode-encoding-name-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 (call-process tm-tar/uudecode-program nil nil nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 tm-tar/tmp-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (copy-file tm-tar/tmp-file-name tm-tar/tar-file-name t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 (delete-file tm-tar/tmp-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 (setq tm-tar/list-args (list "-tvf" tm-tar/tar-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (setq tm-tar/view-args (list "-xOf" tm-tar/tar-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 (if (eq 0 (call-process tm-tar/gzip-program
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 nil nil nil "-t" tm-tar/tar-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (setq tm-tar/list-args
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (append tm-tar/tar-decompress-arg tm-tar/list-args))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (setq tm-tar/view-args
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (append tm-tar/tar-decompress-arg tm-tar/view-args))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 (switch-to-buffer tm-tar/view-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (switch-to-buffer tm-tar/list-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 (setq buffer-read-only nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 (apply 'call-process tm-tar/tar-program
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 nil t nil tm-tar/list-args)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (if mouse-button-2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 (make-local-variable 'tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 (setq tm:mother-button-dispatcher 'tm-tar/mouse-button-2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 (tm-tar/set-properties)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (tm-tar/tar-mode mime::article/preview-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (kill-buffer tm-tar/view-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 (kill-buffer tm-tar/list-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (delete-file tm-tar/tar-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 ;;; @@ program/buffer coding system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (cond ((boundp 'MULE)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (define-program-coding-system tm-tar/view-buffer nil *autoconv*)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 ((boundp 'NEMACS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 (define-program-kanji-code tm-tar/view-buffer nil 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 ;;; @@ message types to use tm-tar
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 '((type . "application/octet-stream")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 (method . mime/decode-message/tar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 (mode . "play") ("type" . "tar")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 '((type . "application/octet-stream")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 (method . mime/decode-message/tar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 (mode . "play") ("type" . "tar+gzip")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 '((type . "application/x-gzip")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325 (method . mime/decode-message/tar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 (mode . "play") ("type" . "tar")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330 '((type . "application/x-tar")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 (method . mime/decode-message/tar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 (mode . "play")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 (provide 'tm-tar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340 ;;; Local Variables:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 ;;; mode: emacs-lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 ;;; mode: outline-minor
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343 ;;; outline-regexp: ";;; @+\\|(......"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344 ;;; End: