Mercurial > emacs
annotate lisp/gnus/gnus-uu.el @ 23192:1ea9db09a678
(checkdoc-buffer-label): New function.
(checkdoc-start-section, checkdoc-error): Use `checkdoc-buffer-label'.
(checkdoc-this-string-valid-engine): Permit ? as terminating
punctuation for first line sentence breaking.
(checkdoc-this-string-valid): When converting a comment into a doc
string, make sure " chars are \".
(checkdoc-sentencespace-region-engine): Only do double space check
if based on the variable `sentence-end-double-space'
author | Eric M. Ludlam <zappo@gnu.org> |
---|---|
date | Sat, 05 Sep 1998 13:46:23 +0000 |
parents | 5f1ab3dd344d |
children | 15fc6acbae7a |
rev | line source |
---|---|
17493 | 1 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus |
2 ;; Copyright (C) 1985,86,87,93,94,95,96,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
5 ;; Created: 2 Oct 1993 | |
6 ;; Keyword: news | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
19634
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
118761d47324
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'gnus-art) | |
33 (require 'message) | |
34 (require 'gnus-msg) | |
35 | |
36 (defgroup gnus-extract nil | |
37 "Extracting encoded files." | |
38 :prefix "gnus-uu-" | |
39 :group 'gnus) | |
40 | |
41 (defgroup gnus-extract-view nil | |
42 "Viewwing extracted files." | |
43 :group 'gnus-extract) | |
44 | |
45 (defgroup gnus-extract-archive nil | |
46 "Extracting encoded archives." | |
47 :group 'gnus-extract) | |
48 | |
49 (defgroup gnus-extract-post nil | |
50 "Extracting encoded archives." | |
51 :prefix "gnus-uu-post" | |
52 :group 'gnus-extract) | |
53 | |
54 ;; Default viewing action rules | |
55 | |
56 (defcustom gnus-uu-default-view-rules | |
57 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed s/\r//g") | |
58 ("\\.pas$" "cat %s | sed s/\r//g") | |
59 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g") | |
60 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv") | |
61 ("\\.tga$" "tgatoppm %s | xv -") | |
62 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$" | |
63 "sox -v .5 %s -t .au -u - > /dev/audio") | |
64 ("\\.au$" "cat %s > /dev/audio") | |
65 ("\\.midi?$" "playmidi -f") | |
66 ("\\.mod$" "str32") | |
67 ("\\.ps$" "ghostview") | |
68 ("\\.dvi$" "xdvi") | |
69 ("\\.html$" "xmosaic") | |
70 ("\\.mpe?g$" "mpeg_play") | |
71 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim") | |
72 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$" | |
73 "gnus-uu-archive")) | |
74 "Default actions to be taken when the user asks to view a file. | |
75 To change the behaviour, you can either edit this variable or set | |
76 `gnus-uu-user-view-rules' to something useful. | |
77 | |
78 For example: | |
79 | |
80 To make gnus-uu use 'xli' to display JPEG and GIF files, put the | |
81 following in your .emacs file: | |
82 | |
83 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\"))) | |
84 | |
85 Both these variables are lists of lists with two string elements. The | |
86 first string is a regular expression. If the file name matches this | |
87 regular expression, the command in the second string is executed with | |
88 the file as an argument. | |
89 | |
90 If the command string contains \"%s\", the file name will be inserted | |
91 at that point in the command string. If there's no \"%s\" in the | |
92 command string, the file name will be appended to the command string | |
93 before executing. | |
94 | |
95 There are several user variables to tailor the behaviour of gnus-uu to | |
96 your needs. First we have `gnus-uu-user-view-rules', which is the | |
97 variable gnus-uu first consults when trying to decide how to view a | |
98 file. If this variable contains no matches, gnus-uu examines the | |
99 default rule variable provided in this package. If gnus-uu finds no | |
100 match here, it uses `gnus-uu-user-view-rules-end' to try to make a | |
101 match." | |
102 :group 'gnus-extract-view | |
103 :type '(repeat (group regexp (string :tag "Command")))) | |
104 | |
105 (defcustom gnus-uu-user-view-rules nil | |
106 "What actions are to be taken to view a file. | |
107 See the documentation on the `gnus-uu-default-view-rules' variable for | |
108 details." | |
109 :group 'gnus-extract-view | |
110 :type '(repeat (group regexp (string :tag "Command")))) | |
111 | |
112 (defcustom gnus-uu-user-view-rules-end | |
113 '(("" "file")) | |
114 "What actions are to be taken if no rule matched the file name. | |
115 See the documentation on the `gnus-uu-default-view-rules' variable for | |
116 details." | |
117 :group 'gnus-extract-view | |
118 :type '(repeat (group regexp (string :tag "Command")))) | |
119 | |
120 ;; Default unpacking commands | |
121 | |
122 (defcustom gnus-uu-default-archive-rules | |
123 '(("\\.tar$" "tar xf") | |
124 ("\\.zip$" "unzip -o") | |
125 ("\\.ar$" "ar x") | |
126 ("\\.arj$" "unarj x") | |
127 ("\\.zoo$" "zoo -e") | |
128 ("\\.\\(lzh\\|lha\\)$" "lha x") | |
129 ("\\.Z$" "uncompress") | |
130 ("\\.gz$" "gunzip") | |
131 ("\\.arc$" "arc -x")) | |
132 "See `gnus-uu-user-archive-rules'." | |
133 :group 'gnus-extract-archive | |
134 :type '(repeat (group regexp (string :tag "Command")))) | |
135 | |
136 (defvar gnus-uu-destructive-archivers | |
137 (list "uncompress" "gunzip")) | |
138 | |
139 (defcustom gnus-uu-user-archive-rules nil | |
140 "A list that can be set to override the default archive unpacking commands. | |
141 To use, for instance, 'untar' to unpack tar files and 'zip -x' to | |
142 unpack zip files, say the following: | |
143 (setq gnus-uu-user-archive-rules | |
144 '((\"\\\\.tar$\" \"untar\") | |
145 (\"\\\\.zip$\" \"zip -x\")))" | |
146 :group 'gnus-extract-archive | |
147 :type '(repeat (group regexp (string :tag "Command")))) | |
148 | |
149 (defcustom gnus-uu-ignore-files-by-name nil | |
150 "*A regular expression saying what files should not be viewed based on name. | |
151 If, for instance, you want gnus-uu to ignore all .au and .wav files, | |
152 you could say something like | |
153 | |
154 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\") | |
155 | |
156 Note that this variable can be used in conjunction with the | |
157 `gnus-uu-ignore-files-by-type' variable." | |
158 :group 'gnus-extract | |
159 :type '(choice (const :tag "off" nil) | |
160 (regexp :format "%v"))) | |
161 | |
162 (defcustom gnus-uu-ignore-files-by-type nil | |
163 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type. | |
164 If, for instance, you want gnus-uu to ignore all audio files and all mpegs, | |
165 you could say something like | |
166 | |
167 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\") | |
168 | |
169 Note that this variable can be used in conjunction with the | |
170 `gnus-uu-ignore-files-by-name' variable." | |
171 :group 'gnus-extract | |
172 :type '(choice (const :tag "off" nil) | |
173 (regexp :format "%v"))) | |
174 | |
175 ;; Pseudo-MIME support | |
176 | |
177 (defconst gnus-uu-ext-to-mime-list | |
178 '(("\\.gif$" "image/gif") | |
179 ("\\.jpe?g$" "image/jpeg") | |
180 ("\\.tiff?$" "image/tiff") | |
181 ("\\.xwd$" "image/xwd") | |
182 ("\\.pbm$" "image/pbm") | |
183 ("\\.pgm$" "image/pgm") | |
184 ("\\.ppm$" "image/ppm") | |
185 ("\\.xbm$" "image/xbm") | |
186 ("\\.pcx$" "image/pcx") | |
187 ("\\.tga$" "image/tga") | |
188 ("\\.ps$" "image/postscript") | |
189 ("\\.fli$" "video/fli") | |
190 ("\\.wav$" "audio/wav") | |
191 ("\\.aiff$" "audio/aiff") | |
192 ("\\.hcom$" "audio/hcom") | |
193 ("\\.voc$" "audio/voc") | |
194 ("\\.smp$" "audio/smp") | |
195 ("\\.mod$" "audio/mod") | |
196 ("\\.dvi$" "image/dvi") | |
197 ("\\.mpe?g$" "video/mpeg") | |
198 ("\\.au$" "audio/basic") | |
199 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain") | |
200 ("\\.\\(c\\|h\\)$" "text/source") | |
201 ("read.*me" "text/plain") | |
202 ("\\.html$" "text/html") | |
203 ("\\.bat$" "text/bat") | |
204 ("\\.[1-6]$" "text/man") | |
205 ("\\.flc$" "video/flc") | |
206 ("\\.rle$" "video/rle") | |
207 ("\\.pfx$" "video/pfx") | |
208 ("\\.avi$" "video/avi") | |
209 ("\\.sme$" "video/sme") | |
210 ("\\.rpza$" "video/prza") | |
211 ("\\.dl$" "video/dl") | |
212 ("\\.qt$" "video/qt") | |
213 ("\\.rsrc$" "video/rsrc") | |
214 ("\\..*$" "unknown/unknown"))) | |
215 | |
216 ;; Various variables users may set | |
217 | |
218 (defcustom gnus-uu-tmp-dir "/tmp/" | |
219 "*Variable saying where gnus-uu is to do its work. | |
220 Default is \"/tmp/\"." | |
221 :group 'gnus-extract | |
222 :type 'directory) | |
223 | |
224 (defcustom gnus-uu-do-not-unpack-archives nil | |
225 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display. | |
226 Default is nil." | |
227 :group 'gnus-extract-archive | |
228 :type 'boolean) | |
229 | |
230 (defcustom gnus-uu-ignore-default-view-rules nil | |
231 "*Non-nil means that gnus-uu will ignore the default viewing rules. | |
232 Only the user viewing rules will be consulted. Default is nil." | |
233 :group 'gnus-extract-view | |
234 :type 'boolean) | |
235 | |
236 (defcustom gnus-uu-grabbed-file-functions nil | |
237 "Functions run on each file after successful decoding. | |
238 They will be called with the name of the file as the argument. | |
239 Likely functions you can use in this list are `gnus-uu-grab-view' | |
240 and `gnus-uu-grab-move'." | |
241 :group 'gnus-extract | |
242 :options '(gnus-uu-grab-view gnus-uu-grab-move) | |
243 :type 'hook) | |
244 | |
245 (defcustom gnus-uu-ignore-default-archive-rules nil | |
246 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands. | |
247 Only the user unpacking commands will be consulted. Default is nil." | |
248 :group 'gnus-extract-archive | |
249 :type 'boolean) | |
250 | |
251 (defcustom gnus-uu-kill-carriage-return t | |
252 "*Non-nil means that gnus-uu will strip all carriage returns from articles. | |
253 Default is t." | |
254 :group 'gnus-extract | |
255 :type 'boolean) | |
256 | |
257 (defcustom gnus-uu-view-with-metamail nil | |
258 "*Non-nil means that files will be viewed with metamail. | |
259 The gnus-uu viewing functions will be ignored and gnus-uu will try | |
260 to guess at a content-type based on file name suffixes. Default | |
261 it nil." | |
262 :group 'gnus-extract | |
263 :type 'boolean) | |
264 | |
265 (defcustom gnus-uu-unmark-articles-not-decoded nil | |
266 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread. | |
267 Default is nil." | |
268 :group 'gnus-extract | |
269 :type 'boolean) | |
270 | |
271 (defcustom gnus-uu-correct-stripped-uucode nil | |
272 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted. | |
273 Default is nil." | |
274 :group 'gnus-extract | |
275 :type 'boolean) | |
276 | |
277 (defcustom gnus-uu-save-in-digest nil | |
278 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests. | |
279 If this variable is nil, gnus-uu will just save everything in a | |
280 file without any embellishments. The digesting almost conforms to RFC1153 - | |
281 no easy way to specify any meaningful volume and issue numbers were found, | |
282 so I simply dropped them." | |
283 :group 'gnus-extract | |
284 :type 'boolean) | |
285 | |
286 (defcustom gnus-uu-digest-headers | |
287 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:" | |
288 "^Summary:" "^References:") | |
289 "List of regexps to match headers included in digested messages. | |
290 The headers will be included in the sequence they are matched." | |
291 :group 'gnus-extract | |
292 :type '(repeat regexp)) | |
293 | |
294 (defcustom gnus-uu-save-separate-articles nil | |
295 "*Non-nil means that gnus-uu will save articles in separate files." | |
296 :group 'gnus-extract | |
297 :type 'boolean) | |
298 | |
299 (defcustom gnus-uu-be-dangerous 'ask | |
300 "*Specifies what to do if unusual situations arise during decoding. | |
301 If nil, be as conservative as possible. If t, ignore things that | |
302 didn't work, and overwrite existing files. Otherwise, ask each time." | |
303 :group 'gnus-extract | |
304 :type '(choice (const :tag "conservative" nil) | |
305 (const :tag "ask" ask) | |
306 (const :tag "liberal" t))) | |
307 | |
308 ;; Internal variables | |
309 | |
310 (defvar gnus-uu-saved-article-name nil) | |
311 | |
312 (defconst gnus-uu-begin-string "^begin[ \t]+[0-7][0-7][0-7][ \t]+\\(.*\\)$") | |
313 (defconst gnus-uu-end-string "^end[ \t]*$") | |
314 | |
315 (defconst gnus-uu-body-line "^M") | |
316 (let ((i 61)) | |
317 (while (> (setq i (1- i)) 0) | |
318 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]"))) | |
319 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$"))) | |
320 | |
321 ;"^M.............................................................?$" | |
322 | |
323 (defconst gnus-uu-shar-begin-string "^#! */bin/sh") | |
324 | |
325 (defvar gnus-uu-shar-file-name nil) | |
326 (defconst gnus-uu-shar-name-marker "begin [0-7][0-7][0-7][ \t]+\\(\\(\\w\\|\\.\\)*\\b\\)") | |
327 | |
328 (defconst gnus-uu-postscript-begin-string "^%!PS-") | |
329 (defconst gnus-uu-postscript-end-string "^%%EOF$") | |
330 | |
331 (defvar gnus-uu-file-name nil) | |
332 (defconst gnus-uu-uudecode-process nil) | |
333 (defvar gnus-uu-binhex-article-name nil) | |
334 | |
335 (defvar gnus-uu-work-dir nil) | |
336 | |
337 (defconst gnus-uu-output-buffer-name " *Gnus UU Output*") | |
338 | |
339 (defvar gnus-uu-default-dir gnus-article-save-directory) | |
340 (defvar gnus-uu-digest-from-subject nil) | |
341 | |
342 ;; Keymaps | |
343 | |
344 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map) | |
345 "p" gnus-summary-mark-as-processable | |
346 "u" gnus-summary-unmark-as-processable | |
347 "U" gnus-summary-unmark-all-processable | |
348 "v" gnus-uu-mark-over | |
349 "s" gnus-uu-mark-series | |
350 "r" gnus-uu-mark-region | |
351 "R" gnus-uu-mark-by-regexp | |
352 "t" gnus-uu-mark-thread | |
353 "T" gnus-uu-unmark-thread | |
354 "a" gnus-uu-mark-all | |
355 "b" gnus-uu-mark-buffer | |
356 "S" gnus-uu-mark-sparse | |
357 "k" gnus-summary-kill-process-mark | |
358 "y" gnus-summary-yank-process-mark | |
359 "w" gnus-summary-save-process-mark | |
360 "i" gnus-uu-invert-processable) | |
361 | |
362 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map) | |
363 ;;"x" gnus-uu-extract-any | |
364 ;;"m" gnus-uu-extract-mime | |
365 "u" gnus-uu-decode-uu | |
366 "U" gnus-uu-decode-uu-and-save | |
367 "s" gnus-uu-decode-unshar | |
368 "S" gnus-uu-decode-unshar-and-save | |
369 "o" gnus-uu-decode-save | |
370 "O" gnus-uu-decode-save | |
371 "b" gnus-uu-decode-binhex | |
372 "B" gnus-uu-decode-binhex | |
373 "p" gnus-uu-decode-postscript | |
374 "P" gnus-uu-decode-postscript-and-save) | |
375 | |
376 (gnus-define-keys | |
377 (gnus-uu-extract-view-map "v" gnus-uu-extract-map) | |
378 "u" gnus-uu-decode-uu-view | |
379 "U" gnus-uu-decode-uu-and-save-view | |
380 "s" gnus-uu-decode-unshar-view | |
381 "S" gnus-uu-decode-unshar-and-save-view | |
382 "o" gnus-uu-decode-save-view | |
383 "O" gnus-uu-decode-save-view | |
384 "b" gnus-uu-decode-binhex-view | |
385 "B" gnus-uu-decode-binhex-view | |
386 "p" gnus-uu-decode-postscript-view | |
387 "P" gnus-uu-decode-postscript-and-save-view) | |
388 | |
389 | |
390 ;; Commands. | |
391 | |
392 (defun gnus-uu-decode-uu (&optional n) | |
393 "Uudecodes the current article." | |
394 (interactive "P") | |
395 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n)) | |
396 | |
397 (defun gnus-uu-decode-uu-and-save (n dir) | |
398 "Decodes and saves the resulting file." | |
399 (interactive | |
400 (list current-prefix-arg | |
401 (file-name-as-directory | |
402 (read-file-name "Uudecode and save in dir: " | |
403 gnus-uu-default-dir | |
404 gnus-uu-default-dir t)))) | |
405 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t)) | |
406 | |
407 (defun gnus-uu-decode-unshar (&optional n) | |
408 "Unshars the current article." | |
409 (interactive "P") | |
410 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t)) | |
411 | |
412 (defun gnus-uu-decode-unshar-and-save (n dir) | |
413 "Unshars and saves the current article." | |
414 (interactive | |
415 (list current-prefix-arg | |
416 (file-name-as-directory | |
417 (read-file-name "Unshar and save in dir: " | |
418 gnus-uu-default-dir | |
419 gnus-uu-default-dir t)))) | |
420 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t)) | |
421 | |
422 (defun gnus-uu-decode-save (n file) | |
423 "Saves the current article." | |
424 (interactive | |
425 (list current-prefix-arg | |
426 (read-file-name | |
427 (if gnus-uu-save-separate-articles | |
428 "Save articles is dir: " | |
429 "Save articles in file: ") | |
430 gnus-uu-default-dir | |
431 gnus-uu-default-dir))) | |
432 (setq gnus-uu-saved-article-name file) | |
433 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t)) | |
434 | |
435 (defun gnus-uu-decode-binhex (n dir) | |
436 "Unbinhexes the current article." | |
437 (interactive | |
438 (list current-prefix-arg | |
439 (file-name-as-directory | |
440 (read-file-name "Unbinhex and save in dir: " | |
441 gnus-uu-default-dir | |
442 gnus-uu-default-dir)))) | |
443 (setq gnus-uu-binhex-article-name | |
444 (make-temp-name (concat gnus-uu-work-dir "binhex"))) | |
445 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir)) | |
446 | |
447 (defun gnus-uu-decode-uu-view (&optional n) | |
448 "Uudecodes and views the current article." | |
449 (interactive "P") | |
450 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
451 (gnus-uu-decode-uu n))) | |
452 | |
453 (defun gnus-uu-decode-uu-and-save-view (n dir) | |
454 "Decodes, views and saves the resulting file." | |
455 (interactive | |
456 (list current-prefix-arg | |
457 (read-file-name "Uudecode, view and save in dir: " | |
458 gnus-uu-default-dir | |
459 gnus-uu-default-dir t))) | |
460 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
461 (gnus-uu-decode-uu-and-save n dir))) | |
462 | |
463 (defun gnus-uu-decode-unshar-view (&optional n) | |
464 "Unshars and views the current article." | |
465 (interactive "P") | |
466 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
467 (gnus-uu-decode-unshar n))) | |
468 | |
469 (defun gnus-uu-decode-unshar-and-save-view (n dir) | |
470 "Unshars and saves the current article." | |
471 (interactive | |
472 (list current-prefix-arg | |
473 (read-file-name "Unshar, view and save in dir: " | |
474 gnus-uu-default-dir | |
475 gnus-uu-default-dir t))) | |
476 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
477 (gnus-uu-decode-unshar-and-save n dir))) | |
478 | |
479 (defun gnus-uu-decode-save-view (n file) | |
480 "Saves and views the current article." | |
481 (interactive | |
482 (list current-prefix-arg | |
483 (read-file-name (if gnus-uu-save-separate-articles | |
484 "Save articles is dir: " | |
485 "Save articles in file: ") | |
486 gnus-uu-default-dir gnus-uu-default-dir))) | |
487 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
488 (gnus-uu-decode-save n file))) | |
489 | |
490 (defun gnus-uu-decode-binhex-view (n file) | |
491 "Unbinhexes and views the current article." | |
492 (interactive | |
493 (list current-prefix-arg | |
494 (read-file-name "Unbinhex, view and save in dir: " | |
495 gnus-uu-default-dir gnus-uu-default-dir))) | |
496 (setq gnus-uu-binhex-article-name | |
497 (make-temp-name (concat gnus-uu-work-dir "binhex"))) | |
498 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
499 (gnus-uu-decode-binhex n file))) | |
500 | |
501 | |
502 ;; Digest and forward articles | |
503 | |
504 (defun gnus-uu-digest-mail-forward (&optional n post) | |
505 "Digests and forwards all articles in this series." | |
506 (interactive "P") | |
507 (let ((gnus-uu-save-in-digest t) | |
508 (file (make-temp-name (nnheader-concat gnus-uu-tmp-dir "forward"))) | |
509 buf subject from newsgroups) | |
510 (gnus-setup-message 'forward | |
511 (setq gnus-uu-digest-from-subject nil) | |
512 (gnus-uu-decode-save n file) | |
513 (setq buf (switch-to-buffer (get-buffer-create " *gnus-uu-forward*"))) | |
514 (gnus-add-current-to-buffer-list) | |
515 (erase-buffer) | |
516 (insert-file file) | |
517 (let ((fs gnus-uu-digest-from-subject)) | |
518 (when fs | |
519 (setq from (caar fs) | |
520 subject (gnus-simplify-subject-fuzzy (cdar fs)) | |
521 fs (cdr fs)) | |
522 (while (and fs (or from subject)) | |
523 (when from | |
524 (unless (string= from (caar fs)) | |
525 (setq from nil))) | |
526 (when subject | |
527 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs)) | |
528 subject) | |
529 (setq subject nil))) | |
530 (setq fs (cdr fs)))) | |
531 (unless subject | |
532 (setq subject "Digested Articles")) | |
533 (unless from | |
534 (setq from | |
535 (if (gnus-news-group-p gnus-newsgroup-name) | |
536 gnus-newsgroup-name | |
537 "Various")))) | |
538 (goto-char (point-min)) | |
539 (when (re-search-forward "^Subject: ") | |
540 (delete-region (point) (gnus-point-at-eol)) | |
541 (insert subject)) | |
542 (goto-char (point-min)) | |
543 (when (re-search-forward "^From: ") | |
544 (delete-region (point) (gnus-point-at-eol)) | |
545 (insert from)) | |
546 (message-forward post)) | |
547 (delete-file file) | |
548 (kill-buffer buf) | |
549 (setq gnus-uu-digest-from-subject nil))) | |
550 | |
551 (defun gnus-uu-digest-post-forward (&optional n) | |
552 "Digest and forward to a newsgroup." | |
553 (interactive "P") | |
554 (gnus-uu-digest-mail-forward n t)) | |
555 | |
556 ;; Process marking. | |
557 | |
558 (defun gnus-uu-mark-by-regexp (regexp &optional unmark) | |
559 "Ask for a regular expression and set the process mark on all articles that match." | |
560 (interactive (list (read-from-minibuffer "Mark (regexp): "))) | |
561 (gnus-set-global-variables) | |
562 (let ((articles (gnus-uu-find-articles-matching regexp))) | |
563 (while articles | |
564 (if unmark | |
565 (gnus-summary-remove-process-mark (pop articles)) | |
566 (gnus-summary-set-process-mark (pop articles)))) | |
567 (message "")) | |
568 (gnus-summary-position-point)) | |
569 | |
570 (defun gnus-uu-unmark-by-regexp (regexp &optional unmark) | |
571 "Ask for a regular expression and remove the process mark on all articles that match." | |
572 (interactive (list (read-from-minibuffer "Mark (regexp): "))) | |
573 (gnus-uu-mark-by-regexp regexp t)) | |
574 | |
575 (defun gnus-uu-mark-series () | |
576 "Mark the current series with the process mark." | |
577 (interactive) | |
578 (gnus-set-global-variables) | |
579 (let ((articles (gnus-uu-find-articles-matching))) | |
580 (while articles | |
581 (gnus-summary-set-process-mark (car articles)) | |
582 (setq articles (cdr articles))) | |
583 (message "")) | |
584 (gnus-summary-position-point)) | |
585 | |
586 (defun gnus-uu-mark-region (beg end &optional unmark) | |
587 "Set the process mark on all articles between point and mark." | |
588 (interactive "r") | |
589 (gnus-set-global-variables) | |
590 (save-excursion | |
591 (goto-char beg) | |
592 (while (< (point) end) | |
593 (if unmark | |
594 (gnus-summary-remove-process-mark (gnus-summary-article-number)) | |
595 (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
596 (forward-line 1))) | |
597 (gnus-summary-position-point)) | |
598 | |
599 (defun gnus-uu-unmark-region (beg end) | |
600 "Remove the process mark from all articles between point and mark." | |
601 (interactive "r") | |
602 (gnus-uu-mark-region beg end t)) | |
603 | |
604 (defun gnus-uu-mark-buffer () | |
605 "Set the process mark on all articles in the buffer." | |
606 (interactive) | |
607 (gnus-uu-mark-region (point-min) (point-max))) | |
608 | |
609 (defun gnus-uu-unmark-buffer () | |
610 "Remove the process mark on all articles in the buffer." | |
611 (interactive) | |
612 (gnus-uu-mark-region (point-min) (point-max) t)) | |
613 | |
614 (defun gnus-uu-mark-thread () | |
615 "Marks all articles downwards in this thread." | |
616 (interactive) | |
617 (gnus-set-global-variables) | |
618 (let ((level (gnus-summary-thread-level))) | |
619 (while (and (gnus-summary-set-process-mark (gnus-summary-article-number)) | |
620 (zerop (gnus-summary-next-subject 1)) | |
621 (> (gnus-summary-thread-level) level)))) | |
622 (gnus-summary-position-point)) | |
623 | |
624 (defun gnus-uu-unmark-thread () | |
625 "Unmarks all articles downwards in this thread." | |
626 (interactive) | |
627 (gnus-set-global-variables) | |
628 (let ((level (gnus-summary-thread-level))) | |
629 (while (and (gnus-summary-remove-process-mark | |
630 (gnus-summary-article-number)) | |
631 (zerop (gnus-summary-next-subject 1)) | |
632 (> (gnus-summary-thread-level) level)))) | |
633 (gnus-summary-position-point)) | |
634 | |
635 (defun gnus-uu-invert-processable () | |
636 "Invert the list of process-marked articles." | |
637 (let ((data gnus-newsgroup-data) | |
638 d number) | |
639 (save-excursion | |
640 (while data | |
641 (if (memq (setq number (gnus-data-number (pop data))) | |
642 gnus-newsgroup-processable) | |
643 (gnus-summary-remove-process-mark number) | |
644 (gnus-summary-set-process-mark number))))) | |
645 (gnus-summary-position-point)) | |
646 | |
647 (defun gnus-uu-mark-over (&optional score) | |
648 "Mark all articles with a score over SCORE (the prefix.)" | |
649 (interactive "P") | |
650 (let ((score (gnus-score-default score)) | |
651 (data gnus-newsgroup-data)) | |
652 (save-excursion | |
653 (while data | |
654 (when (> (or (cdr (assq (gnus-data-number (car data)) | |
655 gnus-newsgroup-scored)) | |
656 gnus-summary-default-score 0) | |
657 score) | |
658 (gnus-summary-set-process-mark (caar data))) | |
659 (setq data (cdr data)))) | |
660 (gnus-summary-position-point))) | |
661 | |
662 (defun gnus-uu-mark-sparse () | |
663 "Mark all series that have some articles marked." | |
664 (interactive) | |
665 (gnus-set-global-variables) | |
666 (let ((marked (nreverse gnus-newsgroup-processable)) | |
667 subject articles total headers) | |
668 (unless marked | |
669 (error "No articles marked with the process mark")) | |
670 (setq gnus-newsgroup-processable nil) | |
671 (save-excursion | |
672 (while marked | |
673 (and (vectorp (setq headers | |
674 (gnus-summary-article-header (car marked)))) | |
675 (setq subject (mail-header-subject headers) | |
676 articles (gnus-uu-find-articles-matching | |
677 (gnus-uu-reginize-string subject)) | |
678 total (nconc total articles))) | |
679 (while articles | |
680 (gnus-summary-set-process-mark (car articles)) | |
681 (setcdr marked (delq (car articles) (cdr marked))) | |
682 (setq articles (cdr articles))) | |
683 (setq marked (cdr marked))) | |
684 (setq gnus-newsgroup-processable (nreverse total))) | |
685 (gnus-summary-position-point))) | |
686 | |
687 (defun gnus-uu-mark-all () | |
688 "Mark all articles in \"series\" order." | |
689 (interactive) | |
690 (gnus-set-global-variables) | |
691 (setq gnus-newsgroup-processable nil) | |
692 (save-excursion | |
693 (let ((data gnus-newsgroup-data) | |
694 number) | |
695 (while data | |
696 (when (and (not (memq (setq number (gnus-data-number (car data))) | |
697 gnus-newsgroup-processable)) | |
698 (vectorp (gnus-data-header (car data)))) | |
699 (gnus-summary-goto-subject number) | |
700 (gnus-uu-mark-series)) | |
701 (setq data (cdr data))))) | |
702 (gnus-summary-position-point)) | |
703 | |
704 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>. | |
705 | |
706 (defun gnus-uu-decode-postscript (&optional n) | |
707 "Gets postscript of the current article." | |
708 (interactive "P") | |
709 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n)) | |
710 | |
711 (defun gnus-uu-decode-postscript-view (&optional n) | |
712 "Gets and views the current article." | |
713 (interactive "P") | |
714 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
715 (gnus-uu-decode-postscript n))) | |
716 | |
717 (defun gnus-uu-decode-postscript-and-save (n dir) | |
718 "Extracts postscript and saves the current article." | |
719 (interactive | |
720 (list current-prefix-arg | |
721 (file-name-as-directory | |
722 (read-file-name "Save in dir: " | |
723 gnus-uu-default-dir | |
724 gnus-uu-default-dir t)))) | |
725 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article | |
726 n dir nil nil t)) | |
727 | |
728 (defun gnus-uu-decode-postscript-and-save-view (n dir) | |
729 "Decodes, views and saves the resulting file." | |
730 (interactive | |
731 (list current-prefix-arg | |
732 (read-file-name "Where do you want to save the file(s)? " | |
733 gnus-uu-default-dir | |
734 gnus-uu-default-dir t))) | |
735 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic))) | |
736 (gnus-uu-decode-postscript-and-save n dir))) | |
737 | |
738 | |
739 ;; Internal functions. | |
740 | |
741 (defun gnus-uu-decode-with-method (method n &optional save not-insert | |
742 scan cdir) | |
743 (gnus-uu-initialize scan) | |
744 (when save | |
745 (setq gnus-uu-default-dir save)) | |
746 ;; Create the directory we save to. | |
747 (when (and scan cdir save | |
748 (not (file-exists-p save))) | |
749 (make-directory save t)) | |
750 (let ((articles (gnus-uu-get-list-of-articles n)) | |
751 files) | |
752 (setq files (gnus-uu-grab-articles articles method t)) | |
753 (let ((gnus-current-article (car articles))) | |
754 (when scan | |
755 (setq files (gnus-uu-scan-directory gnus-uu-work-dir)))) | |
756 (when save | |
757 (gnus-uu-save-files files save)) | |
758 (when (eq gnus-uu-do-not-unpack-archives nil) | |
759 (setq files (gnus-uu-unpack-files files))) | |
760 (setq files (nreverse (gnus-uu-get-actions files))) | |
761 (or not-insert (not gnus-insert-pseudo-articles) | |
762 (gnus-summary-insert-pseudos files save)))) | |
763 | |
764 (defun gnus-uu-scan-directory (dir &optional rec) | |
765 "Return a list of all files under DIR." | |
766 (let ((files (directory-files dir t)) | |
767 out file) | |
768 (while (setq file (pop files)) | |
769 (unless (member (file-name-nondirectory file) '("." "..")) | |
770 (push (list (cons 'name file) | |
771 (cons 'article gnus-current-article)) | |
772 out) | |
773 (when (file-directory-p file) | |
774 (setq out (nconc (gnus-uu-scan-directory file t) out))))) | |
775 (if rec | |
776 out | |
777 (nreverse out)))) | |
778 | |
779 (defun gnus-uu-save-files (files dir) | |
780 "Save FILES in DIR." | |
781 (let ((len (length files)) | |
782 (reg (concat "^" (regexp-quote gnus-uu-work-dir))) | |
783 to-file file fromdir) | |
784 (while (setq file (cdr (assq 'name (pop files)))) | |
785 (when (file-exists-p file) | |
786 (string-match reg file) | |
787 (setq fromdir (substring file (match-end 0))) | |
788 (if (file-directory-p file) | |
789 (gnus-make-directory (concat dir fromdir)) | |
790 (setq to-file (concat dir fromdir)) | |
791 (when (or (not (file-exists-p to-file)) | |
792 (eq gnus-uu-be-dangerous t) | |
793 (and gnus-uu-be-dangerous | |
794 (gnus-y-or-n-p (format "%s exists; overwrite? " | |
795 to-file)))) | |
796 (copy-file file to-file t t))))) | |
797 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s")))) | |
798 | |
799 ;; Functions for saving and possibly digesting articles without | |
800 ;; any decoding. | |
801 | |
802 ;; Function called by gnus-uu-grab-articles to treat each article. | |
803 (defun gnus-uu-save-article (buffer in-state) | |
804 (cond | |
805 (gnus-uu-save-separate-articles | |
806 (save-excursion | |
807 (set-buffer buffer) | |
808 (gnus-write-buffer | |
809 (concat gnus-uu-saved-article-name gnus-current-article)) | |
810 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin)) | |
811 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name | |
812 'begin 'end)) | |
813 ((eq in-state 'last) (list 'end)) | |
814 (t (list 'middle))))) | |
815 ((not gnus-uu-save-in-digest) | |
816 (save-excursion | |
817 (set-buffer buffer) | |
818 (write-region (point-min) (point-max) gnus-uu-saved-article-name t) | |
819 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin)) | |
820 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name | |
821 'begin 'end)) | |
822 ((eq in-state 'last) (list 'end)) | |
823 (t (list 'middle))))) | |
824 (t | |
825 (let ((header (gnus-summary-article-header))) | |
826 (push (cons (mail-header-from header) | |
827 (mail-header-subject header)) | |
828 gnus-uu-digest-from-subject)) | |
829 (let ((name (file-name-nondirectory gnus-uu-saved-article-name)) | |
830 (delim (concat "^" (make-string 30 ?-) "$")) | |
831 beg subj headers headline sorthead body end-string state) | |
832 (if (or (eq in-state 'first) | |
833 (eq in-state 'first-and-last)) | |
834 (progn | |
835 (setq state (list 'begin)) | |
836 (save-excursion (set-buffer (get-buffer-create "*gnus-uu-body*")) | |
837 (erase-buffer)) | |
838 (save-excursion | |
839 (set-buffer (get-buffer-create "*gnus-uu-pre*")) | |
840 (erase-buffer) | |
841 (insert (format | |
842 "Date: %s\nFrom: %s\nSubject: %s Digest\n\nTopics:\n" | |
843 (current-time-string) name name)))) | |
844 (when (not (eq in-state 'end)) | |
845 (setq state (list 'middle)))) | |
846 (save-excursion | |
847 (set-buffer (get-buffer "*gnus-uu-body*")) | |
848 (goto-char (setq beg (point-max))) | |
849 (save-excursion | |
850 (save-restriction | |
851 (set-buffer buffer) | |
852 (let (buffer-read-only) | |
853 (gnus-set-text-properties (point-min) (point-max) nil) | |
854 ;; These two are necessary for XEmacs 19.12 fascism. | |
855 (put-text-property (point-min) (point-max) 'invisible nil) | |
856 (put-text-property (point-min) (point-max) 'intangible nil)) | |
857 (goto-char (point-min)) | |
858 (re-search-forward "\n\n") | |
859 ;; Quote all 30-dash lines. | |
860 (save-excursion | |
861 (while (re-search-forward delim nil t) | |
862 (beginning-of-line) | |
863 (delete-char 1) | |
864 (insert " "))) | |
865 (setq body (buffer-substring (1- (point)) (point-max))) | |
866 (narrow-to-region (point-min) (point)) | |
867 (if (not (setq headers gnus-uu-digest-headers)) | |
868 (setq sorthead (buffer-substring (point-min) (point-max))) | |
869 (while headers | |
870 (setq headline (car headers)) | |
871 (setq headers (cdr headers)) | |
872 (goto-char (point-min)) | |
873 (while (re-search-forward headline nil t) | |
874 (setq sorthead | |
875 (concat sorthead | |
876 (buffer-substring | |
877 (match-beginning 0) | |
878 (or (and (re-search-forward "^[^ \t]" nil t) | |
879 (1- (point))) | |
880 (progn (forward-line 1) (point))))))))) | |
881 (widen))) | |
882 (insert sorthead) (goto-char (point-max)) | |
883 (insert body) (goto-char (point-max)) | |
884 (insert (concat "\n" (make-string 30 ?-) "\n\n")) | |
885 (goto-char beg) | |
886 (when (re-search-forward "^Subject: \\(.*\\)$" nil t) | |
887 (setq subj (buffer-substring (match-beginning 1) (match-end 1))) | |
888 (save-excursion | |
889 (set-buffer (get-buffer "*gnus-uu-pre*")) | |
890 (insert (format " %s\n" subj))))) | |
891 (when (or (eq in-state 'last) | |
892 (eq in-state 'first-and-last)) | |
893 (save-excursion | |
894 (set-buffer (get-buffer "*gnus-uu-pre*")) | |
895 (insert (format "\n\n%s\n\n" (make-string 70 ?-))) | |
896 (gnus-write-buffer gnus-uu-saved-article-name)) | |
897 (save-excursion | |
898 (set-buffer (get-buffer "*gnus-uu-body*")) | |
899 (goto-char (point-max)) | |
900 (insert | |
901 (concat (setq end-string (format "End of %s Digest" name)) | |
902 "\n")) | |
903 (insert (concat (make-string (length end-string) ?*) "\n")) | |
904 (write-region | |
905 (point-min) (point-max) gnus-uu-saved-article-name t)) | |
906 (kill-buffer (get-buffer "*gnus-uu-pre*")) | |
907 (kill-buffer (get-buffer "*gnus-uu-body*")) | |
908 (push 'end state)) | |
909 (if (memq 'begin state) | |
910 (cons gnus-uu-saved-article-name state) | |
911 state))))) | |
912 | |
913 ;; Binhex treatment - not very advanced. | |
914 | |
915 (defconst gnus-uu-binhex-body-line | |
916 "^[^:]...............................................................$") | |
917 (defconst gnus-uu-binhex-begin-line | |
918 "^:...............................................................$") | |
919 (defconst gnus-uu-binhex-end-line | |
920 ":$") | |
921 | |
922 (defun gnus-uu-binhex-article (buffer in-state) | |
923 (let (state start-char) | |
924 (save-excursion | |
925 (set-buffer buffer) | |
926 (widen) | |
927 (goto-char (point-min)) | |
928 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t)) | |
929 (when (not (re-search-forward gnus-uu-binhex-body-line nil t)) | |
930 (setq state (list 'wrong-type)))) | |
931 | |
932 (if (memq 'wrong-type state) | |
933 () | |
934 (beginning-of-line) | |
935 (setq start-char (point)) | |
936 (if (looking-at gnus-uu-binhex-begin-line) | |
937 (progn | |
938 (setq state (list 'begin)) | |
939 (write-region 1 1 gnus-uu-binhex-article-name)) | |
940 (setq state (list 'middle))) | |
941 (goto-char (point-max)) | |
942 (re-search-backward (concat gnus-uu-binhex-body-line "\\|" | |
943 gnus-uu-binhex-end-line) | |
944 nil t) | |
945 (when (looking-at gnus-uu-binhex-end-line) | |
946 (setq state (if (memq 'begin state) | |
947 (cons 'end state) | |
948 (list 'end)))) | |
949 (beginning-of-line) | |
950 (forward-line 1) | |
951 (when (file-exists-p gnus-uu-binhex-article-name) | |
952 (append-to-file start-char (point) gnus-uu-binhex-article-name)))) | |
953 (if (memq 'begin state) | |
954 (cons gnus-uu-binhex-article-name state) | |
955 state))) | |
956 | |
957 ;; PostScript | |
958 | |
959 (defun gnus-uu-decode-postscript-article (process-buffer in-state) | |
960 (let ((state (list 'ok)) | |
961 start-char end-char file-name) | |
962 (save-excursion | |
963 (set-buffer process-buffer) | |
964 (goto-char (point-min)) | |
965 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t)) | |
966 (setq state (list 'wrong-type)) | |
967 (beginning-of-line) | |
968 (setq start-char (point)) | |
969 (if (not (re-search-forward gnus-uu-postscript-end-string nil t)) | |
970 (setq state (list 'wrong-type)) | |
971 (setq end-char (point)) | |
972 (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | |
973 (insert-buffer-substring process-buffer start-char end-char) | |
974 (setq file-name (concat gnus-uu-work-dir | |
975 (cdr gnus-article-current) ".ps")) | |
976 (write-region (point-min) (point-max) file-name) | |
977 (setq state (list file-name 'begin 'end))))) | |
978 state)) | |
979 | |
980 | |
981 ;; Find actions. | |
982 | |
983 (defun gnus-uu-get-actions (files) | |
984 (let ((ofiles files) | |
985 action name) | |
986 (while files | |
987 (setq name (cdr (assq 'name (car files)))) | |
988 (and | |
989 (setq action (gnus-uu-get-action name)) | |
990 (setcar files (nconc (list (if (string= action "gnus-uu-archive") | |
991 (cons 'action "file") | |
992 (cons 'action action)) | |
993 (cons 'execute (gnus-uu-command | |
994 action name))) | |
995 (car files)))) | |
996 (setq files (cdr files))) | |
997 ofiles)) | |
998 | |
999 (defun gnus-uu-get-action (file-name) | |
1000 (let (action) | |
1001 (setq action | |
1002 (gnus-uu-choose-action | |
1003 file-name | |
1004 (append | |
1005 gnus-uu-user-view-rules | |
1006 (if gnus-uu-ignore-default-view-rules | |
1007 nil | |
1008 gnus-uu-default-view-rules) | |
1009 gnus-uu-user-view-rules-end))) | |
1010 (when (and (not (string= (or action "") "gnus-uu-archive")) | |
1011 gnus-uu-view-with-metamail) | |
1012 (when (setq action | |
1013 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)) | |
1014 (setq action (format "metamail -d -b -c \"%s\"" action)))) | |
1015 action)) | |
1016 | |
1017 | |
1018 ;; Functions for treating subjects and collecting series. | |
1019 | |
1020 (defun gnus-uu-reginize-string (string) | |
1021 ;; Takes a string and puts a \ in front of every special character; | |
1022 ;; ignores any leading "version numbers" thingies that they use in | |
1023 ;; the comp.binaries groups, and either replaces anything that looks | |
1024 ;; like "2/3" with "[0-9]+/[0-9]+" or, if it can't find something | |
1025 ;; like that, replaces the last two numbers with "[0-9]+". This, in | |
1026 ;; my experience, should get most postings of a series. | |
1027 (let ((count 2) | |
1028 (vernum "v[0-9]+[a-z][0-9]+:") | |
1029 beg) | |
1030 (save-excursion | |
1031 (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | |
1032 (buffer-disable-undo (current-buffer)) | |
1033 (erase-buffer) | |
1034 (insert (regexp-quote string)) | |
1035 (setq beg 1) | |
1036 | |
1037 (setq case-fold-search nil) | |
1038 (goto-char (point-min)) | |
1039 (when (looking-at vernum) | |
1040 (replace-match vernum t t) | |
1041 (setq beg (length vernum))) | |
1042 | |
1043 (goto-char beg) | |
1044 (if (re-search-forward "[ \t]*[0-9]+/[0-9]+" nil t) | |
1045 (replace-match " [0-9]+/[0-9]+") | |
1046 | |
1047 (goto-char beg) | |
1048 (if (re-search-forward "[0-9]+[ \t]*of[ \t]*[0-9]+" nil t) | |
1049 (replace-match "[0-9]+ of [0-9]+") | |
1050 | |
1051 (end-of-line) | |
1052 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+" | |
1053 nil t) | |
1054 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil)))) | |
1055 | |
1056 (goto-char beg) | |
1057 (while (re-search-forward "[ \t]+" nil t) | |
1058 (replace-match "[ \t]*" t t)) | |
1059 | |
1060 (buffer-substring 1 (point-max))))) | |
1061 | |
1062 (defun gnus-uu-get-list-of-articles (n) | |
1063 ;; If N is non-nil, the article numbers of the N next articles | |
1064 ;; will be returned. | |
1065 ;; If any articles have been marked as processable, they will be | |
1066 ;; returned. | |
1067 ;; Failing that, articles that have subjects that are part of the | |
1068 ;; same "series" as the current will be returned. | |
1069 (let (articles) | |
1070 (cond | |
1071 (n | |
1072 (setq n (prefix-numeric-value n)) | |
1073 (let ((backward (< n 0)) | |
1074 (n (abs n))) | |
1075 (save-excursion | |
1076 (while (and (> n 0) | |
1077 (push (gnus-summary-article-number) | |
1078 articles) | |
1079 (gnus-summary-search-forward nil nil backward)) | |
1080 (setq n (1- n)))) | |
1081 (nreverse articles))) | |
1082 (gnus-newsgroup-processable | |
1083 (reverse gnus-newsgroup-processable)) | |
1084 (t | |
1085 (gnus-uu-find-articles-matching))))) | |
1086 | |
1087 (defun gnus-uu-string< (l1 l2) | |
1088 (string< (car l1) (car l2))) | |
1089 | |
1090 (defun gnus-uu-find-articles-matching | |
1091 (&optional subject only-unread do-not-translate) | |
1092 ;; Finds all articles that matches the regexp SUBJECT. If it is | |
1093 ;; nil, the current article name will be used. If ONLY-UNREAD is | |
1094 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is | |
1095 ;; non-nil, article names are not equalized before sorting. | |
1096 (let ((subject (or subject | |
1097 (gnus-uu-reginize-string (gnus-summary-article-subject)))) | |
1098 list-of-subjects) | |
1099 (save-excursion | |
1100 (if (not subject) | |
1101 () | |
1102 ;; Collect all subjects matching subject. | |
1103 (let ((case-fold-search t) | |
1104 (data gnus-newsgroup-data) | |
1105 subj mark d) | |
1106 (while data | |
1107 (setq d (pop data)) | |
1108 (and (not (gnus-data-pseudo-p d)) | |
1109 (or (not only-unread) | |
1110 (= (setq mark (gnus-data-mark d)) | |
1111 gnus-unread-mark) | |
1112 (= mark gnus-ticked-mark) | |
1113 (= mark gnus-dormant-mark)) | |
1114 (setq subj (mail-header-subject (gnus-data-header d))) | |
1115 (string-match subject subj) | |
1116 (push (cons subj (gnus-data-number d)) | |
1117 list-of-subjects)))) | |
1118 | |
1119 ;; Expand numbers, sort, and return the list of article | |
1120 ;; numbers. | |
1121 (mapcar (lambda (sub) (cdr sub)) | |
1122 (sort (gnus-uu-expand-numbers | |
1123 list-of-subjects | |
1124 (not do-not-translate)) | |
1125 'gnus-uu-string<)))))) | |
1126 | |
1127 (defun gnus-uu-expand-numbers (string-list &optional translate) | |
1128 ;; Takes a list of strings and "expands" all numbers in all the | |
1129 ;; strings. That is, this function makes all numbers equal length by | |
1130 ;; prepending lots of zeroes before each number. This is to ease later | |
1131 ;; sorting to find out what sequence the articles are supposed to be | |
1132 ;; decoded in. Returns the list of expanded strings. | |
1133 (let ((out-list string-list) | |
1134 string) | |
1135 (save-excursion | |
1136 (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | |
1137 (buffer-disable-undo (current-buffer)) | |
1138 (while string-list | |
1139 (erase-buffer) | |
1140 (insert (caar string-list)) | |
1141 ;; Translate multiple spaces to one space. | |
1142 (goto-char (point-min)) | |
1143 (while (re-search-forward "[ \t]+" nil t) | |
1144 (replace-match " ")) | |
1145 ;; Translate all characters to "a". | |
1146 (goto-char (point-min)) | |
1147 (when translate | |
1148 (while (re-search-forward "[A-Za-z]" nil t) | |
1149 (replace-match "a" t t))) | |
1150 ;; Expand numbers. | |
1151 (goto-char (point-min)) | |
1152 (while (re-search-forward "[0-9]+" nil t) | |
1153 (replace-match | |
1154 (format "%06d" | |
1155 (string-to-int (buffer-substring | |
1156 (match-beginning 0) (match-end 0)))))) | |
1157 (setq string (buffer-substring 1 (point-max))) | |
1158 (setcar (car string-list) string) | |
1159 (setq string-list (cdr string-list)))) | |
1160 out-list)) | |
1161 | |
1162 | |
1163 ;; `gnus-uu-grab-articles' is the general multi-article treatment | |
1164 ;; function. It takes a list of articles to be grabbed and a function | |
1165 ;; to apply to each article. | |
1166 ;; | |
1167 ;; The function to be called should take two parameters. The first | |
1168 ;; parameter is the article buffer. The function should leave the | |
1169 ;; result, if any, in this buffer. Most treatment functions will just | |
1170 ;; generate files... | |
1171 ;; | |
1172 ;; The second parameter is the state of the list of articles, and can | |
1173 ;; have four values: `first', `middle', `last' and `first-and-last'. | |
1174 ;; | |
1175 ;; The function should return a list. The list may contain the | |
1176 ;; following symbols: | |
1177 ;; `error' if an error occurred | |
1178 ;; `begin' if the beginning of an encoded file has been received | |
1179 ;; If the list returned contains a `begin', the first element of | |
1180 ;; the list *must* be a string with the file name of the decoded | |
1181 ;; file. | |
1182 ;; `end' if the end of an encoded file has been received | |
1183 ;; `middle' if the article was a body part of an encoded file | |
1184 ;; `wrong-type' if the article was not a part of an encoded file | |
1185 ;; `ok', which can be used everything is ok | |
1186 | |
1187 (defvar gnus-uu-has-been-grabbed nil) | |
1188 | |
1189 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article) | |
1190 (let (art) | |
1191 (if (not (and gnus-uu-has-been-grabbed | |
1192 gnus-uu-unmark-articles-not-decoded)) | |
1193 () | |
1194 (when dont-unmark-last-article | |
1195 (setq art (car gnus-uu-has-been-grabbed)) | |
1196 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed))) | |
1197 (while gnus-uu-has-been-grabbed | |
1198 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t) | |
1199 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed))) | |
1200 (when dont-unmark-last-article | |
1201 (setq gnus-uu-has-been-grabbed (list art)))))) | |
1202 | |
1203 ;; This function takes a list of articles and a function to apply to | |
1204 ;; each article grabbed. | |
1205 ;; | |
1206 ;; This function returns a list of files decoded if the grabbing and | |
1207 ;; the process-function has been successful and nil otherwise. | |
1208 (defun gnus-uu-grab-articles (articles process-function | |
1209 &optional sloppy limit no-errors) | |
1210 (let ((state 'first) | |
1211 has-been-begin article result-file result-files process-state | |
1212 gnus-summary-display-article-function | |
1213 gnus-article-display-hook gnus-article-prepare-hook | |
1214 article-series files) | |
1215 | |
1216 (while (and articles | |
1217 (not (memq 'error process-state)) | |
1218 (or sloppy | |
1219 (not (memq 'end process-state)))) | |
1220 | |
1221 (setq article (pop articles)) | |
1222 (push article article-series) | |
1223 | |
1224 (unless articles | |
1225 (if (eq state 'first) | |
1226 (setq state 'first-and-last) | |
1227 (setq state 'last))) | |
1228 | |
1229 (let ((part (gnus-uu-part-number article))) | |
1230 (gnus-message 6 "Getting article %d%s..." | |
1231 article (if (string= part "") "" (concat ", " part)))) | |
1232 (gnus-summary-display-article article) | |
1233 | |
1234 ;; Push the article to the processing function. | |
1235 (save-excursion | |
1236 (set-buffer gnus-original-article-buffer) | |
1237 (let ((buffer-read-only nil)) | |
1238 (save-excursion | |
1239 (set-buffer gnus-summary-buffer) | |
1240 (setq process-state | |
1241 (funcall process-function | |
1242 gnus-original-article-buffer state))))) | |
1243 | |
1244 (gnus-summary-remove-process-mark article) | |
1245 | |
1246 ;; If this is the beginning of a decoded file, we push it | |
1247 ;; on to a list. | |
1248 (when (or (memq 'begin process-state) | |
1249 (and (or (eq state 'first) | |
1250 (eq state 'first-and-last)) | |
1251 (memq 'ok process-state))) | |
1252 (when has-been-begin | |
1253 ;; If there is a `result-file' here, that means that the | |
1254 ;; file was unsuccessfully decoded, so we delete it. | |
1255 (when (and result-file | |
1256 (file-exists-p result-file) | |
1257 (not gnus-uu-be-dangerous) | |
1258 (or (eq gnus-uu-be-dangerous t) | |
1259 (gnus-y-or-n-p | |
1260 (format "Delete unsuccessfully decoded file %s" | |
1261 result-file)))) | |
1262 (delete-file result-file))) | |
1263 (when (memq 'begin process-state) | |
1264 (setq result-file (car process-state))) | |
1265 (setq has-been-begin t)) | |
1266 | |
1267 ;; Check whether we have decoded one complete file. | |
1268 (when (memq 'end process-state) | |
1269 (setq article-series nil) | |
1270 (setq has-been-begin nil) | |
1271 (if (stringp result-file) | |
1272 (setq files (list result-file)) | |
1273 (setq files result-file)) | |
1274 (setq result-file (car files)) | |
1275 (while files | |
1276 (push (list (cons 'name (pop files)) | |
1277 (cons 'article article)) | |
1278 result-files)) | |
1279 ;; Allow user-defined functions to be run on this file. | |
1280 (when gnus-uu-grabbed-file-functions | |
1281 (let ((funcs gnus-uu-grabbed-file-functions)) | |
1282 (unless (listp funcs) | |
1283 (setq funcs (list funcs))) | |
1284 (while funcs | |
1285 (funcall (pop funcs) result-file)))) | |
1286 (setq result-file nil) | |
1287 ;; Check whether we have decoded enough articles. | |
1288 (and limit (= (length result-files) limit) | |
1289 (setq articles nil))) | |
1290 | |
1291 ;; If this is the last article to be decoded, and | |
1292 ;; we still haven't reached the end, then we delete | |
1293 ;; the partially decoded file. | |
1294 (and (or (eq state 'last) (eq state 'first-and-last)) | |
1295 (not (memq 'end process-state)) | |
1296 result-file | |
1297 (file-exists-p result-file) | |
1298 (not gnus-uu-be-dangerous) | |
1299 (or (eq gnus-uu-be-dangerous t) | |
1300 (gnus-y-or-n-p (format "Delete incomplete file %s? " result-file))) | |
1301 (delete-file result-file)) | |
1302 | |
1303 ;; If this was a file of the wrong sort, then | |
1304 (when (and (or (memq 'wrong-type process-state) | |
1305 (memq 'error process-state)) | |
1306 gnus-uu-unmark-articles-not-decoded) | |
1307 (gnus-summary-tick-article article t)) | |
1308 | |
1309 ;; Set the new series state. | |
1310 (if (and (not has-been-begin) | |
1311 (not sloppy) | |
1312 (or (memq 'end process-state) | |
1313 (memq 'middle process-state))) | |
1314 (progn | |
1315 (setq process-state (list 'error)) | |
1316 (gnus-message 2 "No begin part at the beginning") | |
1317 (sleep-for 2)) | |
1318 (setq state 'middle))) | |
1319 | |
1320 ;; When there are no result-files, then something must be wrong. | |
1321 (if result-files | |
1322 (message "") | |
1323 (cond | |
1324 ((not has-been-begin) | |
1325 (gnus-message 2 "Wrong type file")) | |
1326 ((memq 'error process-state) | |
1327 (gnus-message 2 "An error occurred during decoding")) | |
1328 ((not (or (memq 'ok process-state) | |
1329 (memq 'end process-state))) | |
1330 (gnus-message 2 "End of articles reached before end of file"))) | |
1331 ;; Make unsuccessfully decoded articles unread. | |
1332 (when gnus-uu-unmark-articles-not-decoded | |
1333 (while article-series | |
1334 (gnus-summary-tick-article (pop article-series) t)))) | |
1335 | |
1336 result-files)) | |
1337 | |
1338 (defun gnus-uu-grab-view (file) | |
1339 "View FILE using the gnus-uu methods." | |
1340 (let ((action (gnus-uu-get-action file))) | |
1341 (gnus-execute-command | |
1342 (if (string-match "%" action) | |
1343 (format action file) | |
1344 (concat action " " file)) | |
1345 (eq gnus-view-pseudos 'not-confirm)))) | |
1346 | |
1347 (defun gnus-uu-grab-move (file) | |
1348 "Move FILE to somewhere." | |
1349 (when gnus-uu-default-dir | |
1350 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir) | |
1351 (file-name-nondirectory file)))) | |
1352 (rename-file file to-file) | |
1353 (unless (file-exists-p file) | |
1354 (make-symbolic-link to-file file))))) | |
1355 | |
1356 (defun gnus-uu-part-number (article) | |
1357 (let* ((header (gnus-summary-article-header article)) | |
1358 (subject (and header (mail-header-subject header)))) | |
1359 (if (and subject | |
1360 (string-match "[0-9]+ */[0-9]+\\|[0-9]+ * of *[0-9]+" subject)) | |
1361 (match-string 0 subject) | |
1362 ""))) | |
1363 | |
1364 (defun gnus-uu-uudecode-sentinel (process event) | |
1365 (delete-process (get-process process))) | |
1366 | |
1367 (defun gnus-uu-uustrip-article (process-buffer in-state) | |
1368 ;; Uudecodes a file asynchronously. | |
1369 (save-excursion | |
1370 (set-buffer process-buffer) | |
1371 (let ((state (list 'wrong-type)) | |
1372 process-connection-type case-fold-search buffer-read-only | |
1373 files start-char) | |
1374 (goto-char (point-min)) | |
1375 | |
1376 ;; Deal with ^M at the end of the lines. | |
1377 (when gnus-uu-kill-carriage-return | |
1378 (save-excursion | |
1379 (while (search-forward "\r" nil t) | |
1380 (delete-backward-char 1)))) | |
1381 | |
1382 (while (or (re-search-forward gnus-uu-begin-string nil t) | |
1383 (re-search-forward gnus-uu-body-line nil t)) | |
1384 (setq state (list 'ok)) | |
1385 ;; Ok, we are at the first uucoded line. | |
1386 (beginning-of-line) | |
1387 (setq start-char (point)) | |
1388 | |
1389 (if (not (looking-at gnus-uu-begin-string)) | |
1390 (setq state (list 'middle)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1391 ;; This is the beginning of a uuencoded article. |
17493 | 1392 ;; We replace certain characters that could make things messy. |
1393 (setq gnus-uu-file-name | |
1394 (let ((nnheader-file-name-translation-alist | |
1395 '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_)))) | |
1396 (nnheader-translate-file-chars (match-string 1)))) | |
1397 (replace-match (concat "begin 644 " gnus-uu-file-name) t t) | |
1398 | |
1399 ;; Remove any non gnus-uu-body-line right after start. | |
1400 (forward-line 1) | |
1401 (while (and (not (eobp)) | |
1402 (not (looking-at gnus-uu-body-line))) | |
1403 (gnus-delete-line)) | |
1404 | |
1405 ;; If a process is running, we kill it. | |
1406 (when (and gnus-uu-uudecode-process | |
1407 (memq (process-status gnus-uu-uudecode-process) | |
1408 '(run stop))) | |
1409 (delete-process gnus-uu-uudecode-process) | |
1410 (gnus-uu-unmark-list-of-grabbed t)) | |
1411 | |
1412 ;; Start a new uudecoding process. | |
1413 (let ((cdir default-directory)) | |
1414 (unwind-protect | |
1415 (progn | |
1416 (cd gnus-uu-work-dir) | |
1417 (setq gnus-uu-uudecode-process | |
1418 (start-process | |
1419 "*uudecode*" | |
1420 (get-buffer-create gnus-uu-output-buffer-name) | |
1421 shell-file-name shell-command-switch | |
1422 (format "cd %s %s uudecode" gnus-uu-work-dir | |
1423 gnus-shell-command-separator)))) | |
1424 (cd cdir))) | |
1425 (set-process-sentinel | |
1426 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel) | |
1427 (setq state (list 'begin)) | |
1428 (push (concat gnus-uu-work-dir gnus-uu-file-name) files)) | |
1429 | |
1430 ;; We look for the end of the thing to be decoded. | |
1431 (if (re-search-forward gnus-uu-end-string nil t) | |
1432 (push 'end state) | |
1433 (goto-char (point-max)) | |
1434 (re-search-backward gnus-uu-body-line nil t)) | |
1435 | |
1436 (forward-line 1) | |
1437 | |
1438 (when gnus-uu-uudecode-process | |
1439 (when (memq (process-status gnus-uu-uudecode-process) '(run stop)) | |
1440 ;; Try to correct mishandled uucode. | |
1441 (when gnus-uu-correct-stripped-uucode | |
1442 (gnus-uu-check-correct-stripped-uucode start-char (point))) | |
1443 | |
1444 ;; Send the text to the process. | |
1445 (condition-case nil | |
1446 (process-send-region | |
1447 gnus-uu-uudecode-process start-char (point)) | |
1448 (error | |
1449 (progn | |
1450 (delete-process gnus-uu-uudecode-process) | |
1451 (gnus-message 2 "gnus-uu: Couldn't uudecode") | |
1452 (setq state (list 'wrong-type))))) | |
1453 | |
1454 (if (memq 'end state) | |
1455 (progn | |
1456 ;; Send an EOF, just in case. | |
1457 (ignore-errors | |
1458 (process-send-eof gnus-uu-uudecode-process)) | |
1459 (while (memq (process-status gnus-uu-uudecode-process) | |
1460 '(open run)) | |
1461 (accept-process-output gnus-uu-uudecode-process 1))) | |
1462 (when (or (not gnus-uu-uudecode-process) | |
1463 (not (memq (process-status gnus-uu-uudecode-process) | |
1464 '(run stop)))) | |
1465 (setq state (list 'wrong-type))))))) | |
1466 | |
1467 (if (memq 'begin state) | |
1468 (cons (if (= (length files) 1) (car files) files) state) | |
1469 state)))) | |
1470 | |
1471 ;; This function is used by `gnus-uu-grab-articles' to treat | |
1472 ;; a shared article. | |
1473 (defun gnus-uu-unshar-article (process-buffer in-state) | |
1474 (let ((state (list 'ok)) | |
1475 start-char) | |
1476 (save-excursion | |
1477 (set-buffer process-buffer) | |
1478 (goto-char (point-min)) | |
1479 (if (not (re-search-forward gnus-uu-shar-begin-string nil t)) | |
1480 (setq state (list 'wrong-type)) | |
1481 (beginning-of-line) | |
1482 (setq start-char (point)) | |
1483 (call-process-region | |
1484 start-char (point-max) shell-file-name nil | |
1485 (get-buffer-create gnus-uu-output-buffer-name) nil | |
1486 shell-command-switch | |
1487 (concat "cd " gnus-uu-work-dir " " | |
1488 gnus-shell-command-separator " sh")))) | |
1489 state)) | |
1490 | |
1491 ;; Returns the name of what the shar file is going to unpack. | |
1492 (defun gnus-uu-find-name-in-shar () | |
1493 (let ((oldpoint (point)) | |
1494 res) | |
1495 (goto-char (point-min)) | |
1496 (when (re-search-forward gnus-uu-shar-name-marker nil t) | |
1497 (setq res (buffer-substring (match-beginning 1) (match-end 1)))) | |
1498 (goto-char oldpoint) | |
1499 res)) | |
1500 | |
1501 ;; `gnus-uu-choose-action' chooses what action to perform given the name | |
1502 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is | |
1503 ;; found, or the name of the command to run if such a rule is found. | |
1504 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore) | |
1505 (let ((action-list (copy-sequence file-action-list)) | |
1506 (case-fold-search t) | |
1507 rule action) | |
1508 (and | |
1509 (unless no-ignore | |
1510 (and (not | |
1511 (and gnus-uu-ignore-files-by-name | |
1512 (string-match gnus-uu-ignore-files-by-name file-name))) | |
1513 (not | |
1514 (and gnus-uu-ignore-files-by-type | |
1515 (string-match gnus-uu-ignore-files-by-type | |
1516 (or (gnus-uu-choose-action | |
1517 file-name gnus-uu-ext-to-mime-list t) | |
1518 "")))))) | |
1519 (while (not (or (eq action-list ()) action)) | |
1520 (setq rule (car action-list)) | |
1521 (setq action-list (cdr action-list)) | |
1522 (when (string-match (car rule) file-name) | |
1523 (setq action (cadr rule))))) | |
1524 action)) | |
1525 | |
1526 (defun gnus-uu-treat-archive (file-path) | |
1527 ;; Unpacks an archive. Returns t if unpacking is successful. | |
1528 (let ((did-unpack t) | |
1529 action command dir) | |
1530 (setq action (gnus-uu-choose-action | |
1531 file-path (append gnus-uu-user-archive-rules | |
1532 (if gnus-uu-ignore-default-archive-rules | |
1533 nil | |
1534 gnus-uu-default-archive-rules)))) | |
1535 | |
1536 (when (not action) | |
1537 (error "No unpackers for the file %s" file-path)) | |
1538 | |
1539 (string-match "/[^/]*$" file-path) | |
1540 (setq dir (substring file-path 0 (match-beginning 0))) | |
1541 | |
1542 (when (member action gnus-uu-destructive-archivers) | |
1543 (copy-file file-path (concat file-path "~") t)) | |
1544 | |
1545 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path))) | |
1546 | |
1547 (save-excursion | |
1548 (set-buffer (get-buffer-create gnus-uu-output-buffer-name)) | |
1549 (erase-buffer)) | |
1550 | |
1551 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path)) | |
1552 | |
1553 (if (= 0 (call-process shell-file-name nil | |
1554 (get-buffer-create gnus-uu-output-buffer-name) | |
1555 nil shell-command-switch command)) | |
1556 (message "") | |
1557 (gnus-message 2 "Error during unpacking of archive") | |
1558 (setq did-unpack nil)) | |
1559 | |
1560 (when (member action gnus-uu-destructive-archivers) | |
1561 (rename-file (concat file-path "~") file-path t)) | |
1562 | |
1563 did-unpack)) | |
1564 | |
1565 (defun gnus-uu-dir-files (dir) | |
1566 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$")) | |
1567 files file) | |
1568 (while dirs | |
1569 (if (file-directory-p (setq file (car dirs))) | |
1570 (setq files (append files (gnus-uu-dir-files file))) | |
1571 (push file files)) | |
1572 (setq dirs (cdr dirs))) | |
1573 files)) | |
1574 | |
1575 (defun gnus-uu-unpack-files (files &optional ignore) | |
1576 ;; Go through FILES and look for files to unpack. | |
1577 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir)) | |
1578 (ofiles files) | |
1579 file did-unpack) | |
1580 (while files | |
1581 (setq file (cdr (assq 'name (car files)))) | |
1582 (when (and (not (member file ignore)) | |
1583 (equal (gnus-uu-get-action (file-name-nondirectory file)) | |
1584 "gnus-uu-archive")) | |
1585 (push file did-unpack) | |
1586 (unless (gnus-uu-treat-archive file) | |
1587 (gnus-message 2 "Error during unpacking of %s" file)) | |
1588 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir)) | |
1589 (nfiles newfiles)) | |
1590 (while nfiles | |
1591 (unless (member (car nfiles) totfiles) | |
1592 (push (list (cons 'name (car nfiles)) | |
1593 (cons 'original file)) | |
1594 ofiles)) | |
1595 (setq nfiles (cdr nfiles))) | |
1596 (setq totfiles newfiles))) | |
1597 (setq files (cdr files))) | |
1598 (if did-unpack | |
1599 (gnus-uu-unpack-files ofiles (append did-unpack ignore)) | |
1600 ofiles))) | |
1601 | |
1602 (defun gnus-uu-ls-r (dir) | |
1603 (let* ((files (gnus-uu-directory-files dir t)) | |
1604 (ofiles files)) | |
1605 (while files | |
1606 (when (file-directory-p (car files)) | |
1607 (setq ofiles (delete (car files) ofiles)) | |
1608 (setq ofiles (append ofiles (gnus-uu-ls-r (car files))))) | |
1609 (setq files (cdr files))) | |
1610 ofiles)) | |
1611 | |
1612 ;; Various stuff | |
1613 | |
1614 (defun gnus-uu-directory-files (dir &optional full) | |
1615 (let (files out file) | |
1616 (setq files (directory-files dir full)) | |
1617 (while files | |
1618 (setq file (car files)) | |
1619 (setq files (cdr files)) | |
1620 (unless (member (file-name-nondirectory file) '("." "..")) | |
1621 (push file out))) | |
1622 (setq out (nreverse out)) | |
1623 out)) | |
1624 | |
1625 (defun gnus-uu-check-correct-stripped-uucode (start end) | |
1626 (save-excursion | |
1627 (let (found beg length) | |
1628 (if (not gnus-uu-correct-stripped-uucode) | |
1629 () | |
1630 (goto-char start) | |
1631 | |
1632 (if (re-search-forward " \\|`" end t) | |
1633 (progn | |
1634 (goto-char start) | |
1635 (while (not (eobp)) | |
1636 (progn | |
1637 (when (looking-at "\n") | |
1638 (replace-match "")) | |
1639 (forward-line 1)))) | |
1640 | |
1641 (while (not (eobp)) | |
1642 (if (looking-at (concat gnus-uu-begin-string "\\|" | |
1643 gnus-uu-end-string)) | |
1644 () | |
1645 (when (not found) | |
1646 (beginning-of-line) | |
1647 (setq beg (point)) | |
1648 (end-of-line) | |
1649 (setq length (- (point) beg))) | |
1650 (setq found t) | |
1651 (beginning-of-line) | |
1652 (setq beg (point)) | |
1653 (end-of-line) | |
1654 (when (not (= length (- (point) beg))) | |
1655 (insert (make-string (- length (- (point) beg)) ? )))) | |
1656 (forward-line 1))))))) | |
1657 | |
1658 (defvar gnus-uu-tmp-alist nil) | |
1659 | |
1660 (defun gnus-uu-initialize (&optional scan) | |
1661 (let (entry) | |
1662 (if (and (not scan) | |
1663 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist)) | |
1664 (if (file-exists-p (cdr entry)) | |
1665 (setq gnus-uu-work-dir (cdr entry)) | |
1666 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist)) | |
1667 nil))) | |
1668 t | |
1669 (setq gnus-uu-tmp-dir (file-name-as-directory | |
1670 (expand-file-name gnus-uu-tmp-dir))) | |
1671 (if (not (file-directory-p gnus-uu-tmp-dir)) | |
1672 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir) | |
1673 (when (not (file-writable-p gnus-uu-tmp-dir)) | |
1674 (error "Temp directory %s can't be written to" | |
1675 gnus-uu-tmp-dir))) | |
1676 | |
1677 (setq gnus-uu-work-dir | |
1678 (make-temp-name (concat gnus-uu-tmp-dir "gnus"))) | |
1679 (gnus-make-directory gnus-uu-work-dir) | |
1680 (set-file-modes gnus-uu-work-dir 448) | |
1681 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir)) | |
1682 (push (cons gnus-newsgroup-name gnus-uu-work-dir) | |
1683 gnus-uu-tmp-alist)))) | |
1684 | |
1685 | |
1686 ;; Kills the temporary uu buffers, kills any processes, etc. | |
1687 (defun gnus-uu-clean-up () | |
1688 (let (buf) | |
1689 (and gnus-uu-uudecode-process | |
1690 (memq (process-status (or gnus-uu-uudecode-process "nevair")) | |
1691 '(stop run)) | |
1692 (delete-process gnus-uu-uudecode-process)) | |
1693 (when (setq buf (get-buffer gnus-uu-output-buffer-name)) | |
1694 (kill-buffer buf)))) | |
1695 | |
1696 (defun gnus-quote-arg-for-sh-or-csh (arg) | |
1697 (let ((pos 0) new-pos accum) | |
1698 ;; *** bug: we don't handle newline characters properly | |
1699 (while (setq new-pos (string-match "[!`\"$\\& \t{}]" arg pos)) | |
1700 (push (substring arg pos new-pos) accum) | |
1701 (push "\\" accum) | |
1702 (push (list (aref arg new-pos)) accum) | |
1703 (setq pos (1+ new-pos))) | |
1704 (if (= pos 0) | |
1705 arg | |
1706 (apply 'concat (nconc (nreverse accum) (list (substring arg pos))))))) | |
1707 | |
1708 ;; Inputs an action and a filename and returns a full command, making sure | |
1709 ;; that the filename will be treated as a single argument when the shell | |
1710 ;; executes the command. | |
1711 (defun gnus-uu-command (action file) | |
1712 (let ((quoted-file (gnus-quote-arg-for-sh-or-csh file))) | |
1713 (if (string-match "%s" action) | |
1714 (format action quoted-file) | |
1715 (concat action " " quoted-file)))) | |
1716 | |
1717 (defun gnus-uu-delete-work-dir (&optional dir) | |
1718 "Delete recursively all files and directories under `gnus-uu-work-dir'." | |
1719 (if dir | |
1720 (gnus-message 7 "Deleting directory %s..." dir) | |
1721 (setq dir gnus-uu-work-dir)) | |
1722 (when (and dir | |
1723 (file-exists-p dir)) | |
1724 (let ((files (directory-files dir t nil t)) | |
1725 file) | |
1726 (while (setq file (pop files)) | |
1727 (unless (member (file-name-nondirectory file) '("." "..")) | |
1728 (if (file-directory-p file) | |
1729 (gnus-uu-delete-work-dir file) | |
1730 (gnus-message 9 "Deleting file %s..." file) | |
1731 (delete-file file)))) | |
1732 (delete-directory dir))) | |
1733 (gnus-message 7 "")) | |
1734 | |
1735 ;; Initializing | |
1736 | |
1737 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up) | |
1738 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir) | |
1739 | |
1740 | |
1741 | |
1742 ;;; | |
1743 ;;; uuencoded posting | |
1744 ;;; | |
1745 | |
1746 ;; Any function that is to be used as and encoding method will take two | |
1747 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg" | |
1748 ;; and "spiral.jpg", respectively.) The function should return nil if | |
1749 ;; the encoding wasn't successful. | |
1750 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode | |
1751 "Function used for encoding binary files. | |
1752 There are three functions supplied with gnus-uu for encoding files: | |
1753 `gnus-uu-post-encode-uuencode', which does straight uuencoding; | |
1754 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME | |
1755 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with | |
1756 uuencode and adds MIME headers." | |
1757 :group 'gnus-extract-post | |
1758 :type '(radio (function-item gnus-uu-post-encode-uuencode) | |
1759 (function-item gnus-uu-post-encode-mime) | |
1760 (function-item gnus-uu-post-encode-mime-uuencode) | |
1761 (function :tag "Other"))) | |
1762 | |
1763 (defcustom gnus-uu-post-include-before-composing nil | |
1764 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article. | |
1765 If this variable is t, you can either include an encoded file with | |
1766 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article." | |
1767 :group 'gnus-extract-post | |
1768 :type 'boolean) | |
1769 | |
1770 (defcustom gnus-uu-post-length 990 | |
1771 "Maximum length of an article. | |
1772 The encoded file will be split into how many articles it takes to | |
1773 post the entire file." | |
1774 :group 'gnus-extract-post | |
1775 :type 'integer) | |
1776 | |
1777 (defcustom gnus-uu-post-threaded nil | |
1778 "Non-nil means that gnus-uu will post the encoded file in a thread. | |
1779 This may not be smart, as no other decoder I have seen are able to | |
1780 follow threads when collecting uuencoded articles. (Well, I have seen | |
1781 one package that does that - gnus-uu, but somehow, I don't think that | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1782 counts...) The default is nil." |
17493 | 1783 :group 'gnus-extract-post |
1784 :type 'boolean) | |
1785 | |
1786 (defcustom gnus-uu-post-separate-description t | |
1787 "Non-nil means that the description will be posted in a separate article. | |
1788 The first article will typically be numbered (0/x). If this variable | |
1789 is nil, the description the user enters will be included at the | |
1790 beginning of the first article, which will be numbered (1/x). Default | |
1791 is t." | |
1792 :group 'gnus-extract-post | |
1793 :type 'boolean) | |
1794 | |
1795 (defvar gnus-uu-post-binary-separator "--binary follows this line--") | |
1796 (defvar gnus-uu-post-message-id nil) | |
1797 (defvar gnus-uu-post-inserted-file-name nil) | |
1798 (defvar gnus-uu-winconf-post-news nil) | |
1799 | |
1800 (defun gnus-uu-post-news () | |
1801 "Compose an article and post an encoded file." | |
1802 (interactive) | |
1803 (setq gnus-uu-post-inserted-file-name nil) | |
1804 (setq gnus-uu-winconf-post-news (current-window-configuration)) | |
1805 | |
1806 (gnus-summary-post-news) | |
1807 | |
1808 (use-local-map (copy-keymap (current-local-map))) | |
1809 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done) | |
1810 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews) | |
1811 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews) | |
1812 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article) | |
1813 | |
1814 (when gnus-uu-post-include-before-composing | |
1815 (save-excursion (setq gnus-uu-post-inserted-file-name | |
1816 (gnus-uu-post-insert-binary))))) | |
1817 | |
1818 (defun gnus-uu-post-insert-binary-in-article () | |
1819 "Inserts an encoded file in the buffer. | |
1820 The user will be asked for a file name." | |
1821 (interactive) | |
1822 (save-excursion | |
1823 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary)))) | |
1824 | |
1825 ;; Encodes with uuencode and substitutes all spaces with backticks. | |
1826 (defun gnus-uu-post-encode-uuencode (path file-name) | |
1827 (when (gnus-uu-post-encode-file "uuencode" path file-name) | |
1828 (goto-char (point-min)) | |
1829 (forward-line 1) | |
1830 (while (re-search-forward " " nil t) | |
1831 (replace-match "`")) | |
1832 t)) | |
1833 | |
1834 ;; Encodes with uuencode and adds MIME headers. | |
1835 (defun gnus-uu-post-encode-mime-uuencode (path file-name) | |
1836 (when (gnus-uu-post-encode-uuencode path file-name) | |
1837 (gnus-uu-post-make-mime file-name "x-uue") | |
1838 t)) | |
1839 | |
1840 ;; Encodes with base64 and adds MIME headers | |
1841 (defun gnus-uu-post-encode-mime (path file-name) | |
1842 (when (gnus-uu-post-encode-file "mmencode" path file-name) | |
1843 (gnus-uu-post-make-mime file-name "base64") | |
1844 t)) | |
1845 | |
1846 ;; Adds MIME headers. | |
1847 (defun gnus-uu-post-make-mime (file-name encoding) | |
1848 (goto-char (point-min)) | |
1849 (insert (format "Content-Type: %s; name=\"%s\"\n" | |
1850 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list) | |
1851 file-name)) | |
1852 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding)) | |
1853 (save-restriction | |
1854 (set-buffer gnus-message-buffer) | |
1855 (goto-char (point-min)) | |
1856 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$")) | |
1857 (forward-line -1) | |
1858 (narrow-to-region 1 (point)) | |
1859 (unless (mail-fetch-field "mime-version") | |
1860 (widen) | |
1861 (insert "MIME-Version: 1.0\n")) | |
1862 (widen))) | |
1863 | |
1864 ;; Encodes a file PATH with COMMAND, leaving the result in the | |
1865 ;; current buffer. | |
1866 (defun gnus-uu-post-encode-file (command path file-name) | |
1867 (= 0 (call-process shell-file-name nil t nil shell-command-switch | |
1868 (format "%s %s %s" command path file-name)))) | |
1869 | |
1870 (defun gnus-uu-post-news-inews () | |
1871 "Posts the composed news article and encoded file. | |
1872 If no file has been included, the user will be asked for a file." | |
1873 (interactive) | |
1874 | |
1875 (let (file-name) | |
1876 | |
1877 (if gnus-uu-post-inserted-file-name | |
1878 (setq file-name gnus-uu-post-inserted-file-name) | |
1879 (setq file-name (gnus-uu-post-insert-binary))) | |
1880 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1881 (gnus-uu-post-encoded file-name gnus-uu-post-threaded)) |
17493 | 1882 (setq gnus-uu-post-inserted-file-name nil) |
1883 (when gnus-uu-winconf-post-news | |
1884 (set-window-configuration gnus-uu-winconf-post-news))) | |
1885 | |
1886 ;; Asks for a file to encode, encodes it and inserts the result in | |
1887 ;; the current buffer. Returns the file name the user gave. | |
1888 (defun gnus-uu-post-insert-binary () | |
1889 (let ((uuencode-buffer-name "*uuencode buffer*") | |
1890 file-path uubuf file-name) | |
1891 | |
1892 (setq file-path (read-file-name | |
1893 "What file do you want to encode? ")) | |
1894 (when (not (file-exists-p file-path)) | |
1895 (error "%s: No such file" file-path)) | |
1896 | |
1897 (goto-char (point-max)) | |
1898 (insert (format "\n%s\n" gnus-uu-post-binary-separator)) | |
1899 | |
1900 (when (string-match "^~/" file-path) | |
1901 (setq file-path (concat "$HOME" (substring file-path 1)))) | |
1902 (if (string-match "/[^/]*$" file-path) | |
1903 (setq file-name (substring file-path (1+ (match-beginning 0)))) | |
1904 (setq file-name file-path)) | |
1905 | |
1906 (unwind-protect | |
1907 (if (save-excursion | |
1908 (set-buffer (setq uubuf | |
1909 (get-buffer-create uuencode-buffer-name))) | |
1910 (erase-buffer) | |
1911 (funcall gnus-uu-post-encode-method file-path file-name)) | |
1912 (insert-buffer-substring uubuf) | |
1913 (error "Encoding unsuccessful")) | |
1914 (kill-buffer uubuf)) | |
1915 file-name)) | |
1916 | |
1917 ;; Posts the article and all of the encoded file. | |
1918 (defun gnus-uu-post-encoded (file-name &optional threaded) | |
1919 (let ((send-buffer-name "*uuencode send buffer*") | |
1920 (encoded-buffer-name "*encoded buffer*") | |
1921 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]") | |
1922 (separator (concat mail-header-separator "\n\n")) | |
1923 uubuf length parts header i end beg | |
1924 beg-line minlen buf post-buf whole-len beg-binary end-binary) | |
1925 | |
1926 (setq post-buf (current-buffer)) | |
1927 | |
1928 (goto-char (point-min)) | |
1929 (when (not (re-search-forward | |
1930 (if gnus-uu-post-separate-description | |
1931 (concat "^" (regexp-quote gnus-uu-post-binary-separator) | |
1932 "$") | |
1933 (concat "^" (regexp-quote mail-header-separator) "$")) | |
1934 nil t)) | |
1935 (error "Internal error: No binary/header separator")) | |
1936 (beginning-of-line) | |
1937 (forward-line 1) | |
1938 (setq beg-binary (point)) | |
1939 (setq end-binary (point-max)) | |
1940 | |
1941 (save-excursion | |
1942 (set-buffer (setq uubuf (get-buffer-create encoded-buffer-name))) | |
1943 (erase-buffer) | |
1944 (insert-buffer-substring post-buf beg-binary end-binary) | |
1945 (goto-char (point-min)) | |
1946 (setq length (count-lines 1 (point-max))) | |
1947 (setq parts (/ length gnus-uu-post-length)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1948 (unless (< (% length gnus-uu-post-length) 4) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1949 (incf parts))) |
17493 | 1950 |
1951 (when gnus-uu-post-separate-description | |
1952 (forward-line -1)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1953 (delete-region (point) (point-max)) |
17493 | 1954 |
1955 (goto-char (point-min)) | |
1956 (re-search-forward | |
1957 (concat "^" (regexp-quote mail-header-separator) "$") nil t) | |
1958 (beginning-of-line) | |
1959 (setq header (buffer-substring 1 (point))) | |
1960 | |
1961 (goto-char (point-min)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1962 (when gnus-uu-post-separate-description |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1963 (when (re-search-forward "^Subject: " nil t) |
17493 | 1964 (end-of-line) |
1965 (insert (format " (0/%d)" parts))) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1966 (save-excursion |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1967 (message-send)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1968 (setq gnus-uu-post-message-id (message-fetch-field "message-id"))) |
17493 | 1969 |
1970 (save-excursion | |
1971 (setq i 1) | |
1972 (setq beg 1) | |
1973 (while (not (> i parts)) | |
1974 (set-buffer (get-buffer-create send-buffer-name)) | |
1975 (erase-buffer) | |
1976 (insert header) | |
1977 (when (and threaded gnus-uu-post-message-id) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1978 (insert "References: " gnus-uu-post-message-id "\n")) |
17493 | 1979 (insert separator) |
1980 (setq whole-len | |
1981 (- 62 (length (format top-string "" file-name i parts "")))) | |
1982 (when (> 1 (setq minlen (/ whole-len 2))) | |
1983 (setq minlen 1)) | |
1984 (setq | |
1985 beg-line | |
1986 (format top-string | |
1987 (make-string minlen ?-) | |
1988 file-name i parts | |
1989 (make-string | |
1990 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-))) | |
1991 | |
1992 (goto-char (point-min)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1993 (when (re-search-forward "^Subject: " nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1994 (end-of-line) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
1995 (insert (format " (%d/%d)" i parts))) |
17493 | 1996 |
1997 (goto-char (point-max)) | |
1998 (save-excursion | |
1999 (set-buffer uubuf) | |
2000 (goto-char beg) | |
2001 (if (= i parts) | |
2002 (goto-char (point-max)) | |
2003 (forward-line gnus-uu-post-length)) | |
2004 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4)) | |
2005 (forward-line -4)) | |
2006 (setq end (point))) | |
2007 (insert-buffer-substring uubuf beg end) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2008 (insert beg-line "\n") |
17493 | 2009 (setq beg end) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2010 (incf i) |
17493 | 2011 (goto-char (point-min)) |
2012 (re-search-forward | |
2013 (concat "^" (regexp-quote mail-header-separator) "$") nil t) | |
2014 (beginning-of-line) | |
2015 (forward-line 2) | |
2016 (when (re-search-forward | |
2017 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$") | |
2018 nil t) | |
2019 (replace-match "") | |
2020 (forward-line 1)) | |
2021 (insert beg-line) | |
2022 (insert "\n") | |
2023 (let (message-sent-message-via) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2024 (save-excursion |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2025 (message-send)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2026 (setq gnus-uu-post-message-id |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2027 (concat (message-fetch-field "references") " " |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2028 (message-fetch-field "message-id")))))) |
17493 | 2029 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2030 (gnus-kill-buffer send-buffer-name) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19634
diff
changeset
|
2031 (gnus-kill-buffer encoded-buffer-name) |
17493 | 2032 |
2033 (when (not gnus-uu-post-separate-description) | |
2034 (set-buffer-modified-p nil) | |
2035 (when (fboundp 'bury-buffer) | |
2036 (bury-buffer))))) | |
2037 | |
2038 (provide 'gnus-uu) | |
2039 | |
2040 ;; gnus-uu.el ends here |