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 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
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."
304 :type '(repeat regexp))
306 (defcustom gnus-uu-save-separate-articles nil
307 "*Non-nil means that gnus-uu will save articles in separate files."
311 (defcustom gnus-uu-be-dangerous 'ask
312 "*Specifies what to do if unusual situations arise during decoding.
313 If nil, be as conservative as possible. If t, ignore things that
314 didn't work, and overwrite existing files. Otherwise, ask each time."
316 :type '(choice (const :tag "conservative" nil)
317 (const :tag "ask" ask)
318 (const :tag "liberal" t)))
320 ;; Internal variables
322 (defvar gnus-uu-saved-article-name nil)
324 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
325 (defvar gnus-uu-end-string "^end[ \t]*$")
327 (defvar gnus-uu-body-line "^M")
329 (while (> (setq i (1- i)) 0)
330 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
331 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
333 ;"^M.............................................................?$"
335 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
337 (defvar gnus-uu-shar-file-name nil)
338 (defvar gnus-uu-shar-name-marker
339 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
341 (defvar gnus-uu-postscript-begin-string "^%!PS-")
342 (defvar gnus-uu-postscript-end-string "^%%EOF$")
344 (defvar gnus-uu-file-name nil)
345 (defvar gnus-uu-uudecode-process nil)
346 (defvar gnus-uu-binhex-article-name nil)
348 (defvar gnus-uu-work-dir nil)
350 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
352 (defvar gnus-uu-default-dir gnus-article-save-directory)
353 (defvar gnus-uu-digest-from-subject nil)
354 (defvar gnus-uu-digest-buffer nil)
358 (defun gnus-uu-decode-uu (&optional n)
359 "Uudecodes the current article."
361 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
363 (defun gnus-uu-decode-uu-and-save (n dir)
364 "Decodes and saves the resulting file."
366 (list current-prefix-arg
367 (file-name-as-directory
368 (read-file-name "Uudecode and save in dir: "
370 gnus-uu-default-dir t))))
371 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
373 (defun gnus-uu-decode-unshar (&optional n)
374 "Unshars the current article."
376 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
378 (defun gnus-uu-decode-unshar-and-save (n dir)
379 "Unshars and saves the current article."
381 (list current-prefix-arg
382 (file-name-as-directory
383 (read-file-name "Unshar and save in dir: "
385 gnus-uu-default-dir t))))
386 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
388 (defun gnus-uu-decode-save (n file)
389 "Saves the current article."
391 (list current-prefix-arg
393 (if gnus-uu-save-separate-articles
394 "Save articles is dir: "
395 "Save articles in file: ")
397 gnus-uu-default-dir)))
398 (setq gnus-uu-saved-article-name file)
399 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
401 (defun gnus-uu-decode-binhex (n dir)
402 "Unbinhexes the current article."
404 (list current-prefix-arg
405 (file-name-as-directory
406 (read-file-name "Unbinhex and save in dir: "
408 gnus-uu-default-dir))))
409 (setq gnus-uu-binhex-article-name
410 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
411 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
413 (defun gnus-uu-decode-uu-view (&optional n)
414 "Uudecodes and views the current article."
416 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
417 (gnus-uu-decode-uu n)))
419 (defun gnus-uu-decode-uu-and-save-view (n dir)
420 "Decodes, views and saves the resulting file."
422 (list current-prefix-arg
423 (read-file-name "Uudecode, view and save in dir: "
425 gnus-uu-default-dir t)))
426 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
427 (gnus-uu-decode-uu-and-save n dir)))
429 (defun gnus-uu-decode-unshar-view (&optional n)
430 "Unshars and views the current article."
432 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
433 (gnus-uu-decode-unshar n)))
435 (defun gnus-uu-decode-unshar-and-save-view (n dir)
436 "Unshars and saves the current article."
438 (list current-prefix-arg
439 (read-file-name "Unshar, view and save in dir: "
441 gnus-uu-default-dir t)))
442 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
443 (gnus-uu-decode-unshar-and-save n dir)))
445 (defun gnus-uu-decode-save-view (n file)
446 "Saves and views the current article."
448 (list current-prefix-arg
449 (read-file-name (if gnus-uu-save-separate-articles
450 "Save articles is dir: "
451 "Save articles in file: ")
452 gnus-uu-default-dir gnus-uu-default-dir)))
453 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
454 (gnus-uu-decode-save n file)))
456 (defun gnus-uu-decode-binhex-view (n file)
457 "Unbinhexes and views the current article."
459 (list current-prefix-arg
460 (read-file-name "Unbinhex, view and save in dir: "
461 gnus-uu-default-dir gnus-uu-default-dir)))
462 (setq gnus-uu-binhex-article-name
463 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
464 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
465 (gnus-uu-decode-binhex n file)))
468 ;; Digest and forward articles
470 (defun gnus-uu-digest-mail-forward (&optional n post)
471 "Digests and forwards all articles in this series."
473 (let ((gnus-uu-save-in-digest t)
474 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
475 (message-forward-as-mime message-forward-as-mime)
476 (mail-parse-charset gnus-newsgroup-charset)
477 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
478 gnus-uu-digest-buffer subject from)
479 (if (and n (not (numberp n)))
480 (setq message-forward-as-mime (not message-forward-as-mime)
482 (let ((gnus-article-reply (gnus-summary-work-articles n)))
483 (gnus-setup-message 'forward
484 (setq gnus-uu-digest-from-subject nil)
485 (setq gnus-uu-digest-buffer
486 (gnus-get-buffer-create " *gnus-uu-forward*"))
487 (gnus-uu-decode-save n file)
488 (switch-to-buffer gnus-uu-digest-buffer)
489 (let ((fs gnus-uu-digest-from-subject))
492 subject (gnus-simplify-subject-fuzzy (cdar fs))
494 (while (and fs (or from subject))
496 (unless (string= from (caar fs))
499 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
504 (setq subject "Digested Articles"))
507 (if (gnus-news-group-p gnus-newsgroup-name)
510 (goto-char (point-min))
511 (when (re-search-forward "^Subject: ")
512 (delete-region (point) (gnus-point-at-eol))
514 (goto-char (point-min))
515 (when (re-search-forward "^From:")
516 (delete-region (point) (gnus-point-at-eol))
518 (let ((message-forward-decoded-p t))
519 (message-forward post t))))
520 (setq gnus-uu-digest-from-subject nil)))
522 (defun gnus-uu-digest-post-forward (&optional n)
523 "Digest and forward to a newsgroup."
525 (gnus-uu-digest-mail-forward n t))
529 (defun gnus-message-process-mark (unmarkp new-marked)
530 (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
531 (message "%d mark%s %s%s"
533 (if (= (length new-marked) 1) "" "s")
534 (if unmarkp "removed" "added")
540 (format ", %d remain marked"
541 (length gnus-newsgroup-processable)))
543 (format ", %d already marked" old))))))
545 (defun gnus-new-processable (unmarkp articles)
547 (gnus-intersection gnus-newsgroup-processable articles)
548 (gnus-set-difference articles gnus-newsgroup-processable)))
550 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
551 "Set the process mark on articles whose subjects match REGEXP.
552 When called interactively, prompt for REGEXP.
553 Optional UNMARK non-nil means unmark instead of mark."
554 (interactive "sMark (regexp): \nP")
556 (let* ((articles (gnus-uu-find-articles-matching regexp))
557 (new-marked (gnus-new-processable unmark articles)))
560 (gnus-summary-remove-process-mark (pop articles))
561 (gnus-summary-set-process-mark (pop articles))))
562 (gnus-message-process-mark unmark new-marked)))
563 (gnus-summary-position-point))
565 (defun gnus-uu-unmark-by-regexp (regexp)
566 "Remove the process mark from articles whose subjects match REGEXP.
567 When called interactively, prompt for REGEXP."
568 (interactive "sUnmark (regexp): ")
569 (gnus-uu-mark-by-regexp regexp t))
571 (defun gnus-uu-mark-series ()
572 "Mark the current series with the process mark."
574 (let ((articles (gnus-uu-find-articles-matching)))
576 (gnus-summary-set-process-mark (car articles))
577 (setq articles (cdr articles)))
579 (gnus-summary-position-point))
581 (defun gnus-uu-mark-region (beg end &optional unmark)
582 "Set the process mark on all articles between point and mark."
586 (while (< (point) end)
588 (gnus-summary-remove-process-mark (gnus-summary-article-number))
589 (gnus-summary-set-process-mark (gnus-summary-article-number)))
591 (gnus-summary-position-point))
593 (defun gnus-uu-unmark-region (beg end)
594 "Remove the process mark from all articles between point and mark."
596 (gnus-uu-mark-region beg end t))
598 (defun gnus-uu-mark-buffer ()
599 "Set the process mark on all articles in the buffer."
601 (gnus-uu-mark-region (point-min) (point-max)))
603 (defun gnus-uu-unmark-buffer ()
604 "Remove the process mark on all articles in the buffer."
606 (gnus-uu-mark-region (point-min) (point-max) t))
608 (defun gnus-uu-mark-thread ()
609 "Marks all articles downwards in this thread."
611 (gnus-save-hidden-threads
612 (let ((level (gnus-summary-thread-level)))
613 (while (and (gnus-summary-set-process-mark
614 (gnus-summary-article-number))
615 (zerop (gnus-summary-next-subject 1 nil t))
616 (> (gnus-summary-thread-level) level)))))
617 (gnus-summary-position-point))
619 (defun gnus-uu-unmark-thread ()
620 "Unmarks all articles downwards in this thread."
622 (let ((level (gnus-summary-thread-level)))
623 (while (and (gnus-summary-remove-process-mark
624 (gnus-summary-article-number))
625 (zerop (gnus-summary-next-subject 1))
626 (> (gnus-summary-thread-level) level))))
627 (gnus-summary-position-point))
629 (defun gnus-uu-invert-processable ()
630 "Invert the list of process-marked articles."
632 (let ((data gnus-newsgroup-data)
636 (if (memq (setq number (gnus-data-number (pop data)))
637 gnus-newsgroup-processable)
638 (gnus-summary-remove-process-mark number)
639 (gnus-summary-set-process-mark number)))))
640 (gnus-summary-position-point))
642 (defun gnus-uu-mark-over (&optional score)
643 "Mark all articles with a score over SCORE (the prefix)."
645 (let ((score (or score gnus-summary-default-score 0))
646 (data gnus-newsgroup-data))
649 (when (> (or (cdr (assq (gnus-data-number (car data))
650 gnus-newsgroup-scored))
651 gnus-summary-default-score 0)
653 (gnus-summary-set-process-mark (caar data)))
654 (setq data (cdr data))))
655 (gnus-summary-position-point)))
657 (defun gnus-uu-mark-sparse ()
658 "Mark all series that have some articles marked."
660 (let ((marked (nreverse gnus-newsgroup-processable))
661 subject articles total headers)
663 (error "No articles marked with the process mark"))
664 (setq gnus-newsgroup-processable nil)
667 (and (vectorp (setq headers
668 (gnus-summary-article-header (car marked))))
669 (setq subject (mail-header-subject headers)
670 articles (gnus-uu-find-articles-matching
671 (gnus-uu-reginize-string subject))
672 total (nconc total articles)))
674 (gnus-summary-set-process-mark (car articles))
675 (setcdr marked (delq (car articles) (cdr marked)))
676 (setq articles (cdr articles)))
677 (setq marked (cdr marked)))
678 (setq gnus-newsgroup-processable (nreverse total)))
679 (gnus-summary-position-point)))
681 (defun gnus-uu-mark-all ()
682 "Mark all articles in \"series\" order."
684 (setq gnus-newsgroup-processable nil)
686 (let ((data gnus-newsgroup-data)
689 (when (and (not (memq (setq number (gnus-data-number (car data)))
690 gnus-newsgroup-processable))
691 (vectorp (gnus-data-header (car data))))
692 (gnus-summary-goto-subject number)
693 (gnus-uu-mark-series))
694 (setq data (cdr data)))))
695 (gnus-summary-position-point))
697 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
699 (defun gnus-uu-decode-postscript (&optional n)
700 "Gets postscript of the current article."
702 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
704 (defun gnus-uu-decode-postscript-view (&optional n)
705 "Gets and views the current article."
707 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
708 (gnus-uu-decode-postscript n)))
710 (defun gnus-uu-decode-postscript-and-save (n dir)
711 "Extracts postscript and saves the current article."
713 (list current-prefix-arg
714 (file-name-as-directory
715 (read-file-name "Save in dir: "
717 gnus-uu-default-dir t))))
718 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
721 (defun gnus-uu-decode-postscript-and-save-view (n dir)
722 "Decodes, views and saves the resulting file."
724 (list current-prefix-arg
725 (read-file-name "Where do you want to save the file(s)? "
727 gnus-uu-default-dir t)))
728 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
729 (gnus-uu-decode-postscript-and-save n dir)))
732 ;; Internal functions.
734 (defun gnus-uu-decode-with-method (method n &optional save not-insert
736 (gnus-uu-initialize scan)
738 (setq gnus-uu-default-dir save))
739 ;; Create the directory we save to.
740 (when (and scan cdir save
741 (not (file-exists-p save)))
742 (make-directory save t))
743 (let ((articles (gnus-uu-get-list-of-articles n))
745 (setq files (gnus-uu-grab-articles articles method t))
746 (let ((gnus-current-article (car articles)))
748 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
750 (gnus-uu-save-files files save))
751 (when (eq gnus-uu-do-not-unpack-archives nil)
752 (setq files (gnus-uu-unpack-files files)))
753 (setq files (nreverse (gnus-uu-get-actions files)))
754 (or not-insert (not gnus-insert-pseudo-articles)
755 (gnus-summary-insert-pseudos files save))))
757 (defun gnus-uu-scan-directory (dir &optional rec)
758 "Return a list of all files under DIR."
759 (let ((files (directory-files dir t))
761 (while (setq file (pop files))
762 (unless (member (file-name-nondirectory file) '("." ".."))
763 (push (list (cons 'name file)
764 (cons 'article gnus-current-article))
766 (when (file-directory-p file)
767 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
772 (defun gnus-uu-save-files (files dir)
774 (let ((len (length files))
775 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
776 to-file file fromdir)
777 (while (setq file (cdr (assq 'name (pop files))))
778 (when (file-exists-p file)
779 (string-match reg file)
780 (setq fromdir (substring file (match-end 0)))
781 (if (file-directory-p file)
782 (gnus-make-directory (concat dir fromdir))
783 (setq to-file (concat dir fromdir))
784 (when (or (not (file-exists-p to-file))
785 (eq gnus-uu-be-dangerous t)
786 (and gnus-uu-be-dangerous
787 (gnus-y-or-n-p (format "%s exists; overwrite? "
789 (copy-file file to-file t t)))))
790 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
792 ;; Functions for saving and possibly digesting articles without
795 ;; Function called by gnus-uu-grab-articles to treat each article.
796 (defun gnus-uu-save-article (buffer in-state)
798 (gnus-uu-save-separate-articles
801 (let ((coding-system-for-write mm-text-coding-system))
803 (concat gnus-uu-saved-article-name gnus-current-article)))
804 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
805 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
807 ((eq in-state 'last) (list 'end))
808 (t (list 'middle)))))
809 ((not gnus-uu-save-in-digest)
812 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
813 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
814 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
816 ((eq in-state 'last) (list 'end))
817 (t (list 'middle)))))
819 (let ((header (gnus-summary-article-header)))
820 (push (cons (mail-header-from header)
821 (mail-header-subject header))
822 gnus-uu-digest-from-subject))
823 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
824 beg subj headers headline sorthead body end-string state)
825 (if (or (eq in-state 'first)
826 (eq in-state 'first-and-last))
828 (setq state (list 'begin))
830 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
833 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
836 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
837 (current-time-string) name name))
838 (when (and message-forward-as-mime gnus-uu-digest-buffer)
839 (insert "<#part type=message/rfc822>\nSubject: Topics\n\n"))
840 (insert "Topics:\n")))
841 (when (not (eq in-state 'end))
842 (setq state (list 'middle))))
844 (set-buffer "*gnus-uu-body*")
845 (goto-char (setq beg (point-max)))
849 (let (buffer-read-only)
850 (gnus-set-text-properties (point-min) (point-max) nil)
851 ;; These two are necessary for XEmacs 19.12 fascism.
852 (put-text-property (point-min) (point-max) 'invisible nil)
853 (put-text-property (point-min) (point-max) 'intangible nil))
854 (when (and message-forward-as-mime
855 message-forward-show-mml
856 gnus-uu-digest-buffer)
857 (mm-enable-multibyte)
859 (goto-char (point-min))
860 (re-search-forward "\n\n")
861 (unless (and message-forward-as-mime gnus-uu-digest-buffer)
862 ;; Quote all 30-dash lines.
864 (while (re-search-forward "^-" nil t)
868 (setq body (buffer-substring (1- (point)) (point-max)))
869 (narrow-to-region (point-min) (point))
870 (if (not (setq headers gnus-uu-digest-headers))
871 (setq sorthead (buffer-substring (point-min) (point-max)))
873 (setq headline (car headers))
874 (setq headers (cdr headers))
875 (goto-char (point-min))
876 (while (re-search-forward headline nil t)
881 (or (and (re-search-forward "^[^ \t]" nil t)
883 (progn (forward-line 1) (point)))))))))
885 (if (and message-forward-as-mime gnus-uu-digest-buffer)
886 (if message-forward-show-mml
888 (insert "\n<#mml type=message/rfc822>\n")
889 (insert sorthead) (goto-char (point-max))
890 (insert body) (goto-char (point-max))
891 (insert "\n<#/mml>\n"))
892 (let ((buf (mml-generate-new-buffer " *mml*")))
893 (with-current-buffer buf
895 (goto-char (point-min))
896 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
897 (setq subj (buffer-substring (match-beginning 1)
899 (goto-char (point-max))
901 (insert "\n<#part type=message/rfc822"
902 " buffer=\"" (buffer-name buf) "\">\n")))
903 (insert sorthead) (goto-char (point-max))
904 (insert body) (goto-char (point-max))
905 (insert (concat "\n" (make-string 30 ?-) "\n\n")))
907 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
908 (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
911 (set-buffer "*gnus-uu-pre*")
912 (insert (format " %s\n" subj)))))
913 (when (or (eq in-state 'last)
914 (eq in-state 'first-and-last))
915 (if (and message-forward-as-mime gnus-uu-digest-buffer)
916 (with-current-buffer gnus-uu-digest-buffer
918 (insert-buffer "*gnus-uu-pre*")
919 (goto-char (point-max))
920 (insert-buffer "*gnus-uu-body*"))
922 (set-buffer "*gnus-uu-pre*")
923 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
924 (if gnus-uu-digest-buffer
925 (with-current-buffer gnus-uu-digest-buffer
927 (insert-buffer "*gnus-uu-pre*"))
928 (let ((coding-system-for-write mm-text-coding-system))
929 (gnus-write-buffer gnus-uu-saved-article-name))))
931 (set-buffer "*gnus-uu-body*")
932 (goto-char (point-max))
934 (concat (setq end-string (format "End of %s Digest" name))
936 (insert (concat (make-string (length end-string) ?*) "\n"))
937 (if gnus-uu-digest-buffer
938 (with-current-buffer gnus-uu-digest-buffer
939 (goto-char (point-max))
940 (insert-buffer "*gnus-uu-body*"))
941 (let ((coding-system-for-write mm-text-coding-system)
942 (file-name-coding-system nnmail-pathname-coding-system))
944 (point-min) (point-max) gnus-uu-saved-article-name t)))))
945 (gnus-kill-buffer "*gnus-uu-pre*")
946 (gnus-kill-buffer "*gnus-uu-body*")
948 (if (memq 'begin state)
949 (cons gnus-uu-saved-article-name state)
952 ;; Binhex treatment - not very advanced.
954 (defvar gnus-uu-binhex-body-line
955 "^[^:]...............................................................$")
956 (defvar gnus-uu-binhex-begin-line
957 "^:...............................................................$")
958 (defvar gnus-uu-binhex-end-line
961 (defun gnus-uu-binhex-article (buffer in-state)
962 (let (state start-char)
966 (goto-char (point-min))
967 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
968 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
969 (setq state (list 'wrong-type))))
971 (if (memq 'wrong-type state)
974 (setq start-char (point))
975 (if (looking-at gnus-uu-binhex-begin-line)
977 (setq state (list 'begin))
978 (write-region (point-min) (point-min)
979 gnus-uu-binhex-article-name))
980 (setq state (list 'middle)))
981 (goto-char (point-max))
982 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
983 gnus-uu-binhex-end-line)
985 (when (looking-at gnus-uu-binhex-end-line)
986 (setq state (if (memq 'begin state)
991 (when (file-exists-p gnus-uu-binhex-article-name)
992 (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
993 (if (memq 'begin state)
994 (cons gnus-uu-binhex-article-name state)
999 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
1000 (let ((state (list 'ok))
1001 start-char end-char file-name)
1003 (set-buffer process-buffer)
1004 (goto-char (point-min))
1005 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
1006 (setq state (list 'wrong-type))
1008 (setq start-char (point))
1009 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
1010 (setq state (list 'wrong-type))
1011 (setq end-char (point))
1012 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1013 (insert-buffer-substring process-buffer start-char end-char)
1014 (setq file-name (concat gnus-uu-work-dir
1015 (cdr gnus-article-current) ".ps"))
1016 (write-region (point-min) (point-max) file-name)
1017 (setq state (list file-name 'begin 'end)))))
1023 (defun gnus-uu-get-actions (files)
1024 (let ((ofiles files)
1027 (setq name (cdr (assq 'name (car files))))
1029 (setq action (gnus-uu-get-action name))
1030 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1031 (cons 'action "file")
1032 (cons 'action action))
1033 (cons 'execute (gnus-uu-command
1036 (setq files (cdr files)))
1039 (defun gnus-uu-get-action (file-name)
1042 (gnus-uu-choose-action
1045 gnus-uu-user-view-rules
1046 (if gnus-uu-ignore-default-view-rules
1048 gnus-uu-default-view-rules)
1049 gnus-uu-user-view-rules-end)))
1050 (when (and (not (string= (or action "") "gnus-uu-archive"))
1051 gnus-uu-view-with-metamail)
1053 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1054 (setq action (format "metamail -d -b -c \"%s\"" action))))
1058 ;; Functions for treating subjects and collecting series.
1060 (defun gnus-uu-reginize-string (string)
1061 ;; Takes a string and puts a \ in front of every special character;
1062 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1063 ;; or, if it can't find something like that, tries "2 of 3", then
1064 ;; finally just replaces the next to last number with "[0-9]+".
1066 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1067 (buffer-disable-undo)
1069 (insert (regexp-quote string))
1071 (setq case-fold-search nil)
1074 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1075 (replace-match "\\1[0-9]+/\\2")
1078 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1080 (replace-match "\\1[0-9]+ of \\2")
1083 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1085 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1088 (while (re-search-forward "[ \t]+" nil t)
1089 (replace-match "[ \t]+" t t))
1091 (buffer-substring (point-min) (point-max))))
1093 (defun gnus-uu-get-list-of-articles (n)
1094 ;; If N is non-nil, the article numbers of the N next articles
1095 ;; will be returned.
1096 ;; If any articles have been marked as processable, they will be
1098 ;; Failing that, articles that have subjects that are part of the
1099 ;; same "series" as the current will be returned.
1103 (setq n (prefix-numeric-value n))
1104 (let ((backward (< n 0))
1108 (push (gnus-summary-article-number)
1110 (gnus-summary-search-forward nil nil backward))
1112 (nreverse articles)))
1113 (gnus-newsgroup-processable
1114 (reverse gnus-newsgroup-processable))
1116 (gnus-uu-find-articles-matching)))))
1118 (defun gnus-uu-string< (l1 l2)
1119 (string< (car l1) (car l2)))
1121 (defun gnus-uu-find-articles-matching
1122 (&optional subject only-unread do-not-translate)
1123 ;; Finds all articles that matches the regexp SUBJECT. If it is
1124 ;; nil, the current article name will be used. If ONLY-UNREAD is
1125 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1126 ;; non-nil, article names are not equalized before sorting.
1127 (let ((subject (or subject
1128 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1132 ;; Collect all subjects matching subject.
1133 (let ((case-fold-search t)
1134 (data gnus-newsgroup-data)
1138 (and (not (gnus-data-pseudo-p d))
1139 (or (not only-unread)
1140 (= (setq mark (gnus-data-mark d))
1142 (= mark gnus-ticked-mark)
1143 (= mark gnus-dormant-mark))
1144 (setq subj (mail-header-subject (gnus-data-header d)))
1145 (string-match subject subj)
1146 (push (cons subj (gnus-data-number d))
1147 list-of-subjects))))
1149 ;; Expand numbers, sort, and return the list of article
1151 (mapcar (lambda (sub) (cdr sub))
1152 (sort (gnus-uu-expand-numbers
1154 (not do-not-translate))
1155 'gnus-uu-string<))))))
1157 (defun gnus-uu-expand-numbers (string-list &optional translate)
1158 ;; Takes a list of strings and "expands" all numbers in all the
1159 ;; strings. That is, this function makes all numbers equal length by
1160 ;; prepending lots of zeroes before each number. This is to ease later
1161 ;; sorting to find out what sequence the articles are supposed to be
1162 ;; decoded in. Returns the list of expanded strings.
1163 (let ((out-list string-list)
1166 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1167 (buffer-disable-undo)
1170 (insert (caar string-list))
1171 ;; Translate multiple spaces to one space.
1172 (goto-char (point-min))
1173 (while (re-search-forward "[ \t]+" nil t)
1174 (replace-match " "))
1175 ;; Translate all characters to "a".
1176 (goto-char (point-min))
1178 (while (re-search-forward "[A-Za-z]" nil t)
1179 (replace-match "a" t t)))
1181 (goto-char (point-min))
1182 (while (re-search-forward "[0-9]+" nil t)
1186 (string-to-int (buffer-substring
1187 (match-beginning 0) (match-end 0)))))))
1188 (setq string (buffer-substring 1 (point-max)))
1189 (setcar (car string-list) string)
1190 (setq string-list (cdr string-list))))
1194 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1195 ;; function. It takes a list of articles to be grabbed and a function
1196 ;; to apply to each article.
1198 ;; The function to be called should take two parameters. The first
1199 ;; parameter is the article buffer. The function should leave the
1200 ;; result, if any, in this buffer. Most treatment functions will just
1201 ;; generate files...
1203 ;; The second parameter is the state of the list of articles, and can
1204 ;; have four values: `first', `middle', `last' and `first-and-last'.
1206 ;; The function should return a list. The list may contain the
1207 ;; following symbols:
1208 ;; `error' if an error occurred
1209 ;; `begin' if the beginning of an encoded file has been received
1210 ;; If the list returned contains a `begin', the first element of
1211 ;; the list *must* be a string with the file name of the decoded
1213 ;; `end' if the end of an encoded file has been received
1214 ;; `middle' if the article was a body part of an encoded file
1215 ;; `wrong-type' if the article was not a part of an encoded file
1216 ;; `ok', which can be used everything is ok
1218 (defvar gnus-uu-has-been-grabbed nil)
1220 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1222 (if (not (and gnus-uu-has-been-grabbed
1223 gnus-uu-unmark-articles-not-decoded))
1225 (when dont-unmark-last-article
1226 (setq art (car gnus-uu-has-been-grabbed))
1227 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1228 (while gnus-uu-has-been-grabbed
1229 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1230 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1231 (when dont-unmark-last-article
1232 (setq gnus-uu-has-been-grabbed (list art))))))
1234 ;; This function takes a list of articles and a function to apply to
1235 ;; each article grabbed.
1237 ;; This function returns a list of files decoded if the grabbing and
1238 ;; the process-function has been successful and nil otherwise.
1239 (defun gnus-uu-grab-articles (articles process-function
1240 &optional sloppy limit no-errors)
1241 (let ((state 'first)
1242 (gnus-asynchronous nil)
1243 (gnus-inhibit-treatment t)
1244 has-been-begin article result-file result-files process-state
1245 gnus-summary-display-article-function
1246 gnus-article-prepare-hook gnus-display-mime-function
1247 article-series files)
1249 (while (and articles
1250 (not (memq 'error process-state))
1252 (not (memq 'end process-state))))
1254 (setq article (pop articles))
1255 (when (vectorp (gnus-summary-article-header article))
1256 (push article article-series)
1259 (if (eq state 'first)
1260 (setq state 'first-and-last)
1261 (setq state 'last)))
1263 (let ((part (gnus-uu-part-number article)))
1264 (gnus-message 6 "Getting article %d%s..."
1265 article (if (string= part "") "" (concat ", " part))))
1266 (gnus-summary-display-article article)
1268 ;; Push the article to the processing function.
1270 (set-buffer gnus-original-article-buffer)
1271 (let ((buffer-read-only nil))
1273 (set-buffer gnus-summary-buffer)
1275 (funcall process-function
1276 gnus-original-article-buffer state)))))
1278 (gnus-summary-remove-process-mark article)
1280 ;; If this is the beginning of a decoded file, we push it
1282 (when (or (memq 'begin process-state)
1283 (and (or (eq state 'first)
1284 (eq state 'first-and-last))
1285 (memq 'ok process-state)))
1286 (when has-been-begin
1287 ;; If there is a `result-file' here, that means that the
1288 ;; file was unsuccessfully decoded, so we delete it.
1289 (when (and result-file
1290 (file-exists-p result-file)
1291 (not gnus-uu-be-dangerous)
1292 (or (eq gnus-uu-be-dangerous t)
1294 (format "Delete unsuccessfully decoded file %s"
1296 (delete-file result-file)))
1297 (when (memq 'begin process-state)
1298 (setq result-file (car process-state)))
1299 (setq has-been-begin t))
1301 ;; Check whether we have decoded one complete file.
1302 (when (memq 'end process-state)
1303 (setq article-series nil)
1304 (setq has-been-begin nil)
1305 (if (stringp result-file)
1306 (setq files (list result-file))
1307 (setq files result-file))
1308 (setq result-file (car files))
1310 (push (list (cons 'name (pop files))
1311 (cons 'article article))
1313 ;; Allow user-defined functions to be run on this file.
1314 (when gnus-uu-grabbed-file-functions
1315 (let ((funcs gnus-uu-grabbed-file-functions))
1316 (unless (listp funcs)
1317 (setq funcs (list funcs)))
1319 (funcall (pop funcs) result-file))))
1320 (setq result-file nil)
1321 ;; Check whether we have decoded enough articles.
1322 (and limit (= (length result-files) limit)
1323 (setq articles nil)))
1325 ;; If this is the last article to be decoded, and
1326 ;; we still haven't reached the end, then we delete
1327 ;; the partially decoded file.
1328 (and (or (eq state 'last) (eq state 'first-and-last))
1329 (not (memq 'end process-state))
1331 (file-exists-p result-file)
1332 (not gnus-uu-be-dangerous)
1333 (or (eq gnus-uu-be-dangerous t)
1335 (format "Delete incomplete file %s? " result-file)))
1336 (delete-file result-file))
1338 ;; If this was a file of the wrong sort, then
1339 (when (and (or (memq 'wrong-type process-state)
1340 (memq 'error process-state))
1341 gnus-uu-unmark-articles-not-decoded)
1342 (gnus-summary-tick-article article t))
1344 ;; Set the new series state.
1345 (if (and (not has-been-begin)
1347 (or (memq 'end process-state)
1348 (memq 'middle process-state)))
1350 (setq process-state (list 'error))
1351 (gnus-message 2 "No begin part at the beginning")
1353 (setq state 'middle)))
1355 ;; When there are no result-files, then something must be wrong.
1359 ((not has-been-begin)
1360 (gnus-message 2 "Wrong type file"))
1361 ((memq 'error process-state)
1362 (gnus-message 2 "An error occurred during decoding"))
1363 ((not (or (memq 'ok process-state)
1364 (memq 'end process-state)))
1365 (gnus-message 2 "End of articles reached before end of file")))
1366 ;; Make unsuccessfully decoded articles unread.
1367 (when gnus-uu-unmark-articles-not-decoded
1368 (while article-series
1369 (gnus-summary-tick-article (pop article-series) t)))))
1371 ;; The original article buffer is hosed, shoot it down.
1372 (gnus-kill-buffer gnus-original-article-buffer)
1373 (setq gnus-current-article nil)
1376 (defun gnus-uu-grab-view (file)
1377 "View FILE using the gnus-uu methods."
1378 (let ((action (gnus-uu-get-action file)))
1379 (gnus-execute-command
1380 (if (string-match "%" action)
1381 (format action file)
1382 (concat action " " file))
1383 (eq gnus-view-pseudos 'not-confirm))))
1385 (defun gnus-uu-grab-move (file)
1386 "Move FILE to somewhere."
1387 (when gnus-uu-default-dir
1388 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1389 (file-name-nondirectory file))))
1390 (rename-file file to-file)
1391 (unless (file-exists-p file)
1392 (make-symbolic-link to-file file)))))
1394 (defun gnus-uu-part-number (article)
1395 (let* ((header (gnus-summary-article-header article))
1396 (subject (and header (mail-header-subject header)))
1399 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1401 (setq part (match-string 0 subject))
1402 (setq subject (substring subject (match-end 0)))))
1404 (while (string-match "\\([0-9]+\\)[^0-9]+\\([0-9]+\\)" subject)
1405 (setq part (match-string 0 subject))
1406 (setq subject (substring subject (match-end 0)))))
1409 (defun gnus-uu-uudecode-sentinel (process event)
1410 (delete-process (get-process process)))
1412 (defun gnus-uu-uustrip-article (process-buffer in-state)
1413 ;; Uudecodes a file asynchronously.
1415 (set-buffer process-buffer)
1416 (let ((state (list 'wrong-type))
1417 process-connection-type case-fold-search buffer-read-only
1419 (goto-char (point-min))
1421 ;; Deal with ^M at the end of the lines.
1422 (when gnus-uu-kill-carriage-return
1424 (while (search-forward "\r" nil t)
1425 (delete-backward-char 1))))
1427 (while (or (re-search-forward gnus-uu-begin-string nil t)
1428 (re-search-forward gnus-uu-body-line nil t))
1429 (setq state (list 'ok))
1430 ;; Ok, we are at the first uucoded line.
1432 (setq start-char (point))
1434 (if (not (looking-at gnus-uu-begin-string))
1435 (setq state (list 'middle))
1436 ;; This is the beginning of a uuencoded article.
1437 ;; We replace certain characters that could make things messy.
1438 (setq gnus-uu-file-name
1439 (let ((nnheader-file-name-translation-alist
1440 '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
1441 (nnheader-translate-file-chars (match-string 1))))
1442 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1444 ;; Remove any non gnus-uu-body-line right after start.
1446 (while (and (not (eobp))
1447 (not (looking-at gnus-uu-body-line)))
1450 ;; If a process is running, we kill it.
1451 (when (and gnus-uu-uudecode-process
1452 (memq (process-status gnus-uu-uudecode-process)
1454 (delete-process gnus-uu-uudecode-process)
1455 (gnus-uu-unmark-list-of-grabbed t))
1457 ;; Start a new uudecoding process.
1458 (let ((cdir default-directory))
1461 (cd gnus-uu-work-dir)
1462 (setq gnus-uu-uudecode-process
1465 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1466 shell-file-name shell-command-switch
1467 (format "cd %s %s uudecode" gnus-uu-work-dir
1468 gnus-shell-command-separator))))
1470 (set-process-sentinel
1471 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1472 (setq state (list 'begin))
1473 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1475 ;; We look for the end of the thing to be decoded.
1476 (if (re-search-forward gnus-uu-end-string nil t)
1478 (goto-char (point-max))
1479 (re-search-backward gnus-uu-body-line nil t))
1483 (when gnus-uu-uudecode-process
1484 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1485 ;; Try to correct mishandled uucode.
1486 (when gnus-uu-correct-stripped-uucode
1487 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1488 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1490 ;; Send the text to the process.
1492 (process-send-region
1493 gnus-uu-uudecode-process start-char (point))
1496 (delete-process gnus-uu-uudecode-process)
1497 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1498 (setq state (list 'wrong-type)))))
1500 (if (memq 'end state)
1502 ;; Send an EOF, just in case.
1504 (process-send-eof gnus-uu-uudecode-process))
1505 (while (memq (process-status gnus-uu-uudecode-process)
1507 (accept-process-output gnus-uu-uudecode-process 1)))
1508 (when (or (not gnus-uu-uudecode-process)
1509 (not (memq (process-status gnus-uu-uudecode-process)
1511 (setq state (list 'wrong-type)))))))
1513 (if (memq 'begin state)
1514 (cons (if (= (length files) 1) (car files) files) state)
1517 (defvar gnus-uu-unshar-warning
1520 Shell archives are an archaic method of bundling files for distribution
1521 across computer networks. During the unpacking process, arbitrary commands
1522 are executed on your system, and all kinds of nasty things can happen.
1523 Please examine the archive very carefully before you instruct Emacs to
1524 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1526 If you are unsure what to do, please answer \"no\"."
1527 "Text of warning message displayed by `gnus-uu-unshar-article'.
1528 Make sure that this text consists only of few text lines. Otherwise,
1529 Gnus might fail to display all of it.")
1532 ;; This function is used by `gnus-uu-grab-articles' to treat
1533 ;; a shared article.
1534 (defun gnus-uu-unshar-article (process-buffer in-state)
1535 (let ((state (list 'ok))
1538 (set-buffer process-buffer)
1539 (goto-char (point-min))
1540 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1541 (setq state (list 'wrong-type))
1542 (save-window-excursion
1544 (switch-to-buffer (current-buffer))
1545 (delete-other-windows)
1546 (let ((buffer (get-buffer-create (generate-new-buffer-name
1550 (with-current-buffer buffer
1551 (insert (substitute-command-keys
1552 gnus-uu-unshar-warning))
1553 (goto-char (point-min))
1554 (display-buffer buffer)
1555 (yes-or-no-p "This is a shell archive, unshar it? "))
1556 (kill-buffer buffer))
1557 (setq state (list 'error))))))
1558 (unless (memq 'error state)
1560 (setq start-char (point))
1561 (call-process-region
1562 start-char (point-max) shell-file-name nil
1563 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1564 shell-command-switch
1565 (concat "cd " gnus-uu-work-dir " "
1566 gnus-shell-command-separator " sh")))))
1569 ;; Returns the name of what the shar file is going to unpack.
1570 (defun gnus-uu-find-name-in-shar ()
1571 (let ((oldpoint (point))
1573 (goto-char (point-min))
1574 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1575 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1576 (goto-char oldpoint)
1579 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1580 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1581 ;; found, or the name of the command to run if such a rule is found.
1582 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1583 (let ((action-list (copy-sequence file-action-list))
1584 (case-fold-search t)
1589 (and gnus-uu-ignore-files-by-name
1590 (string-match gnus-uu-ignore-files-by-name file-name)))
1592 (and gnus-uu-ignore-files-by-type
1593 (string-match gnus-uu-ignore-files-by-type
1594 (or (gnus-uu-choose-action
1595 file-name gnus-uu-ext-to-mime-list t)
1597 (while (not (or (eq action-list ()) action))
1598 (setq rule (car action-list))
1599 (setq action-list (cdr action-list))
1600 (when (string-match (car rule) file-name)
1601 (setq action (cadr rule)))))
1604 (defun gnus-uu-treat-archive (file-path)
1605 ;; Unpacks an archive. Returns t if unpacking is successful.
1606 (let ((did-unpack t)
1608 (setq action (gnus-uu-choose-action
1609 file-path (append gnus-uu-user-archive-rules
1610 (if gnus-uu-ignore-default-archive-rules
1612 gnus-uu-default-archive-rules))))
1615 (error "No unpackers for the file %s" file-path))
1617 (string-match "/[^/]*$" file-path)
1618 (setq dir (substring file-path 0 (match-beginning 0)))
1620 (when (member action gnus-uu-destructive-archivers)
1621 (copy-file file-path (concat file-path "~") t))
1623 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1626 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1629 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1631 (if (= 0 (call-process shell-file-name nil
1632 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1633 nil shell-command-switch command))
1635 (gnus-message 2 "Error during unpacking of archive")
1636 (setq did-unpack nil))
1638 (when (member action gnus-uu-destructive-archivers)
1639 (rename-file (concat file-path "~") file-path t))
1643 (defun gnus-uu-dir-files (dir)
1644 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1647 (if (file-directory-p (setq file (car dirs)))
1648 (setq files (append files (gnus-uu-dir-files file)))
1650 (setq dirs (cdr dirs)))
1653 (defun gnus-uu-unpack-files (files &optional ignore)
1654 ;; Go through FILES and look for files to unpack.
1655 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1659 (setq file (cdr (assq 'name (car files))))
1660 (when (and (not (member file ignore))
1661 (equal (gnus-uu-get-action (file-name-nondirectory file))
1663 (push file did-unpack)
1664 (unless (gnus-uu-treat-archive file)
1665 (gnus-message 2 "Error during unpacking of %s" file))
1666 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1669 (unless (member (car nfiles) totfiles)
1670 (push (list (cons 'name (car nfiles))
1671 (cons 'original file))
1673 (setq nfiles (cdr nfiles)))
1674 (setq totfiles newfiles)))
1675 (setq files (cdr files)))
1677 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1680 (defun gnus-uu-ls-r (dir)
1681 (let* ((files (gnus-uu-directory-files dir t))
1684 (when (file-directory-p (car files))
1685 (setq ofiles (delete (car files) ofiles))
1686 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1687 (setq files (cdr files)))
1692 (defun gnus-uu-directory-files (dir &optional full)
1693 (let (files out file)
1694 (setq files (directory-files dir full))
1696 (setq file (car files))
1697 (setq files (cdr files))
1698 (unless (member (file-name-nondirectory file) '("." ".."))
1700 (setq out (nreverse out))
1703 (defun gnus-uu-check-correct-stripped-uucode (start end)
1705 (let (found beg length)
1706 (if (not gnus-uu-correct-stripped-uucode)
1710 (if (re-search-forward " \\|`" end t)
1715 (when (looking-at "\n")
1720 (if (looking-at (concat gnus-uu-begin-string "\\|"
1721 gnus-uu-end-string))
1727 (setq length (- (point) beg)))
1732 (when (not (= length (- (point) beg)))
1733 (insert (make-string (- length (- (point) beg)) ? ))))
1734 (forward-line 1)))))))
1736 (defvar gnus-uu-tmp-alist nil)
1738 (defun gnus-uu-initialize (&optional scan)
1741 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1742 (if (file-exists-p (cdr entry))
1743 (setq gnus-uu-work-dir (cdr entry))
1744 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1747 (setq gnus-uu-tmp-dir (file-name-as-directory
1748 (expand-file-name gnus-uu-tmp-dir)))
1749 (if (not (file-directory-p gnus-uu-tmp-dir))
1750 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1751 (when (not (file-writable-p gnus-uu-tmp-dir))
1752 (error "Temp directory %s can't be written to"
1755 (setq gnus-uu-work-dir
1756 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1757 (set-file-modes gnus-uu-work-dir 448)
1758 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1759 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1760 gnus-uu-tmp-alist))))
1763 ;; Kills the temporary uu buffers, kills any processes, etc.
1764 (defun gnus-uu-clean-up ()
1766 (and gnus-uu-uudecode-process
1767 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1769 (delete-process gnus-uu-uudecode-process))
1770 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1771 (kill-buffer buf))))
1773 ;; Inputs an action and a filename and returns a full command, making sure
1774 ;; that the filename will be treated as a single argument when the shell
1775 ;; executes the command.
1776 (defun gnus-uu-command (action file)
1777 (let ((quoted-file (mm-quote-arg file)))
1778 (if (string-match "%s" action)
1779 (format action quoted-file)
1780 (concat action " " quoted-file))))
1782 (defun gnus-uu-delete-work-dir (&optional dir)
1783 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1785 (gnus-message 7 "Deleting directory %s..." dir)
1786 (setq dir gnus-uu-work-dir))
1788 (file-exists-p dir))
1789 (let ((files (directory-files dir t nil t))
1791 (while (setq file (pop files))
1792 (unless (member (file-name-nondirectory file) '("." ".."))
1793 (if (file-directory-p file)
1794 (gnus-uu-delete-work-dir file)
1795 (gnus-message 9 "Deleting file %s..." file)
1796 (delete-file file))))
1797 (delete-directory dir)))
1798 (gnus-message 7 ""))
1802 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1803 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1808 ;;; uuencoded posting
1811 ;; Any function that is to be used as and encoding method will take two
1812 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1813 ;; and "spiral.jpg", respectively.) The function should return nil if
1814 ;; the encoding wasn't successful.
1815 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1816 "Function used for encoding binary files.
1817 There are three functions supplied with gnus-uu for encoding files:
1818 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1819 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1820 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1821 uuencode and adds MIME headers."
1822 :group 'gnus-extract-post
1823 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1824 (function-item gnus-uu-post-encode-mime)
1825 (function-item gnus-uu-post-encode-mime-uuencode)
1826 (function :tag "Other")))
1828 (defcustom gnus-uu-post-include-before-composing nil
1829 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1830 If this variable is t, you can either include an encoded file with
1831 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1832 :group 'gnus-extract-post
1835 (defcustom gnus-uu-post-length 990
1836 "Maximum length of an article.
1837 The encoded file will be split into how many articles it takes to
1838 post the entire file."
1839 :group 'gnus-extract-post
1842 (defcustom gnus-uu-post-threaded nil
1843 "Non-nil means that gnus-uu will post the encoded file in a thread.
1844 This may not be smart, as no other decoder I have seen are able to
1845 follow threads when collecting uuencoded articles. (Well, I have seen
1846 one package that does that - gnus-uu, but somehow, I don't think that
1847 counts...) The default is nil."
1848 :group 'gnus-extract-post
1851 (defcustom gnus-uu-post-separate-description t
1852 "Non-nil means that the description will be posted in a separate article.
1853 The first article will typically be numbered (0/x). If this variable
1854 is nil, the description the user enters will be included at the
1855 beginning of the first article, which will be numbered (1/x). Default
1857 :group 'gnus-extract-post
1860 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1861 (defvar gnus-uu-post-message-id nil)
1862 (defvar gnus-uu-post-inserted-file-name nil)
1863 (defvar gnus-uu-winconf-post-news nil)
1865 (defun gnus-uu-post-news ()
1866 "Compose an article and post an encoded file."
1868 (setq gnus-uu-post-inserted-file-name nil)
1869 (setq gnus-uu-winconf-post-news (current-window-configuration))
1871 (gnus-summary-post-news)
1873 (let ((map (make-sparse-keymap)))
1874 (set-keymap-parent map (current-local-map))
1875 (use-local-map map))
1876 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1877 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1878 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1879 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1881 (when gnus-uu-post-include-before-composing
1882 (save-excursion (setq gnus-uu-post-inserted-file-name
1883 (gnus-uu-post-insert-binary)))))
1885 (defun gnus-uu-post-insert-binary-in-article ()
1886 "Inserts an encoded file in the buffer.
1887 The user will be asked for a file name."
1890 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1892 ;; Encodes with uuencode and substitutes all spaces with backticks.
1893 (defun gnus-uu-post-encode-uuencode (path file-name)
1894 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1895 (goto-char (point-min))
1897 (while (re-search-forward " " nil t)
1898 (replace-match "`"))
1901 ;; Encodes with uuencode and adds MIME headers.
1902 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1903 (when (gnus-uu-post-encode-uuencode path file-name)
1904 (gnus-uu-post-make-mime file-name "x-uue")
1907 ;; Encodes with base64 and adds MIME headers
1908 (defun gnus-uu-post-encode-mime (path file-name)
1909 (when (zerop (call-process shell-file-name nil t nil shell-command-switch
1910 (format "%s %s -o %s" "mmencode" path file-name)))
1911 (gnus-uu-post-make-mime file-name "base64")
1914 ;; Adds MIME headers.
1915 (defun gnus-uu-post-make-mime (file-name encoding)
1916 (goto-char (point-min))
1917 (insert (format "Content-Type: %s; name=\"%s\"\n"
1918 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1920 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1922 (set-buffer gnus-message-buffer)
1923 (goto-char (point-min))
1924 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1926 (narrow-to-region (point-min) (point))
1927 (unless (mail-fetch-field "mime-version")
1929 (insert "MIME-Version: 1.0\n"))
1932 ;; Encodes a file PATH with COMMAND, leaving the result in the
1934 (defun gnus-uu-post-encode-file (command path file-name)
1935 (= 0 (call-process shell-file-name nil t nil shell-command-switch
1936 (format "%s %s %s" command path file-name))))
1938 (defun gnus-uu-post-news-inews ()
1939 "Posts the composed news article and encoded file.
1940 If no file has been included, the user will be asked for a file."
1945 (if gnus-uu-post-inserted-file-name
1946 (setq file-name gnus-uu-post-inserted-file-name)
1947 (setq file-name (gnus-uu-post-insert-binary)))
1949 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1950 (setq gnus-uu-post-inserted-file-name nil)
1951 (when gnus-uu-winconf-post-news
1952 (set-window-configuration gnus-uu-winconf-post-news)))
1954 ;; Asks for a file to encode, encodes it and inserts the result in
1955 ;; the current buffer. Returns the file name the user gave.
1956 (defun gnus-uu-post-insert-binary ()
1957 (let ((uuencode-buffer-name "*uuencode buffer*")
1958 file-path uubuf file-name)
1960 (setq file-path (read-file-name
1961 "What file do you want to encode? "))
1962 (when (not (file-exists-p file-path))
1963 (error "%s: No such file" file-path))
1965 (goto-char (point-max))
1966 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1968 ;; #### Unix-specific?
1969 (when (string-match "^~/" file-path)
1970 (setq file-path (concat "$HOME" (substring file-path 1))))
1971 ;; #### Unix-specific?
1972 (if (string-match "/[^/]*$" file-path)
1973 (setq file-name (substring file-path (1+ (match-beginning 0))))
1974 (setq file-name file-path))
1978 (set-buffer (setq uubuf
1979 (gnus-get-buffer-create uuencode-buffer-name)))
1981 (funcall gnus-uu-post-encode-method file-path file-name))
1982 (insert-buffer-substring uubuf)
1983 (error "Encoding unsuccessful"))
1984 (kill-buffer uubuf))
1987 ;; Posts the article and all of the encoded file.
1988 (defun gnus-uu-post-encoded (file-name &optional threaded)
1989 (let ((send-buffer-name "*uuencode send buffer*")
1990 (encoded-buffer-name "*encoded buffer*")
1991 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
1992 (separator (concat mail-header-separator "\n\n"))
1993 uubuf length parts header i end beg
1994 beg-line minlen post-buf whole-len beg-binary end-binary)
1996 (setq post-buf (current-buffer))
1998 (goto-char (point-min))
1999 (when (not (re-search-forward
2000 (if gnus-uu-post-separate-description
2001 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2003 (concat "^" (regexp-quote mail-header-separator) "$"))
2005 (error "Internal error: No binary/header separator"))
2008 (setq beg-binary (point))
2009 (setq end-binary (point-max))
2012 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2014 (insert-buffer-substring post-buf beg-binary end-binary)
2015 (goto-char (point-min))
2016 (setq length (count-lines (point-min) (point-max)))
2017 (setq parts (/ length gnus-uu-post-length))
2018 (unless (< (% length gnus-uu-post-length) 4)
2021 (when gnus-uu-post-separate-description
2023 (delete-region (point) (point-max))
2025 (goto-char (point-min))
2027 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2029 (setq header (buffer-substring (point-min) (point)))
2031 (goto-char (point-min))
2032 (when gnus-uu-post-separate-description
2033 (when (re-search-forward "^Subject: " nil t)
2035 (insert (format " (0/%d)" parts)))
2038 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2043 (while (not (> i parts))
2044 (set-buffer (gnus-get-buffer-create send-buffer-name))
2047 (when (and threaded gnus-uu-post-message-id)
2048 (insert "References: " gnus-uu-post-message-id "\n"))
2051 (- 62 (length (format top-string "" file-name i parts ""))))
2052 (when (> 1 (setq minlen (/ whole-len 2)))
2057 (make-string minlen ?-)
2060 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2062 (goto-char (point-min))
2063 (when (re-search-forward "^Subject: " nil t)
2065 (insert (format " (%d/%d)" i parts)))
2067 (goto-char (point-max))
2072 (goto-char (point-max))
2073 (forward-line gnus-uu-post-length))
2074 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2077 (insert-buffer-substring uubuf beg end)
2078 (insert beg-line "\n")
2081 (goto-char (point-min))
2083 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2086 (when (re-search-forward
2087 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2093 (let (message-sent-message-via)
2096 (setq gnus-uu-post-message-id
2097 (concat (message-fetch-field "references") " "
2098 (message-fetch-field "message-id"))))))
2100 (gnus-kill-buffer send-buffer-name)
2101 (gnus-kill-buffer encoded-buffer-name)
2103 (when (not gnus-uu-post-separate-description)
2104 (set-buffer-modified-p nil)
2105 (when (fboundp 'bury-buffer)
2110 ;;; gnus-uu.el ends here