1 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
2 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
3 ;; 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defgroup gnus-extract nil
38 "Extracting encoded files."
42 (defgroup gnus-extract-view nil
43 "Viewwing extracted files."
46 (defgroup gnus-extract-archive nil
47 "Extracting encoded archives."
50 (defgroup gnus-extract-post nil
51 "Extracting encoded archives."
52 :prefix "gnus-uu-post"
55 ;; Default viewing action rules
57 (defcustom gnus-uu-default-view-rules
58 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
59 ("\\.pas$" "cat %s | sed 's/\r$//'")
60 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
61 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
62 ("\\.tga$" "tgatoppm %s | ee -")
63 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
64 "sox -v .5 %s -t .au -u - > /dev/audio")
65 ("\\.au$" "cat %s > /dev/audio")
66 ("\\.midi?$" "playmidi -f")
68 ("\\.ps$" "ghostview")
70 ("\\.html$" "xmosaic")
71 ("\\.mpe?g$" "mpeg_play")
72 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
73 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
75 "*Default actions to be taken when the user asks to view a file.
76 To change the behaviour, you can either edit this variable or set
77 `gnus-uu-user-view-rules' to something useful.
81 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
82 following in your .emacs file:
84 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
86 Both these variables are lists of lists with two string elements. The
87 first string is a regular expression. If the file name matches this
88 regular expression, the command in the second string is executed with
89 the file as an argument.
91 If the command string contains \"%s\", the file name will be inserted
92 at that point in the command string. If there's no \"%s\" in the
93 command string, the file name will be appended to the command string
96 There are several user variables to tailor the behaviour of gnus-uu to
97 your needs. First we have `gnus-uu-user-view-rules', which is the
98 variable gnus-uu first consults when trying to decide how to view a
99 file. If this variable contains no matches, gnus-uu examines the
100 default rule variable provided in this package. If gnus-uu finds no
101 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
103 :group 'gnus-extract-view
104 :type '(repeat (group regexp (string :tag "Command"))))
106 (defcustom gnus-uu-user-view-rules nil
107 "What actions are to be taken to view a file.
108 See the documentation on the `gnus-uu-default-view-rules' variable for
110 :group 'gnus-extract-view
111 :type '(repeat (group regexp (string :tag "Command"))))
113 (defcustom gnus-uu-user-view-rules-end
115 "*What actions are to be taken if no rule matched the file name.
116 See the documentation on the `gnus-uu-default-view-rules' variable for
118 :group 'gnus-extract-view
119 :type '(repeat (group regexp (string :tag "Command"))))
121 ;; Default unpacking commands
123 (defcustom gnus-uu-default-archive-rules
124 '(("\\.tar$" "tar xf")
125 ("\\.zip$" "unzip -o")
127 ("\\.arj$" "unarj x")
129 ("\\.\\(lzh\\|lha\\)$" "lha x")
130 ("\\.Z$" "uncompress")
132 ("\\.arc$" "arc -x"))
133 "*See `gnus-uu-user-archive-rules'."
134 :group 'gnus-extract-archive
135 :type '(repeat (group regexp (string :tag "Command"))))
137 (defvar gnus-uu-destructive-archivers
138 (list "uncompress" "gunzip"))
140 (defcustom gnus-uu-user-archive-rules nil
141 "A list that can be set to override the default archive unpacking commands.
142 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
143 unpack zip files, say the following:
144 (setq gnus-uu-user-archive-rules
145 '((\"\\\\.tar$\" \"untar\")
146 (\"\\\\.zip$\" \"zip -x\")))"
147 :group 'gnus-extract-archive
148 :type '(repeat (group regexp (string :tag "Command"))))
150 (defcustom gnus-uu-ignore-files-by-name nil
151 "*A regular expression saying what files should not be viewed based on name.
152 If, for instance, you want gnus-uu to ignore all .au and .wav files,
153 you could say something like
155 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
157 Note that this variable can be used in conjunction with the
158 `gnus-uu-ignore-files-by-type' variable."
160 :type '(choice (const :tag "off" nil)
161 (regexp :format "%v")))
163 (defcustom gnus-uu-ignore-files-by-type nil
164 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
165 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
166 you could say something like
168 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
170 Note that this variable can be used in conjunction with the
171 `gnus-uu-ignore-files-by-name' variable."
173 :type '(choice (const :tag "off" nil)
174 (regexp :format "%v")))
176 ;; Pseudo-MIME support
178 (defconst gnus-uu-ext-to-mime-list
179 '(("\\.gif$" "image/gif")
180 ("\\.jpe?g$" "image/jpeg")
181 ("\\.tiff?$" "image/tiff")
182 ("\\.xwd$" "image/xwd")
183 ("\\.pbm$" "image/pbm")
184 ("\\.pgm$" "image/pgm")
185 ("\\.ppm$" "image/ppm")
186 ("\\.xbm$" "image/xbm")
187 ("\\.pcx$" "image/pcx")
188 ("\\.tga$" "image/tga")
189 ("\\.ps$" "image/postscript")
190 ("\\.fli$" "video/fli")
191 ("\\.wav$" "audio/wav")
192 ("\\.aiff$" "audio/aiff")
193 ("\\.hcom$" "audio/hcom")
194 ("\\.voc$" "audio/voc")
195 ("\\.smp$" "audio/smp")
196 ("\\.mod$" "audio/mod")
197 ("\\.dvi$" "image/dvi")
198 ("\\.mpe?g$" "video/mpeg")
199 ("\\.au$" "audio/basic")
200 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
201 ("\\.\\(c\\|h\\)$" "text/source")
202 ("read.*me" "text/plain")
203 ("\\.html$" "text/html")
204 ("\\.bat$" "text/bat")
205 ("\\.[1-6]$" "text/man")
206 ("\\.flc$" "video/flc")
207 ("\\.rle$" "video/rle")
208 ("\\.pfx$" "video/pfx")
209 ("\\.avi$" "video/avi")
210 ("\\.sme$" "video/sme")
211 ("\\.rpza$" "video/prza")
212 ("\\.dl$" "video/dl")
213 ("\\.qt$" "video/qt")
214 ("\\.rsrc$" "video/rsrc")
215 ("\\..*$" "unknown/unknown")))
217 ;; Various variables users may set
219 (defcustom gnus-uu-tmp-dir
220 (cond ((fboundp 'temp-directory) (temp-directory))
221 ((boundp 'temporary-file-directory) temporary-file-directory)
223 "*Variable saying where gnus-uu is to do its work.
224 Default is \"/tmp/\"."
228 (defcustom gnus-uu-do-not-unpack-archives nil
229 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
231 :group 'gnus-extract-archive
234 (defcustom gnus-uu-ignore-default-view-rules nil
235 "*Non-nil means that gnus-uu will ignore the default viewing rules.
236 Only the user viewing rules will be consulted. Default is nil."
237 :group 'gnus-extract-view
240 (defcustom gnus-uu-grabbed-file-functions nil
241 "Functions run on each file after successful decoding.
242 They will be called with the name of the file as the argument.
243 Likely functions you can use in this list are `gnus-uu-grab-view'
244 and `gnus-uu-grab-move'."
246 :options '(gnus-uu-grab-view gnus-uu-grab-move)
249 (defcustom gnus-uu-ignore-default-archive-rules nil
250 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
251 Only the user unpacking commands will be consulted. Default is nil."
252 :group 'gnus-extract-archive
255 (defcustom gnus-uu-kill-carriage-return t
256 "*Non-nil means that gnus-uu will strip all carriage returns from articles.
261 (defcustom gnus-uu-view-with-metamail nil
262 "*Non-nil means that files will be viewed with metamail.
263 The gnus-uu viewing functions will be ignored and gnus-uu will try
264 to guess at a content-type based on file name suffixes. Default
269 (defcustom gnus-uu-unmark-articles-not-decoded nil
270 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
275 (defcustom gnus-uu-correct-stripped-uucode nil
276 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
281 (defcustom gnus-uu-save-in-digest nil
282 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
283 If this variable is nil, gnus-uu will just save everything in a
284 file without any embellishments. The digesting almost conforms to RFC1153 -
285 no easy way to specify any meaningful volume and issue numbers were found,
286 so I simply dropped them."
290 (defcustom gnus-uu-pre-uudecode-hook nil
291 "Hook run before sending a message to uudecode."
295 (defcustom gnus-uu-digest-headers
296 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
297 "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
298 "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
299 "^Content-ID:" "^User-Agent:" "^X-Face:")
300 "*List of regexps to match headers included in digested messages.
301 The headers will be included in the sequence they are matched. If nil
302 include all headers."
304 :type '(repeat regexp))
306 (defcustom gnus-uu-save-separate-articles nil
307 "*Non-nil means that gnus-uu will save articles in separate files."
311 (defcustom gnus-uu-be-dangerous 'ask
312 "*Specifies what to do if unusual situations arise during decoding.
313 If nil, be as conservative as possible. If t, ignore things that
314 didn't work, and overwrite existing files. Otherwise, ask each time."
316 :type '(choice (const :tag "conservative" nil)
317 (const :tag "ask" ask)
318 (const :tag "liberal" t)))
320 ;; Internal variables
322 (defvar gnus-uu-saved-article-name nil)
324 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
325 (defvar gnus-uu-end-string "^end[ \t]*$")
327 (defvar gnus-uu-body-line "^M")
329 (while (> (setq i (1- i)) 0)
330 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
331 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
333 ;"^M.............................................................?$"
335 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
337 (defvar gnus-uu-shar-file-name nil)
338 (defvar gnus-uu-shar-name-marker
339 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
341 (defvar gnus-uu-postscript-begin-string "^%!PS-")
342 (defvar gnus-uu-postscript-end-string "^%%EOF$")
344 (defvar gnus-uu-file-name nil)
345 (defvar gnus-uu-uudecode-process nil)
346 (defvar gnus-uu-binhex-article-name nil)
348 (defvar gnus-uu-work-dir nil)
350 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
352 (defvar gnus-uu-default-dir gnus-article-save-directory)
353 (defvar gnus-uu-digest-from-subject nil)
354 (defvar gnus-uu-digest-buffer nil)
358 (defun gnus-uu-decode-uu (&optional n)
359 "Uudecodes the current article."
361 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
363 (defun gnus-uu-decode-uu-and-save (n dir)
364 "Decodes and saves the resulting file."
366 (list current-prefix-arg
367 (file-name-as-directory
368 (read-file-name "Uudecode and save in dir: "
370 gnus-uu-default-dir t))))
371 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
373 (defun gnus-uu-decode-unshar (&optional n)
374 "Unshars the current article."
376 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
378 (defun gnus-uu-decode-unshar-and-save (n dir)
379 "Unshars and saves the current article."
381 (list current-prefix-arg
382 (file-name-as-directory
383 (read-file-name "Unshar and save in dir: "
385 gnus-uu-default-dir t))))
386 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
388 (defun gnus-uu-decode-save (n file)
389 "Saves the current article."
391 (list current-prefix-arg
393 (if gnus-uu-save-separate-articles
394 "Save articles is dir: "
395 "Save articles in file: ")
397 gnus-uu-default-dir)))
398 (setq gnus-uu-saved-article-name file)
399 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
401 (defun gnus-uu-decode-binhex (n dir)
402 "Unbinhexes the current article."
404 (list current-prefix-arg
405 (file-name-as-directory
406 (read-file-name "Unbinhex and save in dir: "
408 gnus-uu-default-dir))))
409 (setq gnus-uu-binhex-article-name
410 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
411 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
413 (defun gnus-uu-decode-uu-view (&optional n)
414 "Uudecodes and views the current article."
416 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
417 (gnus-uu-decode-uu n)))
419 (defun gnus-uu-decode-uu-and-save-view (n dir)
420 "Decodes, views and saves the resulting file."
422 (list current-prefix-arg
423 (read-file-name "Uudecode, view and save in dir: "
425 gnus-uu-default-dir t)))
426 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
427 (gnus-uu-decode-uu-and-save n dir)))
429 (defun gnus-uu-decode-unshar-view (&optional n)
430 "Unshars and views the current article."
432 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
433 (gnus-uu-decode-unshar n)))
435 (defun gnus-uu-decode-unshar-and-save-view (n dir)
436 "Unshars and saves the current article."
438 (list current-prefix-arg
439 (read-file-name "Unshar, view and save in dir: "
441 gnus-uu-default-dir t)))
442 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
443 (gnus-uu-decode-unshar-and-save n dir)))
445 (defun gnus-uu-decode-save-view (n file)
446 "Saves and views the current article."
448 (list current-prefix-arg
449 (read-file-name (if gnus-uu-save-separate-articles
450 "Save articles is dir: "
451 "Save articles in file: ")
452 gnus-uu-default-dir gnus-uu-default-dir)))
453 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
454 (gnus-uu-decode-save n file)))
456 (defun gnus-uu-decode-binhex-view (n file)
457 "Unbinhexes and views the current article."
459 (list current-prefix-arg
460 (read-file-name "Unbinhex, view and save in dir: "
461 gnus-uu-default-dir gnus-uu-default-dir)))
462 (setq gnus-uu-binhex-article-name
463 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
464 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
465 (gnus-uu-decode-binhex n file)))
468 ;; Digest and forward articles
470 (defun gnus-uu-digest-mail-forward (&optional n post)
471 "Digests and forwards all articles in this series."
473 (let ((gnus-uu-save-in-digest t)
474 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
475 (message-forward-as-mime message-forward-as-mime)
476 (mail-parse-charset gnus-newsgroup-charset)
477 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
478 gnus-uu-digest-buffer subject from)
479 (if (and n (not (numberp n)))
480 (setq message-forward-as-mime (not message-forward-as-mime)
482 (let ((gnus-article-reply (gnus-summary-work-articles n))
483 gnus-newsgroup-processable)
485 (= (length gnus-article-reply) 1))
486 ;; The case where neither a number of articles nor a region is
488 (gnus-summary-top-thread)
489 (setq gnus-article-reply (gnus-uu-get-list-of-articles nil)))
490 ;; Specify articles to be forwarded.
491 (setq gnus-newsgroup-processable (copy-sequence gnus-article-reply))
492 (gnus-setup-message 'forward
493 (setq gnus-uu-digest-from-subject nil)
494 (setq gnus-uu-digest-buffer
495 (gnus-get-buffer-create " *gnus-uu-forward*"))
496 (gnus-uu-decode-save n file)
497 (switch-to-buffer gnus-uu-digest-buffer)
498 (let ((fs gnus-uu-digest-from-subject))
501 subject (gnus-simplify-subject-fuzzy (cdar fs))
503 (while (and fs (or from subject))
505 (unless (string= from (caar fs))
508 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
513 (setq subject "Digested Articles"))
516 (if (gnus-news-group-p gnus-newsgroup-name)
519 (goto-char (point-min))
520 (when (re-search-forward "^Subject: ")
521 (delete-region (point) (point-at-eol))
523 (goto-char (point-min))
524 (when (re-search-forward "^From:")
525 (delete-region (point) (point-at-eol))
527 (let ((message-forward-decoded-p t))
528 (message-forward post))))
529 (setq gnus-uu-digest-from-subject nil)))
531 (defun gnus-uu-digest-post-forward (&optional n)
532 "Digest and forward to a newsgroup."
534 (gnus-uu-digest-mail-forward n t))
538 (defun gnus-message-process-mark (unmarkp new-marked)
539 (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
540 (message "%d mark%s %s%s"
542 (if (= (length new-marked) 1) "" "s")
543 (if unmarkp "removed" "added")
549 (format ", %d remain marked"
550 (length gnus-newsgroup-processable)))
552 (format ", %d already marked" old))))))
554 (defun gnus-new-processable (unmarkp articles)
556 (gnus-intersection gnus-newsgroup-processable articles)
557 (gnus-set-difference articles gnus-newsgroup-processable)))
559 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
560 "Set the process mark on articles whose subjects match REGEXP.
561 When called interactively, prompt for REGEXP.
562 Optional UNMARK non-nil means unmark instead of mark."
563 (interactive "sMark (regexp): \nP")
565 (let* ((articles (gnus-uu-find-articles-matching regexp))
566 (new-marked (gnus-new-processable unmark articles)))
569 (gnus-summary-remove-process-mark (pop articles))
570 (gnus-summary-set-process-mark (pop articles))))
571 (gnus-message-process-mark unmark new-marked)))
572 (gnus-summary-position-point))
574 (defun gnus-uu-unmark-by-regexp (regexp)
575 "Remove the process mark from articles whose subjects match REGEXP.
576 When called interactively, prompt for REGEXP."
577 (interactive "sUnmark (regexp): ")
578 (gnus-uu-mark-by-regexp regexp t))
580 (defun gnus-uu-mark-series ()
581 "Mark the current series with the process mark."
583 (let* ((articles (gnus-uu-find-articles-matching))
584 (l (length articles)))
586 (gnus-summary-set-process-mark (car articles))
587 (setq articles (cdr articles)))
588 (message "Marked %d articles" l))
589 (gnus-summary-position-point))
591 (defun gnus-uu-mark-region (beg end &optional unmark)
592 "Set the process mark on all articles between point and mark."
596 (while (< (point) end)
598 (gnus-summary-remove-process-mark (gnus-summary-article-number))
599 (gnus-summary-set-process-mark (gnus-summary-article-number)))
601 (gnus-summary-position-point))
603 (defun gnus-uu-unmark-region (beg end)
604 "Remove the process mark from all articles between point and mark."
606 (gnus-uu-mark-region beg end t))
608 (defun gnus-uu-mark-buffer ()
609 "Set the process mark on all articles in the buffer."
611 (gnus-uu-mark-region (point-min) (point-max)))
613 (defun gnus-uu-unmark-buffer ()
614 "Remove the process mark on all articles in the buffer."
616 (gnus-uu-mark-region (point-min) (point-max) t))
618 (defun gnus-uu-mark-thread ()
619 "Marks all articles downwards in this thread."
621 (gnus-save-hidden-threads
622 (let ((level (gnus-summary-thread-level)))
623 (while (and (gnus-summary-set-process-mark
624 (gnus-summary-article-number))
625 (zerop (gnus-summary-next-subject 1 nil t))
626 (> (gnus-summary-thread-level) level)))))
627 (gnus-summary-position-point))
629 (defun gnus-uu-unmark-thread ()
630 "Unmarks all articles downwards in this thread."
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))
639 (defun gnus-uu-invert-processable ()
640 "Invert the list of process-marked articles."
642 (let ((data gnus-newsgroup-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))
652 (defun gnus-uu-mark-over (&optional score)
653 "Mark all articles with a score over SCORE (the prefix)."
655 (let ((score (or score gnus-summary-default-score 0))
656 (data gnus-newsgroup-data))
659 (when (> (or (cdr (assq (gnus-data-number (car data))
660 gnus-newsgroup-scored))
661 gnus-summary-default-score 0)
663 (gnus-summary-set-process-mark (caar data)))
664 (setq data (cdr data))))
665 (gnus-summary-position-point)))
667 (defun gnus-uu-mark-sparse ()
668 "Mark all series that have some articles marked."
670 (let ((marked (nreverse gnus-newsgroup-processable))
671 subject articles total headers)
673 (error "No articles marked with the process mark"))
674 (setq gnus-newsgroup-processable nil)
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)))
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)))
691 (defun gnus-uu-mark-all ()
692 "Mark all articles in \"series\" order."
694 (setq gnus-newsgroup-processable nil)
696 (let ((data gnus-newsgroup-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))
707 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
709 (defun gnus-uu-decode-postscript (&optional n)
710 "Gets postscript of the current article."
712 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
714 (defun gnus-uu-decode-postscript-view (&optional n)
715 "Gets and views the current article."
717 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
718 (gnus-uu-decode-postscript n)))
720 (defun gnus-uu-decode-postscript-and-save (n dir)
721 "Extracts postscript and saves the current article."
723 (list current-prefix-arg
724 (file-name-as-directory
725 (read-file-name "Save in dir: "
727 gnus-uu-default-dir t))))
728 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
731 (defun gnus-uu-decode-postscript-and-save-view (n dir)
732 "Decodes, views and saves the resulting file."
734 (list current-prefix-arg
735 (read-file-name "Where do you want to save the file(s)? "
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)))
742 ;; Internal functions.
744 (defun gnus-uu-decode-with-method (method n &optional save not-insert
746 (gnus-uu-initialize scan)
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))
755 (setq files (gnus-uu-grab-articles articles method t))
756 (let ((gnus-current-article (car articles)))
758 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
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))))
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))
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))
776 (when (file-directory-p file)
777 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
782 (defun gnus-uu-save-files (files 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? "
799 (copy-file file to-file t t)))))
800 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
802 ;; Functions for saving and possibly digesting articles without
805 ;; Function called by gnus-uu-grab-articles to treat each article.
806 (defun gnus-uu-save-article (buffer in-state)
808 (gnus-uu-save-separate-articles
811 (gnus-write-buffer-as-coding-system
812 nnheader-text-coding-system
813 (concat gnus-uu-saved-article-name gnus-current-article))
814 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
815 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
817 ((eq in-state 'last) (list 'end))
818 (t (list 'middle)))))
819 ((not gnus-uu-save-in-digest)
822 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
823 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
824 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
826 ((eq in-state 'last) (list 'end))
827 (t (list 'middle)))))
829 (let ((header (gnus-summary-article-header)))
830 (push (cons (mail-header-from header)
831 (mail-header-subject header))
832 gnus-uu-digest-from-subject))
833 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
834 beg subj headers headline sorthead body end-string state)
835 (if (or (eq in-state 'first)
836 (eq in-state 'first-and-last))
838 (setq state (list 'begin))
840 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
843 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
846 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
847 (current-time-string) name name))
848 (insert "Topics:\n")))
849 (when (not (eq in-state 'end))
850 (setq state (list 'middle))))
852 (set-buffer "*gnus-uu-body*")
853 (goto-char (setq beg (point-max)))
857 (let (buffer-read-only)
858 (set-text-properties (point-min) (point-max) nil)
859 ;; These two are necessary for XEmacs 19.12 fascism.
860 (put-text-property (point-min) (point-max) 'invisible nil)
861 (put-text-property (point-min) (point-max) 'intangible nil))
862 (goto-char (point-min))
863 (search-forward "\n\n")
864 (unless gnus-uu-digest-buffer
865 ;; Quote all 30-dash lines.
867 (while (re-search-forward "^-" nil t)
871 (setq body (buffer-substring (1- (point)) (point-max)))
872 (narrow-to-region (point-min) (point))
873 (if (not (setq headers gnus-uu-digest-headers))
874 (setq sorthead (buffer-string))
876 (setq headline (car headers))
877 (setq headers (cdr headers))
878 (goto-char (point-min))
879 (while (re-search-forward headline nil t)
884 (or (and (re-search-forward "^[^ \t]" nil t)
886 (progn (forward-line 1) (point)))))))))
888 (insert message-forward-start-separator)
889 (insert sorthead) (goto-char (point-max))
890 (insert body) (goto-char (point-max))
892 (when (re-search-forward "^Subject:" nil t)
893 (setq subj (nnheader-decode-subject
894 (buffer-substring (match-end 0) (std11-field-end)))))
897 (set-buffer "*gnus-uu-pre*")
898 (insert (format " %s\n" subj)))))
899 (when (or (eq in-state 'last)
900 (eq in-state 'first-and-last))
901 (if gnus-uu-digest-buffer
902 (with-current-buffer gnus-uu-digest-buffer
904 (insert-buffer "*gnus-uu-pre*")
905 (goto-char (point-max))
906 (insert-buffer "*gnus-uu-body*"))
908 (set-buffer "*gnus-uu-pre*")
909 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
910 (if gnus-uu-digest-buffer
911 (with-current-buffer gnus-uu-digest-buffer
913 (insert-buffer "*gnus-uu-pre*"))
914 (gnus-write-buffer-as-coding-system
915 nnheader-text-coding-system gnus-uu-saved-article-name)))
917 (set-buffer "*gnus-uu-body*")
918 (goto-char (point-max))
920 (concat (setq end-string (format "End of %s Digest" name))
922 (insert (concat (make-string (length end-string) ?*) "\n"))
923 (if gnus-uu-digest-buffer
924 (with-current-buffer gnus-uu-digest-buffer
925 (goto-char (point-max))
926 (insert-buffer "*gnus-uu-body*"))
927 (let ((file-name-coding-system nnmail-pathname-coding-system))
928 (write-region-as-coding-system
929 nnheader-text-coding-system
930 (point-min) (point-max) gnus-uu-saved-article-name t)))))
931 (gnus-kill-buffer "*gnus-uu-pre*")
932 (gnus-kill-buffer "*gnus-uu-body*")
934 (if (memq 'begin state)
935 (cons gnus-uu-saved-article-name state)
938 ;; Binhex treatment - not very advanced.
940 (defvar gnus-uu-binhex-body-line
941 "^[^:]...............................................................$")
942 (defvar gnus-uu-binhex-begin-line
943 "^:...............................................................$")
944 (defvar gnus-uu-binhex-end-line
947 (defun gnus-uu-binhex-article (buffer in-state)
948 (let (state start-char)
952 (goto-char (point-min))
953 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
954 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
955 (setq state (list 'wrong-type))))
957 (if (memq 'wrong-type state)
960 (setq start-char (point))
961 (if (looking-at gnus-uu-binhex-begin-line)
963 (setq state (list 'begin))
964 (write-region (point-min) (point-min)
965 gnus-uu-binhex-article-name))
966 (setq state (list 'middle)))
967 (goto-char (point-max))
968 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
969 gnus-uu-binhex-end-line)
971 (when (looking-at gnus-uu-binhex-end-line)
972 (setq state (if (memq 'begin state)
977 (when (file-exists-p gnus-uu-binhex-article-name)
978 (write-region-as-binary start-char (point)
979 gnus-uu-binhex-article-name 'append))))
980 (if (memq 'begin state)
981 (cons gnus-uu-binhex-article-name state)
986 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
987 (let ((state (list 'ok))
988 start-char end-char file-name)
990 (set-buffer process-buffer)
991 (goto-char (point-min))
992 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
993 (setq state (list 'wrong-type))
995 (setq start-char (point))
996 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
997 (setq state (list 'wrong-type))
998 (setq end-char (point))
999 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1000 (insert-buffer-substring process-buffer start-char end-char)
1001 (setq file-name (concat gnus-uu-work-dir
1002 (cdr gnus-article-current) ".ps"))
1003 (write-region (point-min) (point-max) file-name)
1004 (setq state (list file-name 'begin 'end)))))
1010 (defun gnus-uu-get-actions (files)
1011 (let ((ofiles files)
1014 (setq name (cdr (assq 'name (car files))))
1016 (setq action (gnus-uu-get-action name))
1017 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1018 (cons 'action "file")
1019 (cons 'action action))
1020 (cons 'execute (gnus-uu-command
1023 (setq files (cdr files)))
1026 (defun gnus-uu-get-action (file-name)
1029 (gnus-uu-choose-action
1032 gnus-uu-user-view-rules
1033 (if gnus-uu-ignore-default-view-rules
1035 gnus-uu-default-view-rules)
1036 gnus-uu-user-view-rules-end)))
1037 (when (and (not (string= (or action "") "gnus-uu-archive"))
1038 gnus-uu-view-with-metamail)
1040 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1041 (setq action (format "metamail -d -b -c \"%s\"" action))))
1045 ;; Functions for treating subjects and collecting series.
1047 (defun gnus-uu-reginize-string (string)
1048 ;; Takes a string and puts a \ in front of every special character;
1049 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1050 ;; or, if it can't find something like that, tries "2 of 3", then
1051 ;; finally just replaces the next to last number with "[0-9]+".
1053 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1054 (buffer-disable-undo)
1056 (insert (regexp-quote string))
1058 (setq case-fold-search nil)
1061 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1062 (replace-match "\\1[0-9]+/\\2")
1065 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1067 (replace-match "\\1[0-9]+ of \\2")
1070 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1072 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1075 (while (re-search-forward "[ \t]+" nil t)
1076 (replace-match "[ \t]+" t t))
1080 (defun gnus-uu-get-list-of-articles (n)
1081 ;; If N is non-nil, the article numbers of the N next articles
1082 ;; will be returned.
1083 ;; If any articles have been marked as processable, they will be
1085 ;; Failing that, articles that have subjects that are part of the
1086 ;; same "series" as the current will be returned.
1090 (setq n (prefix-numeric-value n))
1091 (let ((backward (< n 0))
1095 (push (gnus-summary-article-number)
1097 (gnus-summary-search-forward nil nil backward))
1099 (nreverse articles)))
1100 (gnus-newsgroup-processable
1101 (reverse gnus-newsgroup-processable))
1103 (gnus-uu-find-articles-matching)))))
1105 (defun gnus-uu-string< (l1 l2)
1106 (string< (car l1) (car l2)))
1108 (defun gnus-uu-find-articles-matching
1109 (&optional subject only-unread do-not-translate)
1110 ;; Finds all articles that matches the regexp SUBJECT. If it is
1111 ;; nil, the current article name will be used. If ONLY-UNREAD is
1112 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1113 ;; non-nil, article names are not equalized before sorting.
1114 (let ((subject (or subject
1115 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1119 ;; Collect all subjects matching subject.
1120 (let ((case-fold-search t)
1121 (data gnus-newsgroup-data)
1125 (and (not (gnus-data-pseudo-p d))
1126 (or (not only-unread)
1127 (= (setq mark (gnus-data-mark d))
1129 (= mark gnus-ticked-mark)
1130 (= mark gnus-dormant-mark))
1131 (setq subj (mail-header-subject (gnus-data-header d)))
1132 (string-match subject subj)
1133 (push (cons subj (gnus-data-number d))
1134 list-of-subjects))))
1136 ;; Expand numbers, sort, and return the list of article
1139 (sort (gnus-uu-expand-numbers
1141 (not do-not-translate))
1142 'gnus-uu-string<))))))
1144 (defun gnus-uu-expand-numbers (string-list &optional translate)
1145 ;; Takes a list of strings and "expands" all numbers in all the
1146 ;; strings. That is, this function makes all numbers equal length by
1147 ;; prepending lots of zeroes before each number. This is to ease later
1148 ;; sorting to find out what sequence the articles are supposed to be
1149 ;; decoded in. Returns the list of expanded strings.
1150 (let ((out-list string-list)
1153 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1154 (buffer-disable-undo)
1157 (insert (caar string-list))
1158 ;; Translate multiple spaces to one space.
1159 (goto-char (point-min))
1160 (while (re-search-forward "[ \t]+" nil t)
1161 (replace-match " "))
1162 ;; Translate all characters to "a".
1163 (goto-char (point-min))
1165 (while (re-search-forward "[A-Za-z]" nil t)
1166 (replace-match "a" t t)))
1168 (goto-char (point-min))
1169 (while (re-search-forward "[0-9]+" nil t)
1173 (string-to-number (buffer-substring
1174 (match-beginning 0) (match-end 0)))))))
1175 (setq string (buffer-substring 1 (point-max)))
1176 (setcar (car string-list) string)
1177 (setq string-list (cdr string-list))))
1181 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1182 ;; function. It takes a list of articles to be grabbed and a function
1183 ;; to apply to each article.
1185 ;; The function to be called should take two parameters. The first
1186 ;; parameter is the article buffer. The function should leave the
1187 ;; result, if any, in this buffer. Most treatment functions will just
1188 ;; generate files...
1190 ;; The second parameter is the state of the list of articles, and can
1191 ;; have four values: `first', `middle', `last' and `first-and-last'.
1193 ;; The function should return a list. The list may contain the
1194 ;; following symbols:
1195 ;; `error' if an error occurred
1196 ;; `begin' if the beginning of an encoded file has been received
1197 ;; If the list returned contains a `begin', the first element of
1198 ;; the list *must* be a string with the file name of the decoded
1200 ;; `end' if the end of an encoded file has been received
1201 ;; `middle' if the article was a body part of an encoded file
1202 ;; `wrong-type' if the article was not a part of an encoded file
1203 ;; `ok', which can be used everything is ok
1205 (defvar gnus-uu-has-been-grabbed nil)
1207 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1209 (if (not (and gnus-uu-has-been-grabbed
1210 gnus-uu-unmark-articles-not-decoded))
1212 (when dont-unmark-last-article
1213 (setq art (car gnus-uu-has-been-grabbed))
1214 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1215 (while gnus-uu-has-been-grabbed
1216 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1217 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1218 (when dont-unmark-last-article
1219 (setq gnus-uu-has-been-grabbed (list art))))))
1221 ;; This function takes a list of articles and a function to apply to
1222 ;; each article grabbed.
1224 ;; This function returns a list of files decoded if the grabbing and
1225 ;; the process-function has been successful and nil otherwise.
1226 (defun gnus-uu-grab-articles (articles process-function
1227 &optional sloppy limit no-errors)
1228 (let ((state 'first)
1229 (gnus-asynchronous nil)
1230 (gnus-inhibit-treatment t)
1231 has-been-begin article result-file result-files process-state
1232 gnus-summary-display-article-function
1233 gnus-article-prepare-hook gnus-display-mime-function
1234 article-series files)
1236 (while (and articles
1237 (not (memq 'error process-state))
1239 (not (memq 'end process-state))))
1241 (setq article (pop articles))
1242 (when (vectorp (gnus-summary-article-header article))
1243 (push article article-series)
1246 (if (eq state 'first)
1247 (setq state 'first-and-last)
1248 (setq state 'last)))
1250 (let ((part (gnus-uu-part-number article)))
1251 (gnus-message 6 "Getting article %d%s..."
1252 article (if (string= part "") "" (concat ", " part))))
1253 (gnus-summary-display-article article)
1255 ;; Push the article to the processing function.
1257 (set-buffer gnus-original-article-buffer)
1258 (let ((buffer-read-only nil))
1260 (set-buffer gnus-summary-buffer)
1262 (funcall process-function
1263 gnus-original-article-buffer state)))))
1265 (gnus-summary-remove-process-mark article)
1267 ;; If this is the beginning of a decoded file, we push it
1269 (when (or (memq 'begin process-state)
1270 (and (or (eq state 'first)
1271 (eq state 'first-and-last))
1272 (memq 'ok process-state)))
1273 (when has-been-begin
1274 ;; If there is a `result-file' here, that means that the
1275 ;; file was unsuccessfully decoded, so we delete it.
1276 (when (and result-file
1277 (file-exists-p result-file)
1278 (not gnus-uu-be-dangerous)
1279 (or (eq gnus-uu-be-dangerous t)
1281 (format "Delete unsuccessfully decoded file %s"
1283 (delete-file result-file)))
1284 (when (memq 'begin process-state)
1285 (setq result-file (car process-state)))
1286 (setq has-been-begin t))
1288 ;; Check whether we have decoded one complete file.
1289 (when (memq 'end process-state)
1290 (setq article-series nil)
1291 (setq has-been-begin nil)
1292 (if (stringp result-file)
1293 (setq files (list result-file))
1294 (setq files result-file))
1295 (setq result-file (car files))
1297 (push (list (cons 'name (pop files))
1298 (cons 'article article))
1300 ;; Allow user-defined functions to be run on this file.
1301 (when gnus-uu-grabbed-file-functions
1302 (let ((funcs gnus-uu-grabbed-file-functions))
1303 (unless (listp funcs)
1304 (setq funcs (list funcs)))
1306 (funcall (pop funcs) result-file))))
1307 (setq result-file nil)
1308 ;; Check whether we have decoded enough articles.
1309 (and limit (= (length result-files) limit)
1310 (setq articles nil)))
1312 ;; If this is the last article to be decoded, and
1313 ;; we still haven't reached the end, then we delete
1314 ;; the partially decoded file.
1315 (and (or (eq state 'last) (eq state 'first-and-last))
1316 (not (memq 'end process-state))
1318 (file-exists-p result-file)
1319 (not gnus-uu-be-dangerous)
1320 (or (eq gnus-uu-be-dangerous t)
1322 (format "Delete incomplete file %s? " result-file)))
1323 (delete-file result-file))
1325 ;; If this was a file of the wrong sort, then
1326 (when (and (or (memq 'wrong-type process-state)
1327 (memq 'error process-state))
1328 gnus-uu-unmark-articles-not-decoded)
1329 (gnus-summary-tick-article article t))
1331 ;; Set the new series state.
1332 (if (and (not has-been-begin)
1334 (or (memq 'end process-state)
1335 (memq 'middle process-state)))
1337 (setq process-state (list 'error))
1338 (gnus-message 2 "No begin part at the beginning")
1340 (setq state 'middle))))
1342 ;; When there are no result-files, then something must be wrong.
1346 ((not has-been-begin)
1347 (gnus-message 2 "Wrong type file"))
1348 ((memq 'error process-state)
1349 (gnus-message 2 "An error occurred during decoding"))
1350 ((not (or (memq 'ok process-state)
1351 (memq 'end process-state)))
1352 (gnus-message 2 "End of articles reached before end of file")))
1353 ;; Make unsuccessfully decoded articles unread.
1354 (when gnus-uu-unmark-articles-not-decoded
1355 (while article-series
1356 (gnus-summary-tick-article (pop article-series) t))))
1358 ;; The original article buffer is hosed, shoot it down.
1359 (gnus-kill-buffer gnus-original-article-buffer)
1360 (setq gnus-current-article nil)
1363 (defun gnus-uu-grab-view (file)
1364 "View FILE using the gnus-uu methods."
1365 (let ((action (gnus-uu-get-action file)))
1366 (gnus-execute-command
1367 (if (string-match "%" action)
1368 (format action file)
1369 (concat action " " file))
1370 (eq gnus-view-pseudos 'not-confirm))))
1372 (defun gnus-uu-grab-move (file)
1373 "Move FILE to somewhere."
1374 (when gnus-uu-default-dir
1375 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1376 (file-name-nondirectory file))))
1377 (cond ((fboundp 'make-symbolic-link)
1378 (rename-file file to-file)
1379 (unless (file-exists-p file)
1380 (make-symbolic-link to-file file)))
1382 (copy-file file to-file))))))
1384 (defun gnus-uu-part-number (article)
1385 (let* ((header (gnus-summary-article-header article))
1386 (subject (and header (mail-header-subject header)))
1389 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1391 (setq part (match-string 0 subject))
1392 (setq subject (substring subject (match-end 0)))))
1394 (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
1395 (setq part (match-string 0 subject))
1396 (setq subject (substring subject (match-end 0)))))
1399 (defun gnus-uu-uudecode-sentinel (process event)
1400 (delete-process (get-process process)))
1402 (defun gnus-uu-uustrip-article (process-buffer in-state)
1403 ;; Uudecodes a file asynchronously.
1405 (set-buffer process-buffer)
1406 (let ((state (list 'wrong-type))
1407 process-connection-type case-fold-search buffer-read-only
1409 (goto-char (point-min))
1411 ;; Deal with ^M at the end of the lines.
1412 (when gnus-uu-kill-carriage-return
1414 (while (search-forward "\r" nil t)
1415 (delete-backward-char 1))))
1417 (while (or (re-search-forward gnus-uu-begin-string nil t)
1418 (re-search-forward gnus-uu-body-line nil t))
1419 (setq state (list 'ok))
1420 ;; Ok, we are at the first uucoded line.
1422 (setq start-char (point))
1424 (if (not (looking-at gnus-uu-begin-string))
1425 (setq state (list 'middle))
1426 ;; This is the beginning of a uuencoded article.
1427 ;; We replace certain characters that could make things messy.
1428 (setq gnus-uu-file-name
1429 (let ((nnheader-file-name-translation-alist
1430 '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
1431 (nnheader-translate-file-chars (match-string 1))))
1432 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1434 ;; Remove any non gnus-uu-body-line right after start.
1436 (while (and (not (eobp))
1437 (not (looking-at gnus-uu-body-line)))
1440 ;; If a process is running, we kill it.
1441 (when (and gnus-uu-uudecode-process
1442 (memq (process-status gnus-uu-uudecode-process)
1444 (delete-process gnus-uu-uudecode-process)
1445 (gnus-uu-unmark-list-of-grabbed t))
1447 ;; Start a new uudecoding process.
1448 (let ((cdir default-directory))
1451 (cd gnus-uu-work-dir)
1452 (setq gnus-uu-uudecode-process
1455 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1456 shell-file-name shell-command-switch
1457 (format "cd %s %s uudecode" gnus-uu-work-dir
1458 gnus-shell-command-separator))))
1460 (set-process-sentinel
1461 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1462 (setq state (list 'begin))
1463 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1465 ;; We look for the end of the thing to be decoded.
1466 (if (re-search-forward gnus-uu-end-string nil t)
1468 (goto-char (point-max))
1469 (re-search-backward gnus-uu-body-line nil t))
1473 (when gnus-uu-uudecode-process
1474 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1475 ;; Try to correct mishandled uucode.
1476 (when gnus-uu-correct-stripped-uucode
1477 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1478 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1480 ;; Send the text to the process.
1482 (process-send-region
1483 gnus-uu-uudecode-process start-char (point))
1486 (delete-process gnus-uu-uudecode-process)
1487 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1488 (setq state (list 'wrong-type)))))
1490 (if (memq 'end state)
1492 ;; Send an EOF, just in case.
1494 (process-send-eof gnus-uu-uudecode-process))
1495 (while (memq (process-status gnus-uu-uudecode-process)
1497 (accept-process-output gnus-uu-uudecode-process 1)))
1498 (when (or (not gnus-uu-uudecode-process)
1499 (not (memq (process-status gnus-uu-uudecode-process)
1501 (setq state (list 'wrong-type)))))))
1503 (if (memq 'begin state)
1504 (cons (if (= (length files) 1) (car files) files) state)
1507 (defvar gnus-uu-unshar-warning
1510 Shell archives are an archaic method of bundling files for distribution
1511 across computer networks. During the unpacking process, arbitrary commands
1512 are executed on your system, and all kinds of nasty things can happen.
1513 Please examine the archive very carefully before you instruct Emacs to
1514 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1516 If you are unsure what to do, please answer \"no\"."
1517 "Text of warning message displayed by `gnus-uu-unshar-article'.
1518 Make sure that this text consists only of few text lines. Otherwise,
1519 Gnus might fail to display all of it.")
1522 ;; This function is used by `gnus-uu-grab-articles' to treat
1523 ;; a shared article.
1524 (defun gnus-uu-unshar-article (process-buffer in-state)
1525 (let ((state (list 'ok))
1528 (set-buffer process-buffer)
1529 (goto-char (point-min))
1530 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1531 (setq state (list 'wrong-type))
1532 (save-window-excursion
1534 (switch-to-buffer (current-buffer))
1535 (delete-other-windows)
1536 (let ((buffer (get-buffer-create (generate-new-buffer-name
1540 (with-current-buffer buffer
1541 (insert (substitute-command-keys
1542 gnus-uu-unshar-warning))
1543 (goto-char (point-min))
1544 (display-buffer buffer)
1545 (yes-or-no-p "This is a shell archive, unshar it? "))
1546 (kill-buffer buffer))
1547 (setq state (list 'error))))))
1548 (unless (memq 'error state)
1550 (setq start-char (point))
1551 (call-process-region
1552 start-char (point-max) shell-file-name nil
1553 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1554 shell-command-switch
1555 (concat "cd " gnus-uu-work-dir " "
1556 gnus-shell-command-separator " sh")))))
1559 ;; Returns the name of what the shar file is going to unpack.
1560 (defun gnus-uu-find-name-in-shar ()
1561 (let ((oldpoint (point))
1563 (goto-char (point-min))
1564 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1565 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1566 (goto-char oldpoint)
1569 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1570 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1571 ;; found, or the name of the command to run if such a rule is found.
1572 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1573 (let ((action-list (copy-sequence file-action-list))
1574 (case-fold-search t)
1579 (and gnus-uu-ignore-files-by-name
1580 (string-match gnus-uu-ignore-files-by-name file-name)))
1582 (and gnus-uu-ignore-files-by-type
1583 (string-match gnus-uu-ignore-files-by-type
1584 (or (gnus-uu-choose-action
1585 file-name gnus-uu-ext-to-mime-list t)
1587 (while (not (or (eq action-list ()) action))
1588 (setq rule (car action-list))
1589 (setq action-list (cdr action-list))
1590 (when (string-match (car rule) file-name)
1591 (setq action (cadr rule)))))
1594 (defun gnus-uu-treat-archive (file-path)
1595 ;; Unpacks an archive. Returns t if unpacking is successful.
1596 (let ((did-unpack t)
1598 (setq action (gnus-uu-choose-action
1599 file-path (append gnus-uu-user-archive-rules
1600 (if gnus-uu-ignore-default-archive-rules
1602 gnus-uu-default-archive-rules))))
1605 (error "No unpackers for the file %s" file-path))
1607 (string-match "/[^/]*$" file-path)
1608 (setq dir (substring file-path 0 (match-beginning 0)))
1610 (when (member action gnus-uu-destructive-archivers)
1611 (copy-file file-path (concat file-path "~") t))
1613 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1616 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1619 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1621 (if (eq 0 (call-process shell-file-name nil
1622 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1623 nil shell-command-switch command))
1625 (gnus-message 2 "Error during unpacking of archive")
1626 (setq did-unpack nil))
1628 (when (member action gnus-uu-destructive-archivers)
1629 (rename-file (concat file-path "~") file-path t))
1633 (defun gnus-uu-dir-files (dir)
1634 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1637 (if (file-directory-p (setq file (car dirs)))
1638 (setq files (append files (gnus-uu-dir-files file)))
1640 (setq dirs (cdr dirs)))
1643 (defun gnus-uu-unpack-files (files &optional ignore)
1644 ;; Go through FILES and look for files to unpack.
1645 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1649 (setq file (cdr (assq 'name (car files))))
1650 (when (and (not (member file ignore))
1651 (equal (gnus-uu-get-action (file-name-nondirectory file))
1653 (push file did-unpack)
1654 (unless (gnus-uu-treat-archive file)
1655 (gnus-message 2 "Error during unpacking of %s" file))
1656 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1659 (unless (member (car nfiles) totfiles)
1660 (push (list (cons 'name (car nfiles))
1661 (cons 'original file))
1663 (setq nfiles (cdr nfiles)))
1664 (setq totfiles newfiles)))
1665 (setq files (cdr files)))
1667 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1670 (defun gnus-uu-ls-r (dir)
1671 (let* ((files (gnus-uu-directory-files dir t))
1674 (when (file-directory-p (car files))
1675 (setq ofiles (delete (car files) ofiles))
1676 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1677 (setq files (cdr files)))
1682 (defun gnus-uu-directory-files (dir &optional full)
1683 (let (files out file)
1684 (setq files (directory-files dir full))
1686 (setq file (car files))
1687 (setq files (cdr files))
1688 (unless (member (file-name-nondirectory file) '("." ".."))
1690 (setq out (nreverse out))
1693 (defun gnus-uu-check-correct-stripped-uucode (start end)
1695 (let (found beg length)
1696 (unless gnus-uu-correct-stripped-uucode
1699 (if (re-search-forward " \\|`" end t)
1704 (when (looking-at "\n")
1709 (unless (looking-at (concat gnus-uu-begin-string "\\|"
1710 gnus-uu-end-string))
1712 (setq length (- (point-at-eol) (point-at-bol))))
1717 (unless (= length (- (point) beg))
1718 (insert (make-string (- length (- (point) beg)) ? ))))
1719 (forward-line 1)))))))
1721 (defvar gnus-uu-tmp-alist nil)
1723 (defun gnus-uu-initialize (&optional scan)
1726 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1727 (if (file-exists-p (cdr entry))
1728 (setq gnus-uu-work-dir (cdr entry))
1729 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1732 (setq gnus-uu-tmp-dir (file-name-as-directory
1733 (expand-file-name gnus-uu-tmp-dir)))
1734 (if (not (file-directory-p gnus-uu-tmp-dir))
1735 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1736 (when (not (file-writable-p gnus-uu-tmp-dir))
1737 (error "Temp directory %s can't be written to"
1740 (setq gnus-uu-work-dir
1741 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1742 (gnus-set-file-modes gnus-uu-work-dir 448)
1743 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1744 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1745 gnus-uu-tmp-alist))))
1748 ;; Kills the temporary uu buffers, kills any processes, etc.
1749 (defun gnus-uu-clean-up ()
1751 (and gnus-uu-uudecode-process
1752 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1754 (delete-process gnus-uu-uudecode-process))
1755 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1756 (kill-buffer buf))))
1758 (defun gnus-quote-arg-for-sh-or-csh (arg)
1759 (let ((pos 0) new-pos accum)
1760 ;; *** bug: we don't handle newline characters properly
1761 (while (setq new-pos (string-match "[!`\"$\\& \t{}]" arg pos))
1762 (push (substring arg pos new-pos) accum)
1764 (push (list (aref arg new-pos)) accum)
1765 (setq pos (1+ new-pos)))
1768 (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))
1770 ;; Inputs an action and a filename and returns a full command, making sure
1771 ;; that the filename will be treated as a single argument when the shell
1772 ;; executes the command.
1773 (defun gnus-uu-command (action file)
1774 (let ((quoted-file (shell-quote-argument file)))
1775 (if (string-match "%s" action)
1776 (format action quoted-file)
1777 (concat action " " quoted-file))))
1779 (defun gnus-uu-delete-work-dir (&optional dir)
1780 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1782 (gnus-message 7 "Deleting directory %s..." dir)
1783 (setq dir gnus-uu-work-dir))
1785 (file-exists-p dir))
1786 (let ((files (directory-files dir t nil t))
1788 (while (setq file (pop files))
1789 (unless (member (file-name-nondirectory file) '("." ".."))
1790 (if (file-directory-p file)
1791 (gnus-uu-delete-work-dir file)
1792 (gnus-message 9 "Deleting file %s..." file)
1795 (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
1797 (delete-directory dir)
1798 (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
1799 (gnus-message 7 "")))
1803 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1804 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1809 ;;; uuencoded posting
1812 ;; Any function that is to be used as and encoding method will take two
1813 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1814 ;; and "spiral.jpg", respectively.) The function should return nil if
1815 ;; the encoding wasn't successful.
1816 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1817 "Function used for encoding binary files.
1818 There are three functions supplied with gnus-uu for encoding files:
1819 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1820 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1821 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1822 uuencode and adds MIME headers."
1823 :group 'gnus-extract-post
1824 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1825 (function-item gnus-uu-post-encode-mime)
1826 (function-item gnus-uu-post-encode-mime-uuencode)
1827 (function :tag "Other")))
1829 (defcustom gnus-uu-post-include-before-composing nil
1830 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1831 If this variable is t, you can either include an encoded file with
1832 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1833 :group 'gnus-extract-post
1836 (defcustom gnus-uu-post-length 990
1837 "Maximum length of an article.
1838 The encoded file will be split into how many articles it takes to
1839 post the entire file."
1840 :group 'gnus-extract-post
1843 (defcustom gnus-uu-post-threaded nil
1844 "Non-nil means that gnus-uu will post the encoded file in a thread.
1845 This may not be smart, as no other decoder I have seen are able to
1846 follow threads when collecting uuencoded articles. (Well, I have seen
1847 one package that does that - gnus-uu, but somehow, I don't think that
1848 counts...) The default is nil."
1849 :group 'gnus-extract-post
1852 (defcustom gnus-uu-post-separate-description t
1853 "Non-nil means that the description will be posted in a separate article.
1854 The first article will typically be numbered (0/x). If this variable
1855 is nil, the description the user enters will be included at the
1856 beginning of the first article, which will be numbered (1/x). Default
1858 :group 'gnus-extract-post
1861 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1862 (defvar gnus-uu-post-message-id nil)
1863 (defvar gnus-uu-post-inserted-file-name nil)
1864 (defvar gnus-uu-winconf-post-news nil)
1866 (defun gnus-uu-post-news ()
1867 "Compose an article and post an encoded file."
1869 (setq gnus-uu-post-inserted-file-name nil)
1870 (setq gnus-uu-winconf-post-news (current-window-configuration))
1872 (gnus-summary-post-news)
1874 (let ((map (make-sparse-keymap)))
1875 (set-keymap-parent map (current-local-map))
1876 (use-local-map map))
1877 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1878 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1879 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1880 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1882 (when gnus-uu-post-include-before-composing
1883 (save-excursion (setq gnus-uu-post-inserted-file-name
1884 (gnus-uu-post-insert-binary)))))
1886 (defun gnus-uu-post-insert-binary-in-article ()
1887 "Inserts an encoded file in the buffer.
1888 The user will be asked for a file name."
1891 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1893 ;; Encodes with uuencode and substitutes all spaces with backticks.
1894 (defun gnus-uu-post-encode-uuencode (path file-name)
1895 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1896 (goto-char (point-min))
1898 (while (search-forward " " nil t)
1899 (replace-match "`"))
1902 ;; Encodes with uuencode and adds MIME headers.
1903 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1904 (when (gnus-uu-post-encode-uuencode path file-name)
1905 (gnus-uu-post-make-mime file-name "x-uue")
1908 ;; Encodes with base64 and adds MIME headers
1909 (defun gnus-uu-post-encode-mime (path file-name)
1910 (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1911 (format "%s %s -o %s" "mmencode" path file-name)))
1912 (gnus-uu-post-make-mime file-name "base64")
1915 ;; Adds MIME headers.
1916 (defun gnus-uu-post-make-mime (file-name encoding)
1917 (goto-char (point-min))
1918 (insert (format "Content-Type: %s; name=\"%s\"\n"
1919 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1921 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1923 (set-buffer gnus-message-buffer)
1924 (goto-char (point-min))
1925 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1927 (narrow-to-region (point-min) (point))
1928 (unless (mail-fetch-field "mime-version")
1930 (insert "MIME-Version: 1.0\n"))
1933 ;; Encodes a file PATH with COMMAND, leaving the result in the
1935 (defun gnus-uu-post-encode-file (command path file-name)
1936 (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1937 (format "%s %s %s" command path file-name))))
1939 (defun gnus-uu-post-news-inews ()
1940 "Posts the composed news article and encoded file.
1941 If no file has been included, the user will be asked for a file."
1946 (if gnus-uu-post-inserted-file-name
1947 (setq file-name gnus-uu-post-inserted-file-name)
1948 (setq file-name (gnus-uu-post-insert-binary)))
1950 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1951 (setq gnus-uu-post-inserted-file-name nil)
1952 (when gnus-uu-winconf-post-news
1953 (set-window-configuration gnus-uu-winconf-post-news)))
1955 ;; Asks for a file to encode, encodes it and inserts the result in
1956 ;; the current buffer. Returns the file name the user gave.
1957 (defun gnus-uu-post-insert-binary ()
1958 (let ((uuencode-buffer-name "*uuencode buffer*")
1959 file-path uubuf file-name)
1961 (setq file-path (read-file-name
1962 "What file do you want to encode? "))
1963 (when (not (file-exists-p file-path))
1964 (error "%s: No such file" file-path))
1966 (goto-char (point-max))
1967 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1969 ;; #### Unix-specific?
1970 (when (string-match "^~/" file-path)
1971 (setq file-path (concat "$HOME" (substring file-path 1))))
1972 ;; #### Unix-specific?
1973 (if (string-match "/[^/]*$" file-path)
1974 (setq file-name (substring file-path (1+ (match-beginning 0))))
1975 (setq file-name file-path))
1979 (set-buffer (setq uubuf
1980 (gnus-get-buffer-create uuencode-buffer-name)))
1982 (funcall gnus-uu-post-encode-method file-path file-name))
1983 (insert-buffer-substring uubuf)
1984 (error "Encoding unsuccessful"))
1985 (kill-buffer uubuf))
1988 ;; Posts the article and all of the encoded file.
1989 (defun gnus-uu-post-encoded (file-name &optional threaded)
1990 (let ((send-buffer-name "*uuencode send buffer*")
1991 (encoded-buffer-name "*encoded buffer*")
1992 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
1993 (separator (concat mail-header-separator "\n\n"))
1994 uubuf length parts header i end beg
1995 beg-line minlen post-buf whole-len beg-binary end-binary)
1997 (setq post-buf (current-buffer))
1999 (goto-char (point-min))
2000 (when (not (re-search-forward
2001 (if gnus-uu-post-separate-description
2002 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2004 (concat "^" (regexp-quote mail-header-separator) "$"))
2006 (error "Internal error: No binary/header separator"))
2009 (setq beg-binary (point))
2010 (setq end-binary (point-max))
2013 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2015 (insert-buffer-substring post-buf beg-binary end-binary)
2016 (goto-char (point-min))
2017 (setq length (count-lines (point-min) (point-max)))
2018 (setq parts (/ length gnus-uu-post-length))
2019 (unless (< (% length gnus-uu-post-length) 4)
2022 (when gnus-uu-post-separate-description
2024 (delete-region (point) (point-max))
2026 (goto-char (point-min))
2028 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2029 (setq header (buffer-substring (point-min) (point-at-bol)))
2031 (goto-char (point-min))
2032 (when gnus-uu-post-separate-description
2033 (when (re-search-forward "^Subject: " nil t)
2035 (insert (format " (0/%d)" parts)))
2038 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2043 (while (not (> i parts))
2044 (set-buffer (gnus-get-buffer-create send-buffer-name))
2047 (when (and threaded gnus-uu-post-message-id)
2048 (insert "References: " gnus-uu-post-message-id "\n"))
2051 (- 62 (length (format top-string "" file-name i parts ""))))
2052 (when (> 1 (setq minlen (/ whole-len 2)))
2057 (make-string minlen ?-)
2060 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2062 (goto-char (point-min))
2063 (when (re-search-forward "^Subject: " nil t)
2065 (insert (format " (%d/%d)" i parts)))
2067 (goto-char (point-max))
2072 (goto-char (point-max))
2073 (forward-line gnus-uu-post-length))
2074 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2077 (insert-buffer-substring uubuf beg end)
2078 (insert beg-line "\n")
2081 (goto-char (point-min))
2083 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2086 (when (re-search-forward
2087 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2093 (let (message-sent-message-via)
2096 (setq gnus-uu-post-message-id
2097 (concat (message-fetch-field "references") " "
2098 (message-fetch-field "message-id"))))))
2100 (gnus-kill-buffer send-buffer-name)
2101 (gnus-kill-buffer encoded-buffer-name)
2103 (when (not gnus-uu-post-separate-description)
2104 (set-buffer-modified-p nil)
2109 ;;; gnus-uu.el ends here