6728
|
1 ;;; gnus-uu.el --- extract, view or save (uu)encoded files from gnus
|
7977
|
2
|
6729
|
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994 Free Software Foundation, Inc.
|
|
4
|
6728
|
5 ;; Author: Lars Ingebrigtsen <larsi@ifi.uio.no>
|
|
6 ;; Created: 2 Oct 1993
|
7977
|
7 ;; Version: v2.8
|
|
8 ;; Last Modified: 1994/06/01
|
9504
|
9 ;; Keywords: news
|
6729
|
10
|
|
11 ;; This file is part of GNU Emacs.
|
|
12
|
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
14 ;; it under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ;; GNU General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
6728
|
29 ;; All gnus-uu commands start with `C-c C-v'.
|
|
30 ;;
|
7291
|
31 ;; Short user manual for this package:
|
6728
|
32 ;;
|
7291
|
33 ;; Type `C-c C-v C-v' to decode and view all articles of the current
|
|
34 ;; series. The defaults should be reasonable for most systems.
|
6728
|
35 ;;
|
7291
|
36 ;; Type `C-c C-v C-i' to toggle interactive mode. When using
|
|
37 ;; interactive mode, gnus-uu will which display a buffer that will let
|
|
38 ;; you see the suggested commands to be executed.
|
6728
|
39 ;;
|
7291
|
40 ;; To post an uuencoded file, type `C-c C-v p', which will enter you
|
|
41 ;; into a buffer analogous to the one you will get when typing `a'. Do
|
|
42 ;; an `M-x describe-mode' in this buffer to get a description of what
|
|
43 ;; this buffer lets you do.
|
6728
|
44 ;;
|
7291
|
45 ;; Read the documentation of the `gnus-uu' dummy function for a more
|
|
46 ;; complete description of what this package does and how you can
|
|
47 ;; customize it to fit your needs.
|
|
48 ;;
|
6728
|
49 ;;
|
|
50 ;;
|
|
51 ;; History
|
|
52 ;;
|
|
53 ;; v1.0: First version released Oct 2 1992.
|
|
54 ;;
|
|
55 ;; v1.1: Changed `C-c C-r' to `C-c C-e' and `C-c C-p' to `C-c C-k'.
|
|
56 ;; Changed (setq gnus-exit-group-hook) to (add-hook). Removed
|
|
57 ;; checking for "Re:" for finding parts.
|
|
58 ;;
|
|
59 ;; v2.2: Fixed handling of currupted archives. Changed uudecoding to
|
|
60 ;; an asynchronous process to avoid loading tons of data into emacs
|
|
61 ;; buffers. No longer reads articles emacs already have aboard. Fixed
|
|
62 ;; a firmer support for shar files. Made regexp searches for files
|
|
63 ;; more convenient. Added `C-c C-l' for editing uucode begin
|
|
64 ;; lines. Added multi-system decoder entry point. Added interactive
|
|
65 ;; view mode. Added function for decoding and saving all uuencoded
|
|
66 ;; articles in the current newsgroup.
|
|
67 ;;
|
|
68 ;; v2.3: After suggestions I have changed all the gnus-uu key bindings
|
|
69 ;; to avoid hogging all the user keys (C-c LETTER). Also added
|
|
70 ;; (provide) and fixed some saving stuff. First posted version to
|
|
71 ;; gnu.emacs.sources.
|
|
72 ;;
|
|
73 ;; v2.4: Fixed some more in the save-all category. Automatic fixing of
|
|
74 ;; uucode "begin" lines: names on the form of "dir/file" are
|
|
75 ;; translated into "dir-file". Added a function for fixing stripped
|
|
76 ;; uucode articles. Added binhex save.
|
|
77 ;;
|
6904
|
78 ;; v2.5: First version copyrighted by FSF. Changed lots of
|
|
79 ;; documentation strings.
|
6728
|
80 ;;
|
6904
|
81 ;; v2.5.1: Added uuencode/posting code to post binary files.
|
|
82 ;;
|
7291
|
83 ;; v2.6: Thread support. gnus-uu is now able to decode uuencoded files
|
|
84 ;; posted in threads. gnus-uu can also post in threads. I don't know
|
|
85 ;; if this ability is of much use - I've never seen anyone post
|
|
86 ;; uuencoded files in threads.
|
6728
|
87 ;;
|
7291
|
88 ;; v2.7: gnus-uu is now able to decode (and view/save) multiple
|
|
89 ;; encoded files in one big gulp. Also added pseudo-mime support
|
|
90 ;; (users can use metamail to view files), posting uuencoded/mime
|
|
91 ;; files and various other bits and pieces.
|
6728
|
92 ;;
|
7291
|
93 ;; v2.7.1: New functions for decoding/saving threads bound to `C-c
|
|
94 ;; C-v C-j'. Handy to save entire threads, not very useful for
|
|
95 ;; decoding, as nobody posts encoded files in threads...
|
6728
|
96 ;;
|
7977
|
97 ;; v2.7.2: New functions for digesting and forwarding articles added
|
7291
|
98 ;; on the suggestion of Per Abrahamsen. Also added a function for
|
|
99 ;; marking threads.
|
7977
|
100 ;;
|
|
101 ;; v2.8: Fixed saving original files in interactive mode. Fixed ask
|
|
102 ;; before/save after view. Fixed setting up interactive buffers. Added
|
|
103 ;; scanning and rescanning from interactive mode. Added the
|
|
104 ;; `gnus-uu-ignore-file-by-name' and `...-by-type' variables to allow
|
|
105 ;; users to sift files they don't want to view. At the suggestion of
|
|
106 ;; boris@cs.rochester.edu, `C-c C-v C-h' has been undefined to allow
|
|
107 ;; users to view list of binding beginning with `C-c C-v'. Fixed
|
|
108 ;; viewing with `gnus-uu-asynchronous' set. The
|
|
109 ;; "decode-and-save/view-all-articles" functions now accepts the
|
|
110 ;; numeric prefix to delimit the maximum number of files to be
|
|
111 ;; decoded.
|
6728
|
112
|
6729
|
113 ;;; Code:
|
|
114
|
6728
|
115 (require 'gnus)
|
6904
|
116 (require 'gnuspost)
|
6728
|
117
|
|
118 ;; Binding of keys to the gnus-uu functions.
|
|
119
|
|
120 (defvar gnus-uu-ctl-map nil)
|
|
121 (define-prefix-command 'gnus-uu-ctl-map)
|
|
122 (define-key gnus-summary-mode-map "\C-c\C-v" gnus-uu-ctl-map)
|
|
123
|
|
124 (define-key gnus-uu-ctl-map "\C-v" 'gnus-uu-decode-and-view)
|
|
125 (define-key gnus-uu-ctl-map "v" 'gnus-uu-decode-and-save)
|
|
126 (define-key gnus-uu-ctl-map "\C-s" 'gnus-uu-shar-and-view)
|
|
127 (define-key gnus-uu-ctl-map "s" 'gnus-uu-shar-and-save)
|
|
128 (define-key gnus-uu-ctl-map "\C-m" 'gnus-uu-multi-decode-and-view)
|
|
129 (define-key gnus-uu-ctl-map "m" 'gnus-uu-multi-decode-and-save)
|
|
130
|
|
131 (define-key gnus-uu-ctl-map "\C-b" 'gnus-uu-decode-and-show-in-buffer)
|
|
132
|
|
133 (define-key gnus-summary-mode-map "#" 'gnus-uu-mark-article)
|
|
134 (define-key gnus-summary-mode-map "\M-#" 'gnus-uu-unmark-article)
|
|
135 (define-key gnus-uu-ctl-map "\C-u" 'gnus-uu-unmark-all-articles)
|
|
136 (define-key gnus-uu-ctl-map "\C-r" 'gnus-uu-mark-by-regexp)
|
7291
|
137 (define-key gnus-uu-ctl-map "r" 'gnus-uu-mark-by-regexp)
|
|
138 (define-key gnus-uu-ctl-map "t" 'gnus-uu-mark-thread)
|
6728
|
139
|
|
140 (define-key gnus-uu-ctl-map "\M-\C-v" 'gnus-uu-marked-decode-and-view)
|
|
141 (define-key gnus-uu-ctl-map "\M-v" 'gnus-uu-marked-decode-and-save)
|
|
142 (define-key gnus-uu-ctl-map "\M-\C-s" 'gnus-uu-marked-shar-and-view)
|
|
143 (define-key gnus-uu-ctl-map "\M-s" 'gnus-uu-marked-shar-and-save)
|
|
144 (define-key gnus-uu-ctl-map "\M-\C-m" 'gnus-uu-marked-multi-decode-and-view)
|
|
145 (define-key gnus-uu-ctl-map "\M-m" 'gnus-uu-marked-multi-decode-and-save)
|
|
146
|
7291
|
147 (define-key gnus-uu-ctl-map "f" 'gnus-uu-digest-and-forward)
|
|
148 (define-key gnus-uu-ctl-map "\M-f" 'gnus-uu-marked-digest-and-forward)
|
|
149
|
6728
|
150 (define-key gnus-uu-ctl-map "\C-i" 'gnus-uu-toggle-interactive-view)
|
|
151 (define-key gnus-uu-ctl-map "\C-t" 'gnus-uu-toggle-any-variable)
|
|
152
|
|
153 (define-key gnus-uu-ctl-map "\C-l" 'gnus-uu-edit-begin-line)
|
|
154
|
7291
|
155 (define-key gnus-uu-ctl-map "a" 'gnus-uu-decode-and-save-all-unread-articles)
|
|
156 (define-key gnus-uu-ctl-map "w" 'gnus-uu-decode-and-save-all-articles)
|
|
157 (define-key gnus-uu-ctl-map "\C-a" 'gnus-uu-decode-and-view-all-unread-articles)
|
|
158 (define-key gnus-uu-ctl-map "\C-w" 'gnus-uu-decode-and-view-all-articles)
|
|
159
|
|
160 (define-key gnus-uu-ctl-map "\C-j" 'gnus-uu-threaded-multi-decode-and-view)
|
|
161 (define-key gnus-uu-ctl-map "j" 'gnus-uu-threaded-multi-decode-and-save)
|
|
162
|
|
163 (define-key gnus-uu-ctl-map "p" 'gnus-uu-post-news)
|
6728
|
164
|
6904
|
165 ;; Dummy function gnus-uu
|
|
166
|
|
167 (defun gnus-uu ()
|
|
168 "gnus-uu is a package for uudecoding and viewing articles.
|
|
169
|
7291
|
170
|
|
171 Keymap overview:
|
|
172
|
6904
|
173 By default, all gnus-uu keystrokes begin with `C-c C-v'.
|
|
174
|
|
175 There four decoding commands categories:
|
|
176 All commands for viewing are `C-c C-v C-LETTER'.
|
|
177 All commands for saving are `C-c C-v LETTER'.
|
|
178 All commands for marked viewing are `C-c C-v C-M-LETTER'.
|
|
179 All commands for marked saving are `C-c C-v M-LETTER'.
|
|
180
|
|
181 \\<gnus-summary-mode-map>\\[gnus-uu-decode-and-view]\tDecode and view articles
|
|
182 \\[gnus-uu-decode-and-save]\tDecode and save articles
|
|
183 \\[gnus-uu-shar-and-view]\tUnshar and view articles
|
|
184 \\[gnus-uu-shar-and-save]\tUnshar and save articles
|
|
185 \\[gnus-uu-multi-decode-and-view]\tChoose a decoding method, decode and view articles
|
|
186 \\[gnus-uu-multi-decode-and-save]\tChoose a decoding method, decode and save articles
|
|
187
|
7291
|
188 \\[gnus-uu-threaded-multi-decode-and-view]\tDecode a thread and view
|
|
189 \\[gnus-uu-threaded-multi-decode-and-save]\tDecode a thread and save
|
|
190
|
6904
|
191 \\[gnus-uu-decode-and-show-in-buffer]\tDecode the current article and view the result in a buffer
|
|
192 \\[gnus-uu-edit-begin-line]\tEdit the 'begin' line of an uuencoded article
|
|
193
|
|
194 \\[gnus-uu-decode-and-save-all-unread-articles]\tDecode and save all unread articles
|
|
195 \\[gnus-uu-decode-and-save-all-articles]\tDecode and save all articles
|
7291
|
196 \\[gnus-uu-decode-and-view-all-unread-articles]\tDecode and view all unread articles
|
|
197 \\[gnus-uu-decode-and-view-all-articles]\tDecode and view all articles
|
|
198
|
|
199 \\[gnus-uu-digest-and-forward]\tDigest and forward a series of articles
|
|
200 \\[gnus-uu-marked-digest-and-forward]\tDigest and forward all marked articles
|
6904
|
201
|
|
202 \\[gnus-uu-mark-article]\tMark the current article for decoding
|
|
203 \\[gnus-uu-unmark-article]\tUnmark the current article
|
|
204 \\[gnus-uu-unmark-all-articles]\tUnmark all articles
|
|
205 \\[gnus-uu-mark-by-regexp]\tMark articles for decoding by regexp
|
7291
|
206 \\[gnus-uu-mark-thread]\tMark articles in this thread
|
6904
|
207 \\[gnus-uu-marked-decode-and-view]\tDecode and view marked articles
|
|
208 \\[gnus-uu-marked-decode-and-save]\tDecode and save marked articles
|
|
209 \\[gnus-uu-marked-shar-and-view]\tUnshar and view marked articles
|
|
210 \\[gnus-uu-marked-shar-and-save]\tUnshar and save marked articles
|
|
211 \\[gnus-uu-marked-multi-decode-and-view]\tChoose decoding method, decode and view marked articles
|
|
212 \\[gnus-uu-marked-multi-decode-and-save]\tChoose decoding method, decode and save marked articles
|
|
213
|
|
214 \\[gnus-uu-toggle-asynchronous]\tToggle asynchronous viewing mode
|
|
215 \\[gnus-uu-toggle-query]\tToggle whether to ask before viewing a file
|
|
216 \\[gnus-uu-toggle-always-ask]\tToggle whether to ask to save a file after viewing
|
|
217 \\[gnus-uu-toggle-kill-carriage-return]\tToggle whether to strip trailing carriage returns
|
|
218 \\[gnus-uu-toggle-interactive-view]\tToggle whether to use interactive viewing mode
|
7291
|
219 \\[gnus-uu-toggle-correct-stripped-articles]\tToggle whether to 'correct' articles
|
|
220 \\[gnus-uu-toggle-view-with-metamail]\tToggle whether to use metamail for viewing
|
6904
|
221 \\[gnus-uu-toggle-any-variable]\tToggle any of the things above
|
|
222
|
7291
|
223 \\[gnus-uu-post-news]\tPost an uuencoded article
|
|
224
|
|
225 Function description:
|
|
226
|
|
227 `gnus-uu-decode-and-view' will try to find all articles in the same
|
|
228 series, uudecode them and view the resulting file(s).
|
|
229
|
|
230 gnus-uu guesses what articles are in the series according to the
|
|
231 following simplish rule: The subjects must be (nearly) identical,
|
|
232 except for the last two numbers of the line. (Spaces are largely
|
|
233 ignored, however.)
|
|
234
|
|
235 For example: If you choose a subject called
|
|
236 \"cat.gif (2/3)\"
|
|
237 gnus-uu will find all the articles that matches
|
|
238 \"^cat.gif ([0-9]+/[0-9]+).*$\".
|
|
239
|
|
240 Subjects that are nonstandard, like
|
|
241 \"cat.gif (2/3) Part 6 of a series\",
|
|
242 will not be properly recognized by any of the automatic viewing
|
|
243 commands, and you have to mark the articles manually with '#'.
|
|
244
|
|
245 `gnus-uu-decode-and-save' will do the same as
|
|
246 `gnus-uu-decode-and-view', except that it will not display the
|
|
247 resulting file, but save it instead.
|
|
248
|
|
249 `gnus-uu-shar-and-view' and `gnus-uu-shar-and-save' are the \"shar\"
|
|
250 equivalents to the uudecode functions. Instead of feeding the articles
|
|
251 to uudecode, they are run through /bin/sh. Most shar files can be
|
|
252 viewed and/or saved with the normal uudecode commands, which is much
|
|
253 safer, as no foreign code is run.
|
|
254
|
|
255 Instead of having windows popping up automatically, it can be handy to
|
|
256 view files interactivly, especially when viewing archives. Use
|
|
257 `gnus-uu-toggle-interactive-mode' to toggle interactive mode.
|
|
258
|
|
259 `gnus-uu-mark-article' marks an article for later
|
|
260 decoding/unsharing/saving/viewing. The files will be decoded in the
|
|
261 sequence they were marked. To decode the files after you've marked the
|
|
262 articles you are interested in, type the corresponding key strokes as
|
|
263 the normal decoding commands, but put a `M-' in the last
|
|
264 keystroke. For instance, to perform a standard uudecode and view, you
|
|
265 would type `C-c C-v C-v'. To perform a marked uudecode and view, say
|
|
266 `C-v C-v M-C-v'. All the other view and save commands are handled the
|
|
267 same way; marked uudecode and save is then `C-c C-v M-v'.
|
|
268
|
|
269 `gnus-uu-unmark-article' will remove the mark from a previosly marked
|
|
270 article.
|
|
271
|
|
272 `gnus-uu-unmark-all-articles' will remove the mark from all marked
|
|
273 articles.
|
|
274
|
|
275 `gnus-uu-mark-by-regexp' will prompt for a regular expression and mark
|
|
276 all articles matching that regular expression.
|
|
277
|
|
278 `gnus-uu-mark-thread' will mark all articles downward in the current
|
|
279 thread.
|
|
280
|
|
281 There's an additional way to reach the decoding functions to make
|
|
282 future expansions easier: `gnus-uu-multi-decode-and-view' and the
|
|
283 corresponding save, marked view and marked save functions. You will be
|
|
284 prompted for a decoding method, like uudecode, shar, binhex or plain
|
|
285 save. Note that methods like binhex and save doesn't have view modes;
|
|
286 even if you issue a view command (`C-c C-v C-m' and \"binhex\"),
|
|
287 gnus-uu will just save the resulting binhex file.
|
|
288
|
|
289 `gnus-uu-decode-and-show-in-buffer' will decode the current article
|
|
290 and display the results in an emacs buffer. This might be useful if
|
|
291 there's jsut some text in the current article that has been uuencoded
|
|
292 by some perverse poster.
|
|
293
|
|
294 `gnus-uu-decode-and-save-all-articles' looks at all the articles in
|
|
295 the current newsgroup and tries to uudecode everything it can
|
|
296 find. The user will be prompted for a directory where the resulting
|
|
297 files (if any) will be
|
|
298 saved. `gnus-uu-decode-and-save-unread-articles' does only checks
|
|
299 unread articles.
|
|
300
|
|
301 `gnus-uu-decode-and-view-all-articles' does the same as the function
|
|
302 above, only viewing files instead of saving them.
|
|
303
|
|
304 `gnus-uu-edit-begin-line' lets you edit the begin line of an uuencoded
|
|
305 file in the current article. Useful to change a corrupted begin line.
|
|
306
|
|
307
|
|
308 When using the view commands, `gnus-uu-decode-and-view' for instance,
|
|
309 gnus-uu will (normally, see below) try to view the file according to
|
|
310 the rules given in `gnus-uu-default-view-rules' and
|
|
311 `gnus-uu-user-view-rules'. If it recognizes the file, it will display
|
|
312 it immediately. If the file is some sort of archive, gnus-uu will
|
|
313 attempt to unpack the archive and see if any of the files in the
|
|
314 archive can be viewed. For instance, if you have a gzipped tar file
|
|
315 \"pics.tar.gz\" containing the files \"pic1.jpg\" and \"pic2.gif\",
|
|
316 gnus-uu will uncompress and detar the main file, and then view the two
|
|
317 pictures. This unpacking process is recursive, so if the archive
|
|
318 contains archives of archives, it'll all be unpacked.
|
|
319
|
|
320 If the view command doesn't recognise the file type, or can't view it
|
|
321 because you don't have the viewer, or can't view *any* of the files in
|
|
322 the archive, the user will be asked if she wishes to have the file
|
|
323 saved somewhere. Note that if the decoded file is an archive, and
|
|
324 gnus-uu manages to view some of the files in the archive, it won't
|
|
325 tell the user that there were some files that were unviewable. Try
|
|
326 interactive view for a different approach.
|
|
327
|
|
328
|
|
329 Note that gnus-uu adds a function to `gnus-exit-group-hook' to clear
|
|
330 the list of marked articles and check for any generated files that
|
|
331 might have escaped deletion if the user typed `C-g' during viewing.
|
|
332
|
|
333
|
|
334 `gnus-uu-toggle-asynchronous' toggles the `gnus-uu-asynchronous'
|
|
335 variable.
|
|
336
|
|
337 `gnus-uu-toggle-query' toggles the `gnus-uu-ask-before-view'
|
|
338 variable.
|
|
339
|
|
340 `gnus-uu-toggle-always-ask' toggles the `gnus-uu-view-and-save'
|
|
341 variable.
|
|
342
|
|
343 `gnus-uu-toggle-kill-carriage-return' toggles the
|
|
344 `gnus-uu-kill-carriage-return' variable.
|
|
345
|
|
346 `gnus-uu-toggle-interactive-view' toggles interactive mode. If it is
|
|
347 turned on, gnus-uu won't view files immediately, but will give you a
|
|
348 buffer with the default commands and files and let you edit the
|
|
349 commands and execute them at leisure.
|
|
350
|
|
351 `gnus-uu-toggle-correct-stripped-articles' toggles whether to check
|
|
352 and correct uuencoded articles that may have had trailing spaces
|
|
353 stripped by mailers.
|
|
354
|
|
355 `gnus-uu-toggle-view-with-metamail' toggles whether to skip the
|
|
356 gnus-uu viewing methods and just guess at an content-type based on the
|
|
357 file name suffix and feed it to metamail.
|
|
358
|
|
359 `gnus-uu-toggle-any-variable' is an interface to the toggle commands
|
|
360 listed above.
|
|
361
|
|
362
|
|
363 Customization
|
6904
|
364
|
|
365 Rule Variables
|
|
366
|
|
367 gnus-uu uses \"rule\" variables to decide how to view a file. All
|
|
368 these variables are of the form
|
|
369
|
|
370 (list '(regexp1 command2)
|
|
371 '(regexp2 command2)
|
|
372 ...)
|
|
373
|
|
374 `gnus-uu-user-view-rules'
|
|
375 This variable is consulted first when viewing files. If you wish
|
|
376 to use, for instance, sox to convert an .au sound file, you could
|
|
377 say something like:
|
|
378
|
|
379 (setq gnus-uu-user-view-rules
|
|
380 (list '(\"\\\\.au$\" \"sox %s -t .aiff > /dev/audio\")))
|
|
381
|
|
382 `gnus-uu-user-view-rules-end'
|
|
383 This variable is consulted if gnus-uu couldn't make any matches
|
|
384 from the user and default view rules.
|
|
385
|
|
386 `gnus-uu-user-interactive-view-rules'
|
|
387 This is the variable used instead of `gnus-uu-user-view-rules'
|
|
388 when in interactive mode.
|
|
389
|
|
390 `gnus-uu-user-interactive-view-rules-end'
|
|
391 This variable is used instead of `gnus-uu-user-view-rules-end'
|
|
392 when in interactive mode.
|
|
393
|
|
394 `gnus-uu-user-archive-rules`
|
|
395 This variable can be used to say what comamnds should be used to
|
|
396 unpack archives.
|
|
397
|
|
398
|
|
399 Other Variables
|
|
400
|
7977
|
401 `gnus-uu-ignore-files-by-name'
|
|
402 Files with name matching this regular expression won't be viewed.
|
|
403
|
|
404 `gnus-uu-ignore-files-by-type'
|
|
405 Files with a MIME type matching this variable won't be viewed.
|
|
406 Note that gnus-uu tries to guess what type the file is based on
|
|
407 the name. gnus-uu is not a MIME package, so this is slightly
|
|
408 kludgy.
|
|
409
|
6904
|
410 `gnus-uu-tmp-dir'
|
|
411 Where gnus-uu does its work.
|
|
412
|
|
413 `gnus-uu-do-not-unpack-archives'
|
|
414 Non-nil means that gnus-uu won't peek inside archives looking for
|
|
415 files to dispay.
|
|
416
|
|
417 `gnus-uu-view-and-save'
|
|
418 Non-nil means that the user will always be asked to save a file
|
|
419 after viewing it.
|
|
420
|
7291
|
421 `gnus-uu-asynchronous'
|
|
422 Non-nil means that files will be viewed asynchronously. This can
|
|
423 be useful if you're viewing long .mod files, for instance, which
|
|
424 often takes several minutes. Note, however, that since gnus-uu
|
|
425 doesn't ask, and if you are viewing an archive with lots of
|
|
426 viewable files, you'll get them all up more or less at once,
|
|
427 which can be confusing, to say the least. To get gnus-uu to ask
|
|
428 you before viewing a file, set the `gnus-uu-ask-before-view'
|
|
429 variable.
|
6904
|
430
|
|
431 `gnus-uu-ask-before-view'
|
|
432 Non-nil means that gnus-uu will ask you before viewing each file
|
|
433
|
|
434 `gnus-uu-ignore-default-view-rules'
|
|
435 Non-nil means that gnus-uu will ignore the default viewing rules.
|
|
436
|
|
437 `gnus-uu-ignore-default-archive-rules'
|
|
438 Non-nil means that gnus-uu will ignore the default archive
|
|
439 unpacking commands.
|
|
440
|
|
441 `gnus-uu-kill-carriage-return'
|
|
442 Non-nil means that gnus-uu will strip all carriage returns from
|
|
443 articles.
|
|
444
|
|
445 `gnus-uu-unmark-articles-not-decoded'
|
|
446 Non-nil means that gnus-uu will mark articles that were
|
|
447 unsuccessfully decoded as unread.
|
|
448
|
|
449 `gnus-uu-output-window-height'
|
|
450 This variable says how tall the output buffer window is to be
|
|
451 when using interactive view mode.
|
|
452
|
|
453 `gnus-uu-correct-stripped-uucode'
|
|
454 Non-nil means that gnus-uu will *try* to fix uuencoded files that
|
|
455 have had traling spaces deleted.
|
|
456
|
|
457 `gnus-uu-use-interactive-view'
|
7291
|
458 Non-nil means that gnus-uu will use interactive viewing mode.
|
|
459
|
|
460 `gnus-uu-view-with-metamail'
|
|
461 Non-nil means that gnus-uu will ignore the viewing commands
|
|
462 defined by the rule variables and just fudge a MIME content type
|
|
463 based on the file name. The result will be fed to metamail for
|
|
464 viewing.
|
|
465
|
|
466 `gnus-uu-save-in-digest'
|
|
467 Non-nil means that gnus-uu, when asked to save without decoding,
|
|
468 will save in digests. If this variable is nil, gnus-uu will just
|
|
469 save everything in a file without any embellishments. The
|
|
470 digesting almost conforms to RFC1153 - no easy way to specify any
|
|
471 meaningful volume and issue numbers were found, so I simply
|
|
472 dropped them.
|
|
473
|
|
474 `gnus-uu-post-include-before-composing'
|
|
475 Non-nil means that gnus-uu will ask for a file to encode before
|
|
476 you compose the article. If this variable is t, you can either
|
|
477 include an encoded file with \\<gnus-uu-post-reply-mode-map>\\[gnus-uu-post-insert-binary-in-article] or have one included for you when you
|
|
478 post the article.
|
|
479
|
|
480 `gnus-uu-post-length'
|
|
481 Maximum length of an article. The encoded file will be split
|
|
482 into how many articles it takes to post the entire file.
|
|
483
|
|
484 `gnus-uu-post-threaded'
|
|
485 Non-nil means that gnus-uu will post the encoded file in a
|
|
486 thread. This may not be smart, as no other decoder I have seen
|
|
487 are able to follow threads when collecting uuencoded
|
|
488 articles. (Well, I have seen one package that does that -
|
|
489 gnus-uu, but somehow, I don't think that counts...) Default is
|
|
490 nil.
|
|
491
|
|
492 `gnus-uu-post-separate-description'
|
|
493 Non-nil means that the description will be posted in a separate
|
|
494 article. The first article will typically be numbered (0/x). If
|
|
495 this variable is nil, the description the user enters will be
|
|
496 included at the beginning of the first article, which will be
|
|
497 numbered (1/x). Default is t.
|
|
498 "
|
6904
|
499 (interactive)
|
|
500 )
|
|
501
|
6728
|
502 ;; Default viewing action rules
|
|
503
|
6904
|
504 (defvar gnus-uu-default-view-rules
|
6728
|
505 (list
|
|
506 '("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv")
|
|
507 '("\\.tga$" "tgatoppm %s | xv -")
|
|
508 '("\\.te?xt$\\|\\.doc$\\|read.*me" "xterm -e less")
|
|
509 '("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
|
|
510 "sox -v .5 %s -t .au -u - > /dev/audio")
|
|
511 '("\\.au$" "cat %s > /dev/audio")
|
|
512 '("\\.mod$" "str32")
|
|
513 '("\\.ps$" "ghostview")
|
|
514 '("\\.dvi$" "xdvi")
|
7291
|
515 '("\\.[1-6]$" "xterm -e man -l")
|
6728
|
516 '("\\.html$" "xmosaic")
|
|
517 '("\\.mpe?g$" "mpeg_play")
|
7977
|
518 '("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\)$" "xanim")
|
7291
|
519 '("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
|
6728
|
520 "gnus-uu-archive"))
|
|
521
|
6904
|
522 "Default actions to be taken when the user asks to view a file.
|
|
523 To change the behaviour, you can either edit this variable or set
|
|
524 `gnus-uu-user-view-rules' to something useful.
|
6728
|
525
|
|
526 For example:
|
|
527
|
|
528 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
|
|
529 following in your .emacs file
|
|
530
|
|
531 (setq gnus-uu-user-view-rules (list '(\"jpg$\\\\|gif$\" \"xli\")))
|
|
532
|
6904
|
533 Both these variables are lists of lists with two string elements. The
|
|
534 first string is a regular expression. If the file name matches this
|
|
535 regular expression, the command in the second string is executed with
|
|
536 the file as an argument.
|
6728
|
537
|
|
538 If the command string contains \"%s\", the file name will be inserted
|
|
539 at that point in the command string. If there's no \"%s\" in the
|
6904
|
540 command string, the file name will be appended to the command string
|
|
541 before executing.
|
|
542
|
|
543 There are several user variables to tailor the behaviour of gnus-uu to
|
|
544 your needs. First we have `gnus-uu-user-view-rules', which is the
|
|
545 variable gnus-uu first consults when trying to decide how to view a
|
|
546 file. If this variable contains no matches, gnus-uu examines the
|
|
547 default rule vaiable provided in this package. If gnus-uu finds no
|
|
548 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
|
|
549 match.
|
|
550
|
|
551 Unless, of course, you are using the interactive view mode. Then
|
|
552 `gnus-uu-user-interactive-view-rules' and
|
|
553 `gnus-uu-user-interactive-view-rules-end' will be used instead.")
|
6728
|
554
|
|
555 (defvar gnus-uu-user-view-rules nil
|
6904
|
556 "Variable detailing what actions are to be taken to view a file.
|
|
557 See the documentation on the `gnus-uu-default-view-rules' variable for
|
6728
|
558 details.")
|
|
559
|
|
560 (defvar gnus-uu-user-view-rules-end nil
|
6904
|
561 "Variable saying what actions are to be taken if no rule matched the file name.
|
|
562 See the documentation on the `gnus-uu-default-view-rules' variable for
|
|
563 details.")
|
6728
|
564
|
|
565 (defvar gnus-uu-user-interactive-view-rules nil
|
6904
|
566 "Variable detailing what actions are to be taken to view a file when using interactive mode.
|
|
567 See the documentation on the `gnus-uu-default-view-rules' variable for
|
|
568 details.")
|
6728
|
569
|
|
570 (defvar gnus-uu-user-interactive-view-rules-end nil
|
6904
|
571 "Variable saying what actions are to be taken if no rule matched the file name when using interactive mode.
|
|
572 See the documentation on the `gnus-uu-default-view-rules' variable for
|
|
573 details.")
|
6728
|
574
|
6904
|
575 (defvar gnus-uu-default-interactive-view-rules-begin
|
6728
|
576 (list
|
7291
|
577 '("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed s/\r//g")
|
|
578 '("\\.pas$" "cat %s | sed s/\r//g")
|
6728
|
579 ))
|
|
580
|
7291
|
581 (defvar gnus-uu-default-interactive-view-rules-end
|
|
582 (list
|
|
583 '(".*" "file")))
|
6728
|
584
|
|
585 ;; Default unpacking commands
|
|
586
|
6904
|
587 (defvar gnus-uu-default-archive-rules
|
6728
|
588 (list '("\\.tar$" "tar xf")
|
7291
|
589 '("\\.zip$" "unzip -o")
|
6728
|
590 '("\\.ar$" "ar x")
|
|
591 '("\\.arj$" "unarj x")
|
|
592 '("\\.zoo$" "zoo -e")
|
7291
|
593 '("\\.\\(lzh\\|lha\\)$" "lha x")
|
6728
|
594 '("\\.Z$" "uncompress")
|
|
595 '("\\.gz$" "gunzip")
|
|
596 '("\\.arc$" "arc -x"))
|
6904
|
597 )
|
|
598
|
7291
|
599 (defvar gnus-uu-destructive-archivers
|
|
600 (list "uncompress" "gunzip"))
|
|
601
|
6904
|
602 (defvar gnus-uu-user-archive-rules nil
|
|
603 "A list that can be set to override the default archive unpacking commands.
|
|
604 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
|
|
605 unpack zip files, say the following:
|
|
606 (setq gnus-uu-user-archive-rules
|
|
607 (list '(\"\\\\.tar$\" \"untar\")
|
7977
|
608 '(\"\\\\.zip$\" \"zip -x\")))")
|
|
609
|
|
610 (defvar gnus-uu-ignore-files-by-name nil
|
|
611 "A regular expression saying what files should not be viewed based on name.
|
|
612 If, for instance, you want gnus-uu to ignore all .au and .wav files,
|
|
613 you could say something like
|
|
614
|
|
615 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
|
|
616
|
|
617 Note that this variable can be used in conjunction with the
|
|
618 `gnus-uu-ignore-files-by-type' variable.")
|
|
619
|
|
620 (defvar gnus-uu-ignore-files-by-type nil
|
|
621 "A regular expression saying what files that shouldn't be viewed, based on MIME file type.
|
|
622 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
|
|
623 you could say something like
|
|
624
|
|
625 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
|
|
626
|
|
627 Note that this variable can be used in conjunction with the
|
|
628 `gnus-uu-ignore-files-by-name' variable.")
|
6728
|
629
|
7291
|
630 ;; Pseudo-MIME support
|
|
631
|
|
632 (defconst gnus-uu-ext-to-mime-list
|
|
633 (list '("\\.gif$" "image/gif")
|
|
634 '("\\.jpe?g$" "image/jpeg")
|
|
635 '("\\.tiff?$" "image/tiff")
|
|
636 '("\\.xwd$" "image/xwd")
|
|
637 '("\\.pbm$" "image/pbm")
|
|
638 '("\\.pgm$" "image/pgm")
|
|
639 '("\\.ppm$" "image/ppm")
|
|
640 '("\\.xbm$" "image/xbm")
|
|
641 '("\\.pcx$" "image/pcx")
|
|
642 '("\\.tga$" "image/tga")
|
|
643 '("\\.ps$" "image/postscript")
|
7977
|
644 '("\\.fli$" "video/fli")
|
7291
|
645 '("\\.wav$" "audio/wav")
|
|
646 '("\\.aiff$" "audio/aiff")
|
|
647 '("\\.hcom$" "audio/hcom")
|
|
648 '("\\.voc$" "audio/voc")
|
|
649 '("\\.smp$" "audio/smp")
|
|
650 '("\\.mod$" "audio/mod")
|
|
651 '("\\.dvi$" "image/dvi")
|
|
652 '("\\.mpe?g$" "video/mpeg")
|
|
653 '("\\.au$" "audio/basic")
|
|
654 '("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
|
7977
|
655 '("\\.\\(c\\|h\\)$" "text/source")
|
7291
|
656 '("read.*me" "text/plain")
|
|
657 '("\\.html$" "text/html")
|
7977
|
658 '("\\.bat$" "text/bat")
|
|
659 '("\\.[1-6]$" "text/man")
|
|
660 '("\\.flc$" "video/flc")
|
|
661 '("\\.rle$" "video/rle")
|
|
662 '("\\.pfx$" "video/pfx")
|
|
663 '("\\.avi$" "video/avi")
|
|
664 '("\\.sme$" "video/sme")
|
|
665 '("\\.rpza$" "video/prza")
|
|
666 '("\\.dl$" "video/dl")
|
|
667 '("\\.qt$" "video/qt")
|
|
668 '("\\.rsrc$" "video/rsrc")
|
7291
|
669 '("\\..*$" "unknown/unknown")))
|
6728
|
670
|
|
671 ;; Various variables users may set
|
|
672
|
|
673 (defvar gnus-uu-tmp-dir "/tmp/"
|
6904
|
674 "Variable saying where gnus-uu is to do its work.
|
|
675 Default is \"/tmp/\".")
|
6728
|
676
|
|
677 (defvar gnus-uu-do-not-unpack-archives nil
|
6904
|
678 "Non-nil means that gnus-uu won't peek inside archives looking for files to dispay.
|
|
679 Default is nil.")
|
6728
|
680
|
|
681 (defvar gnus-uu-view-and-save nil
|
6904
|
682 "Non-nil means that the user will always be asked to save a file after viewing it.
|
|
683 If the variable is nil, the suer will only be asked to save if the
|
|
684 viewing is unsuccessful. Default is nil.")
|
6728
|
685
|
|
686 (defvar gnus-uu-asynchronous nil
|
6904
|
687 "Non-nil means that files will be viewed asynchronously.
|
|
688 Default is nil.")
|
6728
|
689
|
|
690 (defvar gnus-uu-ask-before-view nil
|
6904
|
691 "Non-nil means that gnus-uu will ask you before viewing each file.
|
|
692 Especially useful when `gnus-uu-asynchronous' is set. Default is
|
|
693 nil.")
|
6728
|
694
|
|
695 (defvar gnus-uu-ignore-default-view-rules nil
|
6904
|
696 "Non-nil means that gnus-uu will ignore the default viewing rules.
|
|
697 Only the user viewing rules will be consulted. Default is nil.")
|
6728
|
698
|
6904
|
699 (defvar gnus-uu-ignore-default-archive-rules nil
|
|
700 "Non-nil means that gnus-uu will ignore the default archive unpacking commands.
|
|
701 Only the user unpacking commands will be consulted. Default is nil.")
|
6728
|
702
|
|
703 (defvar gnus-uu-kill-carriage-return t
|
6904
|
704 "Non-nil means that gnus-uu will strip all carriage returns from articles.
|
|
705 Default is t.")
|
6728
|
706
|
7291
|
707 (defvar gnus-uu-view-with-metamail nil
|
|
708 "Non-nil means that files will be viewed with metamail.
|
|
709 The gnus-uu viewing functions will be ignored and gnus-uu will try
|
|
710 to guess at a content-type based on file name suffixes. Default
|
|
711 it nil.")
|
|
712
|
6728
|
713 (defvar gnus-uu-unmark-articles-not-decoded nil
|
6904
|
714 "Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
|
|
715 Default is nil.")
|
6728
|
716
|
|
717 (defvar gnus-uu-output-window-height 20
|
6904
|
718 "This variable says how tall the output buffer window is to be when using interactive view mode.
|
|
719 Change it at your convenience. Default is 20.")
|
6728
|
720
|
|
721 (defvar gnus-uu-correct-stripped-uucode nil
|
6904
|
722 "Non-nil means that gnus-uu will *try* to fix uuencoded files that have had traling spaces deleted.
|
|
723 Default is nil.")
|
6728
|
724
|
|
725 (defvar gnus-uu-use-interactive-view nil
|
6904
|
726 "Non-nil means that gnus-uu will use interactive viewing mode.
|
|
727 Gnus-uu will create a special buffer where the user may choose
|
|
728 interactively which files to view and how. Default is nil.")
|
6728
|
729
|
7291
|
730 (defvar gnus-uu-save-in-digest nil
|
|
731 "Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
|
|
732 If this variable is nil, gnus-uu will just save everything in a
|
|
733 file without any embellishments. The digesting almost conforms to RFC1153 -
|
|
734 no easy way to specify any meaningful volume and issue numbers were found,
|
|
735 so I simply dropped them.")
|
|
736
|
6728
|
737
|
|
738 ;; Internal variables
|
|
739
|
6904
|
740 (defconst gnus-uu-begin-string "^begin[ \t]+[0-7][0-7][0-7][ \t]+\\(.*\\)$")
|
6728
|
741 (defconst gnus-uu-end-string "^end[ \t]*$")
|
7291
|
742
|
|
743 (defconst gnus-uu-body-line "^M")
|
|
744 (let ((i 61))
|
|
745 (while (> (setq i (1- i)) 0)
|
|
746 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
|
|
747 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
|
|
748
|
|
749 ;"^M.............................................................?$"
|
|
750
|
6904
|
751 (defconst gnus-uu-shar-begin-string "^#! */bin/sh")
|
6728
|
752
|
6904
|
753 (defvar gnus-uu-shar-file-name nil)
|
|
754 (defconst gnus-uu-shar-name-marker "begin [0-7][0-7][0-7][ \t]+\\(\\(\\w\\|\\.\\)*\\b\\)")
|
6728
|
755 (defvar gnus-uu-shar-directory nil)
|
|
756
|
|
757 (defvar gnus-uu-file-name nil)
|
7977
|
758 (defvar gnus-uu-list-of-files-decoded nil)
|
6728
|
759 (defconst gnus-uu-uudecode-process nil)
|
|
760
|
|
761 (defvar gnus-uu-interactive-file-list nil)
|
|
762 (defvar gnus-uu-marked-article-list nil)
|
|
763 (defvar gnus-uu-generated-file-list nil)
|
7291
|
764 (defvar gnus-uu-work-dir nil)
|
6728
|
765
|
|
766 (defconst gnus-uu-interactive-buffer-name "*gnus-uu interactive*")
|
|
767 (defconst gnus-uu-output-buffer-name "*Gnus UU Output*")
|
|
768 (defconst gnus-uu-result-buffer "*Gnus UU Result Buffer*")
|
|
769
|
7977
|
770 (defconst gnus-uu-highest-article-number 1)
|
6728
|
771
|
|
772 ;; Interactive functions
|
|
773
|
|
774 ;; UUdecode and view
|
|
775
|
|
776 (defun gnus-uu-decode-and-view ()
|
|
777 "UUdecodes and 'views' (if possible) the resulting file.
|
6904
|
778 'Viewing' can be any action at all, as defined in the
|
|
779 `gnus-uu-file-action-list' variable. Running 'xv' on gifs and 'cat
|
|
780 >/dev/audio' on au files are popular actions. If the file can't be
|
|
781 viewed, the user is asked if she would like to save the file instead."
|
|
782 (interactive)
|
6728
|
783 (gnus-uu-decode-and-view-or-save t nil))
|
|
784
|
|
785 (defun gnus-uu-decode-and-save ()
|
6904
|
786 "Decodes and saves the resulting file."
|
6728
|
787 (interactive)
|
|
788 (gnus-uu-decode-and-view-or-save nil nil))
|
|
789
|
|
790 (defun gnus-uu-marked-decode-and-view ()
|
6904
|
791 "Decodes and views articles marked.
|
|
792 The marked equivalent to `gnus-uu-decode-and-view'."
|
6728
|
793 (interactive)
|
|
794 (gnus-uu-decode-and-view-or-save t t))
|
|
795
|
|
796 (defun gnus-uu-marked-decode-and-save ()
|
6904
|
797 "Decodes and saves articles marked.
|
|
798 The marked equivalent to `gnus-uu-decode-and-save'."
|
6728
|
799 (interactive)
|
|
800 (gnus-uu-decode-and-view-or-save nil t))
|
|
801
|
|
802
|
|
803 ;; Unshar and view
|
|
804
|
|
805 (defun gnus-uu-shar-and-view ()
|
6904
|
806 "Unshars and views articles.
|
|
807 The shar equivalent of `gnus-uu-decode-and-view'."
|
6728
|
808 (interactive)
|
|
809 (gnus-uu-unshar-and-view-or-save t nil))
|
|
810
|
|
811 (defun gnus-uu-shar-and-save ()
|
6904
|
812 "Unshars and saves files.
|
|
813 The shar equivalent to `gnus-uu-decode-and-save'."
|
6728
|
814 (interactive)
|
|
815 (gnus-uu-unshar-and-view-or-save nil nil))
|
|
816
|
|
817 (defun gnus-uu-marked-shar-and-view ()
|
6904
|
818 "Unshars and views articles marked.
|
|
819 The marked equivalent to `gnus-uu-shar-and-view'."
|
6728
|
820 (interactive)
|
|
821 (gnus-uu-unshar-and-view-or-save t t))
|
|
822
|
|
823 (defun gnus-uu-marked-shar-and-save ()
|
6904
|
824 "Unshars and saves articles marked.
|
|
825 The marked equivalent to `gnus-uu-shar-and-save'."
|
6728
|
826 (interactive)
|
|
827 (gnus-uu-unshar-and-view-or-save nil t))
|
|
828
|
7291
|
829 ;; Threaded decode
|
|
830
|
|
831 (defun gnus-uu-threaded-decode-and-view ()
|
|
832 "Decodes and saves the resulting file."
|
|
833 (interactive)
|
|
834 (gnus-uu-threaded-decode-and-view-or-save t))
|
|
835
|
|
836 (defun gnus-uu-threaded-decode-and-save ()
|
|
837 "Decodes and saves the resulting file."
|
|
838 (interactive)
|
|
839 (gnus-uu-threaded-decode-and-view-or-save nil))
|
|
840
|
|
841 (defun gnus-uu-threaded-multi-decode-and-view ()
|
|
842 "Decodes and saves the resulting file."
|
|
843 (interactive)
|
|
844 (gnus-uu-threaded-multi-decode-and-view-or-save t))
|
|
845
|
|
846 (defun gnus-uu-threaded-multi-decode-and-save ()
|
|
847 "Decodes and saves the resulting file."
|
6728
|
848 (interactive)
|
7291
|
849 (gnus-uu-threaded-multi-decode-and-view-or-save nil))
|
|
850
|
|
851 (defun gnus-uu-threaded-decode-and-view-or-save (&optional view)
|
|
852 (gnus-uu-unmark-all-articles)
|
|
853 (gnus-uu-mark-thread)
|
|
854 (gnus-uu-decode-and-view-or-save view t))
|
|
855
|
|
856 (defun gnus-uu-threaded-multi-decode-and-view-or-save (view)
|
|
857 (let (type)
|
|
858 (message "Decode type: [u]udecode, (s)har, s(a)ve, (b)inhex: ")
|
|
859 (setq type (read-char))
|
|
860 (if (not (or (= type ?u) (= type ?s) (= type ?b) (= type ?a)))
|
|
861 (error "No such decoding method '%c'" type))
|
|
862
|
|
863 (gnus-uu-unmark-all-articles)
|
|
864 (gnus-uu-mark-thread)
|
|
865
|
|
866 (if (= type ?\r) (setq type ?u))
|
|
867 (cond ((= type ?u) (gnus-uu-decode-and-view-or-save view t))
|
|
868 ((= type ?s) (gnus-uu-unshar-and-view-or-save view t))
|
|
869 ((= type ?b) (gnus-uu-binhex-and-save view t))
|
|
870 ((= type ?a) (gnus-uu-save-articles view t)))))
|
|
871
|
6728
|
872
|
|
873 ;; Toggle commands
|
|
874
|
|
875 (defun gnus-uu-toggle-asynchronous ()
|
|
876 "This function toggles asynchronous viewing."
|
|
877 (interactive)
|
|
878 (if (setq gnus-uu-asynchronous (not gnus-uu-asynchronous))
|
|
879 (message "gnus-uu will now view files asynchronously")
|
|
880 (message "gnus-uu will now view files synchronously")))
|
|
881
|
|
882 (defun gnus-uu-toggle-query ()
|
|
883 "This function toggles whether to ask before viewing or not."
|
|
884 (interactive)
|
|
885 (if (setq gnus-uu-ask-before-view (not gnus-uu-ask-before-view))
|
|
886 (message "gnus-uu will now ask before viewing")
|
|
887 (message "gnus-uu will now view without asking first")))
|
|
888
|
|
889 (defun gnus-uu-toggle-always-ask ()
|
6904
|
890 "This function toggles whether to always ask to save a file after viewing."
|
6728
|
891 (interactive)
|
|
892 (if (setq gnus-uu-view-and-save (not gnus-uu-view-and-save))
|
|
893 (message "gnus-uu will now ask to save the file after viewing")
|
|
894 (message "gnus-uu will now not ask to save after successful viewing")))
|
|
895
|
|
896 (defun gnus-uu-toggle-interactive-view ()
|
|
897 "This function toggles whether to use interactive view."
|
|
898 (interactive)
|
|
899 (if (setq gnus-uu-use-interactive-view (not gnus-uu-use-interactive-view))
|
|
900 (message "gnus-uu will now use interactive view")
|
|
901 (message "gnus-uu will now use non-interactive view")))
|
|
902
|
|
903 (defun gnus-uu-toggle-unmark-undecoded ()
|
|
904 "This function toggles whether to unmark articles not decoded."
|
|
905 (interactive)
|
|
906 (if (setq gnus-uu-unmark-articles-not-decoded
|
|
907 (not gnus-uu-unmark-articles-not-decoded))
|
|
908 (message "gnus-uu will now unmark articles not decoded")
|
|
909 (message "gnus-uu will now not unmark articles not decoded")))
|
|
910
|
|
911 (defun gnus-uu-toggle-kill-carriage-return ()
|
|
912 "This function toggles the stripping of carriage returns from the articles."
|
|
913 (interactive)
|
|
914 (if (setq gnus-uu-kill-carriage-return (not gnus-uu-kill-carriage-return))
|
|
915 (message "gnus-uu will now strip carriage returns")
|
|
916 (message "gnus-uu won't strip carriage returns")))
|
|
917
|
7291
|
918 (defun gnus-uu-toggle-view-with-metamail ()
|
|
919 "This function toggles whether to view files with metamail."
|
|
920 (interactive)
|
|
921 (if (setq gnus-uu-view-with-metamail (not gnus-uu-view-with-metamail))
|
|
922 (message "gnus-uu will now view with metamail")
|
|
923 (message "gnus-uu will now view with the gnus-uu viewing functions")))
|
|
924
|
6728
|
925 (defun gnus-uu-toggle-correct-stripped-uucode ()
|
|
926 "This function toggles whether to correct stripped uucode."
|
|
927 (interactive)
|
|
928 (if (setq gnus-uu-correct-stripped-uucode
|
|
929 (not gnus-uu-correct-stripped-uucode))
|
|
930 (message "gnus-uu will now correct stripped uucode")
|
|
931 (message "gnus-uu won't check and correct stripped uucode")))
|
|
932
|
|
933 (defun gnus-uu-toggle-any-variable ()
|
|
934 "This function ask what variable the user wants to toggle."
|
|
935 (interactive)
|
|
936 (let (rep)
|
7291
|
937 (message "(a)sync, (q)uery, (p)ask, (k)ill CR, (i)nteract, (u)nmark, (c)orrect, (m)eta")
|
6728
|
938 (setq rep (read-char))
|
|
939 (if (= rep ?a)
|
|
940 (gnus-uu-toggle-asynchronous))
|
|
941 (if (= rep ?q)
|
|
942 (gnus-uu-toggle-query))
|
|
943 (if (= rep ?p)
|
|
944 (gnus-uu-toggle-always-ask))
|
|
945 (if (= rep ?k)
|
|
946 (gnus-uu-toggle-kill-carriage-return))
|
|
947 (if (= rep ?u)
|
|
948 (gnus-uu-toggle-unmark-undecoded))
|
|
949 (if (= rep ?c)
|
|
950 (gnus-uu-toggle-correct-stripped-uucode))
|
7291
|
951 (if (= rep ?m)
|
|
952 (gnus-uu-toggle-view-with-metamail))
|
6728
|
953 (if (= rep ?i)
|
|
954 (gnus-uu-toggle-interactive-view))))
|
|
955
|
|
956
|
7291
|
957 ;; Misc interactive functions
|
|
958
|
|
959 (defun gnus-uu-decode-and-show-in-buffer ()
|
|
960 "Uudecodes the current article and displays the result in a buffer.
|
|
961 Might be useful if someone has, for instance, some text uuencoded in
|
|
962 their sigs. (Stranger things have happened.)"
|
|
963 (interactive)
|
|
964 (gnus-uu-initialize)
|
|
965 (let ((uu-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
966 file-name)
|
|
967 (save-excursion
|
|
968 (and
|
|
969 (gnus-summary-select-article)
|
|
970 (gnus-uu-grab-articles (list gnus-current-article)
|
|
971 'gnus-uu-uustrip-article-as)
|
|
972 (setq file-name (concat gnus-uu-work-dir gnus-uu-file-name))
|
|
973 (progn
|
|
974 (save-excursion
|
|
975 (set-buffer uu-buffer)
|
|
976 (erase-buffer)
|
|
977 (insert-file-contents file-name))
|
|
978 (set-window-buffer (get-buffer-window gnus-article-buffer)
|
|
979 uu-buffer)
|
|
980 (message "Showing file %s in buffer" file-name)
|
|
981 (delete-file file-name))))))
|
6728
|
982
|
|
983 (defun gnus-uu-edit-begin-line ()
|
|
984 "Edit the begin line of the current article."
|
|
985 (interactive)
|
|
986 (let ((buffer-read-only nil)
|
|
987 begin b)
|
|
988 (save-excursion
|
7291
|
989 (gnus-summary-select-article)
|
6728
|
990 (set-buffer gnus-article-buffer)
|
|
991 (goto-line 1)
|
|
992 (if (not (re-search-forward "begin " nil t))
|
7291
|
993 (error "No begin line in the current article")
|
6728
|
994 (beginning-of-line)
|
|
995 (setq b (point))
|
|
996 (end-of-line)
|
|
997 (setq begin (buffer-substring b (point)))
|
|
998 (setq begin (read-string "" begin))
|
|
999 (setq buffer-read-only nil)
|
|
1000 (delete-region b (point))
|
|
1001 (insert-string begin)))))
|
|
1002
|
7291
|
1003
|
6728
|
1004 ;; Multi functions
|
|
1005
|
|
1006 (defun gnus-uu-multi-decode-and-view ()
|
6904
|
1007 "Choose a method of decoding and then decode and view.
|
|
1008 This function lets the user decide what method to use for decoding.
|
|
1009 Other than that, it's equivalent to the other decode-and-view
|
|
1010 functions."
|
6728
|
1011 (interactive)
|
|
1012 (gnus-uu-multi-decode-and-view-or-save t nil))
|
|
1013
|
|
1014 (defun gnus-uu-multi-decode-and-save ()
|
6904
|
1015 "Choose a method of decoding and then decode and save.
|
|
1016 This function lets the user decide what method to use for decoding.
|
|
1017 Other than that, it's equivalent to the other decode-and-save
|
|
1018 functions."
|
6728
|
1019 (interactive)
|
|
1020 (gnus-uu-multi-decode-and-view-or-save nil nil))
|
|
1021
|
|
1022 (defun gnus-uu-marked-multi-decode-and-view ()
|
6904
|
1023 "Choose a method of decoding and then decode and view the marked articles.
|
|
1024 This function lets the user decide what method to use for decoding.
|
6728
|
1025 Other than that, it's equivalent to the other marked decode-and-view
|
|
1026 functions."
|
|
1027 (interactive)
|
|
1028 (gnus-uu-multi-decode-and-view-or-save t t))
|
|
1029
|
|
1030 (defun gnus-uu-marked-multi-decode-and-save ()
|
6904
|
1031 "Choose a method of decoding and then decode and save the marked articles.
|
|
1032 This function lets the user decide what method to use for decoding.
|
6728
|
1033 Other than that, it's equivalent to the other marked decode-and-save
|
|
1034 functions."
|
|
1035 (interactive)
|
|
1036 (gnus-uu-multi-decode-and-view-or-save t t))
|
|
1037
|
|
1038 (defun gnus-uu-multi-decode-and-view-or-save (view marked)
|
7291
|
1039 (let (type)
|
|
1040 (message "[u]udecode, (s)har, s(a)ve, (b)inhex: ")
|
|
1041 (setq type (read-char))
|
|
1042 (if (= type ?\r) (setq type ?u))
|
|
1043 (cond ((= type ?u) (gnus-uu-decode-and-view-or-save view marked))
|
|
1044 ((= type ?s) (gnus-uu-unshar-and-view-or-save view marked))
|
|
1045 ((= type ?b) (gnus-uu-binhex-and-save view marked))
|
|
1046 ((= type ?a) (gnus-uu-save-articles view marked))
|
|
1047 (t (error "Unknown decode method '%c'." type)))))
|
|
1048
|
|
1049
|
|
1050 ;; "All articles" commands
|
6728
|
1051
|
|
1052 (defconst gnus-uu-rest-of-articles nil)
|
6904
|
1053 (defvar gnus-uu-current-save-dir nil)
|
6728
|
1054
|
7977
|
1055 (defun gnus-uu-decode-and-view-all-articles (arg &optional unread)
|
|
1056 "Try to decode all articles and view the result.
|
|
1057 ARG delimits the number of files to be decoded."
|
|
1058 (interactive "p")
|
7291
|
1059 (if (not (setq gnus-uu-marked-article-list
|
|
1060 (nreverse (gnus-uu-get-list-of-articles
|
|
1061 "^." nil unread t))))
|
|
1062 (error "No%s articles to be decoded" (if unread " unread" "")))
|
7977
|
1063 (gnus-uu-decode-and-view-or-save t t nil (if (> arg 1) arg nil)))
|
|
1064
|
|
1065 (defun gnus-uu-decode-and-view-all-unread-articles (arg)
|
|
1066 "Try to decode all unread articles and view the result.
|
|
1067 ARG delimits the number of files to be decoded."
|
|
1068 (interactive "p")
|
|
1069 (gnus-uu-decode-and-view-all-articles arg t))
|
|
1070
|
|
1071 (defun gnus-uu-decode-and-save-all-unread-articles (arg)
|
6904
|
1072 "Try to decode all unread articles and saves the result.
|
|
1073 This function reads all unread articles in the current group and sees
|
|
1074 whether it can uudecode the articles. The user will be prompted for an
|
7977
|
1075 directory to put the resulting (if any) files.
|
|
1076 ARG delimits the number of files to be decoded."
|
|
1077 (interactive "p")
|
|
1078 (gnus-uu-decode-and-save-articles arg t t))
|
|
1079
|
|
1080 (defun gnus-uu-decode-and-save-all-articles (arg)
|
6904
|
1081 "Try to decode all articles and saves the result.
|
|
1082 Does the same as `gnus-uu-decode-and-save-all-unread-articles', except
|
7977
|
1083 that it grabs all articles visible, unread or not.
|
|
1084 ARG delimits the number of files to be decoded."
|
|
1085 (interactive "p")
|
|
1086 (gnus-uu-decode-and-save-articles arg nil t))
|
|
1087
|
|
1088 (defun gnus-uu-decode-and-save-articles (arg &optional unread unmark)
|
|
1089 (let (dir)
|
7291
|
1090 (if (not (setq gnus-uu-marked-article-list
|
|
1091 (nreverse (gnus-uu-get-list-of-articles
|
|
1092 "^." nil unread t))))
|
|
1093 (error "No%s articles to be decoded." (if unread " unread" ""))
|
|
1094 (setq dir (gnus-uu-read-directory "Where do you want the files? "))
|
7977
|
1095 (gnus-uu-decode-and-view-or-save nil t dir (if (> arg 1) arg nil))
|
7291
|
1096 (message "Saved."))))
|
6728
|
1097
|
|
1098
|
|
1099 ;; Work functions
|
|
1100
|
7291
|
1101 ; All the interactive uudecode/view/save/marked functions are interfaces
|
|
1102 ; to this function, which does the rest.
|
7977
|
1103 (defun gnus-uu-decode-and-view-or-save (view marked &optional save-dir limit)
|
6728
|
1104 (gnus-uu-initialize)
|
7291
|
1105 (let (decoded)
|
6728
|
1106 (save-excursion
|
7977
|
1107 (if (gnus-uu-decode-and-strip nil marked limit)
|
6728
|
1108 (progn
|
|
1109 (setq decoded t)
|
|
1110 (if view
|
7291
|
1111 (gnus-uu-view-directory gnus-uu-work-dir
|
|
1112 gnus-uu-use-interactive-view)
|
|
1113 (gnus-uu-save-directory gnus-uu-work-dir save-dir save-dir)
|
|
1114 (gnus-uu-check-for-generated-files)))))
|
6728
|
1115
|
|
1116 (gnus-uu-summary-next-subject)
|
|
1117
|
7977
|
1118 (if (and gnus-uu-use-interactive-view view decoded)
|
|
1119 (gnus-uu-do-interactive))
|
6728
|
1120
|
7291
|
1121 (if (or (not view) (not gnus-uu-use-interactive-view) (not decoded))
|
6728
|
1122 (gnus-uu-clean-up))))
|
|
1123
|
6904
|
1124 ; Unshars and views/saves marked/unmarked articles.
|
6728
|
1125 (defun gnus-uu-unshar-and-view-or-save (view marked)
|
|
1126 (gnus-uu-initialize)
|
|
1127 (let (tar-file files decoded)
|
|
1128 (save-excursion
|
|
1129 (setq gnus-uu-shar-directory
|
|
1130 (make-temp-name (concat gnus-uu-tmp-dir "gnusuush")))
|
|
1131 (make-directory gnus-uu-shar-directory)
|
|
1132 (gnus-uu-add-file gnus-uu-shar-directory)
|
|
1133 (if (gnus-uu-decode-and-strip t marked)
|
|
1134 (progn
|
|
1135 (setq decoded t)
|
|
1136 (setq files (directory-files gnus-uu-shar-directory t))
|
|
1137 (setq gnus-uu-generated-file-list
|
|
1138 (append files gnus-uu-generated-file-list))
|
|
1139 (if (> (length files) 3)
|
|
1140 (progn
|
|
1141 (setq tar-file
|
|
1142 (concat
|
|
1143 (make-temp-name (concat gnus-uu-tmp-dir "gnusuuar"))
|
|
1144 ".tar"))
|
|
1145 (gnus-uu-add-file tar-file)
|
7291
|
1146 (call-process
|
|
1147 "sh" nil
|
|
1148 (get-buffer-create gnus-uu-output-buffer-name) nil "-c"
|
|
1149 (format "cd %s ; tar cf %s * ; cd .. ; rm -r %s"
|
|
1150 gnus-uu-shar-directory tar-file
|
|
1151 gnus-uu-shar-directory))
|
6728
|
1152 (if view
|
|
1153 (gnus-uu-view-file tar-file)
|
|
1154 (gnus-uu-save-file tar-file)))
|
|
1155 (if view
|
|
1156 (gnus-uu-view-file (elt files 2))
|
|
1157 (gnus-uu-save-file (elt files 2)))))))
|
|
1158
|
|
1159 (gnus-uu-summary-next-subject)
|
|
1160
|
|
1161 (if (and gnus-uu-use-interactive-view view decoded)
|
|
1162 (gnus-uu-do-interactive))
|
|
1163
|
|
1164 (if (or (not gnus-uu-use-interactive-view) (not decoded))
|
|
1165 (gnus-uu-clean-up))))
|
|
1166
|
|
1167
|
7291
|
1168 ;; Functions for saving and possibly digesting articles without
|
|
1169 ;; any decoding.
|
|
1170
|
6728
|
1171 (defconst gnus-uu-saved-article-name nil)
|
7291
|
1172
|
|
1173 ; VIEW isn't used, but is here anyway, to provide similar interface to
|
|
1174 ; the other related functions. If MARKED is non-nil, the list of
|
|
1175 ; marked articles is used. If NO-SAVE is non-nil, the articles aren't
|
|
1176 ; actually saved in a permanent location, but the collecting is done
|
|
1177 ; and a temporary file with the result is returned.
|
|
1178 (defun gnus-uu-save-articles (view marked &optional no-save)
|
|
1179 (let (list-of-articles)
|
|
1180 (save-excursion
|
|
1181 (gnus-uu-initialize)
|
|
1182 (if (not marked)
|
|
1183 (setq list-of-articles (gnus-uu-get-list-of-articles))
|
|
1184 (setq list-of-articles (reverse gnus-uu-marked-article-list))
|
|
1185 (setq gnus-uu-marked-article-list nil))
|
|
1186
|
|
1187 (if (not list-of-articles)
|
|
1188 (error "No list of articles"))
|
|
1189
|
|
1190 (setq gnus-uu-saved-article-name
|
|
1191 (concat gnus-uu-work-dir
|
|
1192 (if no-save
|
|
1193 gnus-newsgroup-name
|
|
1194 (read-file-name "Enter file name: " gnus-newsgroup-name
|
|
1195 gnus-newsgroup-name))))
|
|
1196 (gnus-uu-add-file gnus-uu-saved-article-name)
|
|
1197 (if (and (gnus-uu-grab-articles list-of-articles 'gnus-uu-save-article t)
|
|
1198 (not no-save))
|
|
1199 (gnus-uu-save-file gnus-uu-saved-article-name)
|
|
1200 gnus-uu-saved-article-name))))
|
|
1201
|
|
1202 ; Function called by gnus-uu-grab-articles to treat each article.
|
|
1203 (defun gnus-uu-save-article (buffer in-state)
|
|
1204 (if (not gnus-uu-save-in-digest)
|
|
1205 (save-excursion
|
|
1206 (set-buffer buffer)
|
|
1207 (write-region 1 (point-max) gnus-uu-saved-article-name t)
|
|
1208 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
|
|
1209 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name 'begin 'end))
|
|
1210 ((eq in-state 'last) (list 'end))
|
|
1211 (t (list 'middle))))
|
|
1212 (let (beg subj name headers headline sorthead body end-string state)
|
|
1213 (string-match "/\\([^/]*\\)$" gnus-uu-saved-article-name)
|
|
1214 (setq name (substring gnus-uu-saved-article-name (match-beginning 1)
|
|
1215 (match-end 1)))
|
|
1216 (if (or (eq in-state 'first)
|
|
1217 (eq in-state 'first-and-last))
|
|
1218 (progn
|
|
1219 (setq state (list 'begin))
|
|
1220 (save-excursion (set-buffer (get-buffer-create "*gnus-uu-body*"))
|
|
1221 (erase-buffer))
|
|
1222 (save-excursion
|
|
1223 (set-buffer (get-buffer-create "*gnus-uu-pre*"))
|
|
1224 (erase-buffer)
|
|
1225 (insert (format
|
|
1226 "Date: %s\nFrom: %s\nSubject: %s Digest\n\nTopics:\n"
|
|
1227 (current-time-string) name name))))
|
|
1228 (if (not (eq in-state 'end))
|
|
1229 (setq state (list 'middle))))
|
|
1230 (save-excursion
|
|
1231 (set-buffer (get-buffer "*gnus-uu-body*"))
|
|
1232 (goto-char (setq beg (point-max)))
|
|
1233 (save-excursion
|
|
1234 (save-restriction
|
|
1235 (set-buffer buffer)
|
|
1236 (goto-char 1)
|
|
1237 (re-search-forward "\n\n")
|
|
1238 (setq body (buffer-substring (1- (point)) (point-max)))
|
|
1239 (narrow-to-region 1 (point))
|
|
1240 (setq headers (list "Date:" "From:" "To:" "Cc:" "Subject:"
|
|
1241 "Message-ID:" "Keywords:" "Summary:"))
|
|
1242 (while headers
|
|
1243 (setq headline (car headers))
|
|
1244 (setq headers (cdr headers))
|
|
1245 (goto-char 1)
|
|
1246 (if (re-search-forward (concat "^" headline ".*$") nil t)
|
|
1247 (setq sorthead
|
|
1248 (concat sorthead (buffer-substring
|
|
1249 (match-beginning 0)
|
|
1250 (match-end 0)) "\n"))))
|
|
1251 (widen)))
|
|
1252 (insert sorthead)(goto-char (point-max))
|
|
1253 (insert body)(goto-char (point-max))
|
|
1254 (insert (concat "\n" (make-string 30 ?-) "\n\n"))
|
|
1255 (goto-char beg)
|
|
1256 (if (re-search-forward "^Subject: \\(.*\\)$" nil t)
|
|
1257 (progn
|
|
1258 (setq subj (buffer-substring (match-beginning 1) (match-end 1)))
|
|
1259 (save-excursion
|
|
1260 (set-buffer (get-buffer "*gnus-uu-pre*"))
|
|
1261 (insert (format " %s\n" subj))))))
|
|
1262 (if (or (eq in-state 'last)
|
|
1263 (eq in-state 'first-and-last))
|
|
1264 (progn
|
|
1265 (save-excursion
|
|
1266 (set-buffer (get-buffer "*gnus-uu-pre*"))
|
|
1267 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
|
|
1268 (write-region 1 (point-max) gnus-uu-saved-article-name))
|
|
1269 (save-excursion
|
|
1270 (set-buffer (get-buffer "*gnus-uu-body*"))
|
|
1271 (goto-char (point-max))
|
|
1272 (insert
|
|
1273 (concat (setq end-string (format "End of %s Digest" name))
|
|
1274 "\n"))
|
|
1275 (insert (concat (make-string (length end-string) ?*) "\n"))
|
|
1276 (write-region 1 (point-max) gnus-uu-saved-article-name t))
|
|
1277 (kill-buffer (get-buffer "*gnus-uu-pre*"))
|
|
1278 (kill-buffer (get-buffer "*gnus-uu-body*"))
|
|
1279 (setq state (cons 'end state))))
|
|
1280 (if (memq 'begin state)
|
|
1281 (cons gnus-uu-saved-article-name state)
|
|
1282 state))))
|
|
1283
|
|
1284
|
|
1285 ;; Digest and forward articles
|
|
1286
|
|
1287 (autoload 'gnus-mail-forward-using-mail "gnusmail"
|
|
1288 "Forward the current message to another user." t)
|
|
1289 (autoload 'gnus-mail-forward-using-mhe "gnusmail"
|
|
1290 "Forward the current message to another user." t)
|
|
1291
|
|
1292 (defun gnus-uu-digest-and-forward (&optional marked)
|
|
1293 "Digests and forwards all articles in this series."
|
|
1294 (interactive)
|
|
1295 (let ((gnus-uu-save-in-digest t)
|
|
1296 file buf)
|
|
1297 (setq file (gnus-uu-save-articles nil marked t))
|
|
1298 (switch-to-buffer (setq buf (get-buffer-create "*gnus-uu-forward*")))
|
|
1299 (erase-buffer)
|
|
1300 (delete-other-windows)
|
|
1301 (erase-buffer)
|
|
1302 (insert-file file)
|
|
1303 (goto-char 1)
|
|
1304 (bury-buffer buf)
|
|
1305 (funcall gnus-mail-forward-method)))
|
|
1306
|
|
1307 (defun gnus-uu-marked-digest-and-forward (&optional marked)
|
|
1308 "Digests and forwards all marked articles."
|
|
1309 (interactive)
|
|
1310 (gnus-uu-digest-and-forward t))
|
|
1311
|
|
1312
|
|
1313 ;; Binhex treatment - not very advanced.
|
|
1314
|
|
1315 (defconst gnus-uu-binhex-body-line
|
|
1316 "^[^:]...............................................................$")
|
|
1317 (defconst gnus-uu-binhex-begin-line
|
|
1318 "^:...............................................................$")
|
|
1319 (defconst gnus-uu-binhex-end-line
|
|
1320 ":$")
|
|
1321 (defvar gnus-uu-binhex-article-name nil)
|
|
1322
|
|
1323 ; This just concatenates and strips stuff from binhexed articles.
|
|
1324 ; No actual unbinhexing takes place. VIEW is ignored.
|
|
1325 (defun gnus-uu-binhex-and-save (view marked)
|
|
1326 (gnus-uu-initialize)
|
6728
|
1327 (let (list-of-articles)
|
|
1328 (save-excursion
|
|
1329 (if (not marked)
|
|
1330 (setq list-of-articles (gnus-uu-get-list-of-articles))
|
|
1331 (setq list-of-articles (reverse gnus-uu-marked-article-list))
|
|
1332 (setq gnus-uu-marked-article-list nil))
|
|
1333 (if (not list-of-articles)
|
7291
|
1334 (error "No list of articles"))
|
|
1335
|
|
1336 (setq gnus-uu-binhex-article-name
|
|
1337 (concat gnus-uu-work-dir
|
|
1338 (read-file-name "Enter binhex file name: "
|
|
1339 gnus-newsgroup-name
|
|
1340 gnus-newsgroup-name)))
|
|
1341 (gnus-uu-add-file gnus-uu-binhex-article-name)
|
|
1342 (if (gnus-uu-grab-articles list-of-articles 'gnus-uu-binhex-article t)
|
|
1343 (gnus-uu-save-file gnus-uu-binhex-article-name))))
|
|
1344 (gnus-uu-check-for-generated-files)
|
|
1345 (gnus-uu-summary-next-subject))
|
6728
|
1346
|
|
1347 (defun gnus-uu-binhex-article (buffer in-state)
|
7291
|
1348 (let (state start-char)
|
6728
|
1349 (save-excursion
|
|
1350 (set-buffer buffer)
|
7291
|
1351 (widen)
|
6728
|
1352 (goto-char 1)
|
7291
|
1353 (if (not (re-search-forward gnus-uu-binhex-begin-line nil t))
|
|
1354 (if (not (re-search-forward gnus-uu-binhex-body-line nil t))
|
|
1355 (setq state (list 'wrong-type))))
|
|
1356
|
|
1357 (if (memq 'wrong-type state)
|
|
1358 ()
|
6728
|
1359 (beginning-of-line)
|
|
1360 (setq start-char (point))
|
|
1361 (if (looking-at gnus-uu-binhex-begin-line)
|
7291
|
1362 (progn
|
|
1363 (setq state (list 'begin))
|
|
1364 (write-region 1 1 gnus-uu-binhex-article-name))
|
|
1365 (setq state (list 'middle)))
|
6728
|
1366 (goto-char (point-max))
|
|
1367 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
|
|
1368 gnus-uu-binhex-end-line) nil t)
|
|
1369 (if (looking-at gnus-uu-binhex-end-line)
|
7291
|
1370 (setq state (if (memq 'begin state)
|
|
1371 (cons 'end state)
|
|
1372 (list 'end))))
|
6728
|
1373 (beginning-of-line)
|
|
1374 (forward-line 1)
|
7291
|
1375 (if (file-exists-p gnus-uu-binhex-article-name)
|
|
1376 (append-to-file start-char (point) gnus-uu-binhex-article-name))))
|
|
1377 (if (memq 'begin state)
|
|
1378 (cons gnus-uu-binhex-article-name state)
|
|
1379 state)))
|
6728
|
1380
|
|
1381
|
|
1382 ;; Internal view commands
|
|
1383
|
6904
|
1384 ; This function takes two parameters. The first is name of the file to
|
|
1385 ; be viewed. `gnus-uu-view-file' will look for an action associated
|
|
1386 ; with the file type of the file. If it finds an appropriate action,
|
|
1387 ; the file will be attempted displayed.
|
|
1388 ;
|
|
1389 ; The second parameter specifies if the user is to be asked whether to
|
|
1390 ; save the file if viewing is unsuccessful. t means "do not ask."
|
|
1391 ;
|
|
1392 ; Note that the file given will be deleted by this function, one way
|
|
1393 ; or another. If `gnus-uu-asynchronous' is set, it won't be deleted
|
|
1394 ; right away, but sometime later. If the user is offered to save the
|
|
1395 ; file, it'll be moved to wherever the user wants it.
|
6728
|
1396
|
6904
|
1397 ; `gnus-uu-view-file' returns t if viewing is successful.
|
6728
|
1398
|
7977
|
1399 (defun gnus-uu-view-file (file &optional silent)
|
|
1400 (let (action did-view)
|
|
1401 (cond
|
|
1402 ((not (setq action (gnus-uu-get-action file)))
|
|
1403 (if (and (not silent) (not gnus-uu-use-interactive-view))
|
7291
|
1404 (progn
|
7977
|
1405 (message "Couldn't find any rule for file '%s'" file)
|
|
1406 (sleep-for 2)
|
|
1407 (gnus-uu-ask-to-save-file file))))
|
|
1408
|
|
1409 ((and gnus-uu-use-interactive-view
|
|
1410 (not (string= (or action "") "gnus-uu-archive")))
|
|
1411 (gnus-uu-enter-interactive-file (or action "") file))
|
|
1412
|
|
1413 (gnus-uu-ask-before-view
|
|
1414 (if (y-or-n-p (format "Do you want to view %s? " file))
|
|
1415 (setq did-view (gnus-uu-call-file-action file action)))
|
|
1416 (message ""))
|
|
1417
|
|
1418 ((setq did-view (gnus-uu-call-file-action file action)))
|
|
1419
|
|
1420 ((not silent)
|
|
1421 (gnus-uu-ask-to-save-file file)))
|
|
1422
|
|
1423 (if (and (file-exists-p file)
|
|
1424 (not gnus-uu-use-interactive-view)
|
|
1425 (or
|
|
1426 (not (and gnus-uu-asynchronous did-view))
|
|
1427 (string= (or action "") "gnus-uu-archive")))
|
|
1428 (delete-file file))
|
|
1429
|
|
1430 did-view))
|
|
1431
|
|
1432 (defun gnus-uu-call-file-action (file action)
|
|
1433 (prog1
|
|
1434 (if gnus-uu-asynchronous
|
|
1435 (gnus-uu-call-asynchronous file action)
|
|
1436 (gnus-uu-call-synchronous file action))
|
|
1437 (if gnus-uu-view-and-save
|
|
1438 (gnus-uu-ask-to-save-file file))))
|
|
1439
|
|
1440 (defun gnus-uu-ask-to-save-file (file)
|
|
1441 (if (y-or-n-p (format "Do you want to save the file %s? " file))
|
|
1442 (gnus-uu-save-file file))
|
|
1443 (message ""))
|
7291
|
1444
|
|
1445 (defun gnus-uu-get-action (file-name)
|
|
1446 (let (action)
|
6728
|
1447 (setq action
|
7291
|
1448 (gnus-uu-choose-action
|
6728
|
1449 file-name
|
|
1450 (append
|
|
1451 (if (and gnus-uu-use-interactive-view
|
|
1452 gnus-uu-user-interactive-view-rules)
|
|
1453 gnus-uu-user-interactive-view-rules
|
|
1454 gnus-uu-user-view-rules)
|
7291
|
1455 (if (or gnus-uu-ignore-default-view-rules
|
6728
|
1456 (not gnus-uu-use-interactive-view))
|
|
1457 ()
|
|
1458 gnus-uu-default-interactive-view-rules-begin)
|
|
1459 (if gnus-uu-ignore-default-view-rules
|
|
1460 nil
|
|
1461 gnus-uu-default-view-rules)
|
7291
|
1462 (if gnus-uu-use-interactive-view
|
|
1463 (append gnus-uu-user-interactive-view-rules-end
|
|
1464 (if gnus-uu-ignore-default-view-rules
|
|
1465 ()
|
|
1466 gnus-uu-default-interactive-view-rules-end))
|
|
1467 gnus-uu-user-view-rules-end))))
|
|
1468 (if (and (not (string= (or action "") "gnus-uu-archive"))
|
|
1469 gnus-uu-view-with-metamail)
|
|
1470 (if (setq action
|
|
1471 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
|
|
1472 (setq action (format "metamail -d -b -c \"%s\"" action))))
|
|
1473 action))
|
6728
|
1474
|
6904
|
1475 ; `gnus-uu-call-synchronous' takes two parameters: The name of the
|
|
1476 ; file to be displayed and the command to display it with. Returns t
|
|
1477 ; on success and nil if the file couldn't be displayed.
|
6728
|
1478 (defun gnus-uu-call-synchronous (file-name action)
|
|
1479 (let (did-view command)
|
|
1480 (save-excursion
|
|
1481 (set-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
1482 (erase-buffer)
|
6904
|
1483 (setq command (gnus-uu-command action file-name))
|
7291
|
1484 (message "Viewing with '%s'" command)
|
6728
|
1485 (if (not (= 0 (call-process "sh" nil t nil "-c" command)))
|
|
1486 (progn
|
|
1487 (goto-char 1)
|
|
1488 (while (re-search-forward "\n" nil t)
|
|
1489 (replace-match " "))
|
|
1490 (message (concat "Error: " (buffer-substring 1 (point-max))))
|
|
1491 (sit-for 2))
|
|
1492 (message "")
|
|
1493 (setq did-view t)))
|
|
1494 did-view))
|
|
1495
|
6904
|
1496 ; `gnus-uu-call-asyncronous' takes two parameters: The name of the
|
|
1497 ; file to be displayed and the command to display it with. Since the
|
|
1498 ; view command is executed asynchronously, it's kinda hard to decide
|
|
1499 ; whether the command succeded or not, so this function always returns
|
|
1500 ; t. It also adds "; rm -f file-name" to the end of the execution
|
|
1501 ; string, so the file will be removed after viewing has ended.
|
6728
|
1502 (defun gnus-uu-call-asynchronous (file-name action)
|
|
1503 (let (command file tmp-file start)
|
|
1504 (while (string-match "/" file-name start)
|
|
1505 (setq start (1+ (match-beginning 0))))
|
|
1506 (setq file (substring file-name start))
|
7291
|
1507 (setq tmp-file (concat gnus-uu-work-dir file))
|
6728
|
1508 (if (string= tmp-file file-name)
|
|
1509 ()
|
|
1510 (rename-file file-name tmp-file t)
|
|
1511 (setq file-name tmp-file))
|
|
1512
|
6904
|
1513 (setq command (gnus-uu-command action file-name))
|
6728
|
1514 (setq command (format "%s ; rm -f %s" command file-name))
|
7291
|
1515 (message "Viewing with %s" command)
|
6904
|
1516 (start-process "gnus-uu-view" nil "sh" "-c" command)
|
6728
|
1517 t))
|
|
1518
|
6904
|
1519 ; `gnus-uu-decode-and-strip' does all the main work. It finds out what
|
|
1520 ; articles to grab, grabs them, strips the result and decodes. If any
|
|
1521 ; of these operations fail, it returns nil, t otherwise. If shar is
|
|
1522 ; t, it will pass this on to `gnus-uu-grab-articles', which will
|
|
1523 ; (probably) unshar the articles. If use-marked is non-nil, it won't
|
|
1524 ; try to find articles, but use the marked list.
|
7977
|
1525 (defun gnus-uu-decode-and-strip (&optional shar use-marked limit)
|
6728
|
1526 (let (list-of-articles)
|
|
1527 (save-excursion
|
|
1528
|
|
1529 (if use-marked
|
7291
|
1530 (if (not gnus-uu-marked-article-list)
|
|
1531 (message "No articles marked")
|
|
1532 (setq list-of-articles (reverse gnus-uu-marked-article-list))
|
7977
|
1533 (setq gnus-uu-marked-article-list nil))
|
6728
|
1534 (setq list-of-articles (gnus-uu-get-list-of-articles)))
|
|
1535
|
|
1536 (and list-of-articles
|
7291
|
1537 (gnus-uu-grab-articles
|
|
1538 list-of-articles
|
|
1539 (if shar 'gnus-uu-unshar-article 'gnus-uu-uustrip-article-as)
|
7977
|
1540 t limit)))))
|
6728
|
1541
|
6904
|
1542 ; Takes a string and puts a \ in front of every special character;
|
|
1543 ; ignores any leading "version numbers" thingies that they use in the
|
|
1544 ; comp.binaries groups, and either replaces anything that looks like
|
|
1545 ; "2/3" with "[0-9]+/[0-9]+" or, if it can't find something like that,
|
|
1546 ; replaces the last two numbers with "[0-9]+". This, in my experience,
|
|
1547 ; should get most postings of a series."
|
6728
|
1548 (defun gnus-uu-reginize-string (string)
|
|
1549 (let ((count 2)
|
6904
|
1550 (vernum "v[0-9]+[a-z][0-9]+:")
|
6728
|
1551 reg beg)
|
|
1552 (save-excursion
|
|
1553 (set-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
1554 (erase-buffer)
|
|
1555 (insert (regexp-quote string))
|
|
1556 (setq beg 1)
|
|
1557
|
|
1558 (setq case-fold-search nil)
|
|
1559 (goto-char 1)
|
|
1560 (if (looking-at vernum)
|
|
1561 (progn
|
|
1562 (replace-match vernum t t)
|
|
1563 (setq beg (length vernum))))
|
|
1564
|
|
1565 (goto-char beg)
|
|
1566 (if (re-search-forward "[ \t]*[0-9]+/[0-9]+" nil t)
|
|
1567 (replace-match " [0-9]+/[0-9]+")
|
|
1568
|
|
1569 (goto-char beg)
|
|
1570 (if (re-search-forward "[0-9]+[ \t]*of[ \t]*[0-9]+" nil t)
|
|
1571 (replace-match "[0-9]+ of [0-9]+")
|
|
1572
|
|
1573 (end-of-line)
|
|
1574 (while (and (re-search-backward "[0-9]" nil t) (> count 0))
|
|
1575 (while (and
|
|
1576 (looking-at "[0-9]")
|
|
1577 (< 1 (goto-char (1- (point))))))
|
|
1578 (re-search-forward "[0-9]+" nil t)
|
|
1579 (replace-match "[0-9]+")
|
|
1580 (backward-char 5)
|
|
1581 (setq count (1- count)))))
|
|
1582
|
|
1583 (goto-char beg)
|
|
1584 (while (re-search-forward "[ \t]+" nil t)
|
|
1585 (replace-match "[ \t]*" t t))
|
|
1586
|
|
1587 (buffer-substring 1 (point-max)))))
|
|
1588
|
6904
|
1589 ; Finds all articles that matches the regular expression given.
|
7291
|
1590 ; Returns the resulting list. SUBJECT is the regular expression to be
|
|
1591 ; matched. If it is nil, the current article name will be used. If
|
|
1592 ; MARK-ARTICLES is non-nil, articles found are marked. If ONLY-UNREAD
|
|
1593 ; is non-nil, only unread articles are chose. If DO-NOT-TRANSLATE is
|
|
1594 ; non-nil, article names are not equialized before sorting.
|
|
1595 (defun gnus-uu-get-list-of-articles (&optional subject mark-articles only-unread do-not-translate)
|
6728
|
1596 (let (beg end reg-subject list-of-subjects list-of-numbers art-num)
|
|
1597 (save-excursion
|
|
1598
|
|
1599 ; If the subject is not given, this function looks at the current subject
|
|
1600 ; and takes that.
|
|
1601
|
|
1602 (if subject
|
|
1603 (setq reg-subject subject)
|
|
1604 (end-of-line)
|
|
1605 (setq end (point))
|
|
1606 (beginning-of-line)
|
|
1607 (if (not (re-search-forward "\\] " end t))
|
|
1608 (progn (message "No valid subject chosen") (sit-for 2))
|
|
1609 (setq subject (buffer-substring (point) end))
|
|
1610 (setq reg-subject
|
|
1611 (concat "\\[.*\\] " (gnus-uu-reginize-string subject)))))
|
|
1612
|
|
1613 ; (message reg-subject)(sleep-for 2)
|
|
1614
|
|
1615 (if reg-subject
|
|
1616 (progn
|
|
1617
|
|
1618 ; Collect all subjects matching reg-subject.
|
|
1619
|
|
1620 (let ((case-fold-search t))
|
|
1621 (goto-char 1)
|
|
1622 (while (re-search-forward reg-subject nil t)
|
|
1623 (beginning-of-line)
|
|
1624 (setq beg (point))
|
|
1625 (if (or (not only-unread) (looking-at " \\|-"))
|
|
1626 (progn
|
|
1627 (end-of-line)
|
|
1628 (setq list-of-subjects (cons
|
|
1629 (buffer-substring beg (point))
|
|
1630 list-of-subjects)))
|
|
1631 (end-of-line))))
|
|
1632
|
|
1633 ; Expand all numbers in all the subjects: (hi9 -> hi0009, etc).
|
|
1634
|
7291
|
1635 (setq list-of-subjects (gnus-uu-expand-numbers
|
|
1636 list-of-subjects
|
|
1637 (not do-not-translate)))
|
6728
|
1638
|
|
1639 ; Sort the subjects.
|
|
1640
|
|
1641 (setq list-of-subjects (sort list-of-subjects 'gnus-uu-string<))
|
|
1642
|
|
1643 ; Get the article numbers from the sorted list of subjects.
|
|
1644
|
|
1645 (while list-of-subjects
|
|
1646 (setq art-num (gnus-uu-article-number (car list-of-subjects)))
|
|
1647 (if mark-articles (gnus-summary-mark-as-read art-num ?#))
|
|
1648 (setq list-of-numbers (cons art-num list-of-numbers))
|
|
1649 (setq list-of-subjects (cdr list-of-subjects)))
|
|
1650
|
7291
|
1651 (setq list-of-numbers (nreverse list-of-numbers))))
|
6728
|
1652
|
|
1653 list-of-numbers)))
|
|
1654
|
6904
|
1655 ; Takes a list of strings and "expands" all numbers in all the
|
|
1656 ; strings. That is, this function makes all numbers equal length by
|
|
1657 ; prepending lots of zeroes before each number. This is to ease later
|
|
1658 ; sorting to find out what sequence the articles are supposed to be
|
|
1659 ; decoded in. Returns the list of expanded strings.
|
7291
|
1660 (defun gnus-uu-expand-numbers (string-list &optional translate)
|
6728
|
1661 (let (string out-list pos num)
|
|
1662 (save-excursion
|
|
1663 (set-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
1664 (while string-list
|
|
1665 (erase-buffer)
|
|
1666 (setq string (car string-list))
|
|
1667 (setq string-list (cdr string-list))
|
|
1668 (insert string)
|
|
1669 (goto-char 1)
|
|
1670 (while (re-search-forward "[ \t]+" nil t)
|
|
1671 (replace-match " "))
|
|
1672 (goto-char 1)
|
7291
|
1673 (if translate
|
|
1674 (while (re-search-forward "[A-Za-z]" nil t)
|
|
1675 (replace-match "a" t t)))
|
6728
|
1676
|
|
1677 (goto-char 1)
|
|
1678 (if (not (search-forward "] " nil t))
|
|
1679 ()
|
|
1680 (while (re-search-forward "[0-9]+" nil t)
|
|
1681 (replace-match
|
|
1682 (format "%06d"
|
|
1683 (string-to-int (buffer-substring
|
|
1684 (match-beginning 0) (match-end 0))))))
|
|
1685 (setq string (buffer-substring 1 (point-max)))
|
|
1686 (setq out-list (cons string out-list)))))
|
|
1687 out-list))
|
|
1688
|
6904
|
1689 ; Used in a sort for finding out what string is bigger, but ignoring
|
|
1690 ; everything before the subject part.
|
6728
|
1691 (defun gnus-uu-string< (string1 string2)
|
|
1692 (string< (substring string1 (string-match "\\] " string1))
|
|
1693 (substring string2 (string-match "\\] " string2))))
|
|
1694
|
|
1695
|
|
1696 ;; gnus-uu-grab-article
|
6904
|
1697 ;
|
|
1698 ; This is the general multi-article treatment function. It takes a
|
|
1699 ; list of articles to be grabbed and a function to apply to each
|
|
1700 ; article. It puts the result in `gnus-uu-result-buffer'.
|
|
1701 ;
|
7291
|
1702 ; The function to be called should take two parameters. The first
|
|
1703 ; parameter is the article buffer. The function should leave the
|
|
1704 ; result, if any, in this buffer. This result is then appended on to
|
|
1705 ; the `gnus-uu-result-buffer'. Most treatment functions will just
|
|
1706 ; generate files...
|
6904
|
1707 ;
|
|
1708 ; The second parameter is the state of the list of articles, and can
|
7291
|
1709 ; have four values: `first', `middle', `last' and `first-and-last'.
|
6904
|
1710 ;
|
7291
|
1711 ; The function should return a list. The list may contain the
|
|
1712 ; following symbols:
|
|
1713 ; `error' if an error occurred
|
|
1714 ; `begin' if the beginning of an encoded file has been received
|
|
1715 ; If the list returned contains a `begin', the first element of
|
|
1716 ; the list *must* be a string with the file name of the decoded
|
|
1717 ; file.
|
|
1718 ; `end' if the the end of an encoded file has been received
|
|
1719 ; `middle' if the article was a body part of an encoded file
|
|
1720 ; `wrong-type' if the article was not a part of an encoded file
|
|
1721 ; `ok', which can be used everything is ok
|
6728
|
1722
|
|
1723 (defvar gnus-uu-has-been-grabbed nil)
|
|
1724
|
|
1725 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
|
|
1726 (let (art)
|
7291
|
1727 (if (not (and gnus-uu-has-been-grabbed
|
|
1728 gnus-uu-unmark-articles-not-decoded))
|
6728
|
1729 ()
|
|
1730 (if dont-unmark-last-article
|
|
1731 (progn
|
|
1732 (setq art (car gnus-uu-has-been-grabbed))
|
|
1733 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed))))
|
|
1734 (while gnus-uu-has-been-grabbed
|
|
1735 (gnus-summary-mark-as-unread (car gnus-uu-has-been-grabbed) t)
|
|
1736 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
|
|
1737 (if dont-unmark-last-article
|
6904
|
1738 (setq gnus-uu-has-been-grabbed (list art))))))
|
|
1739
|
6728
|
1740
|
6904
|
1741 ; This function takes a list of articles and a function to apply to
|
|
1742 ; each article grabbed. The result of the function is appended on to
|
|
1743 ; `gnus-uu-result-buffer'.
|
|
1744 ;
|
7291
|
1745 ; This function returns a list of files decoded if the grabbing and
|
|
1746 ; the process-function has been successful and nil otherwise.
|
7977
|
1747 (defun gnus-uu-grab-articles (list-of-articles process-function &optional sloppy limit)
|
6728
|
1748 (let ((result-buffer (get-buffer-create gnus-uu-result-buffer))
|
|
1749 (state 'first)
|
|
1750 (wrong-type t)
|
7291
|
1751 has-been-begin has-been-end
|
|
1752 article result-file result-files process-state)
|
6728
|
1753
|
|
1754 (save-excursion
|
|
1755 (set-buffer result-buffer)
|
|
1756 (erase-buffer))
|
|
1757 (setq gnus-uu-has-been-grabbed nil)
|
7291
|
1758
|
6728
|
1759 (while (and list-of-articles
|
7291
|
1760 (not (memq 'error process-state))
|
|
1761 (or sloppy
|
|
1762 (not (memq 'end process-state))))
|
|
1763
|
6728
|
1764 (setq article (car list-of-articles))
|
|
1765 (setq list-of-articles (cdr list-of-articles))
|
|
1766 (setq gnus-uu-has-been-grabbed (cons article gnus-uu-has-been-grabbed))
|
|
1767
|
7977
|
1768 (if (> article gnus-uu-highest-article-number)
|
|
1769 (setq gnus-uu-highest-article-number article))
|
|
1770
|
7291
|
1771 (if (eq list-of-articles ())
|
|
1772 (if (eq state 'first)
|
|
1773 (setq state 'first-and-last)
|
|
1774 (setq state 'last)))
|
|
1775
|
|
1776 (message "Getting article %d" article)
|
6728
|
1777 (if (not (= (or gnus-current-article 0) article))
|
|
1778 (gnus-summary-display-article article))
|
|
1779 (gnus-summary-mark-as-read article)
|
|
1780
|
7291
|
1781 (save-excursion (set-buffer gnus-article-buffer) (widen))
|
6728
|
1782
|
|
1783 (setq process-state (funcall process-function gnus-article-buffer state))
|
|
1784
|
7291
|
1785 ; (message "process-state er %s" process-state)(sleep-for 3)
|
|
1786
|
|
1787 (if (or (memq 'begin process-state)
|
|
1788 (and (or (eq state 'first) (eq state 'first-and-last))
|
|
1789 (memq 'ok process-state)))
|
|
1790 (progn
|
|
1791 (if has-been-begin
|
|
1792 (if (file-exists-p result-file) (delete-file result-file)))
|
|
1793 (setq result-file (car process-state))
|
|
1794 (setq has-been-begin t)
|
|
1795 (setq has-been-end nil)))
|
|
1796
|
|
1797 (if (memq 'end process-state)
|
|
1798 (progn
|
|
1799 (setq gnus-uu-has-been-grabbed nil)
|
|
1800 (setq result-files (cons result-file result-files))
|
|
1801 (setq has-been-end t)
|
7977
|
1802 (setq has-been-begin nil)
|
|
1803 (if (and limit (= (length result-files) limit))
|
|
1804 (progn
|
|
1805 (setq list-of-articles nil)
|
|
1806 (setq gnus-uu-marked-article-list nil)))))
|
|
1807
|
|
1808 (if (and (or (eq state 'last) (eq state 'first-and-last))
|
|
1809 (not (memq 'end process-state)))
|
|
1810 (if (and result-file (file-exists-p result-file))
|
|
1811 (delete-file result-file)))
|
|
1812
|
|
1813 (setq result-file nil)
|
7291
|
1814
|
|
1815 (if (not (memq 'wrong-type process-state))
|
6728
|
1816 (setq wrong-type nil)
|
|
1817 (if gnus-uu-unmark-articles-not-decoded
|
|
1818 (gnus-summary-mark-as-unread article t)))
|
|
1819
|
7291
|
1820 (if sloppy (setq wrong-type nil))
|
6728
|
1821
|
|
1822 (if (and (not has-been-begin)
|
7291
|
1823 (not sloppy)
|
|
1824 (or (memq 'end process-state)
|
|
1825 (memq 'middle process-state)))
|
6728
|
1826 (progn
|
7291
|
1827 (setq process-state (list 'error))
|
6728
|
1828 (message "No begin part at the beginning")
|
7291
|
1829 (sleep-for 2))
|
6728
|
1830 (setq state 'middle)))
|
|
1831
|
7291
|
1832 (if result-files
|
|
1833 ()
|
|
1834 (if (not has-been-begin)
|
6728
|
1835 (message "Wrong type file")
|
7291
|
1836 (if (memq 'error process-state)
|
|
1837 (setq result-files nil)
|
|
1838 (if (not (or (memq 'ok process-state)
|
|
1839 (memq 'end process-state)))
|
|
1840 (progn
|
|
1841 (message "End of articles reached before end of file")
|
|
1842 (setq result-files nil))
|
|
1843 (gnus-uu-unmark-list-of-grabbed)))))
|
7977
|
1844 (setq gnus-uu-list-of-files-decoded result-files)
|
7291
|
1845 result-files))
|
6728
|
1846
|
|
1847 (defun gnus-uu-uudecode-sentinel (process event)
|
|
1848 (delete-process (get-process process)))
|
|
1849
|
7291
|
1850 ; Uudecodes a file asynchronously.
|
6728
|
1851 (defun gnus-uu-uustrip-article-as (process-buffer in-state)
|
7291
|
1852 (let ((state (list 'ok))
|
6728
|
1853 (process-connection-type nil)
|
7291
|
1854 start-char pst name-beg name-end)
|
6728
|
1855 (save-excursion
|
|
1856 (set-buffer process-buffer)
|
7291
|
1857 (let ((case-fold-search nil)
|
|
1858 (buffer-read-only nil))
|
|
1859
|
|
1860 (goto-char 1)
|
|
1861
|
|
1862 (if gnus-uu-kill-carriage-return
|
|
1863 (progn
|
|
1864 (while (search-forward "\r" nil t)
|
|
1865 (delete-backward-char 1))
|
|
1866 (goto-char 1)))
|
|
1867
|
|
1868 (if (not (re-search-forward gnus-uu-begin-string nil t))
|
|
1869 (if (not (re-search-forward gnus-uu-body-line nil t))
|
|
1870 (setq state (list 'wrong-type))))
|
6728
|
1871
|
7291
|
1872 (if (memq 'wrong-type state)
|
|
1873 ()
|
|
1874 (beginning-of-line)
|
|
1875 (setq start-char (point))
|
|
1876
|
|
1877 (if (looking-at gnus-uu-begin-string)
|
|
1878 (progn
|
|
1879 (setq name-end (match-end 1))
|
|
1880
|
|
1881 ; Replace any slashes and spaces in file names before decoding
|
|
1882 (goto-char (setq name-beg (match-beginning 1)))
|
|
1883 (while (re-search-forward "/" name-end t)
|
7977
|
1884 (replace-match ","))
|
7291
|
1885 (goto-char name-beg)
|
|
1886 (while (re-search-forward " " name-end t)
|
|
1887 (replace-match "_"))
|
|
1888
|
|
1889 (setq gnus-uu-file-name (buffer-substring name-beg name-end))
|
|
1890 (and gnus-uu-uudecode-process
|
|
1891 (setq pst (process-status
|
|
1892 (or gnus-uu-uudecode-process "nevair")))
|
|
1893 (if (or (eq pst 'stop) (eq pst 'run))
|
|
1894 (progn
|
|
1895 (delete-process gnus-uu-uudecode-process)
|
|
1896 (gnus-uu-unmark-list-of-grabbed t))))
|
|
1897 (setq gnus-uu-uudecode-process
|
|
1898 (start-process
|
|
1899 "*uudecode*"
|
|
1900 (get-buffer-create gnus-uu-output-buffer-name)
|
|
1901 "sh" "-c"
|
|
1902 (format "cd %s ; uudecode" gnus-uu-work-dir)))
|
|
1903 (set-process-sentinel
|
|
1904 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
|
|
1905 (setq state (list 'begin))
|
|
1906 (gnus-uu-add-file (concat gnus-uu-work-dir gnus-uu-file-name)))
|
|
1907 (setq state (list 'middle)))
|
|
1908
|
|
1909 (goto-char (point-max))
|
|
1910
|
|
1911 (re-search-backward
|
|
1912 (concat gnus-uu-body-line "\\|" gnus-uu-end-string) nil t)
|
|
1913 (beginning-of-line)
|
|
1914
|
|
1915 (if (looking-at gnus-uu-end-string)
|
|
1916 (setq state (cons 'end state)))
|
|
1917 (forward-line 1)
|
|
1918
|
|
1919 (and gnus-uu-uudecode-process
|
|
1920 (setq pst (process-status
|
6904
|
1921 (or gnus-uu-uudecode-process "nevair")))
|
7291
|
1922 (if (or (eq pst 'run) (eq pst 'stop))
|
|
1923 (progn
|
|
1924 (if gnus-uu-correct-stripped-uucode
|
|
1925 (progn
|
|
1926 (gnus-uu-check-correct-stripped-uucode
|
|
1927 start-char (point))
|
|
1928 (goto-char (point-max))
|
|
1929 (re-search-backward
|
|
1930 (concat gnus-uu-body-line "\\|"
|
|
1931 gnus-uu-end-string)
|
|
1932 nil t)
|
|
1933 (forward-line 1)))
|
|
1934 (condition-case err
|
|
1935 (process-send-region gnus-uu-uudecode-process
|
|
1936 start-char (point))
|
|
1937 (error
|
|
1938 (progn
|
|
1939 (message "gnus-uu: Couldn't uudecode")
|
|
1940 (sleep-for 2)
|
|
1941 (setq state (list 'wrong-type))
|
7977
|
1942 (delete-process gnus-uu-uudecode-process))))
|
|
1943 (if (memq 'end state)
|
|
1944 (accept-process-output gnus-uu-uudecode-process)))
|
7291
|
1945 (setq state (list 'wrong-type))))
|
|
1946 (if (not gnus-uu-uudecode-process)
|
|
1947 (setq state (list 'wrong-type)))))
|
|
1948
|
|
1949 (if (memq 'begin state)
|
|
1950 (cons (concat gnus-uu-work-dir gnus-uu-file-name) state)
|
|
1951 state))))
|
6728
|
1952
|
6904
|
1953 ; This function is used by `gnus-uu-grab-articles' to treat
|
|
1954 ; a shared article.
|
6728
|
1955 (defun gnus-uu-unshar-article (process-buffer in-state)
|
7291
|
1956 (let ((state (list 'ok))
|
6728
|
1957 start-char)
|
|
1958 (save-excursion
|
|
1959 (set-buffer process-buffer)
|
|
1960 (goto-char 1)
|
|
1961 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
|
7291
|
1962 (setq state (list 'wrong-type))
|
6728
|
1963 (beginning-of-line)
|
|
1964 (setq start-char (point))
|
|
1965 (call-process-region
|
|
1966 start-char (point-max) "sh" nil
|
|
1967 (get-buffer-create gnus-uu-output-buffer-name) nil
|
|
1968 "-c" (concat "cd " gnus-uu-shar-directory " ; sh"))))
|
|
1969 state))
|
|
1970
|
6904
|
1971 ; Returns the name of what the shar file is going to unpack.
|
6728
|
1972 (defun gnus-uu-find-name-in-shar ()
|
|
1973 (let ((oldpoint (point))
|
|
1974 res)
|
|
1975 (goto-char 1)
|
|
1976 (if (re-search-forward gnus-uu-shar-name-marker nil t)
|
|
1977 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
|
|
1978 (goto-char oldpoint)
|
|
1979 res))
|
|
1980
|
6904
|
1981 ; Returns the article number of the given subject.
|
6728
|
1982 (defun gnus-uu-article-number (subject)
|
|
1983 (let (end)
|
|
1984 (string-match "[0-9]+[^0-9]" subject 1)
|
|
1985 (setq end (match-end 0))
|
|
1986 (string-to-int
|
|
1987 (substring subject (string-match "[0-9]" subject 1) end))))
|
|
1988
|
6904
|
1989 ; `gnus-uu-choose-action' chooses what action to perform given the name
|
|
1990 ; and `gnus-uu-file-action-list'. Returns either nil if no action is
|
|
1991 ; found, or the name of the command to run if such a rule is found.
|
7977
|
1992 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
|
6728
|
1993 (let ((action-list (copy-sequence file-action-list))
|
|
1994 rule action)
|
7977
|
1995 (and
|
|
1996 (or no-ignore
|
|
1997 (and (not
|
|
1998 (and gnus-uu-ignore-files-by-name
|
|
1999 (string-match gnus-uu-ignore-files-by-name file-name)))
|
|
2000 (not
|
|
2001 (and gnus-uu-ignore-files-by-type
|
|
2002 (string-match gnus-uu-ignore-files-by-type
|
|
2003 (or (gnus-uu-choose-action
|
|
2004 file-name gnus-uu-ext-to-mime-list t)
|
|
2005 ""))))))
|
|
2006 (while (not (or (eq action-list ()) action))
|
|
2007 (setq rule (car action-list))
|
|
2008 (setq action-list (cdr action-list))
|
|
2009 (if (string-match (car rule) file-name)
|
|
2010 (setq action (car (cdr rule))))))
|
6728
|
2011 action))
|
|
2012
|
7291
|
2013 (defun gnus-uu-save-directory (from-dir &optional default-dir ignore-existing)
|
|
2014 (let (dir file-name command files file)
|
|
2015 (setq files (directory-files from-dir t))
|
|
2016 (if default-dir
|
|
2017 (setq dir default-dir)
|
|
2018 (setq dir (gnus-uu-read-directory
|
|
2019 (concat "Where do you want the file"
|
|
2020 (if (< 3 (length files)) "s" "") "? "))))
|
|
2021
|
|
2022 (while files
|
|
2023 (setq file (car files))
|
|
2024 (setq files (cdr files))
|
|
2025 (string-match "/[^/]*$" file)
|
|
2026 (setq file-name (substring file (1+ (match-beginning 0))))
|
|
2027 (if (string-match "^\\.\\.?$" file-name)
|
|
2028 ()
|
|
2029 (if (and (not ignore-existing) (file-exists-p (concat dir file-name)))
|
|
2030 (setq file-name
|
|
2031 (read-file-name "File exists. Enter a new name: " dir
|
|
2032 (concat dir file-name) nil file-name))
|
|
2033 (setq file-name (concat dir file-name)))
|
|
2034 (rename-file file file-name t)))))
|
6728
|
2035
|
6904
|
2036 ; Moves the file from the tmp directory to where the user wants it.
|
6728
|
2037 (defun gnus-uu-save-file (from-file-name &optional default-dir ignore-existing)
|
|
2038 (let (dir file-name command)
|
|
2039 (string-match "/[^/]*$" from-file-name)
|
|
2040 (setq file-name (substring from-file-name (1+ (match-beginning 0))))
|
|
2041 (if default-dir
|
|
2042 (setq dir default-dir)
|
|
2043 (setq dir (gnus-uu-read-directory "Where do you want the file? ")))
|
|
2044 (if (and (not ignore-existing) (file-exists-p (concat dir file-name)))
|
7291
|
2045 (setq file-name
|
|
2046 (read-file-name "File exist. Enter a new name: " dir
|
|
2047 (concat dir file-name) nil file-name))
|
6728
|
2048 (setq file-name (concat dir file-name)))
|
|
2049 (rename-file from-file-name file-name t)))
|
|
2050
|
|
2051 (defun gnus-uu-read-directory (prompt &optional default)
|
|
2052 (let (dir ok create)
|
|
2053 (while (not ok)
|
|
2054 (setq ok t)
|
|
2055 (setq dir (if default default
|
|
2056 (read-file-name prompt gnus-uu-current-save-dir
|
|
2057 gnus-uu-current-save-dir)))
|
|
2058 (while (string-match "/$" dir)
|
|
2059 (setq dir (substring dir 0 (match-beginning 0))))
|
|
2060 (if (file-exists-p dir)
|
|
2061 (if (not (file-directory-p dir))
|
|
2062 (progn
|
|
2063 (setq ok nil)
|
|
2064 (message "%s is a file" dir)
|
|
2065 (sit-for 2)))
|
|
2066 (setq create ?o)
|
|
2067 (while (not (or (= create ?y) (= create ?n)))
|
|
2068 (message "%s: No such directory. Do you want to create it? (y/n)"
|
|
2069 dir)
|
|
2070 (setq create (read-char)))
|
|
2071 (if (= create ?y) (make-directory dir))))
|
|
2072 (setq gnus-uu-current-save-dir (concat dir "/"))))
|
|
2073
|
6904
|
2074 ; Unpacks an archive and views all the files in it. Returns t if
|
|
2075 ; viewing one or more files is successful.
|
7291
|
2076 (defun gnus-uu-treat-archive (file-path)
|
|
2077 (let ((did-unpack t)
|
|
2078 action command files file file-name dir)
|
6728
|
2079 (setq action (gnus-uu-choose-action
|
7291
|
2080 file-path (append gnus-uu-user-archive-rules
|
6728
|
2081 (if gnus-uu-ignore-default-archive-rules
|
|
2082 nil
|
|
2083 gnus-uu-default-archive-rules))))
|
7291
|
2084
|
|
2085 (if (not action) (error "No unpackers for the file %s" file-path))
|
|
2086
|
|
2087 (string-match "/[^/]*$" file-path)
|
|
2088 (setq file-name (substring file-path (1+ (match-beginning 0))))
|
|
2089 (setq dir (substring file-path 0 (match-beginning 0)))
|
|
2090
|
|
2091 (if (gnus-uu-string-in-list action gnus-uu-destructive-archivers)
|
|
2092 (copy-file file-path (concat file-path "~") t))
|
|
2093
|
|
2094 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
|
|
2095
|
|
2096 (save-excursion
|
|
2097 (set-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
2098 (erase-buffer))
|
|
2099
|
|
2100 (message "Unpacking: %s..." (gnus-uu-command action file-path))
|
|
2101
|
|
2102 (if (= 0 (call-process "sh" nil
|
|
2103 (get-buffer-create gnus-uu-output-buffer-name)
|
|
2104 nil "-c" command))
|
|
2105 (message "")
|
7977
|
2106 (if (not gnus-uu-use-interactive-view)
|
|
2107 (progn
|
|
2108 (message "Error during unpacking of archive")
|
|
2109 (sleep-for 2)))
|
7291
|
2110 (setq did-unpack nil))
|
|
2111
|
|
2112 (if (gnus-uu-string-in-list action gnus-uu-destructive-archivers)
|
|
2113 (rename-file (concat file-path "~") file-path t))
|
|
2114
|
|
2115 did-unpack))
|
6728
|
2116
|
6904
|
2117 ; Tries to view all the files in the given directory. Returns t if
|
|
2118 ; viewing one or more files is successful.
|
7291
|
2119 (defun gnus-uu-view-directory (dir &optional dont-delete-files not-top)
|
|
2120 (let ((first t)
|
|
2121 files file did-view ignore-files)
|
|
2122 (setq files (directory-files dir t "[^/][^\\.][^\\.]?$"))
|
|
2123 (gnus-uu-add-file files)
|
|
2124 (setq ignore-files files)
|
|
2125
|
|
2126 (while (gnus-uu-unpack-archives
|
|
2127 files (if not-top (list ".")
|
|
2128 (if first () ignore-files)))
|
|
2129 (setq first nil)
|
|
2130 (gnus-uu-add-file
|
|
2131 (setq files (directory-files dir t "[^/][^\\.][^\\.]?$"))))
|
7977
|
2132
|
|
2133 (gnus-uu-add-file (directory-files dir t "[^/][^\\.][^\\.]?$"))
|
7291
|
2134
|
6728
|
2135 (while files
|
|
2136 (setq file (car files))
|
|
2137 (setq files (cdr files))
|
7291
|
2138 (if (not (string= (or (gnus-uu-get-action file) "") "gnus-uu-archive"))
|
6728
|
2139 (progn
|
|
2140 (set-file-modes file 448)
|
|
2141 (if (file-directory-p file)
|
7291
|
2142 (setq did-view (or (gnus-uu-view-directory file
|
|
2143 dont-delete-files
|
|
2144 t)
|
6728
|
2145 did-view))
|
7291
|
2146 (setq did-view (or (gnus-uu-view-file file t) did-view)))))
|
7977
|
2147 (if (and (not dont-delete-files) (not gnus-uu-asynchronous)
|
|
2148 (file-exists-p file))
|
7291
|
2149 (delete-file file)))
|
|
2150
|
7977
|
2151 (if (and (not gnus-uu-asynchronous) (not dont-delete-files))
|
|
2152 (if (string-match "/$" dir)
|
|
2153 (delete-directory (substring dir 0 (match-beginning 0)))
|
|
2154 (delete-directory dir)))
|
6728
|
2155 did-view))
|
|
2156
|
7291
|
2157 (defun gnus-uu-unpack-archives (files &optional ignore)
|
|
2158 (let (path did-unpack)
|
|
2159 (while files
|
|
2160 (setq path (car files))
|
|
2161 (setq files (cdr files))
|
|
2162 (if (not (gnus-uu-string-in-list path ignore))
|
|
2163 (if (string= (or (gnus-uu-get-action
|
|
2164 (gnus-uu-name-from-path path)) "")
|
|
2165 "gnus-uu-archive")
|
|
2166 (progn
|
7977
|
2167 (if (and (not (setq did-unpack (gnus-uu-treat-archive path)))
|
|
2168 gnus-uu-use-interactive-view)
|
|
2169 (gnus-uu-enter-interactive-file
|
|
2170 "# error during unpacking of" path))
|
7291
|
2171 (if ignore (delete-file path))))))
|
|
2172 did-unpack))
|
|
2173
|
6728
|
2174
|
|
2175 ;; Manual marking
|
|
2176
|
|
2177 (defun gnus-uu-enter-mark-in-list ()
|
|
2178 (let (article beg)
|
7291
|
2179 (save-excursion
|
|
2180 (beginning-of-line)
|
|
2181 (setq beg (point))
|
|
2182 (end-of-line)
|
|
2183 (setq article (gnus-uu-article-number
|
|
2184 (buffer-substring beg (point))))
|
|
2185 (message "Adding article %d to list" article)
|
|
2186 (setq gnus-uu-marked-article-list
|
|
2187 (cons article gnus-uu-marked-article-list)))))
|
|
2188
|
|
2189 (defun gnus-uu-mark-article (&optional dont-move)
|
6728
|
2190 "Marks the current article to be decoded later."
|
|
2191 (interactive)
|
|
2192 (gnus-uu-enter-mark-in-list)
|
|
2193 (gnus-summary-mark-as-read nil ?#)
|
|
2194 (gnus-summary-next-subject 1 nil))
|
|
2195
|
|
2196 (defun gnus-uu-unmark-article ()
|
|
2197 "Unmarks the current article."
|
|
2198 (interactive)
|
|
2199 (let ((in (copy-sequence gnus-uu-marked-article-list))
|
|
2200 out article beg found
|
|
2201 (old-point (point)))
|
|
2202 (beginning-of-line)
|
|
2203 (setq beg (point))
|
|
2204 (end-of-line)
|
|
2205 (setq article (gnus-uu-article-number (buffer-substring beg (point))))
|
7291
|
2206 (message "Removing article %d" article)
|
6728
|
2207 (while in
|
|
2208 (if (not (= (car in) article))
|
|
2209 (setq out (cons (car in) out))
|
|
2210 (setq found t)
|
7291
|
2211 (message "Removing article %d" article))
|
6728
|
2212 (setq in (cdr in)))
|
|
2213 (if (not found) (message "Not a marked article."))
|
|
2214 (setq gnus-uu-marked-article-list (reverse out))
|
|
2215 (gnus-summary-mark-as-unread nil t)
|
|
2216 (gnus-summary-next-subject 1 nil)))
|
|
2217
|
|
2218 (defun gnus-uu-unmark-all-articles ()
|
|
2219 "Removes the mark from all articles marked for decoding."
|
|
2220 (interactive)
|
7291
|
2221 (while gnus-uu-marked-article-list
|
|
2222 (gnus-summary-goto-subject (car gnus-uu-marked-article-list))
|
|
2223 (gnus-summary-mark-as-unread nil t)
|
|
2224 (setq gnus-uu-marked-article-list (cdr gnus-uu-marked-article-list))))
|
6728
|
2225
|
|
2226 (defun gnus-uu-mark-by-regexp ()
|
6904
|
2227 "Asks for a regular expression and marks all articles that match."
|
6728
|
2228 (interactive)
|
|
2229 (let (exp)
|
7291
|
2230 (setq exp (read-from-minibuffer "Mark (regexp): "))
|
6728
|
2231 (setq gnus-uu-marked-article-list
|
7291
|
2232 (append gnus-uu-marked-article-list
|
|
2233 (reverse (gnus-uu-get-list-of-articles exp t))))
|
6728
|
2234 (message "")))
|
|
2235
|
7291
|
2236 (defun gnus-uu-mark-thread ()
|
|
2237 "Marks all articles downwards in this thread."
|
|
2238 (interactive)
|
|
2239 (beginning-of-line)
|
|
2240 (let (level)
|
|
2241 (if (not (search-forward ":" nil t))
|
|
2242 ()
|
|
2243 (setq level (current-column))
|
|
2244 (gnus-uu-enter-mark-in-list)
|
|
2245 (gnus-summary-mark-as-read nil ?#)
|
|
2246 (gnus-summary-search-forward)
|
|
2247 (while (< level (current-column))
|
|
2248 (gnus-uu-enter-mark-in-list)
|
|
2249 (gnus-summary-mark-as-read nil ?#)
|
|
2250 (gnus-summary-search-forward))
|
|
2251 (gnus-summary-search-backward))))
|
|
2252
|
|
2253
|
|
2254 ;; Various stuff
|
|
2255
|
|
2256 (defun gnus-uu-string-in-list (string list)
|
|
2257 (while (and list
|
|
2258 (not (string= (car list) string))
|
|
2259 (setq list (cdr list))))
|
|
2260 list)
|
|
2261
|
|
2262 (defun gnus-uu-name-from-path (path)
|
|
2263 (string-match "/[^/]*$" path)
|
|
2264 (substring path (1+ (match-beginning 0))))
|
|
2265
|
|
2266 (defun gnus-uu-directory-files (dir)
|
|
2267 (let (files out file)
|
|
2268 (setq files (directory-files dir t))
|
|
2269 (while files
|
|
2270 (setq file (car files))
|
|
2271 (setq files (cdr files))
|
|
2272 (if (not (string-match "/\\.\\.?$" file))
|
|
2273 (setq out (cons file out))))
|
|
2274 (setq out (reverse out))
|
|
2275 out))
|
6728
|
2276
|
|
2277 (defun gnus-uu-check-correct-stripped-uucode (start end)
|
|
2278 (let (found beg length short)
|
|
2279 (if (not gnus-uu-correct-stripped-uucode)
|
|
2280 ()
|
|
2281 (goto-char start)
|
6904
|
2282
|
|
2283 (if (re-search-forward " \\|`" end t)
|
|
2284 (progn
|
|
2285 (goto-char start)
|
|
2286 (while (not (eobp))
|
6728
|
2287 (progn
|
6904
|
2288 (if (looking-at "\n") (replace-match ""))
|
|
2289 (forward-line 1))))
|
|
2290
|
|
2291 (while (not (eobp))
|
|
2292 (if (looking-at (concat gnus-uu-begin-string "\\|"
|
|
2293 gnus-uu-end-string))
|
|
2294 ()
|
|
2295 (if (not found)
|
|
2296 (progn
|
|
2297 (beginning-of-line)
|
|
2298 (setq beg (point))
|
|
2299 (end-of-line)
|
|
2300 (setq length (- (point) beg))))
|
|
2301 (setq found t)
|
|
2302 (beginning-of-line)
|
|
2303 (setq beg (point))
|
|
2304 (end-of-line)
|
|
2305 (if (not (= length (- (point) beg)))
|
|
2306 (insert (make-string (- length (- (point) beg)) ? ))))
|
|
2307 (forward-line 1))))))
|
6728
|
2308
|
|
2309 (defun gnus-uu-initialize ()
|
7977
|
2310 (setq gnus-uu-highest-article-number 1)
|
7291
|
2311 (gnus-uu-check-for-generated-files)
|
|
2312 (setq gnus-uu-tmp-dir (expand-file-name gnus-uu-tmp-dir))
|
|
2313 (if (string-match "[^/]$" gnus-uu-tmp-dir)
|
|
2314 (setq gnus-uu-tmp-dir (concat gnus-uu-tmp-dir "/")))
|
|
2315 (if (not (file-directory-p gnus-uu-tmp-dir))
|
|
2316 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
|
|
2317 (if (not (file-writable-p gnus-uu-tmp-dir))
|
|
2318 (error "Temp directory %s can't be written to" gnus-uu-tmp-dir)))
|
|
2319 (setq gnus-uu-work-dir
|
|
2320 (concat gnus-uu-tmp-dir (make-temp-name "gnus")))
|
|
2321 (gnus-uu-add-file gnus-uu-work-dir)
|
|
2322 (if (not (file-directory-p gnus-uu-work-dir))
|
|
2323 (make-directory gnus-uu-work-dir))
|
|
2324 (setq gnus-uu-work-dir (concat gnus-uu-work-dir "/"))
|
|
2325 (setq gnus-uu-interactive-file-list nil))
|
6728
|
2326
|
6904
|
2327 ; Kills the temporary uu buffers, kills any processes, etc.
|
6728
|
2328 (defun gnus-uu-clean-up ()
|
|
2329 (let (buf pst)
|
6904
|
2330 (and gnus-uu-uudecode-process
|
|
2331 (setq pst (process-status (or gnus-uu-uudecode-process "nevair")))
|
|
2332 (if (or (eq pst 'stop) (eq pst 'run))
|
|
2333 (delete-process gnus-uu-uudecode-process)))
|
6728
|
2334 (and (not gnus-uu-asynchronous)
|
|
2335 (setq buf (get-buffer gnus-uu-output-buffer-name))
|
|
2336 (kill-buffer buf))
|
|
2337 (and (setq buf (get-buffer gnus-uu-result-buffer))
|
|
2338 (kill-buffer buf))))
|
|
2339
|
6904
|
2340 ; `gnus-uu-check-for-generated-files' deletes any generated files that
|
|
2341 ; hasn't been deleted, if, for instance, the user terminated decoding
|
|
2342 ; with `C-g'.
|
6728
|
2343 (defun gnus-uu-check-for-generated-files ()
|
7291
|
2344 (let (file dirs)
|
6728
|
2345 (while gnus-uu-generated-file-list
|
|
2346 (setq file (car gnus-uu-generated-file-list))
|
|
2347 (setq gnus-uu-generated-file-list (cdr gnus-uu-generated-file-list))
|
|
2348 (if (not (string-match "/\\.[\\.]?$" file))
|
|
2349 (progn
|
|
2350 (if (file-directory-p file)
|
7291
|
2351 (setq dirs (cons file dirs))
|
6728
|
2352 (if (file-exists-p file)
|
7291
|
2353 (delete-file file))))))
|
|
2354 (setq dirs (nreverse dirs))
|
|
2355 (while dirs
|
|
2356 (setq file (car dirs))
|
|
2357 (setq dirs (cdr dirs))
|
|
2358 (if (file-directory-p file)
|
7977
|
2359 (if (string-match "/$" file)
|
|
2360 (delete-directory (substring file 0 (match-beginning 0)))
|
|
2361 (delete-directory file))))))
|
7291
|
2362
|
|
2363 ; Add a file (or a list of files) to be checked (and deleted if it/they
|
|
2364 ; still exists upon exiting the newsgroup).
|
6728
|
2365 (defun gnus-uu-add-file (file)
|
7291
|
2366 (if (stringp file)
|
|
2367 (setq gnus-uu-generated-file-list
|
|
2368 (cons file gnus-uu-generated-file-list))
|
|
2369 (setq gnus-uu-generated-file-list
|
|
2370 (append file gnus-uu-generated-file-list))))
|
6904
|
2371
|
|
2372 ; Go to the next unread subject. If there is no further unread
|
|
2373 ; subjects, go to the last subject in the buffer.
|
6728
|
2374 (defun gnus-uu-summary-next-subject ()
|
7291
|
2375 (let (opi)
|
|
2376 (if (not (gnus-summary-search-forward t))
|
|
2377 (progn
|
|
2378 (goto-char 1)
|
|
2379 (sit-for 0)
|
7977
|
2380 (gnus-summary-goto-subject gnus-uu-highest-article-number)))
|
7291
|
2381
|
|
2382 ; You may well find all this a bit puzzling - so do I, but I seem
|
|
2383 ; to have to do something like this to move to the next unread article,
|
|
2384 ; as `sit-for' seems to do some rather strange things here. Might
|
|
2385 ; be a bug in my head, probably.
|
|
2386 (setq opi (point))
|
|
2387 (sit-for 0)
|
|
2388 (goto-char opi)
|
|
2389 (gnus-summary-recenter)))
|
6728
|
2390
|
6904
|
2391 ; Inputs an action and a file and returns a full command, putting
|
|
2392 ; ticks round the file name and escaping any ticks in the file name.
|
|
2393 (defun gnus-uu-command (action file)
|
|
2394 (let ((ofile ""))
|
|
2395 (while (string-match "`\\|\"\\|\\$\\|\\\\" file)
|
|
2396 (progn
|
|
2397 (setq ofile
|
|
2398 (concat ofile (substring file 0 (match-beginning 0)) "\\"
|
|
2399 (substring file (match-beginning 0) (match-end 0))))
|
|
2400 (setq file (substring file (1+ (match-beginning 0))))))
|
|
2401 (setq ofile (concat "\"" ofile file "\""))
|
|
2402 (if (string-match "%s" action)
|
|
2403 (format action ofile)
|
|
2404 (concat action " " ofile))))
|
|
2405
|
6728
|
2406
|
|
2407 ;; Initializing
|
|
2408 (add-hook 'gnus-exit-group-hook
|
|
2409 '(lambda ()
|
|
2410 (gnus-uu-clean-up)
|
|
2411 (setq gnus-uu-marked-article-list nil)
|
|
2412 (gnus-uu-check-for-generated-files)))
|
|
2413
|
|
2414
|
|
2415 ;; Interactive exec mode
|
|
2416
|
|
2417 (defvar gnus-uu-output-window nil)
|
|
2418 (defvar gnus-uu-mode-hook nil)
|
7977
|
2419
|
6728
|
2420 (defvar gnus-uu-mode-map nil)
|
7977
|
2421 (if gnus-uu-mode-map
|
|
2422 ()
|
|
2423 (setq gnus-uu-mode-map (make-sparse-keymap))
|
|
2424 (define-key gnus-uu-mode-map "\C-c\C-x" 'gnus-uu-interactive-execute)
|
|
2425 (define-key gnus-uu-mode-map "\C-c\C-v" 'gnus-uu-interactive-execute)
|
|
2426 (define-key gnus-uu-mode-map "\C-m" 'gnus-uu-interactive-execute)
|
|
2427 (define-key gnus-uu-mode-map "\C-c\C-c" 'gnus-uu-interactive-end)
|
11662
|
2428 (define-key gnus-uu-mode-map "\C-c\C-z"
|
7977
|
2429 'gnus-uu-interactive-save-current-file)
|
|
2430 (define-key gnus-uu-mode-map "\C-c\C-s"
|
|
2431 'gnus-uu-interactive-save-current-file-silent)
|
|
2432 (define-key gnus-uu-mode-map "\C-c\C-w" 'gnus-uu-interactive-save-all-files)
|
|
2433 (define-key gnus-uu-mode-map "\C-c\C-o" 'gnus-uu-interactive-save-original-file)
|
|
2434 (define-key gnus-uu-mode-map "\C-c\C-r" 'gnus-uu-interactive-rescan-directory)
|
11662
|
2435 (define-key gnus-uu-mode-map "\C-c\C-d" 'gnus-uu-interactive-scan-directory)
|
7977
|
2436 )
|
|
2437
|
|
2438 (defun gnus-uu-interactive-set-up-windows ()
|
|
2439 (let (int-buf out-buf)
|
6728
|
2440 (set-buffer
|
7977
|
2441 (setq int-buf (get-buffer-create gnus-uu-interactive-buffer-name)))
|
|
2442 (if (not (get-buffer-window int-buf))
|
|
2443 (switch-to-buffer-other-window int-buf))
|
|
2444 (pop-to-buffer int-buf)
|
|
2445 (setq out-buf (get-buffer-create gnus-uu-output-buffer-name))
|
|
2446 (if (not (get-buffer-window out-buf))
|
|
2447 (progn
|
|
2448 (setq gnus-uu-output-window
|
|
2449 (split-window nil (- (window-height)
|
|
2450 gnus-uu-output-window-height)))
|
|
2451 (set-window-buffer gnus-uu-output-window out-buf)))))
|
|
2452
|
|
2453 (defun gnus-uu-do-interactive (&optional dont-do-windows)
|
|
2454 (if (not gnus-uu-interactive-file-list)
|
|
2455 (gnus-uu-enter-interactive-file "#" ""))
|
|
2456 (if (not dont-do-windows) (gnus-uu-interactive-set-up-windows))
|
|
2457 (save-excursion
|
|
2458 (set-buffer (get-buffer-create gnus-uu-output-buffer-name))
|
|
2459 (erase-buffer))
|
|
2460 (set-buffer (get-buffer-create gnus-uu-interactive-buffer-name))
|
|
2461 (goto-char 1)
|
|
2462 (forward-line 3)
|
|
2463 (run-hooks 'gnus-uu-mode-hook))
|
6728
|
2464
|
|
2465 (defun gnus-uu-enter-interactive-file (action file)
|
|
2466 (let (command)
|
|
2467 (save-excursion
|
7291
|
2468 (set-buffer (get-buffer-create gnus-uu-interactive-buffer-name))
|
|
2469 (if (not gnus-uu-interactive-file-list)
|
|
2470 (progn
|
|
2471 (erase-buffer)
|
|
2472 (gnus-uu-mode)
|
|
2473 (insert
|
|
2474 "# Press return to execute a command.
|
|
2475 # Press `C-c C-c' to exit interactive view.
|
|
2476
|
|
2477 ")))
|
6728
|
2478 (setq gnus-uu-interactive-file-list
|
|
2479 (cons file gnus-uu-interactive-file-list))
|
7977
|
2480 ; (if (string-match (concat "^" gnus-uu-work-dir) file)
|
|
2481 ; (setq file (substring file (match-end 0))))
|
6904
|
2482 (setq command (gnus-uu-command action file))
|
7977
|
2483 (goto-char (point-max))
|
6728
|
2484 (insert (format "%s\n" command)))))
|
|
2485
|
|
2486 (defun gnus-uu-interactive-execute ()
|
6904
|
2487 "Executes the command on the current line in interactive mode."
|
6728
|
2488 (interactive)
|
|
2489 (let (beg out-buf command)
|
|
2490 (beginning-of-line)
|
|
2491 (setq beg (point))
|
|
2492 (end-of-line)
|
|
2493 (setq command (buffer-substring beg (point)))
|
|
2494 (setq out-buf (get-buffer-create gnus-uu-output-buffer-name))
|
|
2495 (save-excursion
|
|
2496 (set-buffer out-buf)
|
|
2497 (erase-buffer)
|
|
2498 (insert (format "$ %s \n\n" command)))
|
7977
|
2499 (setq command (format "cd %s ; %s" gnus-uu-work-dir command))
|
6728
|
2500 (message "Executing...")
|
|
2501 (if gnus-uu-asynchronous
|
|
2502 (start-process "gnus-uu-view" out-buf "sh" "-c" command)
|
|
2503 (call-process "sh" nil out-buf nil "-c" command)
|
|
2504 (message ""))
|
7977
|
2505 (end-of-line)
|
|
2506 (if (= (forward-line 1) 1)
|
|
2507 (progn
|
|
2508 (end-of-line)
|
|
2509 (insert "\n")))
|
6728
|
2510 (beginning-of-line)))
|
|
2511
|
|
2512 (defun gnus-uu-interactive-end ()
|
6904
|
2513 "This function exits interactive view mode and returns to summary mode."
|
6728
|
2514 (interactive)
|
|
2515 (let (buf)
|
|
2516 (delete-window gnus-uu-output-window)
|
|
2517 (gnus-uu-clean-up)
|
|
2518 (if (not gnus-uu-asynchronous) (gnus-uu-check-for-generated-files))
|
|
2519 (setq buf (get-buffer gnus-uu-interactive-buffer-name))
|
|
2520 (if gnus-article-buffer (switch-to-buffer gnus-article-buffer))
|
|
2521 (if buf (kill-buffer buf))
|
|
2522 (pop-to-buffer gnus-summary-buffer)))
|
|
2523
|
7977
|
2524
|
|
2525 (defun gnus-uu-interactive-scan-directory (dir)
|
|
2526 "Read any directory and view the files.
|
|
2527 When used in interactive mode, the files and commands will be displayed,
|
|
2528 as usual, in the interactive mode buffer."
|
|
2529 (interactive "DDirectory: ")
|
|
2530 (setq gnus-uu-interactive-file-list nil)
|
|
2531 (gnus-uu-view-directory dir gnus-uu-use-interactive-view)
|
|
2532 (gnus-uu-do-interactive t))
|
|
2533
|
|
2534 (defun gnus-uu-interactive-rescan-directory ()
|
|
2535 "Reread the directory and view the files.
|
|
2536 When used in interactive mode, the files and commands will be displayed,
|
|
2537 as usual, in the interactive mode buffer."
|
|
2538 (interactive)
|
|
2539 (gnus-uu-interactive-scan-directory gnus-uu-work-dir))
|
6728
|
2540
|
|
2541 (defun gnus-uu-interactive-save-original-file ()
|
6904
|
2542 "Saves the file from whence the file on the current line came from."
|
6728
|
2543 (interactive)
|
7977
|
2544 (let ((files gnus-uu-list-of-files-decoded)
|
|
2545 (filestr "")
|
|
2546 file did dir)
|
|
2547 (while files
|
|
2548 (setq file (car files))
|
|
2549 (setq files (cdr files))
|
|
2550 (if (file-exists-p file)
|
|
2551 (progn
|
|
2552 (if (not did)
|
|
2553 (progn
|
|
2554 (setq dir (gnus-uu-read-directory
|
|
2555 (format "Where do you want the file%s? "
|
|
2556 (if (> (length files) 1) "s" ""))))
|
|
2557 (setq did t)))
|
|
2558 (setq filestr (concat filestr (gnus-uu-name-from-path file) " "))
|
|
2559 (gnus-uu-save-file file dir t)))
|
|
2560 (if did
|
|
2561 (message "Saved %s" filestr)
|
|
2562 (message "Already saved.")))))
|
6728
|
2563
|
|
2564 (defun gnus-uu-interactive-save-current-file-silent ()
|
6904
|
2565 "Saves the file referred to on the current line in the current directory."
|
6728
|
2566 (interactive)
|
|
2567 (gnus-uu-interactive-save-current-file t))
|
|
2568
|
|
2569 (defun gnus-uu-interactive-save-current-file (&optional dont-ask silent)
|
|
2570 "Saves the file referred to on the current line."
|
|
2571 (interactive)
|
|
2572 (let (files beg line file)
|
|
2573 (setq files (copy-sequence gnus-uu-interactive-file-list))
|
|
2574 (beginning-of-line)
|
|
2575 (setq beg (point))
|
|
2576 (end-of-line)
|
|
2577 (setq line (buffer-substring beg (point)))
|
|
2578 (while (and files
|
|
2579 (not (string-match
|
|
2580 (concat "" (regexp-quote (setq file (car files))) "")
|
|
2581 line)))
|
|
2582 (setq files (cdr files)))
|
|
2583 (beginning-of-line)
|
|
2584 (forward-line 1)
|
|
2585 (if (not files)
|
|
2586 (if (not silent)
|
|
2587 (progn (message "Could not find file") (sit-for 2)))
|
|
2588 (gnus-uu-save-file file (if dont-ask gnus-uu-current-save-dir nil) silent)
|
|
2589 (delete-region beg (point)))))
|
|
2590
|
|
2591 (defun gnus-uu-interactive-save-all-files ()
|
6904
|
2592 "Saves all files referred to in the interactive buffer."
|
6728
|
2593 (interactive)
|
|
2594 (let (dir)
|
|
2595 (goto-char 1)
|
|
2596 (setq dir (gnus-uu-read-directory "Where do you want the files? "))
|
|
2597 (while (not (eobp))
|
|
2598 (gnus-uu-interactive-save-current-file t t))))
|
|
2599
|
|
2600 (defun gnus-uu-mode ()
|
|
2601 "Major mode for editing view commands in gnus-uu.
|
|
2602
|
|
2603 Commands:
|
6904
|
2604 \\<gnus-uu-mode-map>Return, C-c C-v, C-c C-x Execute the current command
|
7977
|
2605 \\[gnus-uu-interactive-end]\tEnd interactive mode
|
|
2606 \\[gnus-uu-interactive-save-current-file]\tSave the current file
|
|
2607 \\[gnus-uu-interactive-save-current-file-silent]\tSave the current file without asking
|
|
2608 \twhere to put it
|
|
2609 \\[gnus-uu-interactive-save-all-files]\tSave all files
|
|
2610 \\[gnus-uu-interactive-save-original-file]\tSave the original file: If the files
|
|
2611 \toriginated in an archive, the archive
|
|
2612 \tfile is saved.
|
|
2613 \\[gnus-uu-interactive-rescan-directory]\tRescan the directory
|
|
2614 \\[gnus-uu-interactive-scan-directory]\tScan any directory
|
6728
|
2615 "
|
|
2616 (interactive)
|
|
2617 (kill-all-local-variables)
|
|
2618 (use-local-map gnus-uu-mode-map)
|
|
2619 (setq mode-name "gnus-uu")
|
|
2620 (setq major-mode 'gnus-uu-mode)
|
|
2621 )
|
|
2622
|
|
2623 (define-key gnus-uu-mode-map "\C-c\C-x" 'gnus-uu-interactive-execute)
|
|
2624 (define-key gnus-uu-mode-map "\C-c\C-v" 'gnus-uu-interactive-execute)
|
|
2625 (define-key gnus-uu-mode-map "\C-m" 'gnus-uu-interactive-execute)
|
|
2626 (define-key gnus-uu-mode-map "\C-c\C-c" 'gnus-uu-interactive-end)
|
|
2627 (define-key gnus-uu-mode-map "\C-cs"
|
|
2628 'gnus-uu-interactive-save-current-file)
|
|
2629 (define-key gnus-uu-mode-map "\C-c\C-s"
|
|
2630 'gnus-uu-interactive-save-current-file-silent)
|
|
2631 (define-key gnus-uu-mode-map "\C-c\C-a" 'gnus-uu-interactive-save-all-files)
|
|
2632 (define-key gnus-uu-mode-map "\C-c\C-o" 'gnus-uu-interactive-save-original-file)
|
|
2633
|
7291
|
2634
|
|
2635 ;; Major mode for posting encoded articles.
|
|
2636
|
|
2637 (require 'sendmail)
|
|
2638 (require 'rnews)
|
|
2639
|
|
2640 ; Any function that is to be used as and encoding method will take two
|
|
2641 ; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
|
|
2642 ; and "spiral.jpg", respectively.) The function should return nil if
|
|
2643 ; the encoding wasn't successful.
|
|
2644 (defvar gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
|
|
2645 "Function used for encoding binary files.
|
|
2646 There are three functions supplied with gnus-uu for encoding files:
|
|
2647 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
|
|
2648 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
|
|
2649 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
|
|
2650 uuencode and adds MIME headers.")
|
|
2651
|
|
2652 (defvar gnus-uu-post-include-before-composing nil
|
|
2653 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
|
|
2654 If this variable is t, you can either include an encoded file with
|
|
2655 \\<gnus-uu-post-reply-mode-map>\\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article.")
|
|
2656
|
|
2657 (defvar gnus-uu-post-length 990
|
|
2658 "Maximum length of an article.
|
|
2659 The encoded file will be split into how many articles it takes to
|
|
2660 post the entire file.")
|
|
2661
|
|
2662 (defvar gnus-uu-post-threaded nil
|
|
2663 "Non-nil means that gnus-uu will post the encoded file in a thread.
|
|
2664 This may not be smart, as no other decoder I have seen are able to
|
|
2665 follow threads when collecting uuencoded articles. (Well, I have seen
|
|
2666 one package that does that - gnus-uu, but somehow, I don't think that
|
|
2667 counts...) Default is nil.")
|
|
2668
|
|
2669 (defvar gnus-uu-post-separate-description t
|
|
2670 "Non-nil means that the description will be posted in a separate article.
|
|
2671 The first article will typically be numbered (0/x). If this variable
|
|
2672 is nil, the description the user enters will be included at the
|
|
2673 beginning of the first article, which will be numbered (1/x). Default
|
|
2674 is t.")
|
|
2675
|
|
2676 (defconst gnus-uu-post-binary-separator "--binary follows this line--")
|
|
2677 (defvar gnus-uu-post-message-id nil)
|
|
2678 (defvar gnus-uu-post-inserted-file-name nil)
|
|
2679 (defvar gnus-uu-winconf-post-news nil)
|
|
2680
|
|
2681 ; The following map and mode was taken from rnewspost.el and edited
|
|
2682 ; somewhat.
|
|
2683 (defvar gnus-uu-post-reply-mode-map () "Mode map used by gnus-uu-post-reply.")
|
|
2684 (or gnus-uu-post-reply-mode-map
|
|
2685 (progn
|
|
2686 (setq gnus-uu-post-reply-mode-map (make-keymap))
|
|
2687 (define-key gnus-uu-post-reply-mode-map "\C-c?" 'describe-mode)
|
|
2688 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-d"
|
|
2689 'news-reply-distribution)
|
|
2690 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-k"
|
|
2691 'news-reply-keywords)
|
|
2692 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-n"
|
|
2693 'news-reply-newsgroups)
|
|
2694
|
|
2695 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-f"
|
|
2696 'news-reply-followup-to)
|
|
2697 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-s" 'mail-subject)
|
|
2698 (define-key gnus-uu-post-reply-mode-map "\C-c\C-f\C-a"
|
|
2699 'gnus-uu-post-reply-summary)
|
|
2700 (define-key gnus-uu-post-reply-mode-map "\C-c\C-r"
|
|
2701 'news-caesar-buffer-body)
|
|
2702 (define-key gnus-uu-post-reply-mode-map "\C-c\C-w" 'news-reply-signature)
|
|
2703 (define-key gnus-uu-post-reply-mode-map "\C-c\C-y"
|
|
2704 'news-reply-yank-original)
|
|
2705 (define-key gnus-uu-post-reply-mode-map "\C-c\C-q"
|
|
2706 'mail-fill-yanked-message)
|
|
2707 (define-key gnus-uu-post-reply-mode-map "\C-c\C-c"
|
|
2708 'gnus-uu-post-news-inews)
|
|
2709 (define-key gnus-uu-post-reply-mode-map "\C-c\C-s"
|
|
2710 'gnus-uu-post-news-inews)
|
|
2711 (define-key gnus-uu-post-reply-mode-map "\C-c\C-i"
|
|
2712 'gnus-uu-post-insert-binary-in-article)
|
|
2713 ))
|
|
2714
|
|
2715 ; This mode was taken from rnewspost.el and modified slightly.
|
|
2716 (defun gnus-uu-post-reply-mode ()
|
|
2717 "Major mode for editing binary news to be posted on USENET.
|
|
2718 First-time posters are asked to please read the articles in newsgroup:
|
|
2719 news.announce.newusers .
|
|
2720
|
|
2721 Like news-reply-mode, which is like Text Mode, but with these
|
|
2722 additional commands:
|
|
2723
|
|
2724 \\<gnus-uu-post-reply-mode-map>\\[gnus-uu-post-news-inews] post the message.
|
|
2725 C-c C-f move to a header field (and create it if there isn't):
|
|
2726 C-c C-f C-n move to Newsgroups: C-c C-f C-s move to Subj:
|
|
2727 C-c C-f C-f move to Followup-To: C-c C-f C-k move to Keywords:
|
|
2728 C-c C-f C-d move to Distribution: C-c C-f C-a move to Summary:
|
|
2729 C-c C-y news-reply-yank-original (insert current message, in NEWS).
|
|
2730 C-c C-q mail-fill-yanked-message (fill what was yanked).
|
|
2731 C-c C-r caesar rotate all letters by 13 places in the article's body (rot13).
|
|
2732 \\[gnus-uu-post-insert-binary-in-article] encode and include a file in this article.
|
|
2733
|
|
2734 This mode is almost identical to news-reply-mode, but has some
|
|
2735 additional commands for treating encoded binary articles. In
|
|
2736 particular, \\[gnus-uu-post-news-inews] will ask for a file to include, if
|
|
2737 one hasn't been included already. It will post, first, the message
|
|
2738 composed, and then it will post as many additional articles it takes
|
|
2739 to post the entire encoded files.
|
|
2740
|
|
2741 Relevant Variables
|
|
2742
|
|
2743 `gnus-uu-post-encode-method'
|
|
2744 There are three functions supplied with gnus-uu for encoding files:
|
|
2745 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
|
|
2746 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
|
|
2747 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
|
|
2748 uuencode and adds MIME headers.
|
|
2749
|
|
2750 `gnus-uu-post-include-before-composing'
|
|
2751 Non-nil means that gnus-uu will ask for a file to encode before you
|
|
2752 compose the article. If this variable is t, you can either include
|
|
2753 an encoded file with `C-c C-i' or have one included for you when you
|
|
2754 post the article.
|
|
2755
|
|
2756 `gnus-uu-post-length'
|
|
2757 Maximum length of an article. The encoded file will be split into how
|
|
2758 many articles it takes to post the entire file.
|
|
2759
|
|
2760 `gnus-uu-post-separate-description'
|
|
2761 Non-nil means that the description will be posted in a separate
|
|
2762 article. The first article will typically be numbered (0/x). If
|
|
2763 this variable is nil, the description the user enters will be
|
|
2764 included at the beginning of the first article, which will be
|
|
2765 numbered (1/x). Default is t.
|
|
2766
|
|
2767 `gnus-uu-post-threaded'
|
|
2768 Non-nil means that gnus-uu will post the encoded file in a thread.
|
|
2769 This may not be smart, as no other decoder I have seen are able to
|
|
2770 follow threads when collecting uuencoded articles. (Well, I have seen
|
|
2771 one package that does that - gnus-uu, but somehow, I don't think that
|
|
2772 counts...) Default is nil.
|
|
2773 "
|
|
2774 (interactive)
|
|
2775 ;; require...
|
|
2776 (or (fboundp 'mail-setup) (load "sendmail"))
|
|
2777 (kill-all-local-variables)
|
|
2778 (make-local-variable 'mail-reply-buffer)
|
|
2779 (setq mail-reply-buffer nil)
|
|
2780 (set-syntax-table text-mode-syntax-table)
|
|
2781 (use-local-map gnus-uu-post-reply-mode-map)
|
|
2782 (setq local-abbrev-table text-mode-abbrev-table)
|
|
2783 (setq major-mode 'gnus-uu-post-reply-mode)
|
|
2784 (setq mode-name "Gnus UU News")
|
|
2785 (make-local-variable 'paragraph-separate)
|
|
2786 (make-local-variable 'paragraph-start)
|
10873
1f8938c2c3a8
(gnus-uu-post-reply-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
diff
changeset
|
2787 (setq paragraph-start (concat mail-header-separator "$\\|"
|
7291
|
2788 paragraph-start))
|
10873
1f8938c2c3a8
(gnus-uu-post-reply-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
diff
changeset
|
2789 (setq paragraph-separate (concat mail-header-separator "$\\|"
|
7291
|
2790 paragraph-separate))
|
|
2791 (run-hooks 'text-mode-hook 'gnus-uu-post-reply-mode-hook))
|
|
2792
|
|
2793 (defun gnus-uu-post-news ()
|
|
2794 "Compose an article and post an encoded file."
|
|
2795 (interactive)
|
|
2796 (setq gnus-uu-post-inserted-file-name nil)
|
|
2797 (setq gnus-uu-winconf-post-news (current-window-configuration))
|
|
2798 (let (news-reply-mode)
|
|
2799 (fset 'news-reply-mode 'gnus-uu-post-reply-mode)
|
|
2800 (gnus-summary-post-news)
|
|
2801 (if gnus-uu-post-include-before-composing
|
|
2802 (save-excursion (setq gnus-uu-post-inserted-file-name
|
|
2803 (gnus-uu-post-insert-binary))))))
|
|
2804
|
|
2805 (defun gnus-uu-post-insert-binary-in-article ()
|
|
2806 "Inserts an encoded file in the buffer.
|
|
2807 The user will be asked for a file name."
|
|
2808 (interactive)
|
|
2809 (if (not (eq (current-buffer) (get-buffer gnus-post-news-buffer)))
|
|
2810 (error "Not in post-news buffer"))
|
|
2811 (save-excursion
|
|
2812 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
|
|
2813
|
|
2814 ; Encodes with uuencode and substitutes all spaces with backticks.
|
|
2815 (defun gnus-uu-post-encode-uuencode (path file-name)
|
|
2816 (if (gnus-uu-post-encode-file "uuencode" path file-name)
|
|
2817 (progn
|
|
2818 (goto-char 1)
|
|
2819 (forward-line 1)
|
|
2820 (while (re-search-forward " " nil t)
|
|
2821 (replace-match "`"))
|
|
2822 t)))
|
|
2823
|
|
2824 ; Encodes with uuencode and adds MIME headers.
|
|
2825 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
|
|
2826 (if (gnus-uu-post-encode-uuencode path file-name)
|
|
2827 (progn
|
|
2828 (gnus-uu-post-make-mime file-name "x-uue")
|
|
2829 t)))
|
|
2830
|
|
2831 ; Encodes with base64 and adds MIME headers
|
|
2832 (defun gnus-uu-post-encode-mime (path file-name)
|
|
2833 (if (gnus-uu-post-encode-file "mmencode" path file-name)
|
|
2834 (progn
|
|
2835 (gnus-uu-post-make-mime file-name "base64")
|
|
2836 t)))
|
|
2837
|
|
2838 ; Adds MIME headers.
|
|
2839 (defun gnus-uu-post-make-mime (file-name encoding)
|
|
2840 (goto-char 1)
|
|
2841 (insert (format "Content-Type: %s; name=\"%s\"\n"
|
|
2842 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
|
|
2843 file-name))
|
|
2844 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
|
|
2845 (save-restriction
|
|
2846 (set-buffer gnus-post-news-buffer)
|
|
2847 (goto-char 1)
|
|
2848 (re-search-forward mail-header-separator)
|
|
2849 (beginning-of-line)
|
|
2850 (forward-line -1)
|
|
2851 (narrow-to-region 1 (point))
|
|
2852 (or (mail-fetch-field "mime-version")
|
|
2853 (progn
|
|
2854 (widen)
|
|
2855 (insert "MIME-Version: 1.0\n")))
|
|
2856 (widen)))
|
|
2857
|
|
2858 ; Encodes a file PATH with COMMAND, leaving the result in the
|
|
2859 ; current buffer.
|
|
2860 (defun gnus-uu-post-encode-file (command path file-name)
|
|
2861 (= 0 (call-process "sh" nil t nil "-c"
|
|
2862 (format "%s %s %s" command path file-name))))
|
|
2863
|
|
2864 (defun gnus-uu-post-news-inews ()
|
|
2865 "Posts the composed news article and encoded file.
|
|
2866 If no file has been included, the user will be asked for a file."
|
|
2867 (interactive)
|
|
2868 (if (not (eq (current-buffer) (get-buffer gnus-post-news-buffer)))
|
|
2869 (error "Not in post news buffer"))
|
|
2870
|
|
2871 (let (file-name)
|
|
2872
|
|
2873 (if gnus-uu-post-inserted-file-name
|
|
2874 (setq file-name gnus-uu-post-inserted-file-name)
|
|
2875 (setq file-name (gnus-uu-post-insert-binary)))
|
|
2876
|
|
2877 (if gnus-uu-post-threaded
|
|
2878 (let ((gnus-required-headers
|
|
2879 (if (memq 'Message-ID gnus-required-headers)
|
|
2880 gnus-required-headers
|
|
2881 (cons 'Message-ID gnus-required-headers)))
|
|
2882 gnus-inews-article-hook elem)
|
|
2883
|
|
2884 (setq gnus-inews-article-hook (if (listp gnus-inews-article-hook)
|
|
2885 gnus-inews-article-hook
|
|
2886 (list gnus-inews-article-hook)))
|
|
2887 (setq gnus-inews-article-hook
|
|
2888 (cons
|
|
2889 '(lambda ()
|
|
2890 (save-excursion
|
|
2891 (goto-char 1)
|
|
2892 (if (re-search-forward "^Message-ID: \\(.*\\)$" nil t)
|
|
2893 (setq gnus-uu-post-message-id
|
|
2894 (buffer-substring
|
|
2895 (match-beginning 1) (match-end 1)))
|
|
2896 (setq gnus-uu-post-message-id nil))))
|
|
2897 gnus-inews-article-hook))
|
|
2898 (gnus-uu-post-encoded file-name t))
|
|
2899 (gnus-uu-post-encoded file-name nil)))
|
|
2900 (setq gnus-uu-post-inserted-file-name nil)
|
|
2901 (and gnus-uu-winconf-post-news
|
|
2902 (set-window-configuration gnus-uu-winconf-post-news)))
|
|
2903
|
|
2904 ; Asks for a file to encode, encodes it and inserts the result in
|
|
2905 ; the current buffer. Returns the file name the user gave.
|
|
2906 (defun gnus-uu-post-insert-binary ()
|
|
2907 (let ((uuencode-buffer-name "*uuencode buffer*")
|
|
2908 file-path post-buf uubuf file-name)
|
|
2909
|
|
2910 (setq file-path (read-file-name
|
|
2911 "What file do you want to encode? "))
|
|
2912 (if (not (file-exists-p file-path))
|
|
2913 (error "%s: No such file" file-path))
|
|
2914
|
|
2915 (goto-char (point-max))
|
|
2916 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
|
|
2917
|
|
2918 (if (string-match "^~/" file-path)
|
|
2919 (setq file-path (concat "$HOME" (substring file-path 1))))
|
|
2920 (if (string-match "/[^/]*$" file-path)
|
|
2921 (setq file-name (substring file-path (1+ (match-beginning 0))))
|
|
2922 (setq file-name file-path))
|
|
2923
|
|
2924 (unwind-protect
|
|
2925 (if (save-excursion
|
|
2926 (set-buffer (setq uubuf
|
|
2927 (get-buffer-create uuencode-buffer-name)))
|
|
2928 (erase-buffer)
|
|
2929 (funcall gnus-uu-post-encode-method file-path file-name))
|
|
2930 (insert-buffer uubuf)
|
|
2931 (error "Encoding unsuccessful"))
|
|
2932 (kill-buffer uubuf))
|
|
2933 file-name))
|
|
2934
|
|
2935 ; Posts the article and all of the encoded file.
|
|
2936 (defun gnus-uu-post-encoded (file-name &optional threaded)
|
|
2937 (let ((send-buffer-name "*uuencode send buffer*")
|
|
2938 (encoded-buffer-name "*encoded buffer*")
|
|
2939 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
|
|
2940 (separator (concat mail-header-separator "\n\n"))
|
|
2941 file uubuf length parts header i end beg
|
|
2942 beg-line minlen buf post-buf whole-len beg-binary end-binary)
|
|
2943
|
|
2944 (setq post-buf (current-buffer))
|
|
2945
|
|
2946 (goto-char 1)
|
|
2947 (if (not (re-search-forward
|
|
2948 (if gnus-uu-post-separate-description
|
|
2949 gnus-uu-post-binary-separator
|
|
2950 mail-header-separator) nil t))
|
|
2951 (error "Internal error: No binary/header separator"))
|
|
2952 (beginning-of-line)
|
|
2953 (forward-line 1)
|
|
2954 (setq beg-binary (point))
|
|
2955 (setq end-binary (point-max))
|
|
2956
|
|
2957 (save-excursion
|
|
2958 (set-buffer (setq uubuf (get-buffer-create encoded-buffer-name)))
|
|
2959 (erase-buffer)
|
|
2960 (insert-buffer-substring post-buf beg-binary end-binary)
|
|
2961 (goto-char 1)
|
|
2962 (setq length (count-lines 1 (point-max)))
|
|
2963 (setq parts (/ length gnus-uu-post-length))
|
|
2964 (if (not (< (% length gnus-uu-post-length) 4))
|
|
2965 (setq parts (1+ parts))))
|
|
2966
|
|
2967 (if gnus-uu-post-separate-description
|
|
2968 (forward-line -1))
|
|
2969 (kill-region (point) (point-max))
|
|
2970
|
|
2971 (goto-char 1)
|
|
2972 (search-forward mail-header-separator nil t)
|
|
2973 (beginning-of-line)
|
|
2974 (setq header (buffer-substring 1 (point)))
|
|
2975
|
|
2976 (goto-char 1)
|
|
2977 (if (not gnus-uu-post-separate-description)
|
|
2978 ()
|
|
2979 (if (and (not threaded) (re-search-forward "^Subject: " nil t))
|
|
2980 (progn
|
|
2981 (end-of-line)
|
|
2982 (insert (format " (0/%d)" parts))))
|
|
2983 (gnus-inews-news))
|
|
2984
|
|
2985 (save-excursion
|
|
2986 (setq i 1)
|
|
2987 (setq beg 1)
|
|
2988 (while (not (> i parts))
|
|
2989 (set-buffer (get-buffer-create send-buffer-name))
|
|
2990 (erase-buffer)
|
|
2991 (insert header)
|
|
2992 (if (and threaded gnus-uu-post-message-id)
|
|
2993 (insert (format "References: %s\n" gnus-uu-post-message-id)))
|
|
2994 (insert separator)
|
|
2995 (setq whole-len
|
|
2996 (- 62 (length (format top-string "" file-name i parts ""))))
|
|
2997 (if (> 1 (setq minlen (/ whole-len 2)))
|
|
2998 (setq minlen 1))
|
|
2999 (setq
|
|
3000 beg-line
|
|
3001 (format top-string
|
|
3002 (make-string minlen ?-)
|
|
3003 file-name i parts
|
|
3004 (make-string
|
|
3005 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
|
|
3006
|
|
3007 (goto-char 1)
|
|
3008 (if (not (re-search-forward "^Subject: " nil t))
|
|
3009 ()
|
|
3010 (if (not threaded)
|
|
3011 (progn
|
|
3012 (end-of-line)
|
|
3013 (insert (format " (%d/%d)" i parts)))
|
|
3014 (if (or (and (= i 2) gnus-uu-post-separate-description)
|
|
3015 (and (= i 1) (not gnus-uu-post-separate-description)))
|
|
3016 (replace-match "Subject: Re: "))))
|
|
3017
|
|
3018 (goto-char (point-max))
|
|
3019 (save-excursion
|
|
3020 (set-buffer uubuf)
|
|
3021 (goto-char beg)
|
|
3022 (if (= i parts)
|
|
3023 (goto-char (point-max))
|
|
3024 (forward-line gnus-uu-post-length))
|
7977
|
3025 (if (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
|
|
3026 (forward-line -4))
|
7291
|
3027 (setq end (point)))
|
|
3028 (insert-buffer-substring uubuf beg end)
|
|
3029 (insert beg-line)
|
|
3030 (insert "\n")
|
|
3031 (setq beg end)
|
|
3032 (setq i (1+ i))
|
|
3033 (goto-char 1)
|
|
3034 (re-search-forward mail-header-separator nil t)
|
|
3035 (beginning-of-line)
|
|
3036 (forward-line 2)
|
|
3037 (if (re-search-forward gnus-uu-post-binary-separator nil t)
|
|
3038 (progn
|
|
3039 (replace-match "")
|
|
3040 (forward-line 1)))
|
|
3041 (insert beg-line)
|
|
3042 (insert "\n")
|
|
3043 (gnus-inews-news)))
|
|
3044
|
|
3045 (and (setq buf (get-buffer send-buffer-name))
|
|
3046 (kill-buffer buf))
|
|
3047 (and (setq buf (get-buffer encoded-buffer-name))
|
|
3048 (kill-buffer buf))
|
|
3049
|
|
3050 (if (not gnus-uu-post-separate-description)
|
|
3051 (progn
|
|
3052 (set-buffer-modified-p nil)
|
|
3053 (and (fboundp 'bury-buffer) (bury-buffer))))))
|
|
3054
|
6728
|
3055 (provide 'gnus-uu)
|
|
3056
|
6729
|
3057 ;; gnus-uu.el ends here
|