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