1 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
31 (eval-when-compile (require 'cl))
39 (defgroup gnus-extract nil
40 "Extracting encoded files."
44 (defgroup gnus-extract-view nil
45 "Viewwing extracted files."
48 (defgroup gnus-extract-archive nil
49 "Extracting encoded archives."
52 (defgroup gnus-extract-post nil
53 "Extracting encoded archives."
54 :prefix "gnus-uu-post"
57 ;; Default viewing action rules
59 (defcustom gnus-uu-default-view-rules
60 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
61 ("\\.pas$" "cat %s | sed 's/\r$//'")
62 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
63 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
64 ("\\.tga$" "tgatoppm %s | ee -")
65 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
66 "sox -v .5 %s -t .au -u - > /dev/audio")
67 ("\\.au$" "cat %s > /dev/audio")
68 ("\\.midi?$" "playmidi -f")
70 ("\\.ps$" "ghostview")
72 ("\\.html$" "xmosaic")
73 ("\\.mpe?g$" "mpeg_play")
74 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
75 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
77 "*Default actions to be taken when the user asks to view a file.
78 To change the behaviour, you can either edit this variable or set
79 `gnus-uu-user-view-rules' to something useful.
83 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
84 following in your .emacs file:
86 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
88 Both these variables are lists of lists with two string elements. The
89 first string is a regular expression. If the file name matches this
90 regular expression, the command in the second string is executed with
91 the file as an argument.
93 If the command string contains \"%s\", the file name will be inserted
94 at that point in the command string. If there's no \"%s\" in the
95 command string, the file name will be appended to the command string
98 There are several user variables to tailor the behaviour of gnus-uu to
99 your needs. First we have `gnus-uu-user-view-rules', which is the
100 variable gnus-uu first consults when trying to decide how to view a
101 file. If this variable contains no matches, gnus-uu examines the
102 default rule variable provided in this package. If gnus-uu finds no
103 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
105 :group 'gnus-extract-view
106 :type '(repeat (group regexp (string :tag "Command"))))
108 (defcustom gnus-uu-user-view-rules nil
109 "What actions are to be taken to view a file.
110 See the documentation on the `gnus-uu-default-view-rules' variable for
112 :group 'gnus-extract-view
113 :type '(repeat (group regexp (string :tag "Command"))))
115 (defcustom gnus-uu-user-view-rules-end
117 "*What actions are to be taken if no rule matched the file name.
118 See the documentation on the `gnus-uu-default-view-rules' variable for
120 :group 'gnus-extract-view
121 :type '(repeat (group regexp (string :tag "Command"))))
123 ;; Default unpacking commands
125 (defcustom gnus-uu-default-archive-rules
126 '(("\\.tar$" "tar xf")
127 ("\\.zip$" "unzip -o")
129 ("\\.arj$" "unarj x")
131 ("\\.\\(lzh\\|lha\\)$" "lha x")
132 ("\\.Z$" "uncompress")
134 ("\\.arc$" "arc -x"))
135 "*See `gnus-uu-user-archive-rules'."
136 :group 'gnus-extract-archive
137 :type '(repeat (group regexp (string :tag "Command"))))
139 (defvar gnus-uu-destructive-archivers
140 (list "uncompress" "gunzip"))
142 (defcustom gnus-uu-user-archive-rules nil
143 "A list that can be set to override the default archive unpacking commands.
144 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
145 unpack zip files, say the following:
146 (setq gnus-uu-user-archive-rules
147 '((\"\\\\.tar$\" \"untar\")
148 (\"\\\\.zip$\" \"zip -x\")))"
149 :group 'gnus-extract-archive
150 :type '(repeat (group regexp (string :tag "Command"))))
152 (defcustom gnus-uu-ignore-files-by-name nil
153 "*A regular expression saying what files should not be viewed based on name.
154 If, for instance, you want gnus-uu to ignore all .au and .wav files,
155 you could say something like
157 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
159 Note that this variable can be used in conjunction with the
160 `gnus-uu-ignore-files-by-type' variable."
162 :type '(choice (const :tag "off" nil)
163 (regexp :format "%v")))
165 (defcustom gnus-uu-ignore-files-by-type nil
166 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
167 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
168 you could say something like
170 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
172 Note that this variable can be used in conjunction with the
173 `gnus-uu-ignore-files-by-name' variable."
175 :type '(choice (const :tag "off" nil)
176 (regexp :format "%v")))
178 ;; Pseudo-MIME support
180 (defconst gnus-uu-ext-to-mime-list
181 '(("\\.gif$" "image/gif")
182 ("\\.jpe?g$" "image/jpeg")
183 ("\\.tiff?$" "image/tiff")
184 ("\\.xwd$" "image/xwd")
185 ("\\.pbm$" "image/pbm")
186 ("\\.pgm$" "image/pgm")
187 ("\\.ppm$" "image/ppm")
188 ("\\.xbm$" "image/xbm")
189 ("\\.pcx$" "image/pcx")
190 ("\\.tga$" "image/tga")
191 ("\\.ps$" "image/postscript")
192 ("\\.fli$" "video/fli")
193 ("\\.wav$" "audio/wav")
194 ("\\.aiff$" "audio/aiff")
195 ("\\.hcom$" "audio/hcom")
196 ("\\.voc$" "audio/voc")
197 ("\\.smp$" "audio/smp")
198 ("\\.mod$" "audio/mod")
199 ("\\.dvi$" "image/dvi")
200 ("\\.mpe?g$" "video/mpeg")
201 ("\\.au$" "audio/basic")
202 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
203 ("\\.\\(c\\|h\\)$" "text/source")
204 ("read.*me" "text/plain")
205 ("\\.html$" "text/html")
206 ("\\.bat$" "text/bat")
207 ("\\.[1-6]$" "text/man")
208 ("\\.flc$" "video/flc")
209 ("\\.rle$" "video/rle")
210 ("\\.pfx$" "video/pfx")
211 ("\\.avi$" "video/avi")
212 ("\\.sme$" "video/sme")
213 ("\\.rpza$" "video/prza")
214 ("\\.dl$" "video/dl")
215 ("\\.qt$" "video/qt")
216 ("\\.rsrc$" "video/rsrc")
217 ("\\..*$" "unknown/unknown")))
219 ;; Various variables users may set
221 (defcustom gnus-uu-tmp-dir
222 (cond ((fboundp 'temp-directory) (temp-directory))
223 ((boundp 'temporary-file-directory) temporary-file-directory)
225 "*Variable saying where gnus-uu is to do its work.
226 Default is \"/tmp/\"."
230 (defcustom gnus-uu-do-not-unpack-archives nil
231 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
233 :group 'gnus-extract-archive
236 (defcustom gnus-uu-ignore-default-view-rules nil
237 "*Non-nil means that gnus-uu will ignore the default viewing rules.
238 Only the user viewing rules will be consulted. Default is nil."
239 :group 'gnus-extract-view
242 (defcustom gnus-uu-grabbed-file-functions nil
243 "Functions run on each file after successful decoding.
244 They will be called with the name of the file as the argument.
245 Likely functions you can use in this list are `gnus-uu-grab-view'
246 and `gnus-uu-grab-move'."
248 :options '(gnus-uu-grab-view gnus-uu-grab-move)
251 (defcustom gnus-uu-ignore-default-archive-rules nil
252 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
253 Only the user unpacking commands will be consulted. Default is nil."
254 :group 'gnus-extract-archive
257 (defcustom gnus-uu-kill-carriage-return t
258 "*Non-nil means that gnus-uu will strip all carriage returns from articles.
263 (defcustom gnus-uu-view-with-metamail nil
264 "*Non-nil means that files will be viewed with metamail.
265 The gnus-uu viewing functions will be ignored and gnus-uu will try
266 to guess at a content-type based on file name suffixes. Default
271 (defcustom gnus-uu-unmark-articles-not-decoded nil
272 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
277 (defcustom gnus-uu-correct-stripped-uucode nil
278 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
283 (defcustom gnus-uu-save-in-digest nil
284 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
285 If this variable is nil, gnus-uu will just save everything in a
286 file without any embellishments. The digesting almost conforms to RFC1153 -
287 no easy way to specify any meaningful volume and issue numbers were found,
288 so I simply dropped them."
292 (defcustom gnus-uu-pre-uudecode-hook nil
293 "Hook run before sending a message to uudecode."
297 (defcustom gnus-uu-digest-headers
298 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
299 "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
300 "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
302 "*List of regexps to match headers included in digested messages.
303 The headers will be included in the sequence they are matched. If nil
304 include all headers."
306 :type '(repeat regexp))
308 (defcustom gnus-uu-save-separate-articles nil
309 "*Non-nil means that gnus-uu will save articles in separate files."
313 (defcustom gnus-uu-be-dangerous 'ask
314 "*Specifies what to do if unusual situations arise during decoding.
315 If nil, be as conservative as possible. If t, ignore things that
316 didn't work, and overwrite existing files. Otherwise, ask each time."
318 :type '(choice (const :tag "conservative" nil)
319 (const :tag "ask" ask)
320 (const :tag "liberal" t)))
322 ;; Internal variables
324 (defvar gnus-uu-saved-article-name nil)
326 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
327 (defvar gnus-uu-end-string "^end[ \t]*$")
329 (defvar gnus-uu-body-line "^M")
331 (while (> (setq i (1- i)) 0)
332 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
333 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
335 ;"^M.............................................................?$"
337 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
339 (defvar gnus-uu-shar-file-name nil)
340 (defvar gnus-uu-shar-name-marker
341 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
343 (defvar gnus-uu-postscript-begin-string "^%!PS-")
344 (defvar gnus-uu-postscript-end-string "^%%EOF$")
346 (defvar gnus-uu-file-name nil)
347 (defvar gnus-uu-uudecode-process nil)
348 (defvar gnus-uu-binhex-article-name nil)
350 (defvar gnus-uu-work-dir nil)
352 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
354 (defvar gnus-uu-default-dir gnus-article-save-directory)
355 (defvar gnus-uu-digest-from-subject nil)
356 (defvar gnus-uu-digest-buffer nil)
360 (defun gnus-uu-decode-uu (&optional n)
361 "Uudecodes the current article."
363 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
365 (defun gnus-uu-decode-uu-and-save (n dir)
366 "Decodes and saves the resulting file."
368 (list current-prefix-arg
369 (file-name-as-directory
370 (read-file-name "Uudecode and save in dir: "
372 gnus-uu-default-dir t))))
373 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
375 (defun gnus-uu-decode-unshar (&optional n)
376 "Unshars the current article."
378 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
380 (defun gnus-uu-decode-unshar-and-save (n dir)
381 "Unshars and saves the current article."
383 (list current-prefix-arg
384 (file-name-as-directory
385 (read-file-name "Unshar and save in dir: "
387 gnus-uu-default-dir t))))
388 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
390 (defun gnus-uu-decode-save (n file)
391 "Saves the current article."
393 (list current-prefix-arg
395 (if gnus-uu-save-separate-articles
396 "Save articles in dir: "
397 "Save articles in file: ")
399 gnus-uu-default-dir)))
400 (setq gnus-uu-saved-article-name file)
401 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
403 (defun gnus-uu-decode-binhex (n dir)
404 "Unbinhexes the current article."
406 (list current-prefix-arg
407 (file-name-as-directory
408 (read-file-name "Unbinhex and save in dir: "
410 gnus-uu-default-dir))))
411 (setq gnus-uu-binhex-article-name
412 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
413 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
415 (defun gnus-uu-decode-uu-view (&optional n)
416 "Uudecodes and views the current article."
418 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
419 (gnus-uu-decode-uu n)))
421 (defun gnus-uu-decode-uu-and-save-view (n dir)
422 "Decodes, views and saves the resulting file."
424 (list current-prefix-arg
425 (read-file-name "Uudecode, view and save in dir: "
427 gnus-uu-default-dir t)))
428 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
429 (gnus-uu-decode-uu-and-save n dir)))
431 (defun gnus-uu-decode-unshar-view (&optional n)
432 "Unshars and views the current article."
434 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
435 (gnus-uu-decode-unshar n)))
437 (defun gnus-uu-decode-unshar-and-save-view (n dir)
438 "Unshars and saves the current article."
440 (list current-prefix-arg
441 (read-file-name "Unshar, view and save in dir: "
443 gnus-uu-default-dir t)))
444 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
445 (gnus-uu-decode-unshar-and-save n dir)))
447 (defun gnus-uu-decode-save-view (n file)
448 "Saves and views the current article."
450 (list current-prefix-arg
451 (read-file-name (if gnus-uu-save-separate-articles
452 "Save articles is dir: "
453 "Save articles in file: ")
454 gnus-uu-default-dir gnus-uu-default-dir)))
455 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
456 (gnus-uu-decode-save n file)))
458 (defun gnus-uu-decode-binhex-view (n file)
459 "Unbinhexes and views the current article."
461 (list current-prefix-arg
462 (read-file-name "Unbinhex, view and save in dir: "
463 gnus-uu-default-dir gnus-uu-default-dir)))
464 (setq gnus-uu-binhex-article-name
465 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
466 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
467 (gnus-uu-decode-binhex n file)))
470 ;; Digest and forward articles
472 (defun gnus-uu-digest-mail-forward (&optional n post)
473 "Digests and forwards all articles in this series."
475 (let ((gnus-uu-save-in-digest t)
476 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
477 (message-forward-as-mime message-forward-as-mime)
478 (mail-parse-charset gnus-newsgroup-charset)
479 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
480 gnus-uu-digest-buffer subject from)
481 (if (and n (not (numberp n)))
482 (setq message-forward-as-mime (not message-forward-as-mime)
484 (let ((gnus-article-reply (gnus-summary-work-articles n)))
486 (= (length gnus-article-reply) 1))
487 ;; The case where neither a number of articles nor a region is
489 (gnus-summary-top-thread)
490 (setq gnus-article-reply (nreverse (gnus-uu-find-articles-matching))))
491 (gnus-setup-message 'forward
492 (setq gnus-uu-digest-from-subject nil)
493 (setq gnus-uu-digest-buffer
494 (gnus-get-buffer-create " *gnus-uu-forward*"))
495 ;; Specify articles to be forwarded. Note that they should be
496 ;; reversed; see `gnus-uu-get-list-of-articles'.
497 (let ((gnus-newsgroup-processable (reverse gnus-article-reply)))
498 (gnus-uu-decode-save n file)
499 (setq gnus-article-reply gnus-newsgroup-processable))
500 ;; Restore the value of `gnus-newsgroup-processable' to which
501 ;; it should be set when it is not `let'-bound.
502 (setq gnus-newsgroup-processable (reverse gnus-article-reply))
503 (switch-to-buffer gnus-uu-digest-buffer)
504 (let ((fs gnus-uu-digest-from-subject))
507 subject (gnus-simplify-subject-fuzzy (cdar fs))
509 (while (and fs (or from subject))
511 (unless (string= from (caar fs))
514 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
519 (setq subject "Digested Articles"))
522 (if (gnus-news-group-p gnus-newsgroup-name)
525 (goto-char (point-min))
526 (when (re-search-forward "^Subject: ")
527 (delete-region (point) (point-at-eol))
529 (goto-char (point-min))
530 (when (re-search-forward "^From:")
531 (delete-region (point) (point-at-eol))
533 (let ((message-forward-decoded-p t))
534 (message-forward post t))))
535 (setq gnus-uu-digest-from-subject nil)))
537 (defun gnus-uu-digest-post-forward (&optional n)
538 "Digest and forward to a newsgroup."
540 (gnus-uu-digest-mail-forward n t))
544 (defun gnus-message-process-mark (unmarkp new-marked)
545 (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
546 (gnus-message 6 "%d mark%s %s%s"
548 (if (= (length new-marked) 1) "" "s")
549 (if unmarkp "removed" "added")
555 (format ", %d remain marked"
556 (length gnus-newsgroup-processable)))
558 (format ", %d already marked" old))))))
560 (defun gnus-new-processable (unmarkp articles)
562 (gnus-intersection gnus-newsgroup-processable articles)
563 (gnus-set-difference articles gnus-newsgroup-processable)))
565 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
566 "Set the process mark on articles whose subjects match REGEXP.
567 When called interactively, prompt for REGEXP.
568 Optional UNMARK non-nil means unmark instead of mark."
569 (interactive "sMark (regexp): \nP")
571 (let* ((articles (gnus-uu-find-articles-matching regexp))
572 (new-marked (gnus-new-processable unmark articles)))
575 (gnus-summary-remove-process-mark (pop articles))
576 (gnus-summary-set-process-mark (pop articles))))
577 (gnus-message-process-mark unmark new-marked)))
578 (gnus-summary-position-point))
580 (defun gnus-uu-unmark-by-regexp (regexp)
581 "Remove the process mark from articles whose subjects match REGEXP.
582 When called interactively, prompt for REGEXP."
583 (interactive "sUnmark (regexp): ")
584 (gnus-uu-mark-by-regexp regexp t))
586 (defun gnus-uu-mark-series (&optional silent)
587 "Mark the current series with the process mark."
589 (let* ((articles (gnus-uu-find-articles-matching))
590 (l (length articles)))
592 (gnus-summary-set-process-mark (car articles))
593 (setq articles (cdr articles)))
595 (gnus-message 6 "Marked %d articles" l))
596 (gnus-summary-position-point)
599 (defun gnus-uu-mark-region (beg end &optional unmark)
600 "Set the process mark on all articles between point and mark."
604 (while (< (point) end)
606 (gnus-summary-remove-process-mark (gnus-summary-article-number))
607 (gnus-summary-set-process-mark (gnus-summary-article-number)))
609 (gnus-summary-position-point))
611 (defun gnus-uu-unmark-region (beg end)
612 "Remove the process mark from all articles between point and mark."
614 (gnus-uu-mark-region beg end t))
616 (defun gnus-uu-mark-buffer ()
617 "Set the process mark on all articles in the buffer."
619 (gnus-uu-mark-region (point-min) (point-max)))
621 (defun gnus-uu-unmark-buffer ()
622 "Remove the process mark on all articles in the buffer."
624 (gnus-uu-mark-region (point-min) (point-max) t))
626 (defun gnus-uu-mark-thread ()
627 "Marks all articles downwards in this thread."
629 (gnus-save-hidden-threads
630 (let ((level (gnus-summary-thread-level)))
631 (while (and (gnus-summary-set-process-mark
632 (gnus-summary-article-number))
633 (zerop (gnus-summary-next-subject 1 nil t))
634 (> (gnus-summary-thread-level) level)))))
635 (gnus-summary-position-point))
637 (defun gnus-uu-unmark-thread ()
638 "Unmarks all articles downwards in this thread."
640 (let ((level (gnus-summary-thread-level)))
641 (while (and (gnus-summary-remove-process-mark
642 (gnus-summary-article-number))
643 (zerop (gnus-summary-next-subject 1))
644 (> (gnus-summary-thread-level) level))))
645 (gnus-summary-position-point))
647 (defun gnus-uu-invert-processable ()
648 "Invert the list of process-marked articles."
650 (let ((data gnus-newsgroup-data)
654 (if (memq (setq number (gnus-data-number (pop data)))
655 gnus-newsgroup-processable)
656 (gnus-summary-remove-process-mark number)
657 (gnus-summary-set-process-mark number)))))
658 (gnus-summary-position-point))
660 (defun gnus-uu-mark-over (&optional score)
661 "Mark all articles with a score over SCORE (the prefix)."
663 (let ((score (or score gnus-summary-default-score 0))
664 (data gnus-newsgroup-data))
667 (when (> (or (cdr (assq (gnus-data-number (car data))
668 gnus-newsgroup-scored))
669 gnus-summary-default-score 0)
671 (gnus-summary-set-process-mark (caar data)))
672 (setq data (cdr data))))
673 (gnus-summary-position-point)))
675 (defun gnus-uu-mark-sparse ()
676 "Mark all series that have some articles marked."
678 (let ((marked (nreverse gnus-newsgroup-processable))
679 subject articles total headers)
681 (error "No articles marked with the process mark"))
682 (setq gnus-newsgroup-processable nil)
685 (and (vectorp (setq headers
686 (gnus-summary-article-header (car marked))))
687 (setq subject (mail-header-subject headers)
688 articles (gnus-uu-find-articles-matching
689 (gnus-uu-reginize-string subject))
690 total (nconc total articles)))
692 (gnus-summary-set-process-mark (car articles))
693 (setcdr marked (delq (car articles) (cdr marked)))
694 (setq articles (cdr articles)))
695 (setq marked (cdr marked)))
696 (setq gnus-newsgroup-processable (nreverse total)))
697 (gnus-summary-position-point)))
699 (defun gnus-uu-mark-all ()
700 "Mark all articles in \"series\" order."
702 (setq gnus-newsgroup-processable nil)
704 (let ((data gnus-newsgroup-data)
708 (when (and (not (memq (setq number (gnus-data-number (car data)))
709 gnus-newsgroup-processable))
710 (vectorp (gnus-data-header (car data))))
711 (gnus-summary-goto-subject number)
712 (setq count (+ count (gnus-uu-mark-series t))))
713 (setq data (cdr data)))
714 (gnus-message 6 "Marked %d articles" count)))
715 (gnus-summary-position-point))
717 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
719 (defun gnus-uu-decode-postscript (&optional n)
720 "Gets postscript of the current article."
722 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
724 (defun gnus-uu-decode-postscript-view (&optional n)
725 "Gets and views the current article."
727 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
728 (gnus-uu-decode-postscript n)))
730 (defun gnus-uu-decode-postscript-and-save (n dir)
731 "Extracts postscript and saves the current article."
733 (list current-prefix-arg
734 (file-name-as-directory
735 (read-file-name "Save in dir: "
737 gnus-uu-default-dir t))))
738 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
741 (defun gnus-uu-decode-postscript-and-save-view (n dir)
742 "Decodes, views and saves the resulting file."
744 (list current-prefix-arg
745 (read-file-name "Where do you want to save the file(s)? "
747 gnus-uu-default-dir t)))
748 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
749 (gnus-uu-decode-postscript-and-save n dir)))
752 ;; Internal functions.
754 (defun gnus-uu-decode-with-method (method n &optional save not-insert
756 (gnus-uu-initialize scan)
758 (setq gnus-uu-default-dir save))
759 ;; Create the directory we save to.
760 (when (and scan cdir save
761 (not (file-exists-p save)))
762 (make-directory save t))
763 (let ((articles (gnus-uu-get-list-of-articles n))
765 (setq files (gnus-uu-grab-articles articles method t))
766 (let ((gnus-current-article (car articles)))
768 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
770 (gnus-uu-save-files files save))
771 (when (eq gnus-uu-do-not-unpack-archives nil)
772 (setq files (gnus-uu-unpack-files files)))
773 (setq files (nreverse (gnus-uu-get-actions files)))
774 (or not-insert (not gnus-insert-pseudo-articles)
775 (gnus-summary-insert-pseudos files save))))
777 (defun gnus-uu-scan-directory (dir &optional rec)
778 "Return a list of all files under DIR."
779 (let ((files (directory-files dir t))
781 (while (setq file (pop files))
782 (unless (member (file-name-nondirectory file) '("." ".."))
783 (push (list (cons 'name file)
784 (cons 'article gnus-current-article))
786 (when (file-directory-p file)
787 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
792 (defun gnus-uu-save-files (files dir)
794 (let ((len (length files))
795 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
796 to-file file fromdir)
797 (while (setq file (cdr (assq 'name (pop files))))
798 (when (file-exists-p file)
799 (string-match reg file)
800 (setq fromdir (substring file (match-end 0)))
801 (if (file-directory-p file)
802 (gnus-make-directory (concat dir fromdir))
803 (setq to-file (concat dir fromdir))
804 (when (or (not (file-exists-p to-file))
805 (eq gnus-uu-be-dangerous t)
806 (and gnus-uu-be-dangerous
807 (gnus-y-or-n-p (format "%s exists; overwrite? "
809 (copy-file file to-file t t)))))
810 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
812 ;; Functions for saving and possibly digesting articles without
815 ;; Function called by gnus-uu-grab-articles to treat each article.
816 (defun gnus-uu-save-article (buffer in-state)
818 (gnus-uu-save-separate-articles
821 (let ((coding-system-for-write mm-text-coding-system))
823 (concat gnus-uu-saved-article-name gnus-current-article)))
824 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
825 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
827 ((eq in-state 'last) (list 'end))
828 (t (list 'middle)))))
829 ((not gnus-uu-save-in-digest)
832 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
833 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
834 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
836 ((eq in-state 'last) (list 'end))
837 (t (list 'middle)))))
839 (let ((header (gnus-summary-article-header)))
840 (push (cons (mail-header-from header)
841 (mail-header-subject header))
842 gnus-uu-digest-from-subject))
843 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
844 beg subj headers headline sorthead body end-string state)
845 (if (or (eq in-state 'first)
846 (eq in-state 'first-and-last))
848 (setq state (list 'begin))
850 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
853 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
856 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
857 (message-make-date) name name))
858 (when (and message-forward-as-mime gnus-uu-digest-buffer)
860 "<#mml type=message/rfc822>\nSubject: Topics\n\n<#/mml>\n")
862 (insert "Topics:\n")))
863 (when (not (eq in-state 'end))
864 (setq state (list 'middle))))
866 (set-buffer "*gnus-uu-body*")
867 (goto-char (setq beg (point-max)))
871 (let (buffer-read-only)
872 (set-text-properties (point-min) (point-max) nil)
873 ;; These two are necessary for XEmacs 19.12 fascism.
874 (put-text-property (point-min) (point-max) 'invisible nil)
875 (put-text-property (point-min) (point-max) 'intangible nil))
876 (when (and message-forward-as-mime
877 message-forward-show-mml
878 gnus-uu-digest-buffer)
879 (mm-enable-multibyte)
881 (goto-char (point-min))
882 (search-forward "\n\n")
883 (unless (and message-forward-as-mime gnus-uu-digest-buffer)
884 ;; Quote all 30-dash lines.
886 (while (re-search-forward "^-" nil t)
890 (setq body (buffer-substring (1- (point)) (point-max)))
891 (narrow-to-region (point-min) (point))
892 (if (not (setq headers gnus-uu-digest-headers))
893 (setq sorthead (buffer-string))
895 (setq headline (car headers))
896 (setq headers (cdr headers))
897 (goto-char (point-min))
898 (while (re-search-forward headline nil t)
903 (or (and (re-search-forward "^[^ \t]" nil t)
905 (progn (forward-line 1) (point)))))))))
907 (if (and message-forward-as-mime gnus-uu-digest-buffer)
908 (if message-forward-show-mml
910 (insert "\n<#mml type=message/rfc822>\n")
911 (insert sorthead) (goto-char (point-max))
912 (insert body) (goto-char (point-max))
913 (insert "\n<#/mml>\n"))
914 (let ((buf (mml-generate-new-buffer " *mml*")))
915 (with-current-buffer buf
917 (goto-char (point-min))
918 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
919 (setq subj (buffer-substring (match-beginning 1)
921 (goto-char (point-max))
923 (insert "\n<#part type=message/rfc822"
924 " buffer=\"" (buffer-name buf) "\">\n")))
925 (insert sorthead) (goto-char (point-max))
926 (insert body) (goto-char (point-max))
927 (insert (concat "\n" (make-string 30 ?-) "\n\n")))
929 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
930 (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
933 (set-buffer "*gnus-uu-pre*")
934 (insert (format " %s\n" subj)))))
935 (when (or (eq in-state 'last)
936 (eq in-state 'first-and-last))
937 (if (and message-forward-as-mime gnus-uu-digest-buffer)
938 (with-current-buffer gnus-uu-digest-buffer
940 (insert-buffer-substring "*gnus-uu-pre*")
941 (goto-char (point-max))
942 (insert-buffer-substring "*gnus-uu-body*"))
944 (set-buffer "*gnus-uu-pre*")
945 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
946 (if gnus-uu-digest-buffer
947 (with-current-buffer gnus-uu-digest-buffer
949 (insert-buffer-substring "*gnus-uu-pre*"))
950 (let ((coding-system-for-write mm-text-coding-system))
951 (gnus-write-buffer gnus-uu-saved-article-name))))
953 (set-buffer "*gnus-uu-body*")
954 (goto-char (point-max))
956 (concat (setq end-string (format "End of %s Digest" name))
958 (insert (concat (make-string (length end-string) ?*) "\n"))
959 (if gnus-uu-digest-buffer
960 (with-current-buffer gnus-uu-digest-buffer
961 (goto-char (point-max))
962 (insert-buffer-substring "*gnus-uu-body*"))
963 (let ((coding-system-for-write mm-text-coding-system)
964 (file-name-coding-system nnmail-pathname-coding-system))
966 (point-min) (point-max) gnus-uu-saved-article-name t)))))
967 (gnus-kill-buffer "*gnus-uu-pre*")
968 (gnus-kill-buffer "*gnus-uu-body*")
970 (if (memq 'begin state)
971 (cons gnus-uu-saved-article-name state)
974 ;; Binhex treatment - not very advanced.
976 (defvar gnus-uu-binhex-body-line
977 "^[^:]...............................................................$")
978 (defvar gnus-uu-binhex-begin-line
979 "^:...............................................................$")
980 (defvar gnus-uu-binhex-end-line
983 (defun gnus-uu-binhex-article (buffer in-state)
984 (let (state start-char)
988 (goto-char (point-min))
989 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
990 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
991 (setq state (list 'wrong-type))))
993 (if (memq 'wrong-type state)
996 (setq start-char (point))
997 (if (looking-at gnus-uu-binhex-begin-line)
999 (setq state (list 'begin))
1000 (write-region (point-min) (point-min)
1001 gnus-uu-binhex-article-name))
1002 (setq state (list 'middle)))
1003 (goto-char (point-max))
1004 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
1005 gnus-uu-binhex-end-line)
1007 (when (looking-at gnus-uu-binhex-end-line)
1008 (setq state (if (memq 'begin state)
1013 (when (file-exists-p gnus-uu-binhex-article-name)
1014 (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
1015 (if (memq 'begin state)
1016 (cons gnus-uu-binhex-article-name state)
1021 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
1022 (let ((state (list 'ok))
1023 start-char end-char file-name)
1025 (set-buffer process-buffer)
1026 (goto-char (point-min))
1027 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
1028 (setq state (list 'wrong-type))
1030 (setq start-char (point))
1031 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
1032 (setq state (list 'wrong-type))
1033 (setq end-char (point))
1034 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1035 (insert-buffer-substring process-buffer start-char end-char)
1036 (setq file-name (concat gnus-uu-work-dir
1037 (cdr gnus-article-current) ".ps"))
1038 (write-region (point-min) (point-max) file-name)
1039 (setq state (list file-name 'begin 'end)))))
1045 (defun gnus-uu-get-actions (files)
1046 (let ((ofiles files)
1049 (setq name (cdr (assq 'name (car files))))
1051 (setq action (gnus-uu-get-action name))
1052 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1053 (cons 'action "file")
1054 (cons 'action action))
1055 (cons 'execute (gnus-uu-command
1058 (setq files (cdr files)))
1061 (defun gnus-uu-get-action (file-name)
1064 (gnus-uu-choose-action
1067 gnus-uu-user-view-rules
1068 (if gnus-uu-ignore-default-view-rules
1070 gnus-uu-default-view-rules)
1071 gnus-uu-user-view-rules-end)))
1072 (when (and (not (string= (or action "") "gnus-uu-archive"))
1073 gnus-uu-view-with-metamail)
1075 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1076 (setq action (format "metamail -d -b -c \"%s\"" action))))
1080 ;; Functions for treating subjects and collecting series.
1082 (defun gnus-uu-reginize-string (string)
1083 ;; Takes a string and puts a \ in front of every special character;
1084 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1085 ;; or, if it can't find something like that, tries "2 of 3", then
1086 ;; finally just replaces the next to last number with "[0-9]+".
1088 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1089 (buffer-disable-undo)
1091 (insert (regexp-quote string))
1093 (setq case-fold-search nil)
1096 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1097 (replace-match "\\1[0-9]+/\\2")
1100 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1102 (replace-match "\\1[0-9]+ of \\2")
1105 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1107 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1110 (while (re-search-forward "[ \t]+" nil t)
1111 (replace-match "[ \t]+" t t))
1115 (defun gnus-uu-get-list-of-articles (n)
1116 ;; If N is non-nil, the article numbers of the N next articles
1117 ;; will be returned.
1118 ;; If any articles have been marked as processable, they will be
1120 ;; Failing that, articles that have subjects that are part of the
1121 ;; same "series" as the current will be returned.
1125 (setq n (prefix-numeric-value n))
1126 (let ((backward (< n 0))
1130 (push (gnus-summary-article-number)
1132 (gnus-summary-search-forward nil nil backward))
1134 (nreverse articles)))
1135 (gnus-newsgroup-processable
1136 (reverse gnus-newsgroup-processable))
1138 (gnus-uu-find-articles-matching)))))
1140 (defun gnus-uu-string< (l1 l2)
1141 (string< (car l1) (car l2)))
1143 (defun gnus-uu-find-articles-matching
1144 (&optional subject only-unread do-not-translate)
1145 ;; Finds all articles that matches the regexp SUBJECT. If it is
1146 ;; nil, the current article name will be used. If ONLY-UNREAD is
1147 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1148 ;; non-nil, article names are not equalized before sorting.
1149 (let ((subject (or subject
1150 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1154 ;; Collect all subjects matching subject.
1155 (let ((case-fold-search t)
1156 (data gnus-newsgroup-data)
1160 (and (not (gnus-data-pseudo-p d))
1161 (or (not only-unread)
1162 (= (setq mark (gnus-data-mark d))
1164 (= mark gnus-ticked-mark)
1165 (= mark gnus-dormant-mark))
1166 (setq subj (mail-header-subject (gnus-data-header d)))
1167 (string-match subject subj)
1168 (push (cons subj (gnus-data-number d))
1169 list-of-subjects))))
1171 ;; Expand numbers, sort, and return the list of article
1174 (sort (gnus-uu-expand-numbers
1176 (not do-not-translate))
1177 'gnus-uu-string<))))))
1179 (defun gnus-uu-expand-numbers (string-list &optional translate)
1180 ;; Takes a list of strings and "expands" all numbers in all the
1181 ;; strings. That is, this function makes all numbers equal length by
1182 ;; prepending lots of zeroes before each number. This is to ease later
1183 ;; sorting to find out what sequence the articles are supposed to be
1184 ;; decoded in. Returns the list of expanded strings.
1185 (let ((out-list string-list)
1188 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1189 (buffer-disable-undo)
1192 (insert (caar string-list))
1193 ;; Translate multiple spaces to one space.
1194 (goto-char (point-min))
1195 (while (re-search-forward "[ \t]+" nil t)
1196 (replace-match " "))
1197 ;; Translate all characters to "a".
1198 (goto-char (point-min))
1200 (while (re-search-forward "[A-Za-z]" nil t)
1201 (replace-match "a" t t)))
1203 (goto-char (point-min))
1204 (while (re-search-forward "[0-9]+" nil t)
1208 (string-to-number (buffer-substring
1209 (match-beginning 0) (match-end 0)))))))
1210 (setq string (buffer-substring 1 (point-max)))
1211 (setcar (car string-list) string)
1212 (setq string-list (cdr string-list))))
1216 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1217 ;; function. It takes a list of articles to be grabbed and a function
1218 ;; to apply to each article.
1220 ;; The function to be called should take two parameters. The first
1221 ;; parameter is the article buffer. The function should leave the
1222 ;; result, if any, in this buffer. Most treatment functions will just
1223 ;; generate files...
1225 ;; The second parameter is the state of the list of articles, and can
1226 ;; have four values: `first', `middle', `last' and `first-and-last'.
1228 ;; The function should return a list. The list may contain the
1229 ;; following symbols:
1230 ;; `error' if an error occurred
1231 ;; `begin' if the beginning of an encoded file has been received
1232 ;; If the list returned contains a `begin', the first element of
1233 ;; the list *must* be a string with the file name of the decoded
1235 ;; `end' if the end of an encoded file has been received
1236 ;; `middle' if the article was a body part of an encoded file
1237 ;; `wrong-type' if the article was not a part of an encoded file
1238 ;; `ok', which can be used everything is ok
1240 (defvar gnus-uu-has-been-grabbed nil)
1242 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1244 (if (not (and gnus-uu-has-been-grabbed
1245 gnus-uu-unmark-articles-not-decoded))
1247 (when dont-unmark-last-article
1248 (setq art (car gnus-uu-has-been-grabbed))
1249 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1250 (while gnus-uu-has-been-grabbed
1251 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1252 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1253 (when dont-unmark-last-article
1254 (setq gnus-uu-has-been-grabbed (list art))))))
1256 ;; This function takes a list of articles and a function to apply to
1257 ;; each article grabbed.
1259 ;; This function returns a list of files decoded if the grabbing and
1260 ;; the process-function has been successful and nil otherwise.
1261 (defun gnus-uu-grab-articles (articles process-function
1262 &optional sloppy limit no-errors)
1263 (let ((state 'first)
1264 (gnus-asynchronous nil)
1265 (gnus-inhibit-treatment t)
1266 has-been-begin article result-file result-files process-state
1267 gnus-summary-display-article-function
1268 gnus-article-prepare-hook gnus-display-mime-function
1269 article-series files)
1271 (while (and articles
1272 (not (memq 'error process-state))
1274 (not (memq 'end process-state))))
1276 (setq article (pop articles))
1277 (when (vectorp (gnus-summary-article-header article))
1278 (push article article-series)
1281 (if (eq state 'first)
1282 (setq state 'first-and-last)
1283 (setq state 'last)))
1285 (let ((part (gnus-uu-part-number article)))
1286 (gnus-message 6 "Getting article %d%s..."
1287 article (if (string= part "") "" (concat ", " part))))
1288 (gnus-summary-display-article article)
1290 ;; Push the article to the processing function.
1292 (set-buffer gnus-original-article-buffer)
1293 (let ((buffer-read-only nil))
1295 (set-buffer gnus-summary-buffer)
1297 (funcall process-function
1298 gnus-original-article-buffer state)))))
1300 (gnus-summary-remove-process-mark article)
1302 ;; If this is the beginning of a decoded file, we push it
1304 (when (or (memq 'begin process-state)
1305 (and (or (eq state 'first)
1306 (eq state 'first-and-last))
1307 (memq 'ok process-state)))
1308 (when has-been-begin
1309 ;; If there is a `result-file' here, that means that the
1310 ;; file was unsuccessfully decoded, so we delete it.
1311 (when (and result-file
1312 (file-exists-p result-file)
1313 (not gnus-uu-be-dangerous)
1314 (or (eq gnus-uu-be-dangerous t)
1316 (format "Delete unsuccessfully decoded file %s? "
1318 (delete-file result-file)))
1319 (when (memq 'begin process-state)
1320 (setq result-file (car process-state)))
1321 (setq has-been-begin t))
1323 ;; Check whether we have decoded one complete file.
1324 (when (memq 'end process-state)
1325 (setq article-series nil)
1326 (setq has-been-begin nil)
1327 (if (stringp result-file)
1328 (setq files (list result-file))
1329 (setq files result-file))
1330 (setq result-file (car files))
1332 (push (list (cons 'name (pop files))
1333 (cons 'article article))
1335 ;; Allow user-defined functions to be run on this file.
1336 (when gnus-uu-grabbed-file-functions
1337 (let ((funcs gnus-uu-grabbed-file-functions))
1338 (unless (listp funcs)
1339 (setq funcs (list funcs)))
1341 (funcall (pop funcs) result-file))))
1342 (setq result-file nil)
1343 ;; Check whether we have decoded enough articles.
1344 (and limit (= (length result-files) limit)
1345 (setq articles nil)))
1347 ;; If this is the last article to be decoded, and
1348 ;; we still haven't reached the end, then we delete
1349 ;; the partially decoded file.
1350 (and (or (eq state 'last) (eq state 'first-and-last))
1351 (not (memq 'end process-state))
1353 (file-exists-p result-file)
1354 (not gnus-uu-be-dangerous)
1355 (or (eq gnus-uu-be-dangerous t)
1357 (format "Delete incomplete file %s? " result-file)))
1358 (delete-file result-file))
1360 ;; If this was a file of the wrong sort, then
1361 (when (and (or (memq 'wrong-type process-state)
1362 (memq 'error process-state))
1363 gnus-uu-unmark-articles-not-decoded)
1364 (gnus-summary-tick-article article t))
1366 ;; Set the new series state.
1367 (if (and (not has-been-begin)
1369 (or (memq 'end process-state)
1370 (memq 'middle process-state)))
1372 (setq process-state (list 'error))
1373 (gnus-message 2 "No begin part at the beginning")
1375 (setq state 'middle))))
1377 ;; When there are no result-files, then something must be wrong.
1381 ((not has-been-begin)
1382 (gnus-message 2 "Wrong type file"))
1383 ((memq 'error process-state)
1384 (gnus-message 2 "An error occurred during decoding"))
1385 ((not (or (memq 'ok process-state)
1386 (memq 'end process-state)))
1387 (gnus-message 2 "End of articles reached before end of file")))
1388 ;; Make unsuccessfully decoded articles unread.
1389 (when gnus-uu-unmark-articles-not-decoded
1390 (while article-series
1391 (gnus-summary-tick-article (pop article-series) t))))
1393 ;; The original article buffer is hosed, shoot it down.
1394 (gnus-kill-buffer gnus-original-article-buffer)
1395 (setq gnus-current-article nil)
1398 (defun gnus-uu-grab-view (file)
1399 "View FILE using the gnus-uu methods."
1400 (let ((action (gnus-uu-get-action file)))
1401 (gnus-execute-command
1402 (if (string-match "%" action)
1403 (format action file)
1404 (concat action " " file))
1405 (eq gnus-view-pseudos 'not-confirm))))
1407 (defun gnus-uu-grab-move (file)
1408 "Move FILE to somewhere."
1409 (when gnus-uu-default-dir
1410 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1411 (file-name-nondirectory file))))
1412 (rename-file file to-file)
1413 (unless (file-exists-p file)
1414 (make-symbolic-link to-file file)))))
1416 (defun gnus-uu-part-number (article)
1417 (let* ((header (gnus-summary-article-header article))
1418 (subject (and header (mail-header-subject header)))
1421 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1423 (setq part (match-string 0 subject))
1424 (setq subject (substring subject (match-end 0)))))
1426 (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
1427 (setq part (match-string 0 subject))
1428 (setq subject (substring subject (match-end 0)))))
1431 (defun gnus-uu-uudecode-sentinel (process event)
1432 (delete-process (get-process process)))
1434 (defun gnus-uu-uustrip-article (process-buffer in-state)
1435 ;; Uudecodes a file asynchronously.
1437 (set-buffer process-buffer)
1438 (let ((state (list 'wrong-type))
1439 process-connection-type case-fold-search buffer-read-only
1441 (goto-char (point-min))
1443 ;; Deal with ^M at the end of the lines.
1444 (when gnus-uu-kill-carriage-return
1446 (while (search-forward "\r" nil t)
1447 (delete-backward-char 1))))
1449 (while (or (re-search-forward gnus-uu-begin-string nil t)
1450 (re-search-forward gnus-uu-body-line nil t))
1451 (setq state (list 'ok))
1452 ;; Ok, we are at the first uucoded line.
1454 (setq start-char (point))
1456 (if (not (looking-at gnus-uu-begin-string))
1457 (setq state (list 'middle))
1458 ;; This is the beginning of a uuencoded article.
1459 ;; We replace certain characters that could make things messy.
1460 (setq gnus-uu-file-name
1462 mm-file-name-rewrite-functions
1463 (file-name-nondirectory (match-string 1))))
1464 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1466 ;; Remove any non gnus-uu-body-line right after start.
1468 (while (and (not (eobp))
1469 (not (looking-at gnus-uu-body-line)))
1472 ;; If a process is running, we kill it.
1473 (when (and gnus-uu-uudecode-process
1474 (memq (process-status gnus-uu-uudecode-process)
1476 (delete-process gnus-uu-uudecode-process)
1477 (gnus-uu-unmark-list-of-grabbed t))
1479 ;; Start a new uudecoding process.
1480 (let ((cdir default-directory))
1483 (cd gnus-uu-work-dir)
1484 (setq gnus-uu-uudecode-process
1487 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1488 shell-file-name shell-command-switch
1489 (format "cd %s %s uudecode" gnus-uu-work-dir
1490 gnus-shell-command-separator))))
1492 (set-process-sentinel
1493 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1494 (setq state (list 'begin))
1495 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1497 ;; We look for the end of the thing to be decoded.
1498 (if (re-search-forward gnus-uu-end-string nil t)
1500 (goto-char (point-max))
1501 (re-search-backward gnus-uu-body-line nil t))
1505 (when gnus-uu-uudecode-process
1506 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1507 ;; Try to correct mishandled uucode.
1508 (when gnus-uu-correct-stripped-uucode
1509 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1510 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1512 ;; Send the text to the process.
1514 (process-send-region
1515 gnus-uu-uudecode-process start-char (point))
1518 (delete-process gnus-uu-uudecode-process)
1519 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1520 (setq state (list 'wrong-type)))))
1522 (if (memq 'end state)
1524 ;; Send an EOF, just in case.
1526 (process-send-eof gnus-uu-uudecode-process))
1527 (while (memq (process-status gnus-uu-uudecode-process)
1529 (accept-process-output gnus-uu-uudecode-process 1)))
1530 (when (or (not gnus-uu-uudecode-process)
1531 (not (memq (process-status gnus-uu-uudecode-process)
1533 (setq state (list 'wrong-type)))))))
1535 (if (memq 'begin state)
1536 (cons (if (= (length files) 1) (car files) files) state)
1539 (defvar gnus-uu-unshar-warning
1542 Shell archives are an archaic method of bundling files for distribution
1543 across computer networks. During the unpacking process, arbitrary commands
1544 are executed on your system, and all kinds of nasty things can happen.
1545 Please examine the archive very carefully before you instruct Emacs to
1546 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1548 If you are unsure what to do, please answer \"no\"."
1549 "Text of warning message displayed by `gnus-uu-unshar-article'.
1550 Make sure that this text consists only of few text lines. Otherwise,
1551 Gnus might fail to display all of it.")
1554 ;; This function is used by `gnus-uu-grab-articles' to treat
1555 ;; a shared article.
1556 (defun gnus-uu-unshar-article (process-buffer in-state)
1557 (let ((state (list 'ok))
1560 (set-buffer process-buffer)
1561 (goto-char (point-min))
1562 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1563 (setq state (list 'wrong-type))
1564 (save-window-excursion
1566 (switch-to-buffer (current-buffer))
1567 (delete-other-windows)
1568 (let ((buffer (get-buffer-create (generate-new-buffer-name
1572 (with-current-buffer buffer
1573 (insert (substitute-command-keys
1574 gnus-uu-unshar-warning))
1575 (goto-char (point-min))
1576 (display-buffer buffer)
1577 (yes-or-no-p "This is a shell archive, unshar it? "))
1578 (kill-buffer buffer))
1579 (setq state (list 'error))))))
1580 (unless (memq 'error state)
1582 (setq start-char (point))
1583 (call-process-region
1584 start-char (point-max) shell-file-name nil
1585 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1586 shell-command-switch
1587 (concat "cd " gnus-uu-work-dir " "
1588 gnus-shell-command-separator " sh")))))
1591 ;; Returns the name of what the shar file is going to unpack.
1592 (defun gnus-uu-find-name-in-shar ()
1593 (let ((oldpoint (point))
1595 (goto-char (point-min))
1596 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1597 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1598 (goto-char oldpoint)
1601 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1602 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1603 ;; found, or the name of the command to run if such a rule is found.
1604 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1605 (let ((action-list (copy-sequence file-action-list))
1606 (case-fold-search t)
1611 (and gnus-uu-ignore-files-by-name
1612 (string-match gnus-uu-ignore-files-by-name file-name)))
1614 (and gnus-uu-ignore-files-by-type
1615 (string-match gnus-uu-ignore-files-by-type
1616 (or (gnus-uu-choose-action
1617 file-name gnus-uu-ext-to-mime-list t)
1619 (while (not (or (eq action-list ()) action))
1620 (setq rule (car action-list))
1621 (setq action-list (cdr action-list))
1622 (when (string-match (car rule) file-name)
1623 (setq action (cadr rule)))))
1626 (defun gnus-uu-treat-archive (file-path)
1627 ;; Unpacks an archive. Returns t if unpacking is successful.
1628 (let ((did-unpack t)
1630 (setq action (gnus-uu-choose-action
1631 file-path (append gnus-uu-user-archive-rules
1632 (if gnus-uu-ignore-default-archive-rules
1634 gnus-uu-default-archive-rules))))
1637 (error "No unpackers for the file %s" file-path))
1639 (string-match "/[^/]*$" file-path)
1640 (setq dir (substring file-path 0 (match-beginning 0)))
1642 (when (member action gnus-uu-destructive-archivers)
1643 (copy-file file-path (concat file-path "~") t))
1645 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1648 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1651 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1653 (if (eq 0 (call-process shell-file-name nil
1654 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1655 nil shell-command-switch command))
1657 (gnus-message 2 "Error during unpacking of archive")
1658 (setq did-unpack nil))
1660 (when (member action gnus-uu-destructive-archivers)
1661 (rename-file (concat file-path "~") file-path t))
1665 (defun gnus-uu-dir-files (dir)
1666 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1669 (if (file-directory-p (setq file (car dirs)))
1670 (setq files (append files (gnus-uu-dir-files file)))
1672 (setq dirs (cdr dirs)))
1675 (defun gnus-uu-unpack-files (files &optional ignore)
1676 ;; Go through FILES and look for files to unpack.
1677 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1681 (setq file (cdr (assq 'name (car files))))
1682 (when (and (not (member file ignore))
1683 (equal (gnus-uu-get-action (file-name-nondirectory file))
1685 (push file did-unpack)
1686 (unless (gnus-uu-treat-archive file)
1687 (gnus-message 2 "Error during unpacking of %s" file))
1688 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1691 (unless (member (car nfiles) totfiles)
1692 (push (list (cons 'name (car nfiles))
1693 (cons 'original file))
1695 (setq nfiles (cdr nfiles)))
1696 (setq totfiles newfiles)))
1697 (setq files (cdr files)))
1699 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1702 (defun gnus-uu-ls-r (dir)
1703 (let* ((files (gnus-uu-directory-files dir t))
1706 (when (file-directory-p (car files))
1707 (setq ofiles (delete (car files) ofiles))
1708 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1709 (setq files (cdr files)))
1714 (defun gnus-uu-directory-files (dir &optional full)
1715 (let (files out file)
1716 (setq files (directory-files dir full))
1718 (setq file (car files))
1719 (setq files (cdr files))
1720 (unless (member (file-name-nondirectory file) '("." ".."))
1722 (setq out (nreverse out))
1725 (defun gnus-uu-check-correct-stripped-uucode (start end)
1727 (let (found beg length)
1728 (unless gnus-uu-correct-stripped-uucode
1731 (if (re-search-forward " \\|`" end t)
1736 (when (looking-at "\n")
1741 (unless (looking-at (concat gnus-uu-begin-string "\\|"
1742 gnus-uu-end-string))
1744 (setq length (- (point-at-eol) (point-at-bol))))
1749 (unless (= length (- (point) beg))
1750 (insert (make-string (- length (- (point) beg)) ? ))))
1751 (forward-line 1)))))))
1753 (defvar gnus-uu-tmp-alist nil)
1755 (defun gnus-uu-initialize (&optional scan)
1758 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1759 (if (file-exists-p (cdr entry))
1760 (setq gnus-uu-work-dir (cdr entry))
1761 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1764 (setq gnus-uu-tmp-dir (file-name-as-directory
1765 (expand-file-name gnus-uu-tmp-dir)))
1766 (if (not (file-directory-p gnus-uu-tmp-dir))
1767 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1768 (when (not (file-writable-p gnus-uu-tmp-dir))
1769 (error "Temp directory %s can't be written to"
1772 (setq gnus-uu-work-dir
1773 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1774 (gnus-set-file-modes gnus-uu-work-dir 448)
1775 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1776 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1777 gnus-uu-tmp-alist))))
1780 ;; Kills the temporary uu buffers, kills any processes, etc.
1781 (defun gnus-uu-clean-up ()
1783 (and gnus-uu-uudecode-process
1784 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1786 (delete-process gnus-uu-uudecode-process))
1787 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1788 (kill-buffer buf))))
1790 ;; Inputs an action and a filename and returns a full command, making sure
1791 ;; that the filename will be treated as a single argument when the shell
1792 ;; executes the command.
1793 (defun gnus-uu-command (action file)
1794 (let ((quoted-file (shell-quote-argument file)))
1795 (if (string-match "%s" action)
1796 (format action quoted-file)
1797 (concat action " " quoted-file))))
1799 (defun gnus-uu-delete-work-dir (&optional dir)
1800 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1802 (gnus-message 7 "Deleting directory %s..." dir)
1803 (setq dir gnus-uu-work-dir))
1805 (file-exists-p dir))
1806 (let ((files (directory-files dir t nil t))
1808 (while (setq file (pop files))
1809 (unless (member (file-name-nondirectory file) '("." ".."))
1810 (if (file-directory-p file)
1811 (gnus-uu-delete-work-dir file)
1812 (gnus-message 9 "Deleting file %s..." file)
1815 (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
1817 (delete-directory dir)
1818 (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
1819 (gnus-message 7 "")))
1823 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1824 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1829 ;;; uuencoded posting
1832 ;; Any function that is to be used as and encoding method will take two
1833 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1834 ;; and "spiral.jpg", respectively.) The function should return nil if
1835 ;; the encoding wasn't successful.
1836 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1837 "Function used for encoding binary files.
1838 There are three functions supplied with gnus-uu for encoding files:
1839 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1840 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1841 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1842 uuencode and adds MIME headers."
1843 :group 'gnus-extract-post
1844 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1845 (function-item gnus-uu-post-encode-mime)
1846 (function-item gnus-uu-post-encode-mime-uuencode)
1847 (function :tag "Other")))
1849 (defcustom gnus-uu-post-include-before-composing nil
1850 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1851 If this variable is t, you can either include an encoded file with
1852 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1853 :group 'gnus-extract-post
1856 (defcustom gnus-uu-post-length 990
1857 "Maximum length of an article.
1858 The encoded file will be split into how many articles it takes to
1859 post the entire file."
1860 :group 'gnus-extract-post
1863 (defcustom gnus-uu-post-threaded nil
1864 "Non-nil means that gnus-uu will post the encoded file in a thread.
1865 This may not be smart, as no other decoder I have seen are able to
1866 follow threads when collecting uuencoded articles. (Well, I have seen
1867 one package that does that - gnus-uu, but somehow, I don't think that
1868 counts...) The default is nil."
1869 :group 'gnus-extract-post
1872 (defcustom gnus-uu-post-separate-description t
1873 "Non-nil means that the description will be posted in a separate article.
1874 The first article will typically be numbered (0/x). If this variable
1875 is nil, the description the user enters will be included at the
1876 beginning of the first article, which will be numbered (1/x). Default
1878 :group 'gnus-extract-post
1881 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1882 (defvar gnus-uu-post-message-id nil)
1883 (defvar gnus-uu-post-inserted-file-name nil)
1884 (defvar gnus-uu-winconf-post-news nil)
1886 (defun gnus-uu-post-news ()
1887 "Compose an article and post an encoded file."
1889 (setq gnus-uu-post-inserted-file-name nil)
1890 (setq gnus-uu-winconf-post-news (current-window-configuration))
1892 (gnus-summary-post-news)
1894 (let ((map (make-sparse-keymap)))
1895 (set-keymap-parent map (current-local-map))
1896 (use-local-map map))
1897 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1898 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1899 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1900 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1902 (when gnus-uu-post-include-before-composing
1903 (save-excursion (setq gnus-uu-post-inserted-file-name
1904 (gnus-uu-post-insert-binary)))))
1906 (defun gnus-uu-post-insert-binary-in-article ()
1907 "Inserts an encoded file in the buffer.
1908 The user will be asked for a file name."
1911 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1913 ;; Encodes with uuencode and substitutes all spaces with backticks.
1914 (defun gnus-uu-post-encode-uuencode (path file-name)
1915 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1916 (goto-char (point-min))
1918 (while (search-forward " " nil t)
1919 (replace-match "`"))
1922 ;; Encodes with uuencode and adds MIME headers.
1923 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1924 (when (gnus-uu-post-encode-uuencode path file-name)
1925 (gnus-uu-post-make-mime file-name "x-uue")
1928 ;; Encodes with base64 and adds MIME headers
1929 (defun gnus-uu-post-encode-mime (path file-name)
1930 (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1931 (format "%s %s -o %s" "mmencode" path file-name)))
1932 (gnus-uu-post-make-mime file-name "base64")
1935 ;; Adds MIME headers.
1936 (defun gnus-uu-post-make-mime (file-name encoding)
1937 (goto-char (point-min))
1938 (insert (format "Content-Type: %s; name=\"%s\"\n"
1939 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1941 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1943 (set-buffer gnus-message-buffer)
1944 (goto-char (point-min))
1945 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1947 (narrow-to-region (point-min) (point))
1948 (unless (mail-fetch-field "mime-version")
1950 (insert "MIME-Version: 1.0\n"))
1953 ;; Encodes a file PATH with COMMAND, leaving the result in the
1955 (defun gnus-uu-post-encode-file (command path file-name)
1956 (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1957 (format "%s %s %s" command path file-name))))
1959 (defun gnus-uu-post-news-inews ()
1960 "Posts the composed news article and encoded file.
1961 If no file has been included, the user will be asked for a file."
1966 (if gnus-uu-post-inserted-file-name
1967 (setq file-name gnus-uu-post-inserted-file-name)
1968 (setq file-name (gnus-uu-post-insert-binary)))
1970 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1971 (setq gnus-uu-post-inserted-file-name nil)
1972 (when gnus-uu-winconf-post-news
1973 (set-window-configuration gnus-uu-winconf-post-news)))
1975 ;; Asks for a file to encode, encodes it and inserts the result in
1976 ;; the current buffer. Returns the file name the user gave.
1977 (defun gnus-uu-post-insert-binary ()
1978 (let ((uuencode-buffer-name "*uuencode buffer*")
1979 file-path uubuf file-name)
1981 (setq file-path (read-file-name
1982 "What file do you want to encode? "))
1983 (when (not (file-exists-p file-path))
1984 (error "%s: No such file" file-path))
1986 (goto-char (point-max))
1987 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1989 ;; #### Unix-specific?
1990 (when (string-match "^~/" file-path)
1991 (setq file-path (concat "$HOME" (substring file-path 1))))
1992 ;; #### Unix-specific?
1993 (if (string-match "/[^/]*$" file-path)
1994 (setq file-name (substring file-path (1+ (match-beginning 0))))
1995 (setq file-name file-path))
1999 (set-buffer (setq uubuf
2000 (gnus-get-buffer-create uuencode-buffer-name)))
2002 (funcall gnus-uu-post-encode-method file-path file-name))
2003 (insert-buffer-substring uubuf)
2004 (error "Encoding unsuccessful"))
2005 (kill-buffer uubuf))
2008 ;; Posts the article and all of the encoded file.
2009 (defun gnus-uu-post-encoded (file-name &optional threaded)
2010 (let ((send-buffer-name "*uuencode send buffer*")
2011 (encoded-buffer-name "*encoded buffer*")
2012 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
2013 (separator (concat mail-header-separator "\n\n"))
2014 uubuf length parts header i end beg
2015 beg-line minlen post-buf whole-len beg-binary end-binary)
2017 (setq post-buf (current-buffer))
2019 (goto-char (point-min))
2020 (when (not (re-search-forward
2021 (if gnus-uu-post-separate-description
2022 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2024 (concat "^" (regexp-quote mail-header-separator) "$"))
2026 (error "Internal error: No binary/header separator"))
2029 (setq beg-binary (point))
2030 (setq end-binary (point-max))
2033 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2035 (insert-buffer-substring post-buf beg-binary end-binary)
2036 (goto-char (point-min))
2037 (setq length (count-lines (point-min) (point-max)))
2038 (setq parts (/ length gnus-uu-post-length))
2039 (unless (< (% length gnus-uu-post-length) 4)
2042 (when gnus-uu-post-separate-description
2044 (delete-region (point) (point-max))
2046 (goto-char (point-min))
2048 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2049 (setq header (buffer-substring (point-min) (point-at-bol)))
2051 (goto-char (point-min))
2052 (when gnus-uu-post-separate-description
2053 (when (re-search-forward "^Subject: " nil t)
2055 (insert (format " (0/%d)" parts)))
2058 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2063 (while (not (> i parts))
2064 (set-buffer (gnus-get-buffer-create send-buffer-name))
2067 (when (and threaded gnus-uu-post-message-id)
2068 (insert "References: " gnus-uu-post-message-id "\n"))
2071 (- 62 (length (format top-string "" file-name i parts ""))))
2072 (when (> 1 (setq minlen (/ whole-len 2)))
2077 (make-string minlen ?-)
2080 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2082 (goto-char (point-min))
2083 (when (re-search-forward "^Subject: " nil t)
2085 (insert (format " (%d/%d)" i parts)))
2087 (goto-char (point-max))
2092 (goto-char (point-max))
2093 (forward-line gnus-uu-post-length))
2094 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2097 (insert-buffer-substring uubuf beg end)
2098 (insert beg-line "\n")
2101 (goto-char (point-min))
2103 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2106 (when (re-search-forward
2107 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2113 (let (message-sent-message-via)
2116 (setq gnus-uu-post-message-id
2117 (concat (message-fetch-field "references") " "
2118 (message-fetch-field "message-id"))))))
2120 (gnus-kill-buffer send-buffer-name)
2121 (gnus-kill-buffer encoded-buffer-name)
2123 (when (not gnus-uu-post-separate-description)
2124 (set-buffer-modified-p nil)
2129 ;;; arch-tag: 05312384-0a83-4720-9a58-b3160b888853
2130 ;;; gnus-uu.el ends here