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 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
37 (defgroup gnus-extract nil
38 "Extracting encoded files."
42 (defgroup gnus-extract-view nil
43 "Viewwing extracted files."
46 (defgroup gnus-extract-archive nil
47 "Extracting encoded archives."
50 (defgroup gnus-extract-post nil
51 "Extracting encoded archives."
52 :prefix "gnus-uu-post"
55 ;; Default viewing action rules
57 (defcustom gnus-uu-default-view-rules
58 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
59 ("\\.pas$" "cat %s | sed 's/\r$//'")
60 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
61 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
62 ("\\.tga$" "tgatoppm %s | ee -")
63 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
64 "sox -v .5 %s -t .au -u - > /dev/audio")
65 ("\\.au$" "cat %s > /dev/audio")
66 ("\\.midi?$" "playmidi -f")
68 ("\\.ps$" "ghostview")
70 ("\\.html$" "xmosaic")
71 ("\\.mpe?g$" "mpeg_play")
72 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
73 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
75 "*Default actions to be taken when the user asks to view a file.
76 To change the behaviour, you can either edit this variable or set
77 `gnus-uu-user-view-rules' to something useful.
81 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
82 following in your .emacs file:
84 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
86 Both these variables are lists of lists with two string elements. The
87 first string is a regular expression. If the file name matches this
88 regular expression, the command in the second string is executed with
89 the file as an argument.
91 If the command string contains \"%s\", the file name will be inserted
92 at that point in the command string. If there's no \"%s\" in the
93 command string, the file name will be appended to the command string
96 There are several user variables to tailor the behaviour of gnus-uu to
97 your needs. First we have `gnus-uu-user-view-rules', which is the
98 variable gnus-uu first consults when trying to decide how to view a
99 file. If this variable contains no matches, gnus-uu examines the
100 default rule variable provided in this package. If gnus-uu finds no
101 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
103 :group 'gnus-extract-view
104 :type '(repeat (group regexp (string :tag "Command"))))
106 (defcustom gnus-uu-user-view-rules nil
107 "What actions are to be taken to view a file.
108 See the documentation on the `gnus-uu-default-view-rules' variable for
110 :group 'gnus-extract-view
111 :type '(repeat (group regexp (string :tag "Command"))))
113 (defcustom gnus-uu-user-view-rules-end
115 "*What actions are to be taken if no rule matched the file name.
116 See the documentation on the `gnus-uu-default-view-rules' variable for
118 :group 'gnus-extract-view
119 :type '(repeat (group regexp (string :tag "Command"))))
121 ;; Default unpacking commands
123 (defcustom gnus-uu-default-archive-rules
124 '(("\\.tar$" "tar xf")
125 ("\\.zip$" "unzip -o")
127 ("\\.arj$" "unarj x")
129 ("\\.\\(lzh\\|lha\\)$" "lha x")
130 ("\\.Z$" "uncompress")
132 ("\\.arc$" "arc -x"))
133 "*See `gnus-uu-user-archive-rules'."
134 :group 'gnus-extract-archive
135 :type '(repeat (group regexp (string :tag "Command"))))
137 (defvar gnus-uu-destructive-archivers
138 (list "uncompress" "gunzip"))
140 (defcustom gnus-uu-user-archive-rules nil
141 "A list that can be set to override the default archive unpacking commands.
142 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
143 unpack zip files, say the following:
144 (setq gnus-uu-user-archive-rules
145 '((\"\\\\.tar$\" \"untar\")
146 (\"\\\\.zip$\" \"zip -x\")))"
147 :group 'gnus-extract-archive
148 :type '(repeat (group regexp (string :tag "Command"))))
150 (defcustom gnus-uu-ignore-files-by-name nil
151 "*A regular expression saying what files should not be viewed based on name.
152 If, for instance, you want gnus-uu to ignore all .au and .wav files,
153 you could say something like
155 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
157 Note that this variable can be used in conjunction with the
158 `gnus-uu-ignore-files-by-type' variable."
160 :type '(choice (const :tag "off" nil)
161 (regexp :format "%v")))
163 (defcustom gnus-uu-ignore-files-by-type nil
164 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
165 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
166 you could say something like
168 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
170 Note that this variable can be used in conjunction with the
171 `gnus-uu-ignore-files-by-name' variable."
173 :type '(choice (const :tag "off" nil)
174 (regexp :format "%v")))
176 ;; Pseudo-MIME support
178 (defconst gnus-uu-ext-to-mime-list
179 '(("\\.gif$" "image/gif")
180 ("\\.jpe?g$" "image/jpeg")
181 ("\\.tiff?$" "image/tiff")
182 ("\\.xwd$" "image/xwd")
183 ("\\.pbm$" "image/pbm")
184 ("\\.pgm$" "image/pgm")
185 ("\\.ppm$" "image/ppm")
186 ("\\.xbm$" "image/xbm")
187 ("\\.pcx$" "image/pcx")
188 ("\\.tga$" "image/tga")
189 ("\\.ps$" "image/postscript")
190 ("\\.fli$" "video/fli")
191 ("\\.wav$" "audio/wav")
192 ("\\.aiff$" "audio/aiff")
193 ("\\.hcom$" "audio/hcom")
194 ("\\.voc$" "audio/voc")
195 ("\\.smp$" "audio/smp")
196 ("\\.mod$" "audio/mod")
197 ("\\.dvi$" "image/dvi")
198 ("\\.mpe?g$" "video/mpeg")
199 ("\\.au$" "audio/basic")
200 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
201 ("\\.\\(c\\|h\\)$" "text/source")
202 ("read.*me" "text/plain")
203 ("\\.html$" "text/html")
204 ("\\.bat$" "text/bat")
205 ("\\.[1-6]$" "text/man")
206 ("\\.flc$" "video/flc")
207 ("\\.rle$" "video/rle")
208 ("\\.pfx$" "video/pfx")
209 ("\\.avi$" "video/avi")
210 ("\\.sme$" "video/sme")
211 ("\\.rpza$" "video/prza")
212 ("\\.dl$" "video/dl")
213 ("\\.qt$" "video/qt")
214 ("\\.rsrc$" "video/rsrc")
215 ("\\..*$" "unknown/unknown")))
217 ;; Various variables users may set
219 (defcustom gnus-uu-tmp-dir
220 (cond ((fboundp 'temp-directory) (temp-directory))
221 ((boundp 'temporary-file-directory) temporary-file-directory)
223 "*Variable saying where gnus-uu is to do its work.
224 Default is \"/tmp/\"."
228 (defcustom gnus-uu-do-not-unpack-archives nil
229 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
231 :group 'gnus-extract-archive
234 (defcustom gnus-uu-ignore-default-view-rules nil
235 "*Non-nil means that gnus-uu will ignore the default viewing rules.
236 Only the user viewing rules will be consulted. Default is nil."
237 :group 'gnus-extract-view
240 (defcustom gnus-uu-grabbed-file-functions nil
241 "Functions run on each file after successful decoding.
242 They will be called with the name of the file as the argument.
243 Likely functions you can use in this list are `gnus-uu-grab-view'
244 and `gnus-uu-grab-move'."
246 :options '(gnus-uu-grab-view gnus-uu-grab-move)
249 (defcustom gnus-uu-ignore-default-archive-rules nil
250 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
251 Only the user unpacking commands will be consulted. Default is nil."
252 :group 'gnus-extract-archive
255 (defcustom gnus-uu-kill-carriage-return t
256 "*Non-nil means that gnus-uu will strip all carriage returns from articles.
261 (defcustom gnus-uu-view-with-metamail nil
262 "*Non-nil means that files will be viewed with metamail.
263 The gnus-uu viewing functions will be ignored and gnus-uu will try
264 to guess at a content-type based on file name suffixes. Default
269 (defcustom gnus-uu-unmark-articles-not-decoded nil
270 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
275 (defcustom gnus-uu-correct-stripped-uucode nil
276 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
281 (defcustom gnus-uu-save-in-digest nil
282 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
283 If this variable is nil, gnus-uu will just save everything in a
284 file without any embellishments. The digesting almost conforms to RFC1153 -
285 no easy way to specify any meaningful volume and issue numbers were found,
286 so I simply dropped them."
290 (defcustom gnus-uu-pre-uudecode-hook nil
291 "Hook run before sending a message to uudecode."
295 (defcustom gnus-uu-digest-headers
296 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
297 "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
298 "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
299 "^Content-ID:" "^User-Agent:" "^X-Face:")
300 "*List of regexps to match headers included in digested messages.
301 The headers will be included in the sequence they are matched. If nil
302 include all headers."
304 :type '(repeat regexp))
306 (defcustom gnus-uu-save-separate-articles nil
307 "*Non-nil means that gnus-uu will save articles in separate files."
311 (defcustom gnus-uu-be-dangerous 'ask
312 "*Specifies what to do if unusual situations arise during decoding.
313 If nil, be as conservative as possible. If t, ignore things that
314 didn't work, and overwrite existing files. Otherwise, ask each time."
316 :type '(choice (const :tag "conservative" nil)
317 (const :tag "ask" ask)
318 (const :tag "liberal" t)))
320 ;; Internal variables
322 (defvar gnus-uu-saved-article-name nil)
324 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
325 (defvar gnus-uu-end-string "^end[ \t]*$")
327 (defvar gnus-uu-body-line "^M")
329 (while (> (setq i (1- i)) 0)
330 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
331 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
333 ;"^M.............................................................?$"
335 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
337 (defvar gnus-uu-shar-file-name nil)
338 (defvar gnus-uu-shar-name-marker
339 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
341 (defvar gnus-uu-postscript-begin-string "^%!PS-")
342 (defvar gnus-uu-postscript-end-string "^%%EOF$")
344 (defvar gnus-uu-file-name nil)
345 (defvar gnus-uu-uudecode-process nil)
346 (defvar gnus-uu-binhex-article-name nil)
348 (defvar gnus-uu-work-dir nil)
350 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
352 (defvar gnus-uu-default-dir gnus-article-save-directory)
353 (defvar gnus-uu-digest-from-subject nil)
354 (defvar gnus-uu-digest-buffer nil)
358 (defun gnus-uu-decode-uu (&optional n)
359 "Uudecodes the current article."
361 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
363 (defun gnus-uu-decode-uu-and-save (n dir)
364 "Decodes and saves the resulting file."
366 (list current-prefix-arg
367 (file-name-as-directory
368 (read-file-name "Uudecode and save in dir: "
370 gnus-uu-default-dir t))))
371 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
373 (defun gnus-uu-decode-unshar (&optional n)
374 "Unshars the current article."
376 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
378 (defun gnus-uu-decode-unshar-and-save (n dir)
379 "Unshars and saves the current article."
381 (list current-prefix-arg
382 (file-name-as-directory
383 (read-file-name "Unshar and save in dir: "
385 gnus-uu-default-dir t))))
386 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
388 (defun gnus-uu-decode-save (n file)
389 "Saves the current article."
391 (list current-prefix-arg
393 (if gnus-uu-save-separate-articles
394 "Save articles is dir: "
395 "Save articles in file: ")
397 gnus-uu-default-dir)))
398 (setq gnus-uu-saved-article-name file)
399 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
401 (defun gnus-uu-decode-binhex (n dir)
402 "Unbinhexes the current article."
404 (list current-prefix-arg
405 (file-name-as-directory
406 (read-file-name "Unbinhex and save in dir: "
408 gnus-uu-default-dir))))
409 (setq gnus-uu-binhex-article-name
410 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
411 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
413 (defun gnus-uu-decode-uu-view (&optional n)
414 "Uudecodes and views the current article."
416 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
417 (gnus-uu-decode-uu n)))
419 (defun gnus-uu-decode-uu-and-save-view (n dir)
420 "Decodes, views and saves the resulting file."
422 (list current-prefix-arg
423 (read-file-name "Uudecode, view and save in dir: "
425 gnus-uu-default-dir t)))
426 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
427 (gnus-uu-decode-uu-and-save n dir)))
429 (defun gnus-uu-decode-unshar-view (&optional n)
430 "Unshars and views the current article."
432 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
433 (gnus-uu-decode-unshar n)))
435 (defun gnus-uu-decode-unshar-and-save-view (n dir)
436 "Unshars and saves the current article."
438 (list current-prefix-arg
439 (read-file-name "Unshar, view and save in dir: "
441 gnus-uu-default-dir t)))
442 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
443 (gnus-uu-decode-unshar-and-save n dir)))
445 (defun gnus-uu-decode-save-view (n file)
446 "Saves and views the current article."
448 (list current-prefix-arg
449 (read-file-name (if gnus-uu-save-separate-articles
450 "Save articles is dir: "
451 "Save articles in file: ")
452 gnus-uu-default-dir gnus-uu-default-dir)))
453 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
454 (gnus-uu-decode-save n file)))
456 (defun gnus-uu-decode-binhex-view (n file)
457 "Unbinhexes and views the current article."
459 (list current-prefix-arg
460 (read-file-name "Unbinhex, view and save in dir: "
461 gnus-uu-default-dir gnus-uu-default-dir)))
462 (setq gnus-uu-binhex-article-name
463 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
464 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
465 (gnus-uu-decode-binhex n file)))
468 ;; Digest and forward articles
470 (defun gnus-uu-digest-mail-forward (&optional n post)
471 "Digests and forwards all articles in this series."
473 (let ((gnus-uu-save-in-digest t)
474 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
475 (message-forward-as-mime message-forward-as-mime)
476 (mail-parse-charset gnus-newsgroup-charset)
477 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
478 gnus-uu-digest-buffer subject from)
479 (if (and n (not (numberp n)))
480 (setq message-forward-as-mime (not message-forward-as-mime)
482 (let ((gnus-article-reply (gnus-summary-work-articles n)))
483 (gnus-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) (point-at-eol))
514 (goto-char (point-min))
515 (when (re-search-forward "^From:")
516 (delete-region (point) (point-at-eol))
518 (let ((message-forward-decoded-p t))
519 (message-forward post))))
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))
575 (l (length articles)))
577 (gnus-summary-set-process-mark (car articles))
578 (setq articles (cdr articles)))
579 (message "Marked %d articles" l))
580 (gnus-summary-position-point))
582 (defun gnus-uu-mark-region (beg end &optional unmark)
583 "Set the process mark on all articles between point and mark."
587 (while (< (point) end)
589 (gnus-summary-remove-process-mark (gnus-summary-article-number))
590 (gnus-summary-set-process-mark (gnus-summary-article-number)))
592 (gnus-summary-position-point))
594 (defun gnus-uu-unmark-region (beg end)
595 "Remove the process mark from all articles between point and mark."
597 (gnus-uu-mark-region beg end t))
599 (defun gnus-uu-mark-buffer ()
600 "Set the process mark on all articles in the buffer."
602 (gnus-uu-mark-region (point-min) (point-max)))
604 (defun gnus-uu-unmark-buffer ()
605 "Remove the process mark on all articles in the buffer."
607 (gnus-uu-mark-region (point-min) (point-max) t))
609 (defun gnus-uu-mark-thread ()
610 "Marks all articles downwards in this thread."
612 (gnus-save-hidden-threads
613 (let ((level (gnus-summary-thread-level)))
614 (while (and (gnus-summary-set-process-mark
615 (gnus-summary-article-number))
616 (zerop (gnus-summary-next-subject 1 nil t))
617 (> (gnus-summary-thread-level) level)))))
618 (gnus-summary-position-point))
620 (defun gnus-uu-unmark-thread ()
621 "Unmarks all articles downwards in this thread."
623 (let ((level (gnus-summary-thread-level)))
624 (while (and (gnus-summary-remove-process-mark
625 (gnus-summary-article-number))
626 (zerop (gnus-summary-next-subject 1))
627 (> (gnus-summary-thread-level) level))))
628 (gnus-summary-position-point))
630 (defun gnus-uu-invert-processable ()
631 "Invert the list of process-marked articles."
633 (let ((data gnus-newsgroup-data)
637 (if (memq (setq number (gnus-data-number (pop data)))
638 gnus-newsgroup-processable)
639 (gnus-summary-remove-process-mark number)
640 (gnus-summary-set-process-mark number)))))
641 (gnus-summary-position-point))
643 (defun gnus-uu-mark-over (&optional score)
644 "Mark all articles with a score over SCORE (the prefix)."
646 (let ((score (or score gnus-summary-default-score 0))
647 (data gnus-newsgroup-data))
650 (when (> (or (cdr (assq (gnus-data-number (car data))
651 gnus-newsgroup-scored))
652 gnus-summary-default-score 0)
654 (gnus-summary-set-process-mark (caar data)))
655 (setq data (cdr data))))
656 (gnus-summary-position-point)))
658 (defun gnus-uu-mark-sparse ()
659 "Mark all series that have some articles marked."
661 (let ((marked (nreverse gnus-newsgroup-processable))
662 subject articles total headers)
664 (error "No articles marked with the process mark"))
665 (setq gnus-newsgroup-processable nil)
668 (and (vectorp (setq headers
669 (gnus-summary-article-header (car marked))))
670 (setq subject (mail-header-subject headers)
671 articles (gnus-uu-find-articles-matching
672 (gnus-uu-reginize-string subject))
673 total (nconc total articles)))
675 (gnus-summary-set-process-mark (car articles))
676 (setcdr marked (delq (car articles) (cdr marked)))
677 (setq articles (cdr articles)))
678 (setq marked (cdr marked)))
679 (setq gnus-newsgroup-processable (nreverse total)))
680 (gnus-summary-position-point)))
682 (defun gnus-uu-mark-all ()
683 "Mark all articles in \"series\" order."
685 (setq gnus-newsgroup-processable nil)
687 (let ((data gnus-newsgroup-data)
690 (when (and (not (memq (setq number (gnus-data-number (car data)))
691 gnus-newsgroup-processable))
692 (vectorp (gnus-data-header (car data))))
693 (gnus-summary-goto-subject number)
694 (gnus-uu-mark-series))
695 (setq data (cdr data)))))
696 (gnus-summary-position-point))
698 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
700 (defun gnus-uu-decode-postscript (&optional n)
701 "Gets postscript of the current article."
703 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
705 (defun gnus-uu-decode-postscript-view (&optional n)
706 "Gets and views the current article."
708 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
709 (gnus-uu-decode-postscript n)))
711 (defun gnus-uu-decode-postscript-and-save (n dir)
712 "Extracts postscript and saves the current article."
714 (list current-prefix-arg
715 (file-name-as-directory
716 (read-file-name "Save in dir: "
718 gnus-uu-default-dir t))))
719 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
722 (defun gnus-uu-decode-postscript-and-save-view (n dir)
723 "Decodes, views and saves the resulting file."
725 (list current-prefix-arg
726 (read-file-name "Where do you want to save the file(s)? "
728 gnus-uu-default-dir t)))
729 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
730 (gnus-uu-decode-postscript-and-save n dir)))
733 ;; Internal functions.
735 (defun gnus-uu-decode-with-method (method n &optional save not-insert
737 (gnus-uu-initialize scan)
739 (setq gnus-uu-default-dir save))
740 ;; Create the directory we save to.
741 (when (and scan cdir save
742 (not (file-exists-p save)))
743 (make-directory save t))
744 (let ((articles (gnus-uu-get-list-of-articles n))
746 (setq files (gnus-uu-grab-articles articles method t))
747 (let ((gnus-current-article (car articles)))
749 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
751 (gnus-uu-save-files files save))
752 (when (eq gnus-uu-do-not-unpack-archives nil)
753 (setq files (gnus-uu-unpack-files files)))
754 (setq files (nreverse (gnus-uu-get-actions files)))
755 (or not-insert (not gnus-insert-pseudo-articles)
756 (gnus-summary-insert-pseudos files save))))
758 (defun gnus-uu-scan-directory (dir &optional rec)
759 "Return a list of all files under DIR."
760 (let ((files (directory-files dir t))
762 (while (setq file (pop files))
763 (unless (member (file-name-nondirectory file) '("." ".."))
764 (push (list (cons 'name file)
765 (cons 'article gnus-current-article))
767 (when (file-directory-p file)
768 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
773 (defun gnus-uu-save-files (files dir)
775 (let ((len (length files))
776 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
777 to-file file fromdir)
778 (while (setq file (cdr (assq 'name (pop files))))
779 (when (file-exists-p file)
780 (string-match reg file)
781 (setq fromdir (substring file (match-end 0)))
782 (if (file-directory-p file)
783 (gnus-make-directory (concat dir fromdir))
784 (setq to-file (concat dir fromdir))
785 (when (or (not (file-exists-p to-file))
786 (eq gnus-uu-be-dangerous t)
787 (and gnus-uu-be-dangerous
788 (gnus-y-or-n-p (format "%s exists; overwrite? "
790 (copy-file file to-file t t)))))
791 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
793 ;; Functions for saving and possibly digesting articles without
796 ;; Function called by gnus-uu-grab-articles to treat each article.
797 (defun gnus-uu-save-article (buffer in-state)
799 (gnus-uu-save-separate-articles
802 (gnus-write-buffer-as-coding-system
803 nnheader-text-coding-system
804 (concat gnus-uu-saved-article-name gnus-current-article))
805 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
806 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
808 ((eq in-state 'last) (list 'end))
809 (t (list 'middle)))))
810 ((not gnus-uu-save-in-digest)
813 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
814 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
815 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
817 ((eq in-state 'last) (list 'end))
818 (t (list 'middle)))))
820 (let ((header (gnus-summary-article-header)))
821 (push (cons (mail-header-from header)
822 (mail-header-subject header))
823 gnus-uu-digest-from-subject))
824 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
825 beg subj headers headline sorthead body end-string state)
826 (if (or (eq in-state 'first)
827 (eq in-state 'first-and-last))
829 (setq state (list 'begin))
831 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
834 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
837 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
838 (current-time-string) name name))
839 (insert "Topics:\n")))
840 (when (not (eq in-state 'end))
841 (setq state (list 'middle))))
843 (set-buffer "*gnus-uu-body*")
844 (goto-char (setq beg (point-max)))
848 (let (buffer-read-only)
849 (set-text-properties (point-min) (point-max) nil)
850 ;; These two are necessary for XEmacs 19.12 fascism.
851 (put-text-property (point-min) (point-max) 'invisible nil)
852 (put-text-property (point-min) (point-max) 'intangible nil))
853 (goto-char (point-min))
854 (re-search-forward "\n\n")
855 (unless gnus-uu-digest-buffer
856 ;; Quote all 30-dash lines.
858 (while (re-search-forward "^-" nil t)
862 (setq body (buffer-substring (1- (point)) (point-max)))
863 (narrow-to-region (point-min) (point))
864 (if (not (setq headers gnus-uu-digest-headers))
865 (setq sorthead (buffer-string))
867 (setq headline (car headers))
868 (setq headers (cdr headers))
869 (goto-char (point-min))
870 (while (re-search-forward headline nil t)
875 (or (and (re-search-forward "^[^ \t]" nil t)
877 (progn (forward-line 1) (point)))))))))
879 (insert message-forward-start-separator)
880 (insert sorthead) (goto-char (point-max))
881 (insert body) (goto-char (point-max))
883 (when (re-search-forward "^Subject:" nil t)
884 (setq subj (nnheader-decode-subject
885 (buffer-substring (match-end 0) (std11-field-end)))))
888 (set-buffer "*gnus-uu-pre*")
889 (insert (format " %s\n" subj)))))
890 (when (or (eq in-state 'last)
891 (eq in-state 'first-and-last))
892 (if gnus-uu-digest-buffer
893 (with-current-buffer gnus-uu-digest-buffer
895 (insert-buffer "*gnus-uu-pre*")
896 (goto-char (point-max))
897 (insert-buffer "*gnus-uu-body*"))
899 (set-buffer "*gnus-uu-pre*")
900 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
901 (if gnus-uu-digest-buffer
902 (with-current-buffer gnus-uu-digest-buffer
904 (insert-buffer "*gnus-uu-pre*"))
905 (gnus-write-buffer-as-coding-system
906 nnheader-text-coding-system gnus-uu-saved-article-name)))
908 (set-buffer "*gnus-uu-body*")
909 (goto-char (point-max))
911 (concat (setq end-string (format "End of %s Digest" name))
913 (insert (concat (make-string (length end-string) ?*) "\n"))
914 (if gnus-uu-digest-buffer
915 (with-current-buffer gnus-uu-digest-buffer
916 (goto-char (point-max))
917 (insert-buffer "*gnus-uu-body*"))
918 (let ((file-name-coding-system nnmail-pathname-coding-system))
919 (write-region-as-coding-system
920 nnheader-text-coding-system
921 (point-min) (point-max) gnus-uu-saved-article-name t)))))
922 (gnus-kill-buffer "*gnus-uu-pre*")
923 (gnus-kill-buffer "*gnus-uu-body*")
925 (if (memq 'begin state)
926 (cons gnus-uu-saved-article-name state)
929 ;; Binhex treatment - not very advanced.
931 (defvar gnus-uu-binhex-body-line
932 "^[^:]...............................................................$")
933 (defvar gnus-uu-binhex-begin-line
934 "^:...............................................................$")
935 (defvar gnus-uu-binhex-end-line
938 (defun gnus-uu-binhex-article (buffer in-state)
939 (let (state start-char)
943 (goto-char (point-min))
944 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
945 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
946 (setq state (list 'wrong-type))))
948 (if (memq 'wrong-type state)
951 (setq start-char (point))
952 (if (looking-at gnus-uu-binhex-begin-line)
954 (setq state (list 'begin))
955 (write-region (point-min) (point-min)
956 gnus-uu-binhex-article-name))
957 (setq state (list 'middle)))
958 (goto-char (point-max))
959 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
960 gnus-uu-binhex-end-line)
962 (when (looking-at gnus-uu-binhex-end-line)
963 (setq state (if (memq 'begin state)
968 (when (file-exists-p gnus-uu-binhex-article-name)
969 (write-region-as-binary start-char (point)
970 gnus-uu-binhex-article-name 'append))))
971 (if (memq 'begin state)
972 (cons gnus-uu-binhex-article-name state)
977 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
978 (let ((state (list 'ok))
979 start-char end-char file-name)
981 (set-buffer process-buffer)
982 (goto-char (point-min))
983 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
984 (setq state (list 'wrong-type))
986 (setq start-char (point))
987 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
988 (setq state (list 'wrong-type))
989 (setq end-char (point))
990 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
991 (insert-buffer-substring process-buffer start-char end-char)
992 (setq file-name (concat gnus-uu-work-dir
993 (cdr gnus-article-current) ".ps"))
994 (write-region (point-min) (point-max) file-name)
995 (setq state (list file-name 'begin 'end)))))
1001 (defun gnus-uu-get-actions (files)
1002 (let ((ofiles files)
1005 (setq name (cdr (assq 'name (car files))))
1007 (setq action (gnus-uu-get-action name))
1008 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1009 (cons 'action "file")
1010 (cons 'action action))
1011 (cons 'execute (gnus-uu-command
1014 (setq files (cdr files)))
1017 (defun gnus-uu-get-action (file-name)
1020 (gnus-uu-choose-action
1023 gnus-uu-user-view-rules
1024 (if gnus-uu-ignore-default-view-rules
1026 gnus-uu-default-view-rules)
1027 gnus-uu-user-view-rules-end)))
1028 (when (and (not (string= (or action "") "gnus-uu-archive"))
1029 gnus-uu-view-with-metamail)
1031 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1032 (setq action (format "metamail -d -b -c \"%s\"" action))))
1036 ;; Functions for treating subjects and collecting series.
1038 (defun gnus-uu-reginize-string (string)
1039 ;; Takes a string and puts a \ in front of every special character;
1040 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1041 ;; or, if it can't find something like that, tries "2 of 3", then
1042 ;; finally just replaces the next to last number with "[0-9]+".
1044 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1045 (buffer-disable-undo)
1047 (insert (regexp-quote string))
1049 (setq case-fold-search nil)
1052 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1053 (replace-match "\\1[0-9]+/\\2")
1056 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1058 (replace-match "\\1[0-9]+ of \\2")
1061 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1063 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1066 (while (re-search-forward "[ \t]+" nil t)
1067 (replace-match "[ \t]+" t t))
1071 (defun gnus-uu-get-list-of-articles (n)
1072 ;; If N is non-nil, the article numbers of the N next articles
1073 ;; will be returned.
1074 ;; If any articles have been marked as processable, they will be
1076 ;; Failing that, articles that have subjects that are part of the
1077 ;; same "series" as the current will be returned.
1081 (setq n (prefix-numeric-value n))
1082 (let ((backward (< n 0))
1086 (push (gnus-summary-article-number)
1088 (gnus-summary-search-forward nil nil backward))
1090 (nreverse articles)))
1091 (gnus-newsgroup-processable
1092 (reverse gnus-newsgroup-processable))
1094 (gnus-uu-find-articles-matching)))))
1096 (defun gnus-uu-string< (l1 l2)
1097 (string< (car l1) (car l2)))
1099 (defun gnus-uu-find-articles-matching
1100 (&optional subject only-unread do-not-translate)
1101 ;; Finds all articles that matches the regexp SUBJECT. If it is
1102 ;; nil, the current article name will be used. If ONLY-UNREAD is
1103 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1104 ;; non-nil, article names are not equalized before sorting.
1105 (let ((subject (or subject
1106 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1110 ;; Collect all subjects matching subject.
1111 (let ((case-fold-search t)
1112 (data gnus-newsgroup-data)
1116 (and (not (gnus-data-pseudo-p d))
1117 (or (not only-unread)
1118 (= (setq mark (gnus-data-mark d))
1120 (= mark gnus-ticked-mark)
1121 (= mark gnus-dormant-mark))
1122 (setq subj (mail-header-subject (gnus-data-header d)))
1123 (string-match subject subj)
1124 (push (cons subj (gnus-data-number d))
1125 list-of-subjects))))
1127 ;; Expand numbers, sort, and return the list of article
1129 (mapcar (lambda (sub) (cdr sub))
1130 (sort (gnus-uu-expand-numbers
1132 (not do-not-translate))
1133 'gnus-uu-string<))))))
1135 (defun gnus-uu-expand-numbers (string-list &optional translate)
1136 ;; Takes a list of strings and "expands" all numbers in all the
1137 ;; strings. That is, this function makes all numbers equal length by
1138 ;; prepending lots of zeroes before each number. This is to ease later
1139 ;; sorting to find out what sequence the articles are supposed to be
1140 ;; decoded in. Returns the list of expanded strings.
1141 (let ((out-list string-list)
1144 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1145 (buffer-disable-undo)
1148 (insert (caar string-list))
1149 ;; Translate multiple spaces to one space.
1150 (goto-char (point-min))
1151 (while (re-search-forward "[ \t]+" nil t)
1152 (replace-match " "))
1153 ;; Translate all characters to "a".
1154 (goto-char (point-min))
1156 (while (re-search-forward "[A-Za-z]" nil t)
1157 (replace-match "a" t t)))
1159 (goto-char (point-min))
1160 (while (re-search-forward "[0-9]+" nil t)
1164 (string-to-int (buffer-substring
1165 (match-beginning 0) (match-end 0)))))))
1166 (setq string (buffer-substring 1 (point-max)))
1167 (setcar (car string-list) string)
1168 (setq string-list (cdr string-list))))
1172 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1173 ;; function. It takes a list of articles to be grabbed and a function
1174 ;; to apply to each article.
1176 ;; The function to be called should take two parameters. The first
1177 ;; parameter is the article buffer. The function should leave the
1178 ;; result, if any, in this buffer. Most treatment functions will just
1179 ;; generate files...
1181 ;; The second parameter is the state of the list of articles, and can
1182 ;; have four values: `first', `middle', `last' and `first-and-last'.
1184 ;; The function should return a list. The list may contain the
1185 ;; following symbols:
1186 ;; `error' if an error occurred
1187 ;; `begin' if the beginning of an encoded file has been received
1188 ;; If the list returned contains a `begin', the first element of
1189 ;; the list *must* be a string with the file name of the decoded
1191 ;; `end' if the end of an encoded file has been received
1192 ;; `middle' if the article was a body part of an encoded file
1193 ;; `wrong-type' if the article was not a part of an encoded file
1194 ;; `ok', which can be used everything is ok
1196 (defvar gnus-uu-has-been-grabbed nil)
1198 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1200 (if (not (and gnus-uu-has-been-grabbed
1201 gnus-uu-unmark-articles-not-decoded))
1203 (when dont-unmark-last-article
1204 (setq art (car gnus-uu-has-been-grabbed))
1205 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1206 (while gnus-uu-has-been-grabbed
1207 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1208 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1209 (when dont-unmark-last-article
1210 (setq gnus-uu-has-been-grabbed (list art))))))
1212 ;; This function takes a list of articles and a function to apply to
1213 ;; each article grabbed.
1215 ;; This function returns a list of files decoded if the grabbing and
1216 ;; the process-function has been successful and nil otherwise.
1217 (defun gnus-uu-grab-articles (articles process-function
1218 &optional sloppy limit no-errors)
1219 (let ((state 'first)
1220 (gnus-asynchronous nil)
1221 (gnus-inhibit-treatment t)
1222 has-been-begin article result-file result-files process-state
1223 gnus-summary-display-article-function
1224 gnus-article-prepare-hook gnus-display-mime-function
1225 article-series files)
1227 (while (and articles
1228 (not (memq 'error process-state))
1230 (not (memq 'end process-state))))
1232 (setq article (pop articles))
1233 (when (vectorp (gnus-summary-article-header article))
1234 (push article article-series)
1237 (if (eq state 'first)
1238 (setq state 'first-and-last)
1239 (setq state 'last)))
1241 (let ((part (gnus-uu-part-number article)))
1242 (gnus-message 6 "Getting article %d%s..."
1243 article (if (string= part "") "" (concat ", " part))))
1244 (gnus-summary-display-article article)
1246 ;; Push the article to the processing function.
1248 (set-buffer gnus-original-article-buffer)
1249 (let ((buffer-read-only nil))
1251 (set-buffer gnus-summary-buffer)
1253 (funcall process-function
1254 gnus-original-article-buffer state)))))
1256 (gnus-summary-remove-process-mark article)
1258 ;; If this is the beginning of a decoded file, we push it
1260 (when (or (memq 'begin process-state)
1261 (and (or (eq state 'first)
1262 (eq state 'first-and-last))
1263 (memq 'ok process-state)))
1264 (when has-been-begin
1265 ;; If there is a `result-file' here, that means that the
1266 ;; file was unsuccessfully decoded, so we delete it.
1267 (when (and result-file
1268 (file-exists-p result-file)
1269 (not gnus-uu-be-dangerous)
1270 (or (eq gnus-uu-be-dangerous t)
1272 (format "Delete unsuccessfully decoded file %s"
1274 (delete-file result-file)))
1275 (when (memq 'begin process-state)
1276 (setq result-file (car process-state)))
1277 (setq has-been-begin t))
1279 ;; Check whether we have decoded one complete file.
1280 (when (memq 'end process-state)
1281 (setq article-series nil)
1282 (setq has-been-begin nil)
1283 (if (stringp result-file)
1284 (setq files (list result-file))
1285 (setq files result-file))
1286 (setq result-file (car files))
1288 (push (list (cons 'name (pop files))
1289 (cons 'article article))
1291 ;; Allow user-defined functions to be run on this file.
1292 (when gnus-uu-grabbed-file-functions
1293 (let ((funcs gnus-uu-grabbed-file-functions))
1294 (unless (listp funcs)
1295 (setq funcs (list funcs)))
1297 (funcall (pop funcs) result-file))))
1298 (setq result-file nil)
1299 ;; Check whether we have decoded enough articles.
1300 (and limit (= (length result-files) limit)
1301 (setq articles nil)))
1303 ;; If this is the last article to be decoded, and
1304 ;; we still haven't reached the end, then we delete
1305 ;; the partially decoded file.
1306 (and (or (eq state 'last) (eq state 'first-and-last))
1307 (not (memq 'end process-state))
1309 (file-exists-p result-file)
1310 (not gnus-uu-be-dangerous)
1311 (or (eq gnus-uu-be-dangerous t)
1313 (format "Delete incomplete file %s? " result-file)))
1314 (delete-file result-file))
1316 ;; If this was a file of the wrong sort, then
1317 (when (and (or (memq 'wrong-type process-state)
1318 (memq 'error process-state))
1319 gnus-uu-unmark-articles-not-decoded)
1320 (gnus-summary-tick-article article t))
1322 ;; Set the new series state.
1323 (if (and (not has-been-begin)
1325 (or (memq 'end process-state)
1326 (memq 'middle process-state)))
1328 (setq process-state (list 'error))
1329 (gnus-message 2 "No begin part at the beginning")
1331 (setq state 'middle))))
1333 ;; When there are no result-files, then something must be wrong.
1337 ((not has-been-begin)
1338 (gnus-message 2 "Wrong type file"))
1339 ((memq 'error process-state)
1340 (gnus-message 2 "An error occurred during decoding"))
1341 ((not (or (memq 'ok process-state)
1342 (memq 'end process-state)))
1343 (gnus-message 2 "End of articles reached before end of file")))
1344 ;; Make unsuccessfully decoded articles unread.
1345 (when gnus-uu-unmark-articles-not-decoded
1346 (while article-series
1347 (gnus-summary-tick-article (pop article-series) t))))
1349 ;; The original article buffer is hosed, shoot it down.
1350 (gnus-kill-buffer gnus-original-article-buffer)
1351 (setq gnus-current-article nil)
1354 (defun gnus-uu-grab-view (file)
1355 "View FILE using the gnus-uu methods."
1356 (let ((action (gnus-uu-get-action file)))
1357 (gnus-execute-command
1358 (if (string-match "%" action)
1359 (format action file)
1360 (concat action " " file))
1361 (eq gnus-view-pseudos 'not-confirm))))
1363 (defun gnus-uu-grab-move (file)
1364 "Move FILE to somewhere."
1365 (when gnus-uu-default-dir
1366 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1367 (file-name-nondirectory file))))
1368 (cond ((fboundp 'make-symbolic-link)
1369 (rename-file file to-file)
1370 (unless (file-exists-p file)
1371 (make-symbolic-link to-file file)))
1373 (copy-file file to-file))))))
1375 (defun gnus-uu-part-number (article)
1376 (let* ((header (gnus-summary-article-header article))
1377 (subject (and header (mail-header-subject header)))
1380 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1382 (setq part (match-string 0 subject))
1383 (setq subject (substring subject (match-end 0)))))
1385 (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
1386 (setq part (match-string 0 subject))
1387 (setq subject (substring subject (match-end 0)))))
1390 (defun gnus-uu-uudecode-sentinel (process event)
1391 (delete-process (get-process process)))
1393 (defun gnus-uu-uustrip-article (process-buffer in-state)
1394 ;; Uudecodes a file asynchronously.
1396 (set-buffer process-buffer)
1397 (let ((state (list 'wrong-type))
1398 process-connection-type case-fold-search buffer-read-only
1400 (goto-char (point-min))
1402 ;; Deal with ^M at the end of the lines.
1403 (when gnus-uu-kill-carriage-return
1405 (while (search-forward "\r" nil t)
1406 (delete-backward-char 1))))
1408 (while (or (re-search-forward gnus-uu-begin-string nil t)
1409 (re-search-forward gnus-uu-body-line nil t))
1410 (setq state (list 'ok))
1411 ;; Ok, we are at the first uucoded line.
1413 (setq start-char (point))
1415 (if (not (looking-at gnus-uu-begin-string))
1416 (setq state (list 'middle))
1417 ;; This is the beginning of a uuencoded article.
1418 ;; We replace certain characters that could make things messy.
1419 (setq gnus-uu-file-name
1420 (let ((nnheader-file-name-translation-alist
1421 '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
1422 (nnheader-translate-file-chars (match-string 1))))
1423 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1425 ;; Remove any non gnus-uu-body-line right after start.
1427 (while (and (not (eobp))
1428 (not (looking-at gnus-uu-body-line)))
1431 ;; If a process is running, we kill it.
1432 (when (and gnus-uu-uudecode-process
1433 (memq (process-status gnus-uu-uudecode-process)
1435 (delete-process gnus-uu-uudecode-process)
1436 (gnus-uu-unmark-list-of-grabbed t))
1438 ;; Start a new uudecoding process.
1439 (let ((cdir default-directory))
1442 (cd gnus-uu-work-dir)
1443 (setq gnus-uu-uudecode-process
1446 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1447 shell-file-name shell-command-switch
1448 (format "cd %s %s uudecode" gnus-uu-work-dir
1449 gnus-shell-command-separator))))
1451 (set-process-sentinel
1452 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1453 (setq state (list 'begin))
1454 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1456 ;; We look for the end of the thing to be decoded.
1457 (if (re-search-forward gnus-uu-end-string nil t)
1459 (goto-char (point-max))
1460 (re-search-backward gnus-uu-body-line nil t))
1464 (when gnus-uu-uudecode-process
1465 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1466 ;; Try to correct mishandled uucode.
1467 (when gnus-uu-correct-stripped-uucode
1468 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1469 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1471 ;; Send the text to the process.
1473 (process-send-region
1474 gnus-uu-uudecode-process start-char (point))
1477 (delete-process gnus-uu-uudecode-process)
1478 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1479 (setq state (list 'wrong-type)))))
1481 (if (memq 'end state)
1483 ;; Send an EOF, just in case.
1485 (process-send-eof gnus-uu-uudecode-process))
1486 (while (memq (process-status gnus-uu-uudecode-process)
1488 (accept-process-output gnus-uu-uudecode-process 1)))
1489 (when (or (not gnus-uu-uudecode-process)
1490 (not (memq (process-status gnus-uu-uudecode-process)
1492 (setq state (list 'wrong-type)))))))
1494 (if (memq 'begin state)
1495 (cons (if (= (length files) 1) (car files) files) state)
1498 (defvar gnus-uu-unshar-warning
1501 Shell archives are an archaic method of bundling files for distribution
1502 across computer networks. During the unpacking process, arbitrary commands
1503 are executed on your system, and all kinds of nasty things can happen.
1504 Please examine the archive very carefully before you instruct Emacs to
1505 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1507 If you are unsure what to do, please answer \"no\"."
1508 "Text of warning message displayed by `gnus-uu-unshar-article'.
1509 Make sure that this text consists only of few text lines. Otherwise,
1510 Gnus might fail to display all of it.")
1513 ;; This function is used by `gnus-uu-grab-articles' to treat
1514 ;; a shared article.
1515 (defun gnus-uu-unshar-article (process-buffer in-state)
1516 (let ((state (list 'ok))
1519 (set-buffer process-buffer)
1520 (goto-char (point-min))
1521 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1522 (setq state (list 'wrong-type))
1523 (save-window-excursion
1525 (switch-to-buffer (current-buffer))
1526 (delete-other-windows)
1527 (let ((buffer (get-buffer-create (generate-new-buffer-name
1531 (with-current-buffer buffer
1532 (insert (substitute-command-keys
1533 gnus-uu-unshar-warning))
1534 (goto-char (point-min))
1535 (display-buffer buffer)
1536 (yes-or-no-p "This is a shell archive, unshar it? "))
1537 (kill-buffer buffer))
1538 (setq state (list 'error))))))
1539 (unless (memq 'error state)
1541 (setq start-char (point))
1542 (call-process-region
1543 start-char (point-max) shell-file-name nil
1544 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1545 shell-command-switch
1546 (concat "cd " gnus-uu-work-dir " "
1547 gnus-shell-command-separator " sh")))))
1550 ;; Returns the name of what the shar file is going to unpack.
1551 (defun gnus-uu-find-name-in-shar ()
1552 (let ((oldpoint (point))
1554 (goto-char (point-min))
1555 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1556 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1557 (goto-char oldpoint)
1560 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1561 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1562 ;; found, or the name of the command to run if such a rule is found.
1563 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1564 (let ((action-list (copy-sequence file-action-list))
1565 (case-fold-search t)
1570 (and gnus-uu-ignore-files-by-name
1571 (string-match gnus-uu-ignore-files-by-name file-name)))
1573 (and gnus-uu-ignore-files-by-type
1574 (string-match gnus-uu-ignore-files-by-type
1575 (or (gnus-uu-choose-action
1576 file-name gnus-uu-ext-to-mime-list t)
1578 (while (not (or (eq action-list ()) action))
1579 (setq rule (car action-list))
1580 (setq action-list (cdr action-list))
1581 (when (string-match (car rule) file-name)
1582 (setq action (cadr rule)))))
1585 (defun gnus-uu-treat-archive (file-path)
1586 ;; Unpacks an archive. Returns t if unpacking is successful.
1587 (let ((did-unpack t)
1589 (setq action (gnus-uu-choose-action
1590 file-path (append gnus-uu-user-archive-rules
1591 (if gnus-uu-ignore-default-archive-rules
1593 gnus-uu-default-archive-rules))))
1596 (error "No unpackers for the file %s" file-path))
1598 (string-match "/[^/]*$" file-path)
1599 (setq dir (substring file-path 0 (match-beginning 0)))
1601 (when (member action gnus-uu-destructive-archivers)
1602 (copy-file file-path (concat file-path "~") t))
1604 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1607 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1610 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1612 (if (eq 0 (call-process shell-file-name nil
1613 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1614 nil shell-command-switch command))
1616 (gnus-message 2 "Error during unpacking of archive")
1617 (setq did-unpack nil))
1619 (when (member action gnus-uu-destructive-archivers)
1620 (rename-file (concat file-path "~") file-path t))
1624 (defun gnus-uu-dir-files (dir)
1625 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1628 (if (file-directory-p (setq file (car dirs)))
1629 (setq files (append files (gnus-uu-dir-files file)))
1631 (setq dirs (cdr dirs)))
1634 (defun gnus-uu-unpack-files (files &optional ignore)
1635 ;; Go through FILES and look for files to unpack.
1636 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1640 (setq file (cdr (assq 'name (car files))))
1641 (when (and (not (member file ignore))
1642 (equal (gnus-uu-get-action (file-name-nondirectory file))
1644 (push file did-unpack)
1645 (unless (gnus-uu-treat-archive file)
1646 (gnus-message 2 "Error during unpacking of %s" file))
1647 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1650 (unless (member (car nfiles) totfiles)
1651 (push (list (cons 'name (car nfiles))
1652 (cons 'original file))
1654 (setq nfiles (cdr nfiles)))
1655 (setq totfiles newfiles)))
1656 (setq files (cdr files)))
1658 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1661 (defun gnus-uu-ls-r (dir)
1662 (let* ((files (gnus-uu-directory-files dir t))
1665 (when (file-directory-p (car files))
1666 (setq ofiles (delete (car files) ofiles))
1667 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1668 (setq files (cdr files)))
1673 (defun gnus-uu-directory-files (dir &optional full)
1674 (let (files out file)
1675 (setq files (directory-files dir full))
1677 (setq file (car files))
1678 (setq files (cdr files))
1679 (unless (member (file-name-nondirectory file) '("." ".."))
1681 (setq out (nreverse out))
1684 (defun gnus-uu-check-correct-stripped-uucode (start end)
1686 (let (found beg length)
1687 (if (not gnus-uu-correct-stripped-uucode)
1691 (if (re-search-forward " \\|`" end t)
1696 (when (looking-at "\n")
1701 (if (looking-at (concat gnus-uu-begin-string "\\|"
1702 gnus-uu-end-string))
1708 (setq length (- (point) beg)))
1713 (when (not (= length (- (point) beg)))
1714 (insert (make-string (- length (- (point) beg)) ? ))))
1715 (forward-line 1)))))))
1717 (defvar gnus-uu-tmp-alist nil)
1719 (defun gnus-uu-initialize (&optional scan)
1722 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1723 (if (file-exists-p (cdr entry))
1724 (setq gnus-uu-work-dir (cdr entry))
1725 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1728 (setq gnus-uu-tmp-dir (file-name-as-directory
1729 (expand-file-name gnus-uu-tmp-dir)))
1730 (if (not (file-directory-p gnus-uu-tmp-dir))
1731 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1732 (when (not (file-writable-p gnus-uu-tmp-dir))
1733 (error "Temp directory %s can't be written to"
1736 (setq gnus-uu-work-dir
1737 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1738 (set-file-modes gnus-uu-work-dir 448)
1739 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1740 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1741 gnus-uu-tmp-alist))))
1744 ;; Kills the temporary uu buffers, kills any processes, etc.
1745 (defun gnus-uu-clean-up ()
1747 (and gnus-uu-uudecode-process
1748 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1750 (delete-process gnus-uu-uudecode-process))
1751 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1752 (kill-buffer buf))))
1754 (defun gnus-quote-arg-for-sh-or-csh (arg)
1755 (let ((pos 0) new-pos accum)
1756 ;; *** bug: we don't handle newline characters properly
1757 (while (setq new-pos (string-match "[!`\"$\\& \t{}]" arg pos))
1758 (push (substring arg pos new-pos) accum)
1760 (push (list (aref arg new-pos)) accum)
1761 (setq pos (1+ new-pos)))
1764 (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))
1766 ;; Inputs an action and a filename and returns a full command, making sure
1767 ;; that the filename will be treated as a single argument when the shell
1768 ;; executes the command.
1769 (defun gnus-uu-command (action file)
1770 (let ((quoted-file (shell-quote-argument file)))
1771 (if (string-match "%s" action)
1772 (format action quoted-file)
1773 (concat action " " quoted-file))))
1775 (defun gnus-uu-delete-work-dir (&optional dir)
1776 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1778 (gnus-message 7 "Deleting directory %s..." dir)
1779 (setq dir gnus-uu-work-dir))
1781 (file-exists-p dir))
1782 (let ((files (directory-files dir t nil t))
1784 (while (setq file (pop files))
1785 (unless (member (file-name-nondirectory file) '("." ".."))
1786 (if (file-directory-p file)
1787 (gnus-uu-delete-work-dir file)
1788 (gnus-message 9 "Deleting file %s..." file)
1791 (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
1793 (delete-directory dir)
1794 (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
1795 (gnus-message 7 "")))
1799 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1800 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1805 ;;; uuencoded posting
1808 ;; Any function that is to be used as and encoding method will take two
1809 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1810 ;; and "spiral.jpg", respectively.) The function should return nil if
1811 ;; the encoding wasn't successful.
1812 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1813 "Function used for encoding binary files.
1814 There are three functions supplied with gnus-uu for encoding files:
1815 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1816 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1817 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1818 uuencode and adds MIME headers."
1819 :group 'gnus-extract-post
1820 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1821 (function-item gnus-uu-post-encode-mime)
1822 (function-item gnus-uu-post-encode-mime-uuencode)
1823 (function :tag "Other")))
1825 (defcustom gnus-uu-post-include-before-composing nil
1826 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1827 If this variable is t, you can either include an encoded file with
1828 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1829 :group 'gnus-extract-post
1832 (defcustom gnus-uu-post-length 990
1833 "Maximum length of an article.
1834 The encoded file will be split into how many articles it takes to
1835 post the entire file."
1836 :group 'gnus-extract-post
1839 (defcustom gnus-uu-post-threaded nil
1840 "Non-nil means that gnus-uu will post the encoded file in a thread.
1841 This may not be smart, as no other decoder I have seen are able to
1842 follow threads when collecting uuencoded articles. (Well, I have seen
1843 one package that does that - gnus-uu, but somehow, I don't think that
1844 counts...) The default is nil."
1845 :group 'gnus-extract-post
1848 (defcustom gnus-uu-post-separate-description t
1849 "Non-nil means that the description will be posted in a separate article.
1850 The first article will typically be numbered (0/x). If this variable
1851 is nil, the description the user enters will be included at the
1852 beginning of the first article, which will be numbered (1/x). Default
1854 :group 'gnus-extract-post
1857 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1858 (defvar gnus-uu-post-message-id nil)
1859 (defvar gnus-uu-post-inserted-file-name nil)
1860 (defvar gnus-uu-winconf-post-news nil)
1862 (defun gnus-uu-post-news ()
1863 "Compose an article and post an encoded file."
1865 (setq gnus-uu-post-inserted-file-name nil)
1866 (setq gnus-uu-winconf-post-news (current-window-configuration))
1868 (gnus-summary-post-news)
1870 (let ((map (make-sparse-keymap)))
1871 (set-keymap-parent map (current-local-map))
1872 (use-local-map map))
1873 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1874 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1875 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1876 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1878 (when gnus-uu-post-include-before-composing
1879 (save-excursion (setq gnus-uu-post-inserted-file-name
1880 (gnus-uu-post-insert-binary)))))
1882 (defun gnus-uu-post-insert-binary-in-article ()
1883 "Inserts an encoded file in the buffer.
1884 The user will be asked for a file name."
1887 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1889 ;; Encodes with uuencode and substitutes all spaces with backticks.
1890 (defun gnus-uu-post-encode-uuencode (path file-name)
1891 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1892 (goto-char (point-min))
1894 (while (re-search-forward " " nil t)
1895 (replace-match "`"))
1898 ;; Encodes with uuencode and adds MIME headers.
1899 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1900 (when (gnus-uu-post-encode-uuencode path file-name)
1901 (gnus-uu-post-make-mime file-name "x-uue")
1904 ;; Encodes with base64 and adds MIME headers
1905 (defun gnus-uu-post-encode-mime (path file-name)
1906 (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1907 (format "%s %s -o %s" "mmencode" path file-name)))
1908 (gnus-uu-post-make-mime file-name "base64")
1911 ;; Adds MIME headers.
1912 (defun gnus-uu-post-make-mime (file-name encoding)
1913 (goto-char (point-min))
1914 (insert (format "Content-Type: %s; name=\"%s\"\n"
1915 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1917 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1919 (set-buffer gnus-message-buffer)
1920 (goto-char (point-min))
1921 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1923 (narrow-to-region (point-min) (point))
1924 (unless (mail-fetch-field "mime-version")
1926 (insert "MIME-Version: 1.0\n"))
1929 ;; Encodes a file PATH with COMMAND, leaving the result in the
1931 (defun gnus-uu-post-encode-file (command path file-name)
1932 (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1933 (format "%s %s %s" command path file-name))))
1935 (defun gnus-uu-post-news-inews ()
1936 "Posts the composed news article and encoded file.
1937 If no file has been included, the user will be asked for a file."
1942 (if gnus-uu-post-inserted-file-name
1943 (setq file-name gnus-uu-post-inserted-file-name)
1944 (setq file-name (gnus-uu-post-insert-binary)))
1946 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1947 (setq gnus-uu-post-inserted-file-name nil)
1948 (when gnus-uu-winconf-post-news
1949 (set-window-configuration gnus-uu-winconf-post-news)))
1951 ;; Asks for a file to encode, encodes it and inserts the result in
1952 ;; the current buffer. Returns the file name the user gave.
1953 (defun gnus-uu-post-insert-binary ()
1954 (let ((uuencode-buffer-name "*uuencode buffer*")
1955 file-path uubuf file-name)
1957 (setq file-path (read-file-name
1958 "What file do you want to encode? "))
1959 (when (not (file-exists-p file-path))
1960 (error "%s: No such file" file-path))
1962 (goto-char (point-max))
1963 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1965 ;; #### Unix-specific?
1966 (when (string-match "^~/" file-path)
1967 (setq file-path (concat "$HOME" (substring file-path 1))))
1968 ;; #### Unix-specific?
1969 (if (string-match "/[^/]*$" file-path)
1970 (setq file-name (substring file-path (1+ (match-beginning 0))))
1971 (setq file-name file-path))
1975 (set-buffer (setq uubuf
1976 (gnus-get-buffer-create uuencode-buffer-name)))
1978 (funcall gnus-uu-post-encode-method file-path file-name))
1979 (insert-buffer-substring uubuf)
1980 (error "Encoding unsuccessful"))
1981 (kill-buffer uubuf))
1984 ;; Posts the article and all of the encoded file.
1985 (defun gnus-uu-post-encoded (file-name &optional threaded)
1986 (let ((send-buffer-name "*uuencode send buffer*")
1987 (encoded-buffer-name "*encoded buffer*")
1988 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
1989 (separator (concat mail-header-separator "\n\n"))
1990 uubuf length parts header i end beg
1991 beg-line minlen post-buf whole-len beg-binary end-binary)
1993 (setq post-buf (current-buffer))
1995 (goto-char (point-min))
1996 (when (not (re-search-forward
1997 (if gnus-uu-post-separate-description
1998 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2000 (concat "^" (regexp-quote mail-header-separator) "$"))
2002 (error "Internal error: No binary/header separator"))
2005 (setq beg-binary (point))
2006 (setq end-binary (point-max))
2009 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2011 (insert-buffer-substring post-buf beg-binary end-binary)
2012 (goto-char (point-min))
2013 (setq length (count-lines (point-min) (point-max)))
2014 (setq parts (/ length gnus-uu-post-length))
2015 (unless (< (% length gnus-uu-post-length) 4)
2018 (when gnus-uu-post-separate-description
2020 (delete-region (point) (point-max))
2022 (goto-char (point-min))
2024 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2026 (setq header (buffer-substring (point-min) (point)))
2028 (goto-char (point-min))
2029 (when gnus-uu-post-separate-description
2030 (when (re-search-forward "^Subject: " nil t)
2032 (insert (format " (0/%d)" parts)))
2035 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2040 (while (not (> i parts))
2041 (set-buffer (gnus-get-buffer-create send-buffer-name))
2044 (when (and threaded gnus-uu-post-message-id)
2045 (insert "References: " gnus-uu-post-message-id "\n"))
2048 (- 62 (length (format top-string "" file-name i parts ""))))
2049 (when (> 1 (setq minlen (/ whole-len 2)))
2054 (make-string minlen ?-)
2057 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2059 (goto-char (point-min))
2060 (when (re-search-forward "^Subject: " nil t)
2062 (insert (format " (%d/%d)" i parts)))
2064 (goto-char (point-max))
2069 (goto-char (point-max))
2070 (forward-line gnus-uu-post-length))
2071 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2074 (insert-buffer-substring uubuf beg end)
2075 (insert beg-line "\n")
2078 (goto-char (point-min))
2080 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2083 (when (re-search-forward
2084 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2090 (let (message-sent-message-via)
2093 (setq gnus-uu-post-message-id
2094 (concat (message-fetch-field "references") " "
2095 (message-fetch-field "message-id"))))))
2097 (gnus-kill-buffer send-buffer-name)
2098 (gnus-kill-buffer encoded-buffer-name)
2100 (when (not gnus-uu-post-separate-description)
2101 (set-buffer-modified-p nil)
2106 ;;; gnus-uu.el ends here