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, 2005 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., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
30 (eval-when-compile (require 'cl))
38 (defgroup gnus-extract nil
39 "Extracting encoded files."
43 (defgroup gnus-extract-view nil
44 "Viewwing extracted files."
47 (defgroup gnus-extract-archive nil
48 "Extracting encoded archives."
51 (defgroup gnus-extract-post nil
52 "Extracting encoded archives."
53 :prefix "gnus-uu-post"
56 ;; Default viewing action rules
58 (defcustom gnus-uu-default-view-rules
59 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
60 ("\\.pas$" "cat %s | sed 's/\r$//'")
61 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
62 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
63 ("\\.tga$" "tgatoppm %s | ee -")
64 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
65 "sox -v .5 %s -t .au -u - > /dev/audio")
66 ("\\.au$" "cat %s > /dev/audio")
67 ("\\.midi?$" "playmidi -f")
69 ("\\.ps$" "ghostview")
71 ("\\.html$" "xmosaic")
72 ("\\.mpe?g$" "mpeg_play")
73 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
74 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
76 "*Default actions to be taken when the user asks to view a file.
77 To change the behaviour, you can either edit this variable or set
78 `gnus-uu-user-view-rules' to something useful.
82 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
83 following in your .emacs file:
85 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
87 Both these variables are lists of lists with two string elements. The
88 first string is a regular expression. If the file name matches this
89 regular expression, the command in the second string is executed with
90 the file as an argument.
92 If the command string contains \"%s\", the file name will be inserted
93 at that point in the command string. If there's no \"%s\" in the
94 command string, the file name will be appended to the command string
97 There are several user variables to tailor the behaviour of gnus-uu to
98 your needs. First we have `gnus-uu-user-view-rules', which is the
99 variable gnus-uu first consults when trying to decide how to view a
100 file. If this variable contains no matches, gnus-uu examines the
101 default rule variable provided in this package. If gnus-uu finds no
102 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
104 :group 'gnus-extract-view
105 :type '(repeat (group regexp (string :tag "Command"))))
107 (defcustom gnus-uu-user-view-rules nil
108 "What actions are to be taken to view a file.
109 See the documentation on the `gnus-uu-default-view-rules' variable for
111 :group 'gnus-extract-view
112 :type '(repeat (group regexp (string :tag "Command"))))
114 (defcustom gnus-uu-user-view-rules-end
116 "*What actions are to be taken if no rule matched the file name.
117 See the documentation on the `gnus-uu-default-view-rules' variable for
119 :group 'gnus-extract-view
120 :type '(repeat (group regexp (string :tag "Command"))))
122 ;; Default unpacking commands
124 (defcustom gnus-uu-default-archive-rules
125 '(("\\.tar$" "tar xf")
126 ("\\.zip$" "unzip -o")
128 ("\\.arj$" "unarj x")
130 ("\\.\\(lzh\\|lha\\)$" "lha x")
131 ("\\.Z$" "uncompress")
133 ("\\.arc$" "arc -x"))
134 "*See `gnus-uu-user-archive-rules'."
135 :group 'gnus-extract-archive
136 :type '(repeat (group regexp (string :tag "Command"))))
138 (defvar gnus-uu-destructive-archivers
139 (list "uncompress" "gunzip"))
141 (defcustom gnus-uu-user-archive-rules nil
142 "A list that can be set to override the default archive unpacking commands.
143 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
144 unpack zip files, say the following:
145 (setq gnus-uu-user-archive-rules
146 '((\"\\\\.tar$\" \"untar\")
147 (\"\\\\.zip$\" \"zip -x\")))"
148 :group 'gnus-extract-archive
149 :type '(repeat (group regexp (string :tag "Command"))))
151 (defcustom gnus-uu-ignore-files-by-name nil
152 "*A regular expression saying what files should not be viewed based on name.
153 If, for instance, you want gnus-uu to ignore all .au and .wav files,
154 you could say something like
156 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
158 Note that this variable can be used in conjunction with the
159 `gnus-uu-ignore-files-by-type' variable."
161 :type '(choice (const :tag "off" nil)
162 (regexp :format "%v")))
164 (defcustom gnus-uu-ignore-files-by-type nil
165 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
166 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
167 you could say something like
169 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
171 Note that this variable can be used in conjunction with the
172 `gnus-uu-ignore-files-by-name' variable."
174 :type '(choice (const :tag "off" nil)
175 (regexp :format "%v")))
177 ;; Pseudo-MIME support
179 (defconst gnus-uu-ext-to-mime-list
180 '(("\\.gif$" "image/gif")
181 ("\\.jpe?g$" "image/jpeg")
182 ("\\.tiff?$" "image/tiff")
183 ("\\.xwd$" "image/xwd")
184 ("\\.pbm$" "image/pbm")
185 ("\\.pgm$" "image/pgm")
186 ("\\.ppm$" "image/ppm")
187 ("\\.xbm$" "image/xbm")
188 ("\\.pcx$" "image/pcx")
189 ("\\.tga$" "image/tga")
190 ("\\.ps$" "image/postscript")
191 ("\\.fli$" "video/fli")
192 ("\\.wav$" "audio/wav")
193 ("\\.aiff$" "audio/aiff")
194 ("\\.hcom$" "audio/hcom")
195 ("\\.voc$" "audio/voc")
196 ("\\.smp$" "audio/smp")
197 ("\\.mod$" "audio/mod")
198 ("\\.dvi$" "image/dvi")
199 ("\\.mpe?g$" "video/mpeg")
200 ("\\.au$" "audio/basic")
201 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
202 ("\\.\\(c\\|h\\)$" "text/source")
203 ("read.*me" "text/plain")
204 ("\\.html$" "text/html")
205 ("\\.bat$" "text/bat")
206 ("\\.[1-6]$" "text/man")
207 ("\\.flc$" "video/flc")
208 ("\\.rle$" "video/rle")
209 ("\\.pfx$" "video/pfx")
210 ("\\.avi$" "video/avi")
211 ("\\.sme$" "video/sme")
212 ("\\.rpza$" "video/prza")
213 ("\\.dl$" "video/dl")
214 ("\\.qt$" "video/qt")
215 ("\\.rsrc$" "video/rsrc")
216 ("\\..*$" "unknown/unknown")))
218 ;; Various variables users may set
220 (defcustom gnus-uu-tmp-dir
221 (cond ((fboundp 'temp-directory) (temp-directory))
222 ((boundp 'temporary-file-directory) temporary-file-directory)
224 "*Variable saying where gnus-uu is to do its work.
225 Default is \"/tmp/\"."
229 (defcustom gnus-uu-do-not-unpack-archives nil
230 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
232 :group 'gnus-extract-archive
235 (defcustom gnus-uu-ignore-default-view-rules nil
236 "*Non-nil means that gnus-uu will ignore the default viewing rules.
237 Only the user viewing rules will be consulted. Default is nil."
238 :group 'gnus-extract-view
241 (defcustom gnus-uu-grabbed-file-functions nil
242 "Functions run on each file after successful decoding.
243 They will be called with the name of the file as the argument.
244 Likely functions you can use in this list are `gnus-uu-grab-view'
245 and `gnus-uu-grab-move'."
247 :options '(gnus-uu-grab-view gnus-uu-grab-move)
250 (defcustom gnus-uu-ignore-default-archive-rules nil
251 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
252 Only the user unpacking commands will be consulted. Default is nil."
253 :group 'gnus-extract-archive
256 (defcustom gnus-uu-kill-carriage-return t
257 "*Non-nil means that gnus-uu will strip all carriage returns from articles.
262 (defcustom gnus-uu-view-with-metamail nil
263 "*Non-nil means that files will be viewed with metamail.
264 The gnus-uu viewing functions will be ignored and gnus-uu will try
265 to guess at a content-type based on file name suffixes. Default
270 (defcustom gnus-uu-unmark-articles-not-decoded nil
271 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
276 (defcustom gnus-uu-correct-stripped-uucode nil
277 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
282 (defcustom gnus-uu-save-in-digest nil
283 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
284 If this variable is nil, gnus-uu will just save everything in a
285 file without any embellishments. The digesting almost conforms to RFC1153 -
286 no easy way to specify any meaningful volume and issue numbers were found,
287 so I simply dropped them."
291 (defcustom gnus-uu-pre-uudecode-hook nil
292 "Hook run before sending a message to uudecode."
296 (defcustom gnus-uu-digest-headers
297 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
298 "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
299 "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
301 "*List of regexps to match headers included in digested messages.
302 The headers will be included in the sequence they are matched. If nil
303 include all headers."
305 :type '(repeat regexp))
307 (defcustom gnus-uu-save-separate-articles nil
308 "*Non-nil means that gnus-uu will save articles in separate files."
312 (defcustom gnus-uu-be-dangerous 'ask
313 "*Specifies what to do if unusual situations arise during decoding.
314 If nil, be as conservative as possible. If t, ignore things that
315 didn't work, and overwrite existing files. Otherwise, ask each time."
317 :type '(choice (const :tag "conservative" nil)
318 (const :tag "ask" ask)
319 (const :tag "liberal" t)))
321 ;; Internal variables
323 (defvar gnus-uu-saved-article-name nil)
325 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
326 (defvar gnus-uu-end-string "^end[ \t]*$")
328 (defvar gnus-uu-body-line "^M")
330 (while (> (setq i (1- i)) 0)
331 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
332 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
334 ;"^M.............................................................?$"
336 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
338 (defvar gnus-uu-shar-file-name nil)
339 (defvar gnus-uu-shar-name-marker
340 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
342 (defvar gnus-uu-postscript-begin-string "^%!PS-")
343 (defvar gnus-uu-postscript-end-string "^%%EOF$")
345 (defvar gnus-uu-file-name nil)
346 (defvar gnus-uu-uudecode-process nil)
347 (defvar gnus-uu-binhex-article-name nil)
349 (defvar gnus-uu-work-dir nil)
351 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
353 (defvar gnus-uu-default-dir gnus-article-save-directory)
354 (defvar gnus-uu-digest-from-subject nil)
355 (defvar gnus-uu-digest-buffer nil)
359 (defun gnus-uu-decode-uu (&optional n)
360 "Uudecodes the current article."
362 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
364 (defun gnus-uu-decode-uu-and-save (n dir)
365 "Decodes and saves the resulting file."
367 (list current-prefix-arg
368 (file-name-as-directory
369 (read-file-name "Uudecode and save in dir: "
371 gnus-uu-default-dir t))))
372 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
374 (defun gnus-uu-decode-unshar (&optional n)
375 "Unshars the current article."
377 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
379 (defun gnus-uu-decode-unshar-and-save (n dir)
380 "Unshars and saves the current article."
382 (list current-prefix-arg
383 (file-name-as-directory
384 (read-file-name "Unshar and save in dir: "
386 gnus-uu-default-dir t))))
387 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
389 (defun gnus-uu-decode-save (n file)
390 "Saves the current article."
392 (list current-prefix-arg
394 (if gnus-uu-save-separate-articles
395 "Save articles is dir: "
396 "Save articles in file: ")
398 gnus-uu-default-dir)))
399 (setq gnus-uu-saved-article-name file)
400 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
402 (defun gnus-uu-decode-binhex (n dir)
403 "Unbinhexes the current article."
405 (list current-prefix-arg
406 (file-name-as-directory
407 (read-file-name "Unbinhex and save in dir: "
409 gnus-uu-default-dir))))
410 (setq gnus-uu-binhex-article-name
411 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
412 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
414 (defun gnus-uu-decode-uu-view (&optional n)
415 "Uudecodes and views the current article."
417 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
418 (gnus-uu-decode-uu n)))
420 (defun gnus-uu-decode-uu-and-save-view (n dir)
421 "Decodes, views and saves the resulting file."
423 (list current-prefix-arg
424 (read-file-name "Uudecode, view and save in dir: "
426 gnus-uu-default-dir t)))
427 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
428 (gnus-uu-decode-uu-and-save n dir)))
430 (defun gnus-uu-decode-unshar-view (&optional n)
431 "Unshars and views the current article."
433 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
434 (gnus-uu-decode-unshar n)))
436 (defun gnus-uu-decode-unshar-and-save-view (n dir)
437 "Unshars and saves the current article."
439 (list current-prefix-arg
440 (read-file-name "Unshar, view and save in dir: "
442 gnus-uu-default-dir t)))
443 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
444 (gnus-uu-decode-unshar-and-save n dir)))
446 (defun gnus-uu-decode-save-view (n file)
447 "Saves and views the current article."
449 (list current-prefix-arg
450 (read-file-name (if gnus-uu-save-separate-articles
451 "Save articles is dir: "
452 "Save articles in file: ")
453 gnus-uu-default-dir gnus-uu-default-dir)))
454 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
455 (gnus-uu-decode-save n file)))
457 (defun gnus-uu-decode-binhex-view (n file)
458 "Unbinhexes and views the current article."
460 (list current-prefix-arg
461 (read-file-name "Unbinhex, view and save in dir: "
462 gnus-uu-default-dir gnus-uu-default-dir)))
463 (setq gnus-uu-binhex-article-name
464 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
465 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
466 (gnus-uu-decode-binhex n file)))
469 ;; Digest and forward articles
471 (defun gnus-uu-digest-mail-forward (&optional n post)
472 "Digests and forwards all articles in this series."
474 (let ((gnus-uu-save-in-digest t)
475 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
476 (message-forward-as-mime message-forward-as-mime)
477 (mail-parse-charset gnus-newsgroup-charset)
478 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
479 gnus-uu-digest-buffer subject from)
480 (if (and n (not (numberp n)))
481 (setq message-forward-as-mime (not message-forward-as-mime)
483 (let ((gnus-article-reply (gnus-summary-work-articles n))
484 gnus-newsgroup-processable)
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 (gnus-uu-get-list-of-articles nil)))
491 ;; Specify articles to be forwarded.
492 (setq gnus-newsgroup-processable (copy-sequence gnus-article-reply))
493 (gnus-setup-message 'forward
494 (setq gnus-uu-digest-from-subject nil)
495 (setq gnus-uu-digest-buffer
496 (gnus-get-buffer-create " *gnus-uu-forward*"))
497 (gnus-uu-decode-save n file)
498 (switch-to-buffer gnus-uu-digest-buffer)
499 (let ((fs gnus-uu-digest-from-subject))
502 subject (gnus-simplify-subject-fuzzy (cdar fs))
504 (while (and fs (or from subject))
506 (unless (string= from (caar fs))
509 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
514 (setq subject "Digested Articles"))
517 (if (gnus-news-group-p gnus-newsgroup-name)
520 (goto-char (point-min))
521 (when (re-search-forward "^Subject: ")
522 (delete-region (point) (point-at-eol))
524 (goto-char (point-min))
525 (when (re-search-forward "^From:")
526 (delete-region (point) (point-at-eol))
528 (let ((message-forward-decoded-p t))
529 (message-forward post t))))
530 (setq gnus-uu-digest-from-subject nil)))
532 (defun gnus-uu-digest-post-forward (&optional n)
533 "Digest and forward to a newsgroup."
535 (gnus-uu-digest-mail-forward n t))
539 (defun gnus-message-process-mark (unmarkp new-marked)
540 (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
541 (message "%d mark%s %s%s"
543 (if (= (length new-marked) 1) "" "s")
544 (if unmarkp "removed" "added")
550 (format ", %d remain marked"
551 (length gnus-newsgroup-processable)))
553 (format ", %d already marked" old))))))
555 (defun gnus-new-processable (unmarkp articles)
557 (gnus-intersection gnus-newsgroup-processable articles)
558 (gnus-set-difference articles gnus-newsgroup-processable)))
560 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
561 "Set the process mark on articles whose subjects match REGEXP.
562 When called interactively, prompt for REGEXP.
563 Optional UNMARK non-nil means unmark instead of mark."
564 (interactive "sMark (regexp): \nP")
566 (let* ((articles (gnus-uu-find-articles-matching regexp))
567 (new-marked (gnus-new-processable unmark articles)))
570 (gnus-summary-remove-process-mark (pop articles))
571 (gnus-summary-set-process-mark (pop articles))))
572 (gnus-message-process-mark unmark new-marked)))
573 (gnus-summary-position-point))
575 (defun gnus-uu-unmark-by-regexp (regexp)
576 "Remove the process mark from articles whose subjects match REGEXP.
577 When called interactively, prompt for REGEXP."
578 (interactive "sUnmark (regexp): ")
579 (gnus-uu-mark-by-regexp regexp t))
581 (defun gnus-uu-mark-series ()
582 "Mark the current series with the process mark."
584 (let* ((articles (gnus-uu-find-articles-matching))
585 (l (length articles)))
587 (gnus-summary-set-process-mark (car articles))
588 (setq articles (cdr articles)))
589 (message "Marked %d articles" l))
590 (gnus-summary-position-point))
592 (defun gnus-uu-mark-region (beg end &optional unmark)
593 "Set the process mark on all articles between point and mark."
597 (while (< (point) end)
599 (gnus-summary-remove-process-mark (gnus-summary-article-number))
600 (gnus-summary-set-process-mark (gnus-summary-article-number)))
602 (gnus-summary-position-point))
604 (defun gnus-uu-unmark-region (beg end)
605 "Remove the process mark from all articles between point and mark."
607 (gnus-uu-mark-region beg end t))
609 (defun gnus-uu-mark-buffer ()
610 "Set the process mark on all articles in the buffer."
612 (gnus-uu-mark-region (point-min) (point-max)))
614 (defun gnus-uu-unmark-buffer ()
615 "Remove the process mark on all articles in the buffer."
617 (gnus-uu-mark-region (point-min) (point-max) t))
619 (defun gnus-uu-mark-thread ()
620 "Marks all articles downwards in this thread."
622 (gnus-save-hidden-threads
623 (let ((level (gnus-summary-thread-level)))
624 (while (and (gnus-summary-set-process-mark
625 (gnus-summary-article-number))
626 (zerop (gnus-summary-next-subject 1 nil t))
627 (> (gnus-summary-thread-level) level)))))
628 (gnus-summary-position-point))
630 (defun gnus-uu-unmark-thread ()
631 "Unmarks all articles downwards in this thread."
633 (let ((level (gnus-summary-thread-level)))
634 (while (and (gnus-summary-remove-process-mark
635 (gnus-summary-article-number))
636 (zerop (gnus-summary-next-subject 1))
637 (> (gnus-summary-thread-level) level))))
638 (gnus-summary-position-point))
640 (defun gnus-uu-invert-processable ()
641 "Invert the list of process-marked articles."
643 (let ((data gnus-newsgroup-data)
647 (if (memq (setq number (gnus-data-number (pop data)))
648 gnus-newsgroup-processable)
649 (gnus-summary-remove-process-mark number)
650 (gnus-summary-set-process-mark number)))))
651 (gnus-summary-position-point))
653 (defun gnus-uu-mark-over (&optional score)
654 "Mark all articles with a score over SCORE (the prefix)."
656 (let ((score (or score gnus-summary-default-score 0))
657 (data gnus-newsgroup-data))
660 (when (> (or (cdr (assq (gnus-data-number (car data))
661 gnus-newsgroup-scored))
662 gnus-summary-default-score 0)
664 (gnus-summary-set-process-mark (caar data)))
665 (setq data (cdr data))))
666 (gnus-summary-position-point)))
668 (defun gnus-uu-mark-sparse ()
669 "Mark all series that have some articles marked."
671 (let ((marked (nreverse gnus-newsgroup-processable))
672 subject articles total headers)
674 (error "No articles marked with the process mark"))
675 (setq gnus-newsgroup-processable nil)
678 (and (vectorp (setq headers
679 (gnus-summary-article-header (car marked))))
680 (setq subject (mail-header-subject headers)
681 articles (gnus-uu-find-articles-matching
682 (gnus-uu-reginize-string subject))
683 total (nconc total articles)))
685 (gnus-summary-set-process-mark (car articles))
686 (setcdr marked (delq (car articles) (cdr marked)))
687 (setq articles (cdr articles)))
688 (setq marked (cdr marked)))
689 (setq gnus-newsgroup-processable (nreverse total)))
690 (gnus-summary-position-point)))
692 (defun gnus-uu-mark-all ()
693 "Mark all articles in \"series\" order."
695 (setq gnus-newsgroup-processable nil)
697 (let ((data gnus-newsgroup-data)
700 (when (and (not (memq (setq number (gnus-data-number (car data)))
701 gnus-newsgroup-processable))
702 (vectorp (gnus-data-header (car data))))
703 (gnus-summary-goto-subject number)
704 (gnus-uu-mark-series))
705 (setq data (cdr data)))))
706 (gnus-summary-position-point))
708 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
710 (defun gnus-uu-decode-postscript (&optional n)
711 "Gets postscript of the current article."
713 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
715 (defun gnus-uu-decode-postscript-view (&optional n)
716 "Gets and views the current article."
718 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
719 (gnus-uu-decode-postscript n)))
721 (defun gnus-uu-decode-postscript-and-save (n dir)
722 "Extracts postscript and saves the current article."
724 (list current-prefix-arg
725 (file-name-as-directory
726 (read-file-name "Save in dir: "
728 gnus-uu-default-dir t))))
729 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
732 (defun gnus-uu-decode-postscript-and-save-view (n dir)
733 "Decodes, views and saves the resulting file."
735 (list current-prefix-arg
736 (read-file-name "Where do you want to save the file(s)? "
738 gnus-uu-default-dir t)))
739 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
740 (gnus-uu-decode-postscript-and-save n dir)))
743 ;; Internal functions.
745 (defun gnus-uu-decode-with-method (method n &optional save not-insert
747 (gnus-uu-initialize scan)
749 (setq gnus-uu-default-dir save))
750 ;; Create the directory we save to.
751 (when (and scan cdir save
752 (not (file-exists-p save)))
753 (make-directory save t))
754 (let ((articles (gnus-uu-get-list-of-articles n))
756 (setq files (gnus-uu-grab-articles articles method t))
757 (let ((gnus-current-article (car articles)))
759 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
761 (gnus-uu-save-files files save))
762 (when (eq gnus-uu-do-not-unpack-archives nil)
763 (setq files (gnus-uu-unpack-files files)))
764 (setq files (nreverse (gnus-uu-get-actions files)))
765 (or not-insert (not gnus-insert-pseudo-articles)
766 (gnus-summary-insert-pseudos files save))))
768 (defun gnus-uu-scan-directory (dir &optional rec)
769 "Return a list of all files under DIR."
770 (let ((files (directory-files dir t))
772 (while (setq file (pop files))
773 (unless (member (file-name-nondirectory file) '("." ".."))
774 (push (list (cons 'name file)
775 (cons 'article gnus-current-article))
777 (when (file-directory-p file)
778 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
783 (defun gnus-uu-save-files (files dir)
785 (let ((len (length files))
786 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
787 to-file file fromdir)
788 (while (setq file (cdr (assq 'name (pop files))))
789 (when (file-exists-p file)
790 (string-match reg file)
791 (setq fromdir (substring file (match-end 0)))
792 (if (file-directory-p file)
793 (gnus-make-directory (concat dir fromdir))
794 (setq to-file (concat dir fromdir))
795 (when (or (not (file-exists-p to-file))
796 (eq gnus-uu-be-dangerous t)
797 (and gnus-uu-be-dangerous
798 (gnus-y-or-n-p (format "%s exists; overwrite? "
800 (copy-file file to-file t t)))))
801 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
803 ;; Functions for saving and possibly digesting articles without
806 ;; Function called by gnus-uu-grab-articles to treat each article.
807 (defun gnus-uu-save-article (buffer in-state)
809 (gnus-uu-save-separate-articles
812 (let ((coding-system-for-write mm-text-coding-system))
814 (concat gnus-uu-saved-article-name gnus-current-article)))
815 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
816 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
818 ((eq in-state 'last) (list 'end))
819 (t (list 'middle)))))
820 ((not gnus-uu-save-in-digest)
823 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
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)))))
830 (let ((header (gnus-summary-article-header)))
831 (push (cons (mail-header-from header)
832 (mail-header-subject header))
833 gnus-uu-digest-from-subject))
834 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
835 beg subj headers headline sorthead body end-string state)
836 (if (or (eq in-state 'first)
837 (eq in-state 'first-and-last))
839 (setq state (list 'begin))
841 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
844 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
847 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
848 (message-make-date) name name))
849 (when (and message-forward-as-mime gnus-uu-digest-buffer)
850 (insert "<#part type=message/rfc822>\nSubject: Topics\n\n"))
851 (insert "Topics:\n")))
852 (when (not (eq in-state 'end))
853 (setq state (list 'middle))))
855 (set-buffer "*gnus-uu-body*")
856 (goto-char (setq beg (point-max)))
860 (let (buffer-read-only)
861 (set-text-properties (point-min) (point-max) nil)
862 ;; These two are necessary for XEmacs 19.12 fascism.
863 (put-text-property (point-min) (point-max) 'invisible nil)
864 (put-text-property (point-min) (point-max) 'intangible nil))
865 (when (and message-forward-as-mime
866 message-forward-show-mml
867 gnus-uu-digest-buffer)
868 (mm-enable-multibyte)
870 (goto-char (point-min))
871 (search-forward "\n\n")
872 (unless (and message-forward-as-mime gnus-uu-digest-buffer)
873 ;; Quote all 30-dash lines.
875 (while (re-search-forward "^-" nil t)
879 (setq body (buffer-substring (1- (point)) (point-max)))
880 (narrow-to-region (point-min) (point))
881 (if (not (setq headers gnus-uu-digest-headers))
882 (setq sorthead (buffer-string))
884 (setq headline (car headers))
885 (setq headers (cdr headers))
886 (goto-char (point-min))
887 (while (re-search-forward headline nil t)
892 (or (and (re-search-forward "^[^ \t]" nil t)
894 (progn (forward-line 1) (point)))))))))
896 (if (and message-forward-as-mime gnus-uu-digest-buffer)
897 (if message-forward-show-mml
899 (insert "\n<#mml type=message/rfc822>\n")
900 (insert sorthead) (goto-char (point-max))
901 (insert body) (goto-char (point-max))
902 (insert "\n<#/mml>\n"))
903 (let ((buf (mml-generate-new-buffer " *mml*")))
904 (with-current-buffer buf
906 (goto-char (point-min))
907 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
908 (setq subj (buffer-substring (match-beginning 1)
910 (goto-char (point-max))
912 (insert "\n<#part type=message/rfc822"
913 " buffer=\"" (buffer-name buf) "\">\n")))
914 (insert sorthead) (goto-char (point-max))
915 (insert body) (goto-char (point-max))
916 (insert (concat "\n" (make-string 30 ?-) "\n\n")))
918 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
919 (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
922 (set-buffer "*gnus-uu-pre*")
923 (insert (format " %s\n" subj)))))
924 (when (or (eq in-state 'last)
925 (eq in-state 'first-and-last))
926 (if (and message-forward-as-mime gnus-uu-digest-buffer)
927 (with-current-buffer gnus-uu-digest-buffer
929 (insert-buffer-substring "*gnus-uu-pre*")
930 (goto-char (point-max))
931 (insert-buffer-substring "*gnus-uu-body*"))
933 (set-buffer "*gnus-uu-pre*")
934 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
935 (if gnus-uu-digest-buffer
936 (with-current-buffer gnus-uu-digest-buffer
938 (insert-buffer-substring "*gnus-uu-pre*"))
939 (let ((coding-system-for-write mm-text-coding-system))
940 (gnus-write-buffer gnus-uu-saved-article-name))))
942 (set-buffer "*gnus-uu-body*")
943 (goto-char (point-max))
945 (concat (setq end-string (format "End of %s Digest" name))
947 (insert (concat (make-string (length end-string) ?*) "\n"))
948 (if gnus-uu-digest-buffer
949 (with-current-buffer gnus-uu-digest-buffer
950 (goto-char (point-max))
951 (insert-buffer-substring "*gnus-uu-body*"))
952 (let ((coding-system-for-write mm-text-coding-system)
953 (file-name-coding-system nnmail-pathname-coding-system))
955 (point-min) (point-max) gnus-uu-saved-article-name t)))))
956 (gnus-kill-buffer "*gnus-uu-pre*")
957 (gnus-kill-buffer "*gnus-uu-body*")
959 (if (memq 'begin state)
960 (cons gnus-uu-saved-article-name state)
963 ;; Binhex treatment - not very advanced.
965 (defvar gnus-uu-binhex-body-line
966 "^[^:]...............................................................$")
967 (defvar gnus-uu-binhex-begin-line
968 "^:...............................................................$")
969 (defvar gnus-uu-binhex-end-line
972 (defun gnus-uu-binhex-article (buffer in-state)
973 (let (state start-char)
977 (goto-char (point-min))
978 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
979 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
980 (setq state (list 'wrong-type))))
982 (if (memq 'wrong-type state)
985 (setq start-char (point))
986 (if (looking-at gnus-uu-binhex-begin-line)
988 (setq state (list 'begin))
989 (write-region (point-min) (point-min)
990 gnus-uu-binhex-article-name))
991 (setq state (list 'middle)))
992 (goto-char (point-max))
993 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
994 gnus-uu-binhex-end-line)
996 (when (looking-at gnus-uu-binhex-end-line)
997 (setq state (if (memq 'begin state)
1002 (when (file-exists-p gnus-uu-binhex-article-name)
1003 (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
1004 (if (memq 'begin state)
1005 (cons gnus-uu-binhex-article-name state)
1010 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
1011 (let ((state (list 'ok))
1012 start-char end-char file-name)
1014 (set-buffer process-buffer)
1015 (goto-char (point-min))
1016 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
1017 (setq state (list 'wrong-type))
1019 (setq start-char (point))
1020 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
1021 (setq state (list 'wrong-type))
1022 (setq end-char (point))
1023 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1024 (insert-buffer-substring process-buffer start-char end-char)
1025 (setq file-name (concat gnus-uu-work-dir
1026 (cdr gnus-article-current) ".ps"))
1027 (write-region (point-min) (point-max) file-name)
1028 (setq state (list file-name 'begin 'end)))))
1034 (defun gnus-uu-get-actions (files)
1035 (let ((ofiles files)
1038 (setq name (cdr (assq 'name (car files))))
1040 (setq action (gnus-uu-get-action name))
1041 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1042 (cons 'action "file")
1043 (cons 'action action))
1044 (cons 'execute (gnus-uu-command
1047 (setq files (cdr files)))
1050 (defun gnus-uu-get-action (file-name)
1053 (gnus-uu-choose-action
1056 gnus-uu-user-view-rules
1057 (if gnus-uu-ignore-default-view-rules
1059 gnus-uu-default-view-rules)
1060 gnus-uu-user-view-rules-end)))
1061 (when (and (not (string= (or action "") "gnus-uu-archive"))
1062 gnus-uu-view-with-metamail)
1064 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1065 (setq action (format "metamail -d -b -c \"%s\"" action))))
1069 ;; Functions for treating subjects and collecting series.
1071 (defun gnus-uu-reginize-string (string)
1072 ;; Takes a string and puts a \ in front of every special character;
1073 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1074 ;; or, if it can't find something like that, tries "2 of 3", then
1075 ;; finally just replaces the next to last number with "[0-9]+".
1077 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1078 (buffer-disable-undo)
1080 (insert (regexp-quote string))
1082 (setq case-fold-search nil)
1085 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1086 (replace-match "\\1[0-9]+/\\2")
1089 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1091 (replace-match "\\1[0-9]+ of \\2")
1094 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1096 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1099 (while (re-search-forward "[ \t]+" nil t)
1100 (replace-match "[ \t]+" t t))
1104 (defun gnus-uu-get-list-of-articles (n)
1105 ;; If N is non-nil, the article numbers of the N next articles
1106 ;; will be returned.
1107 ;; If any articles have been marked as processable, they will be
1109 ;; Failing that, articles that have subjects that are part of the
1110 ;; same "series" as the current will be returned.
1114 (setq n (prefix-numeric-value n))
1115 (let ((backward (< n 0))
1119 (push (gnus-summary-article-number)
1121 (gnus-summary-search-forward nil nil backward))
1123 (nreverse articles)))
1124 (gnus-newsgroup-processable
1125 (reverse gnus-newsgroup-processable))
1127 (gnus-uu-find-articles-matching)))))
1129 (defun gnus-uu-string< (l1 l2)
1130 (string< (car l1) (car l2)))
1132 (defun gnus-uu-find-articles-matching
1133 (&optional subject only-unread do-not-translate)
1134 ;; Finds all articles that matches the regexp SUBJECT. If it is
1135 ;; nil, the current article name will be used. If ONLY-UNREAD is
1136 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1137 ;; non-nil, article names are not equalized before sorting.
1138 (let ((subject (or subject
1139 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1143 ;; Collect all subjects matching subject.
1144 (let ((case-fold-search t)
1145 (data gnus-newsgroup-data)
1149 (and (not (gnus-data-pseudo-p d))
1150 (or (not only-unread)
1151 (= (setq mark (gnus-data-mark d))
1153 (= mark gnus-ticked-mark)
1154 (= mark gnus-dormant-mark))
1155 (setq subj (mail-header-subject (gnus-data-header d)))
1156 (string-match subject subj)
1157 (push (cons subj (gnus-data-number d))
1158 list-of-subjects))))
1160 ;; Expand numbers, sort, and return the list of article
1163 (sort (gnus-uu-expand-numbers
1165 (not do-not-translate))
1166 'gnus-uu-string<))))))
1168 (defun gnus-uu-expand-numbers (string-list &optional translate)
1169 ;; Takes a list of strings and "expands" all numbers in all the
1170 ;; strings. That is, this function makes all numbers equal length by
1171 ;; prepending lots of zeroes before each number. This is to ease later
1172 ;; sorting to find out what sequence the articles are supposed to be
1173 ;; decoded in. Returns the list of expanded strings.
1174 (let ((out-list string-list)
1177 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1178 (buffer-disable-undo)
1181 (insert (caar string-list))
1182 ;; Translate multiple spaces to one space.
1183 (goto-char (point-min))
1184 (while (re-search-forward "[ \t]+" nil t)
1185 (replace-match " "))
1186 ;; Translate all characters to "a".
1187 (goto-char (point-min))
1189 (while (re-search-forward "[A-Za-z]" nil t)
1190 (replace-match "a" t t)))
1192 (goto-char (point-min))
1193 (while (re-search-forward "[0-9]+" nil t)
1197 (string-to-number (buffer-substring
1198 (match-beginning 0) (match-end 0)))))))
1199 (setq string (buffer-substring 1 (point-max)))
1200 (setcar (car string-list) string)
1201 (setq string-list (cdr string-list))))
1205 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1206 ;; function. It takes a list of articles to be grabbed and a function
1207 ;; to apply to each article.
1209 ;; The function to be called should take two parameters. The first
1210 ;; parameter is the article buffer. The function should leave the
1211 ;; result, if any, in this buffer. Most treatment functions will just
1212 ;; generate files...
1214 ;; The second parameter is the state of the list of articles, and can
1215 ;; have four values: `first', `middle', `last' and `first-and-last'.
1217 ;; The function should return a list. The list may contain the
1218 ;; following symbols:
1219 ;; `error' if an error occurred
1220 ;; `begin' if the beginning of an encoded file has been received
1221 ;; If the list returned contains a `begin', the first element of
1222 ;; the list *must* be a string with the file name of the decoded
1224 ;; `end' if the end of an encoded file has been received
1225 ;; `middle' if the article was a body part of an encoded file
1226 ;; `wrong-type' if the article was not a part of an encoded file
1227 ;; `ok', which can be used everything is ok
1229 (defvar gnus-uu-has-been-grabbed nil)
1231 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1233 (if (not (and gnus-uu-has-been-grabbed
1234 gnus-uu-unmark-articles-not-decoded))
1236 (when dont-unmark-last-article
1237 (setq art (car gnus-uu-has-been-grabbed))
1238 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1239 (while gnus-uu-has-been-grabbed
1240 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1241 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1242 (when dont-unmark-last-article
1243 (setq gnus-uu-has-been-grabbed (list art))))))
1245 ;; This function takes a list of articles and a function to apply to
1246 ;; each article grabbed.
1248 ;; This function returns a list of files decoded if the grabbing and
1249 ;; the process-function has been successful and nil otherwise.
1250 (defun gnus-uu-grab-articles (articles process-function
1251 &optional sloppy limit no-errors)
1252 (let ((state 'first)
1253 (gnus-asynchronous nil)
1254 (gnus-inhibit-treatment t)
1255 has-been-begin article result-file result-files process-state
1256 gnus-summary-display-article-function
1257 gnus-article-prepare-hook gnus-display-mime-function
1258 article-series files)
1260 (while (and articles
1261 (not (memq 'error process-state))
1263 (not (memq 'end process-state))))
1265 (setq article (pop articles))
1266 (when (vectorp (gnus-summary-article-header article))
1267 (push article article-series)
1270 (if (eq state 'first)
1271 (setq state 'first-and-last)
1272 (setq state 'last)))
1274 (let ((part (gnus-uu-part-number article)))
1275 (gnus-message 6 "Getting article %d%s..."
1276 article (if (string= part "") "" (concat ", " part))))
1277 (gnus-summary-display-article article)
1279 ;; Push the article to the processing function.
1281 (set-buffer gnus-original-article-buffer)
1282 (let ((buffer-read-only nil))
1284 (set-buffer gnus-summary-buffer)
1286 (funcall process-function
1287 gnus-original-article-buffer state)))))
1289 (gnus-summary-remove-process-mark article)
1291 ;; If this is the beginning of a decoded file, we push it
1293 (when (or (memq 'begin process-state)
1294 (and (or (eq state 'first)
1295 (eq state 'first-and-last))
1296 (memq 'ok process-state)))
1297 (when has-been-begin
1298 ;; If there is a `result-file' here, that means that the
1299 ;; file was unsuccessfully decoded, so we delete it.
1300 (when (and result-file
1301 (file-exists-p result-file)
1302 (not gnus-uu-be-dangerous)
1303 (or (eq gnus-uu-be-dangerous t)
1305 (format "Delete unsuccessfully decoded file %s"
1307 (delete-file result-file)))
1308 (when (memq 'begin process-state)
1309 (setq result-file (car process-state)))
1310 (setq has-been-begin t))
1312 ;; Check whether we have decoded one complete file.
1313 (when (memq 'end process-state)
1314 (setq article-series nil)
1315 (setq has-been-begin nil)
1316 (if (stringp result-file)
1317 (setq files (list result-file))
1318 (setq files result-file))
1319 (setq result-file (car files))
1321 (push (list (cons 'name (pop files))
1322 (cons 'article article))
1324 ;; Allow user-defined functions to be run on this file.
1325 (when gnus-uu-grabbed-file-functions
1326 (let ((funcs gnus-uu-grabbed-file-functions))
1327 (unless (listp funcs)
1328 (setq funcs (list funcs)))
1330 (funcall (pop funcs) result-file))))
1331 (setq result-file nil)
1332 ;; Check whether we have decoded enough articles.
1333 (and limit (= (length result-files) limit)
1334 (setq articles nil)))
1336 ;; If this is the last article to be decoded, and
1337 ;; we still haven't reached the end, then we delete
1338 ;; the partially decoded file.
1339 (and (or (eq state 'last) (eq state 'first-and-last))
1340 (not (memq 'end process-state))
1342 (file-exists-p result-file)
1343 (not gnus-uu-be-dangerous)
1344 (or (eq gnus-uu-be-dangerous t)
1346 (format "Delete incomplete file %s? " result-file)))
1347 (delete-file result-file))
1349 ;; If this was a file of the wrong sort, then
1350 (when (and (or (memq 'wrong-type process-state)
1351 (memq 'error process-state))
1352 gnus-uu-unmark-articles-not-decoded)
1353 (gnus-summary-tick-article article t))
1355 ;; Set the new series state.
1356 (if (and (not has-been-begin)
1358 (or (memq 'end process-state)
1359 (memq 'middle process-state)))
1361 (setq process-state (list 'error))
1362 (gnus-message 2 "No begin part at the beginning")
1364 (setq state 'middle))))
1366 ;; When there are no result-files, then something must be wrong.
1370 ((not has-been-begin)
1371 (gnus-message 2 "Wrong type file"))
1372 ((memq 'error process-state)
1373 (gnus-message 2 "An error occurred during decoding"))
1374 ((not (or (memq 'ok process-state)
1375 (memq 'end process-state)))
1376 (gnus-message 2 "End of articles reached before end of file")))
1377 ;; Make unsuccessfully decoded articles unread.
1378 (when gnus-uu-unmark-articles-not-decoded
1379 (while article-series
1380 (gnus-summary-tick-article (pop article-series) t))))
1382 ;; The original article buffer is hosed, shoot it down.
1383 (gnus-kill-buffer gnus-original-article-buffer)
1384 (setq gnus-current-article nil)
1387 (defun gnus-uu-grab-view (file)
1388 "View FILE using the gnus-uu methods."
1389 (let ((action (gnus-uu-get-action file)))
1390 (gnus-execute-command
1391 (if (string-match "%" action)
1392 (format action file)
1393 (concat action " " file))
1394 (eq gnus-view-pseudos 'not-confirm))))
1396 (defun gnus-uu-grab-move (file)
1397 "Move FILE to somewhere."
1398 (when gnus-uu-default-dir
1399 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1400 (file-name-nondirectory file))))
1401 (rename-file file to-file)
1402 (unless (file-exists-p file)
1403 (make-symbolic-link to-file file)))))
1405 (defun gnus-uu-part-number (article)
1406 (let* ((header (gnus-summary-article-header article))
1407 (subject (and header (mail-header-subject header)))
1410 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1412 (setq part (match-string 0 subject))
1413 (setq subject (substring subject (match-end 0)))))
1415 (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
1416 (setq part (match-string 0 subject))
1417 (setq subject (substring subject (match-end 0)))))
1420 (defun gnus-uu-uudecode-sentinel (process event)
1421 (delete-process (get-process process)))
1423 (defun gnus-uu-uustrip-article (process-buffer in-state)
1424 ;; Uudecodes a file asynchronously.
1426 (set-buffer process-buffer)
1427 (let ((state (list 'wrong-type))
1428 process-connection-type case-fold-search buffer-read-only
1430 (goto-char (point-min))
1432 ;; Deal with ^M at the end of the lines.
1433 (when gnus-uu-kill-carriage-return
1435 (while (search-forward "\r" nil t)
1436 (delete-backward-char 1))))
1438 (while (or (re-search-forward gnus-uu-begin-string nil t)
1439 (re-search-forward gnus-uu-body-line nil t))
1440 (setq state (list 'ok))
1441 ;; Ok, we are at the first uucoded line.
1443 (setq start-char (point))
1445 (if (not (looking-at gnus-uu-begin-string))
1446 (setq state (list 'middle))
1447 ;; This is the beginning of a uuencoded article.
1448 ;; We replace certain characters that could make things messy.
1449 (setq gnus-uu-file-name
1451 mm-file-name-rewrite-functions
1452 (file-name-nondirectory (match-string 1))))
1453 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1455 ;; Remove any non gnus-uu-body-line right after start.
1457 (while (and (not (eobp))
1458 (not (looking-at gnus-uu-body-line)))
1461 ;; If a process is running, we kill it.
1462 (when (and gnus-uu-uudecode-process
1463 (memq (process-status gnus-uu-uudecode-process)
1465 (delete-process gnus-uu-uudecode-process)
1466 (gnus-uu-unmark-list-of-grabbed t))
1468 ;; Start a new uudecoding process.
1469 (let ((cdir default-directory))
1472 (cd gnus-uu-work-dir)
1473 (setq gnus-uu-uudecode-process
1476 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1477 shell-file-name shell-command-switch
1478 (format "cd %s %s uudecode" gnus-uu-work-dir
1479 gnus-shell-command-separator))))
1481 (set-process-sentinel
1482 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1483 (setq state (list 'begin))
1484 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1486 ;; We look for the end of the thing to be decoded.
1487 (if (re-search-forward gnus-uu-end-string nil t)
1489 (goto-char (point-max))
1490 (re-search-backward gnus-uu-body-line nil t))
1494 (when gnus-uu-uudecode-process
1495 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1496 ;; Try to correct mishandled uucode.
1497 (when gnus-uu-correct-stripped-uucode
1498 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1499 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1501 ;; Send the text to the process.
1503 (process-send-region
1504 gnus-uu-uudecode-process start-char (point))
1507 (delete-process gnus-uu-uudecode-process)
1508 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1509 (setq state (list 'wrong-type)))))
1511 (if (memq 'end state)
1513 ;; Send an EOF, just in case.
1515 (process-send-eof gnus-uu-uudecode-process))
1516 (while (memq (process-status gnus-uu-uudecode-process)
1518 (accept-process-output gnus-uu-uudecode-process 1)))
1519 (when (or (not gnus-uu-uudecode-process)
1520 (not (memq (process-status gnus-uu-uudecode-process)
1522 (setq state (list 'wrong-type)))))))
1524 (if (memq 'begin state)
1525 (cons (if (= (length files) 1) (car files) files) state)
1528 (defvar gnus-uu-unshar-warning
1531 Shell archives are an archaic method of bundling files for distribution
1532 across computer networks. During the unpacking process, arbitrary commands
1533 are executed on your system, and all kinds of nasty things can happen.
1534 Please examine the archive very carefully before you instruct Emacs to
1535 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1537 If you are unsure what to do, please answer \"no\"."
1538 "Text of warning message displayed by `gnus-uu-unshar-article'.
1539 Make sure that this text consists only of few text lines. Otherwise,
1540 Gnus might fail to display all of it.")
1543 ;; This function is used by `gnus-uu-grab-articles' to treat
1544 ;; a shared article.
1545 (defun gnus-uu-unshar-article (process-buffer in-state)
1546 (let ((state (list 'ok))
1549 (set-buffer process-buffer)
1550 (goto-char (point-min))
1551 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1552 (setq state (list 'wrong-type))
1553 (save-window-excursion
1555 (switch-to-buffer (current-buffer))
1556 (delete-other-windows)
1557 (let ((buffer (get-buffer-create (generate-new-buffer-name
1561 (with-current-buffer buffer
1562 (insert (substitute-command-keys
1563 gnus-uu-unshar-warning))
1564 (goto-char (point-min))
1565 (display-buffer buffer)
1566 (yes-or-no-p "This is a shell archive, unshar it? "))
1567 (kill-buffer buffer))
1568 (setq state (list 'error))))))
1569 (unless (memq 'error state)
1571 (setq start-char (point))
1572 (call-process-region
1573 start-char (point-max) shell-file-name nil
1574 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1575 shell-command-switch
1576 (concat "cd " gnus-uu-work-dir " "
1577 gnus-shell-command-separator " sh")))))
1580 ;; Returns the name of what the shar file is going to unpack.
1581 (defun gnus-uu-find-name-in-shar ()
1582 (let ((oldpoint (point))
1584 (goto-char (point-min))
1585 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1586 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1587 (goto-char oldpoint)
1590 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1591 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1592 ;; found, or the name of the command to run if such a rule is found.
1593 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1594 (let ((action-list (copy-sequence file-action-list))
1595 (case-fold-search t)
1600 (and gnus-uu-ignore-files-by-name
1601 (string-match gnus-uu-ignore-files-by-name file-name)))
1603 (and gnus-uu-ignore-files-by-type
1604 (string-match gnus-uu-ignore-files-by-type
1605 (or (gnus-uu-choose-action
1606 file-name gnus-uu-ext-to-mime-list t)
1608 (while (not (or (eq action-list ()) action))
1609 (setq rule (car action-list))
1610 (setq action-list (cdr action-list))
1611 (when (string-match (car rule) file-name)
1612 (setq action (cadr rule)))))
1615 (defun gnus-uu-treat-archive (file-path)
1616 ;; Unpacks an archive. Returns t if unpacking is successful.
1617 (let ((did-unpack t)
1619 (setq action (gnus-uu-choose-action
1620 file-path (append gnus-uu-user-archive-rules
1621 (if gnus-uu-ignore-default-archive-rules
1623 gnus-uu-default-archive-rules))))
1626 (error "No unpackers for the file %s" file-path))
1628 (string-match "/[^/]*$" file-path)
1629 (setq dir (substring file-path 0 (match-beginning 0)))
1631 (when (member action gnus-uu-destructive-archivers)
1632 (copy-file file-path (concat file-path "~") t))
1634 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1637 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1640 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1642 (if (eq 0 (call-process shell-file-name nil
1643 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1644 nil shell-command-switch command))
1646 (gnus-message 2 "Error during unpacking of archive")
1647 (setq did-unpack nil))
1649 (when (member action gnus-uu-destructive-archivers)
1650 (rename-file (concat file-path "~") file-path t))
1654 (defun gnus-uu-dir-files (dir)
1655 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1658 (if (file-directory-p (setq file (car dirs)))
1659 (setq files (append files (gnus-uu-dir-files file)))
1661 (setq dirs (cdr dirs)))
1664 (defun gnus-uu-unpack-files (files &optional ignore)
1665 ;; Go through FILES and look for files to unpack.
1666 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1670 (setq file (cdr (assq 'name (car files))))
1671 (when (and (not (member file ignore))
1672 (equal (gnus-uu-get-action (file-name-nondirectory file))
1674 (push file did-unpack)
1675 (unless (gnus-uu-treat-archive file)
1676 (gnus-message 2 "Error during unpacking of %s" file))
1677 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1680 (unless (member (car nfiles) totfiles)
1681 (push (list (cons 'name (car nfiles))
1682 (cons 'original file))
1684 (setq nfiles (cdr nfiles)))
1685 (setq totfiles newfiles)))
1686 (setq files (cdr files)))
1688 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1691 (defun gnus-uu-ls-r (dir)
1692 (let* ((files (gnus-uu-directory-files dir t))
1695 (when (file-directory-p (car files))
1696 (setq ofiles (delete (car files) ofiles))
1697 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1698 (setq files (cdr files)))
1703 (defun gnus-uu-directory-files (dir &optional full)
1704 (let (files out file)
1705 (setq files (directory-files dir full))
1707 (setq file (car files))
1708 (setq files (cdr files))
1709 (unless (member (file-name-nondirectory file) '("." ".."))
1711 (setq out (nreverse out))
1714 (defun gnus-uu-check-correct-stripped-uucode (start end)
1716 (let (found beg length)
1717 (unless gnus-uu-correct-stripped-uucode
1720 (if (re-search-forward " \\|`" end t)
1725 (when (looking-at "\n")
1730 (unless (looking-at (concat gnus-uu-begin-string "\\|"
1731 gnus-uu-end-string))
1733 (setq length (- (point-at-eol) (point-at-bol))))
1738 (unless (= length (- (point) beg))
1739 (insert (make-string (- length (- (point) beg)) ? ))))
1740 (forward-line 1)))))))
1742 (defvar gnus-uu-tmp-alist nil)
1744 (defun gnus-uu-initialize (&optional scan)
1747 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1748 (if (file-exists-p (cdr entry))
1749 (setq gnus-uu-work-dir (cdr entry))
1750 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1753 (setq gnus-uu-tmp-dir (file-name-as-directory
1754 (expand-file-name gnus-uu-tmp-dir)))
1755 (if (not (file-directory-p gnus-uu-tmp-dir))
1756 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1757 (when (not (file-writable-p gnus-uu-tmp-dir))
1758 (error "Temp directory %s can't be written to"
1761 (setq gnus-uu-work-dir
1762 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1763 (gnus-set-file-modes gnus-uu-work-dir 448)
1764 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1765 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1766 gnus-uu-tmp-alist))))
1769 ;; Kills the temporary uu buffers, kills any processes, etc.
1770 (defun gnus-uu-clean-up ()
1772 (and gnus-uu-uudecode-process
1773 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1775 (delete-process gnus-uu-uudecode-process))
1776 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1777 (kill-buffer buf))))
1779 ;; Inputs an action and a filename and returns a full command, making sure
1780 ;; that the filename will be treated as a single argument when the shell
1781 ;; executes the command.
1782 (defun gnus-uu-command (action file)
1783 (let ((quoted-file (shell-quote-argument file)))
1784 (if (string-match "%s" action)
1785 (format action quoted-file)
1786 (concat action " " quoted-file))))
1788 (defun gnus-uu-delete-work-dir (&optional dir)
1789 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1791 (gnus-message 7 "Deleting directory %s..." dir)
1792 (setq dir gnus-uu-work-dir))
1794 (file-exists-p dir))
1795 (let ((files (directory-files dir t nil t))
1797 (while (setq file (pop files))
1798 (unless (member (file-name-nondirectory file) '("." ".."))
1799 (if (file-directory-p file)
1800 (gnus-uu-delete-work-dir file)
1801 (gnus-message 9 "Deleting file %s..." file)
1804 (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
1806 (delete-directory dir)
1807 (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
1808 (gnus-message 7 "")))
1812 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1813 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1818 ;;; uuencoded posting
1821 ;; Any function that is to be used as and encoding method will take two
1822 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1823 ;; and "spiral.jpg", respectively.) The function should return nil if
1824 ;; the encoding wasn't successful.
1825 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1826 "Function used for encoding binary files.
1827 There are three functions supplied with gnus-uu for encoding files:
1828 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1829 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1830 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1831 uuencode and adds MIME headers."
1832 :group 'gnus-extract-post
1833 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1834 (function-item gnus-uu-post-encode-mime)
1835 (function-item gnus-uu-post-encode-mime-uuencode)
1836 (function :tag "Other")))
1838 (defcustom gnus-uu-post-include-before-composing nil
1839 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1840 If this variable is t, you can either include an encoded file with
1841 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1842 :group 'gnus-extract-post
1845 (defcustom gnus-uu-post-length 990
1846 "Maximum length of an article.
1847 The encoded file will be split into how many articles it takes to
1848 post the entire file."
1849 :group 'gnus-extract-post
1852 (defcustom gnus-uu-post-threaded nil
1853 "Non-nil means that gnus-uu will post the encoded file in a thread.
1854 This may not be smart, as no other decoder I have seen are able to
1855 follow threads when collecting uuencoded articles. (Well, I have seen
1856 one package that does that - gnus-uu, but somehow, I don't think that
1857 counts...) The default is nil."
1858 :group 'gnus-extract-post
1861 (defcustom gnus-uu-post-separate-description t
1862 "Non-nil means that the description will be posted in a separate article.
1863 The first article will typically be numbered (0/x). If this variable
1864 is nil, the description the user enters will be included at the
1865 beginning of the first article, which will be numbered (1/x). Default
1867 :group 'gnus-extract-post
1870 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1871 (defvar gnus-uu-post-message-id nil)
1872 (defvar gnus-uu-post-inserted-file-name nil)
1873 (defvar gnus-uu-winconf-post-news nil)
1875 (defun gnus-uu-post-news ()
1876 "Compose an article and post an encoded file."
1878 (setq gnus-uu-post-inserted-file-name nil)
1879 (setq gnus-uu-winconf-post-news (current-window-configuration))
1881 (gnus-summary-post-news)
1883 (let ((map (make-sparse-keymap)))
1884 (set-keymap-parent map (current-local-map))
1885 (use-local-map map))
1886 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1887 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1888 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1889 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1891 (when gnus-uu-post-include-before-composing
1892 (save-excursion (setq gnus-uu-post-inserted-file-name
1893 (gnus-uu-post-insert-binary)))))
1895 (defun gnus-uu-post-insert-binary-in-article ()
1896 "Inserts an encoded file in the buffer.
1897 The user will be asked for a file name."
1900 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1902 ;; Encodes with uuencode and substitutes all spaces with backticks.
1903 (defun gnus-uu-post-encode-uuencode (path file-name)
1904 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1905 (goto-char (point-min))
1907 (while (search-forward " " nil t)
1908 (replace-match "`"))
1911 ;; Encodes with uuencode and adds MIME headers.
1912 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1913 (when (gnus-uu-post-encode-uuencode path file-name)
1914 (gnus-uu-post-make-mime file-name "x-uue")
1917 ;; Encodes with base64 and adds MIME headers
1918 (defun gnus-uu-post-encode-mime (path file-name)
1919 (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1920 (format "%s %s -o %s" "mmencode" path file-name)))
1921 (gnus-uu-post-make-mime file-name "base64")
1924 ;; Adds MIME headers.
1925 (defun gnus-uu-post-make-mime (file-name encoding)
1926 (goto-char (point-min))
1927 (insert (format "Content-Type: %s; name=\"%s\"\n"
1928 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1930 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1932 (set-buffer gnus-message-buffer)
1933 (goto-char (point-min))
1934 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1936 (narrow-to-region (point-min) (point))
1937 (unless (mail-fetch-field "mime-version")
1939 (insert "MIME-Version: 1.0\n"))
1942 ;; Encodes a file PATH with COMMAND, leaving the result in the
1944 (defun gnus-uu-post-encode-file (command path file-name)
1945 (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1946 (format "%s %s %s" command path file-name))))
1948 (defun gnus-uu-post-news-inews ()
1949 "Posts the composed news article and encoded file.
1950 If no file has been included, the user will be asked for a file."
1955 (if gnus-uu-post-inserted-file-name
1956 (setq file-name gnus-uu-post-inserted-file-name)
1957 (setq file-name (gnus-uu-post-insert-binary)))
1959 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1960 (setq gnus-uu-post-inserted-file-name nil)
1961 (when gnus-uu-winconf-post-news
1962 (set-window-configuration gnus-uu-winconf-post-news)))
1964 ;; Asks for a file to encode, encodes it and inserts the result in
1965 ;; the current buffer. Returns the file name the user gave.
1966 (defun gnus-uu-post-insert-binary ()
1967 (let ((uuencode-buffer-name "*uuencode buffer*")
1968 file-path uubuf file-name)
1970 (setq file-path (read-file-name
1971 "What file do you want to encode? "))
1972 (when (not (file-exists-p file-path))
1973 (error "%s: No such file" file-path))
1975 (goto-char (point-max))
1976 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1978 ;; #### Unix-specific?
1979 (when (string-match "^~/" file-path)
1980 (setq file-path (concat "$HOME" (substring file-path 1))))
1981 ;; #### Unix-specific?
1982 (if (string-match "/[^/]*$" file-path)
1983 (setq file-name (substring file-path (1+ (match-beginning 0))))
1984 (setq file-name file-path))
1988 (set-buffer (setq uubuf
1989 (gnus-get-buffer-create uuencode-buffer-name)))
1991 (funcall gnus-uu-post-encode-method file-path file-name))
1992 (insert-buffer-substring uubuf)
1993 (error "Encoding unsuccessful"))
1994 (kill-buffer uubuf))
1997 ;; Posts the article and all of the encoded file.
1998 (defun gnus-uu-post-encoded (file-name &optional threaded)
1999 (let ((send-buffer-name "*uuencode send buffer*")
2000 (encoded-buffer-name "*encoded buffer*")
2001 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
2002 (separator (concat mail-header-separator "\n\n"))
2003 uubuf length parts header i end beg
2004 beg-line minlen post-buf whole-len beg-binary end-binary)
2006 (setq post-buf (current-buffer))
2008 (goto-char (point-min))
2009 (when (not (re-search-forward
2010 (if gnus-uu-post-separate-description
2011 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2013 (concat "^" (regexp-quote mail-header-separator) "$"))
2015 (error "Internal error: No binary/header separator"))
2018 (setq beg-binary (point))
2019 (setq end-binary (point-max))
2022 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2024 (insert-buffer-substring post-buf beg-binary end-binary)
2025 (goto-char (point-min))
2026 (setq length (count-lines (point-min) (point-max)))
2027 (setq parts (/ length gnus-uu-post-length))
2028 (unless (< (% length gnus-uu-post-length) 4)
2031 (when gnus-uu-post-separate-description
2033 (delete-region (point) (point-max))
2035 (goto-char (point-min))
2037 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2038 (setq header (buffer-substring (point-min) (point-at-bol)))
2040 (goto-char (point-min))
2041 (when gnus-uu-post-separate-description
2042 (when (re-search-forward "^Subject: " nil t)
2044 (insert (format " (0/%d)" parts)))
2047 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2052 (while (not (> i parts))
2053 (set-buffer (gnus-get-buffer-create send-buffer-name))
2056 (when (and threaded gnus-uu-post-message-id)
2057 (insert "References: " gnus-uu-post-message-id "\n"))
2060 (- 62 (length (format top-string "" file-name i parts ""))))
2061 (when (> 1 (setq minlen (/ whole-len 2)))
2066 (make-string minlen ?-)
2069 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2071 (goto-char (point-min))
2072 (when (re-search-forward "^Subject: " nil t)
2074 (insert (format " (%d/%d)" i parts)))
2076 (goto-char (point-max))
2081 (goto-char (point-max))
2082 (forward-line gnus-uu-post-length))
2083 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2086 (insert-buffer-substring uubuf beg end)
2087 (insert beg-line "\n")
2090 (goto-char (point-min))
2092 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2095 (when (re-search-forward
2096 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2102 (let (message-sent-message-via)
2105 (setq gnus-uu-post-message-id
2106 (concat (message-fetch-field "references") " "
2107 (message-fetch-field "message-id"))))))
2109 (gnus-kill-buffer send-buffer-name)
2110 (gnus-kill-buffer encoded-buffer-name)
2112 (when (not gnus-uu-post-separate-description)
2113 (set-buffer-modified-p nil)
2118 ;;; arch-tag: 05312384-0a83-4720-9a58-b3160b888853
2119 ;;; gnus-uu.el ends here