1 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
2 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000
3 ;; 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-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-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 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
359 "p" gnus-summary-mark-as-processable
360 "u" gnus-summary-unmark-as-processable
361 "U" gnus-summary-unmark-all-processable
362 "v" gnus-uu-mark-over
363 "s" gnus-uu-mark-series
364 "r" gnus-uu-mark-region
365 "g" gnus-uu-unmark-region
366 "R" gnus-uu-mark-by-regexp
367 "G" gnus-uu-unmark-by-regexp
368 "t" gnus-uu-mark-thread
369 "T" gnus-uu-unmark-thread
371 "b" gnus-uu-mark-buffer
372 "S" gnus-uu-mark-sparse
373 "k" gnus-summary-kill-process-mark
374 "y" gnus-summary-yank-process-mark
375 "w" gnus-summary-save-process-mark
376 "i" gnus-uu-invert-processable)
378 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
379 ;;"x" gnus-uu-extract-any
380 "m" gnus-summary-save-parts
381 "u" gnus-uu-decode-uu
382 "U" gnus-uu-decode-uu-and-save
383 "s" gnus-uu-decode-unshar
384 "S" gnus-uu-decode-unshar-and-save
385 "o" gnus-uu-decode-save
386 "O" gnus-uu-decode-save
387 "b" gnus-uu-decode-binhex
388 "B" gnus-uu-decode-binhex
389 "p" gnus-uu-decode-postscript
390 "P" gnus-uu-decode-postscript-and-save)
393 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
394 "u" gnus-uu-decode-uu-view
395 "U" gnus-uu-decode-uu-and-save-view
396 "s" gnus-uu-decode-unshar-view
397 "S" gnus-uu-decode-unshar-and-save-view
398 "o" gnus-uu-decode-save-view
399 "O" gnus-uu-decode-save-view
400 "b" gnus-uu-decode-binhex-view
401 "B" gnus-uu-decode-binhex-view
402 "p" gnus-uu-decode-postscript-view
403 "P" gnus-uu-decode-postscript-and-save-view)
408 (defun gnus-uu-decode-uu (&optional n)
409 "Uudecodes the current article."
411 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
413 (defun gnus-uu-decode-uu-and-save (n dir)
414 "Decodes and saves the resulting file."
416 (list current-prefix-arg
417 (file-name-as-directory
418 (read-file-name "Uudecode and save in dir: "
420 gnus-uu-default-dir t))))
421 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
423 (defun gnus-uu-decode-unshar (&optional n)
424 "Unshars the current article."
426 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
428 (defun gnus-uu-decode-unshar-and-save (n dir)
429 "Unshars and saves the current article."
431 (list current-prefix-arg
432 (file-name-as-directory
433 (read-file-name "Unshar and save in dir: "
435 gnus-uu-default-dir t))))
436 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
438 (defun gnus-uu-decode-save (n file)
439 "Saves the current article."
441 (list current-prefix-arg
443 (if gnus-uu-save-separate-articles
444 "Save articles is dir: "
445 "Save articles in file: ")
447 gnus-uu-default-dir)))
448 (setq gnus-uu-saved-article-name file)
449 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
451 (defun gnus-uu-decode-binhex (n dir)
452 "Unbinhexes the current article."
454 (list current-prefix-arg
455 (file-name-as-directory
456 (read-file-name "Unbinhex and save in dir: "
458 gnus-uu-default-dir))))
459 (setq gnus-uu-binhex-article-name
460 (make-temp-name (concat gnus-uu-work-dir "binhex")))
461 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
463 (defun gnus-uu-decode-uu-view (&optional n)
464 "Uudecodes and views the current article."
466 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
467 (gnus-uu-decode-uu n)))
469 (defun gnus-uu-decode-uu-and-save-view (n dir)
470 "Decodes, views and saves the resulting file."
472 (list current-prefix-arg
473 (read-file-name "Uudecode, view and save in dir: "
475 gnus-uu-default-dir t)))
476 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
477 (gnus-uu-decode-uu-and-save n dir)))
479 (defun gnus-uu-decode-unshar-view (&optional n)
480 "Unshars and views the current article."
482 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
483 (gnus-uu-decode-unshar n)))
485 (defun gnus-uu-decode-unshar-and-save-view (n dir)
486 "Unshars and saves the current article."
488 (list current-prefix-arg
489 (read-file-name "Unshar, view and save in dir: "
491 gnus-uu-default-dir t)))
492 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
493 (gnus-uu-decode-unshar-and-save n dir)))
495 (defun gnus-uu-decode-save-view (n file)
496 "Saves and views the current article."
498 (list current-prefix-arg
499 (read-file-name (if gnus-uu-save-separate-articles
500 "Save articles is dir: "
501 "Save articles in file: ")
502 gnus-uu-default-dir gnus-uu-default-dir)))
503 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
504 (gnus-uu-decode-save n file)))
506 (defun gnus-uu-decode-binhex-view (n file)
507 "Unbinhexes and views the current article."
509 (list current-prefix-arg
510 (read-file-name "Unbinhex, view and save in dir: "
511 gnus-uu-default-dir gnus-uu-default-dir)))
512 (setq gnus-uu-binhex-article-name
513 (make-temp-name (concat gnus-uu-work-dir "binhex")))
514 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
515 (gnus-uu-decode-binhex n file)))
518 ;; Digest and forward articles
520 (defun gnus-uu-digest-mail-forward (&optional n post)
521 "Digests and forwards all articles in this series."
523 (let ((gnus-uu-save-in-digest t)
524 (file (make-temp-name (nnheader-concat gnus-uu-tmp-dir "forward")))
525 (message-forward-as-mime message-forward-as-mime)
526 (mail-parse-charset gnus-newsgroup-charset)
527 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
528 gnus-uu-digest-buffer subject from)
529 (if (and n (not (numberp n)))
530 (setq message-forward-as-mime (not message-forward-as-mime)
532 (gnus-setup-message 'forward
533 (setq gnus-uu-digest-from-subject nil)
534 (setq gnus-uu-digest-buffer
535 (gnus-get-buffer-create " *gnus-uu-forward*"))
536 (gnus-uu-decode-save n file)
537 (switch-to-buffer gnus-uu-digest-buffer)
538 (let ((fs gnus-uu-digest-from-subject))
541 subject (gnus-simplify-subject-fuzzy (cdar fs))
543 (while (and fs (or from subject))
545 (unless (string= from (caar fs))
548 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
553 (setq subject "Digested Articles"))
556 (if (gnus-news-group-p gnus-newsgroup-name)
559 (goto-char (point-min))
560 (when (re-search-forward "^Subject: ")
561 (delete-region (point) (gnus-point-at-eol))
563 (goto-char (point-min))
564 (when (re-search-forward "^From:")
565 (delete-region (point) (gnus-point-at-eol))
567 (message-forward post t))
568 (setq gnus-uu-digest-from-subject nil)))
570 (defun gnus-uu-digest-post-forward (&optional n)
571 "Digest and forward to a newsgroup."
573 (gnus-uu-digest-mail-forward n t))
577 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
578 "Set the process mark on articles whose subjects match REGEXP.
579 When called interactively, prompt for REGEXP.
580 Optional UNMARK non-nil means unmark instead of mark."
581 (interactive "sMark (regexp): \nP")
582 (let ((articles (gnus-uu-find-articles-matching regexp)))
585 (gnus-summary-remove-process-mark (pop articles))
586 (gnus-summary-set-process-mark (pop articles))))
588 (gnus-summary-position-point))
590 (defun gnus-uu-unmark-by-regexp (regexp)
591 "Remove the process mark from articles whose subjects match REGEXP.
592 When called interactively, prompt for REGEXP."
593 (interactive "sUnmark (regexp): ")
594 (gnus-uu-mark-by-regexp regexp t))
596 (defun gnus-uu-mark-series ()
597 "Mark the current series with the process mark."
599 (let ((articles (gnus-uu-find-articles-matching)))
601 (gnus-summary-set-process-mark (car articles))
602 (setq articles (cdr articles)))
604 (gnus-summary-position-point))
606 (defun gnus-uu-mark-region (beg end &optional unmark)
607 "Set the process mark on all articles between point and mark."
611 (while (< (point) end)
613 (gnus-summary-remove-process-mark (gnus-summary-article-number))
614 (gnus-summary-set-process-mark (gnus-summary-article-number)))
616 (gnus-summary-position-point))
618 (defun gnus-uu-unmark-region (beg end)
619 "Remove the process mark from all articles between point and mark."
621 (gnus-uu-mark-region beg end t))
623 (defun gnus-uu-mark-buffer ()
624 "Set the process mark on all articles in the buffer."
626 (gnus-uu-mark-region (point-min) (point-max)))
628 (defun gnus-uu-unmark-buffer ()
629 "Remove the process mark on all articles in the buffer."
631 (gnus-uu-mark-region (point-min) (point-max) t))
633 (defun gnus-uu-mark-thread ()
634 "Marks all articles downwards in this thread."
636 (gnus-save-hidden-threads
637 (let ((level (gnus-summary-thread-level)))
638 (while (and (gnus-summary-set-process-mark
639 (gnus-summary-article-number))
640 (zerop (gnus-summary-next-subject 1 nil t))
641 (> (gnus-summary-thread-level) level)))))
642 (gnus-summary-position-point))
644 (defun gnus-uu-unmark-thread ()
645 "Unmarks all articles downwards in this thread."
647 (let ((level (gnus-summary-thread-level)))
648 (while (and (gnus-summary-remove-process-mark
649 (gnus-summary-article-number))
650 (zerop (gnus-summary-next-subject 1))
651 (> (gnus-summary-thread-level) level))))
652 (gnus-summary-position-point))
654 (defun gnus-uu-invert-processable ()
655 "Invert the list of process-marked articles."
657 (let ((data gnus-newsgroup-data)
661 (if (memq (setq number (gnus-data-number (pop data)))
662 gnus-newsgroup-processable)
663 (gnus-summary-remove-process-mark number)
664 (gnus-summary-set-process-mark number)))))
665 (gnus-summary-position-point))
667 (defun gnus-uu-mark-over (&optional score)
668 "Mark all articles with a score over SCORE (the prefix)."
670 (let ((score (or score gnus-summary-default-score 0))
671 (data gnus-newsgroup-data))
674 (when (> (or (cdr (assq (gnus-data-number (car data))
675 gnus-newsgroup-scored))
676 gnus-summary-default-score 0)
678 (gnus-summary-set-process-mark (caar data)))
679 (setq data (cdr data))))
680 (gnus-summary-position-point)))
682 (defun gnus-uu-mark-sparse ()
683 "Mark all series that have some articles marked."
685 (let ((marked (nreverse gnus-newsgroup-processable))
686 subject articles total headers)
688 (error "No articles marked with the process mark"))
689 (setq gnus-newsgroup-processable nil)
692 (and (vectorp (setq headers
693 (gnus-summary-article-header (car marked))))
694 (setq subject (mail-header-subject headers)
695 articles (gnus-uu-find-articles-matching
696 (gnus-uu-reginize-string subject))
697 total (nconc total articles)))
699 (gnus-summary-set-process-mark (car articles))
700 (setcdr marked (delq (car articles) (cdr marked)))
701 (setq articles (cdr articles)))
702 (setq marked (cdr marked)))
703 (setq gnus-newsgroup-processable (nreverse total)))
704 (gnus-summary-position-point)))
706 (defun gnus-uu-mark-all ()
707 "Mark all articles in \"series\" order."
709 (setq gnus-newsgroup-processable nil)
711 (let ((data gnus-newsgroup-data)
714 (when (and (not (memq (setq number (gnus-data-number (car data)))
715 gnus-newsgroup-processable))
716 (vectorp (gnus-data-header (car data))))
717 (gnus-summary-goto-subject number)
718 (gnus-uu-mark-series))
719 (setq data (cdr data)))))
720 (gnus-summary-position-point))
722 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
724 (defun gnus-uu-decode-postscript (&optional n)
725 "Gets postscript of the current article."
727 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
729 (defun gnus-uu-decode-postscript-view (&optional n)
730 "Gets and views the current article."
732 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
733 (gnus-uu-decode-postscript n)))
735 (defun gnus-uu-decode-postscript-and-save (n dir)
736 "Extracts postscript and saves the current article."
738 (list current-prefix-arg
739 (file-name-as-directory
740 (read-file-name "Save in dir: "
742 gnus-uu-default-dir t))))
743 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
746 (defun gnus-uu-decode-postscript-and-save-view (n dir)
747 "Decodes, views and saves the resulting file."
749 (list current-prefix-arg
750 (read-file-name "Where do you want to save the file(s)? "
752 gnus-uu-default-dir t)))
753 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
754 (gnus-uu-decode-postscript-and-save n dir)))
757 ;; Internal functions.
759 (defun gnus-uu-decode-with-method (method n &optional save not-insert
761 (gnus-uu-initialize scan)
763 (setq gnus-uu-default-dir save))
764 ;; Create the directory we save to.
765 (when (and scan cdir save
766 (not (file-exists-p save)))
767 (make-directory save t))
768 (let ((articles (gnus-uu-get-list-of-articles n))
770 (setq files (gnus-uu-grab-articles articles method t))
771 (let ((gnus-current-article (car articles)))
773 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
775 (gnus-uu-save-files files save))
776 (when (eq gnus-uu-do-not-unpack-archives nil)
777 (setq files (gnus-uu-unpack-files files)))
778 (setq files (nreverse (gnus-uu-get-actions files)))
779 (or not-insert (not gnus-insert-pseudo-articles)
780 (gnus-summary-insert-pseudos files save))))
782 (defun gnus-uu-scan-directory (dir &optional rec)
783 "Return a list of all files under DIR."
784 (let ((files (directory-files dir t))
786 (while (setq file (pop files))
787 (unless (member (file-name-nondirectory file) '("." ".."))
788 (push (list (cons 'name file)
789 (cons 'article gnus-current-article))
791 (when (file-directory-p file)
792 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
797 (defun gnus-uu-save-files (files dir)
799 (let ((len (length files))
800 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
801 to-file file fromdir)
802 (while (setq file (cdr (assq 'name (pop files))))
803 (when (file-exists-p file)
804 (string-match reg file)
805 (setq fromdir (substring file (match-end 0)))
806 (if (file-directory-p file)
807 (gnus-make-directory (concat dir fromdir))
808 (setq to-file (concat dir fromdir))
809 (when (or (not (file-exists-p to-file))
810 (eq gnus-uu-be-dangerous t)
811 (and gnus-uu-be-dangerous
812 (gnus-y-or-n-p (format "%s exists; overwrite? "
814 (copy-file file to-file t t)))))
815 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
817 ;; Functions for saving and possibly digesting articles without
820 ;; Function called by gnus-uu-grab-articles to treat each article.
821 (defun gnus-uu-save-article (buffer in-state)
823 (gnus-uu-save-separate-articles
826 (let ((coding-system-for-write mm-text-coding-system))
828 (concat gnus-uu-saved-article-name gnus-current-article)))
829 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
830 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
832 ((eq in-state 'last) (list 'end))
833 (t (list 'middle)))))
834 ((not gnus-uu-save-in-digest)
837 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
838 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
839 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
841 ((eq in-state 'last) (list 'end))
842 (t (list 'middle)))))
844 (let ((header (gnus-summary-article-header)))
845 (push (cons (mail-header-from header)
846 (mail-header-subject header))
847 gnus-uu-digest-from-subject))
848 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
849 beg subj headers headline sorthead body end-string state)
850 (if (or (eq in-state 'first)
851 (eq in-state 'first-and-last))
853 (setq state (list 'begin))
855 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
858 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
861 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
862 (current-time-string) name name))
863 (when (and message-forward-as-mime gnus-uu-digest-buffer)
864 ;; The default part in multipart/digest is message/rfc822.
865 ;; Subject is a fake head.
866 (insert "<#part type=text/plain>\nSubject: Topics\n\n"))
867 (insert "Topics:\n")))
868 (when (not (eq in-state 'end))
869 (setq state (list 'middle))))
871 (set-buffer "*gnus-uu-body*")
872 (goto-char (setq beg (point-max)))
876 (let (buffer-read-only)
877 (gnus-set-text-properties (point-min) (point-max) nil)
878 ;; These two are necessary for XEmacs 19.12 fascism.
879 (put-text-property (point-min) (point-max) 'invisible nil)
880 (put-text-property (point-min) (point-max) 'intangible nil))
881 (when (and message-forward-as-mime
882 message-forward-show-mml
883 gnus-uu-digest-buffer)
884 (mm-enable-multibyte)
886 (goto-char (point-min))
887 (re-search-forward "\n\n")
888 (unless (and message-forward-as-mime gnus-uu-digest-buffer)
889 ;; Quote all 30-dash lines.
891 (while (re-search-forward "^-" nil t)
895 (setq body (buffer-substring (1- (point)) (point-max)))
896 (narrow-to-region (point-min) (point))
897 (if (not (setq headers gnus-uu-digest-headers))
898 (setq sorthead (buffer-substring (point-min) (point-max)))
900 (setq headline (car headers))
901 (setq headers (cdr headers))
902 (goto-char (point-min))
903 (while (re-search-forward headline nil t)
908 (or (and (re-search-forward "^[^ \t]" nil t)
910 (progn (forward-line 1) (point)))))))))
912 (if (and message-forward-as-mime gnus-uu-digest-buffer)
913 (if message-forward-show-mml
915 (insert "\n<#mml type=message/rfc822>\n")
916 (insert sorthead) (goto-char (point-max))
917 (insert body) (goto-char (point-max))
918 (insert "\n<#/mml>\n"))
919 (let ((buf (mml-generate-new-buffer " *mml*")))
920 (with-current-buffer buf
922 (goto-char (point-min))
923 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
924 (setq subj (buffer-substring (match-beginning 1)
926 (goto-char (point-max))
928 (insert "\n<#part type=message/rfc822"
929 " buffer=\"" (buffer-name buf) "\">\n")))
930 (insert sorthead) (goto-char (point-max))
931 (insert body) (goto-char (point-max))
932 (insert (concat "\n" (make-string 30 ?-) "\n\n")))
934 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
935 (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
938 (set-buffer "*gnus-uu-pre*")
939 (insert (format " %s\n" subj)))))
940 (when (or (eq in-state 'last)
941 (eq in-state 'first-and-last))
942 (if (and message-forward-as-mime gnus-uu-digest-buffer)
943 (with-current-buffer gnus-uu-digest-buffer
945 (insert-buffer "*gnus-uu-pre*")
946 (goto-char (point-max))
947 (insert-buffer "*gnus-uu-body*"))
949 (set-buffer "*gnus-uu-pre*")
950 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
951 (if gnus-uu-digest-buffer
952 (with-current-buffer gnus-uu-digest-buffer
954 (insert-buffer "*gnus-uu-pre*"))
955 (let ((coding-system-for-write mm-text-coding-system))
956 (gnus-write-buffer gnus-uu-saved-article-name))))
958 (set-buffer "*gnus-uu-body*")
959 (goto-char (point-max))
961 (concat (setq end-string (format "End of %s Digest" name))
963 (insert (concat (make-string (length end-string) ?*) "\n"))
964 (if gnus-uu-digest-buffer
965 (with-current-buffer gnus-uu-digest-buffer
966 (goto-char (point-max))
967 (insert-buffer "*gnus-uu-body*"))
968 (let ((coding-system-for-write mm-text-coding-system)
969 (file-name-coding-system nnmail-pathname-coding-system))
971 (point-min) (point-max) gnus-uu-saved-article-name t)))))
972 (gnus-kill-buffer "*gnus-uu-pre*")
973 (gnus-kill-buffer "*gnus-uu-body*")
975 (if (memq 'begin state)
976 (cons gnus-uu-saved-article-name state)
979 ;; Binhex treatment - not very advanced.
981 (defvar gnus-uu-binhex-body-line
982 "^[^:]...............................................................$")
983 (defvar gnus-uu-binhex-begin-line
984 "^:...............................................................$")
985 (defvar gnus-uu-binhex-end-line
988 (defun gnus-uu-binhex-article (buffer in-state)
989 (let (state start-char)
993 (goto-char (point-min))
994 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
995 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
996 (setq state (list 'wrong-type))))
998 (if (memq 'wrong-type state)
1001 (setq start-char (point))
1002 (if (looking-at gnus-uu-binhex-begin-line)
1004 (setq state (list 'begin))
1005 (write-region 1 1 gnus-uu-binhex-article-name))
1006 (setq state (list 'middle)))
1007 (goto-char (point-max))
1008 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
1009 gnus-uu-binhex-end-line)
1011 (when (looking-at gnus-uu-binhex-end-line)
1012 (setq state (if (memq 'begin state)
1017 (when (file-exists-p gnus-uu-binhex-article-name)
1018 (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
1019 (if (memq 'begin state)
1020 (cons gnus-uu-binhex-article-name state)
1025 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
1026 (let ((state (list 'ok))
1027 start-char end-char file-name)
1029 (set-buffer process-buffer)
1030 (goto-char (point-min))
1031 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
1032 (setq state (list 'wrong-type))
1034 (setq start-char (point))
1035 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
1036 (setq state (list 'wrong-type))
1037 (setq end-char (point))
1038 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1039 (insert-buffer-substring process-buffer start-char end-char)
1040 (setq file-name (concat gnus-uu-work-dir
1041 (cdr gnus-article-current) ".ps"))
1042 (write-region (point-min) (point-max) file-name)
1043 (setq state (list file-name 'begin 'end)))))
1049 (defun gnus-uu-get-actions (files)
1050 (let ((ofiles files)
1053 (setq name (cdr (assq 'name (car files))))
1055 (setq action (gnus-uu-get-action name))
1056 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1057 (cons 'action "file")
1058 (cons 'action action))
1059 (cons 'execute (gnus-uu-command
1062 (setq files (cdr files)))
1065 (defun gnus-uu-get-action (file-name)
1068 (gnus-uu-choose-action
1071 gnus-uu-user-view-rules
1072 (if gnus-uu-ignore-default-view-rules
1074 gnus-uu-default-view-rules)
1075 gnus-uu-user-view-rules-end)))
1076 (when (and (not (string= (or action "") "gnus-uu-archive"))
1077 gnus-uu-view-with-metamail)
1079 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1080 (setq action (format "metamail -d -b -c \"%s\"" action))))
1084 ;; Functions for treating subjects and collecting series.
1086 (defun gnus-uu-reginize-string (string)
1087 ;; Takes a string and puts a \ in front of every special character;
1088 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1089 ;; or, if it can't find something like that, tries "2 of 3", then
1090 ;; finally just replaces the next to last number with "[0-9]+".
1092 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1093 (buffer-disable-undo)
1095 (insert (regexp-quote string))
1097 (setq case-fold-search nil)
1100 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1101 (replace-match "\\1[0-9]+/\\2")
1104 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1106 (replace-match "\\1[0-9]+ of \\2")
1109 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1111 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1114 (while (re-search-forward "[ \t]+" nil t)
1115 (replace-match "[ \t]+" t t))
1117 (buffer-substring 1 (point-max))))
1119 (defun gnus-uu-get-list-of-articles (n)
1120 ;; If N is non-nil, the article numbers of the N next articles
1121 ;; will be returned.
1122 ;; If any articles have been marked as processable, they will be
1124 ;; Failing that, articles that have subjects that are part of the
1125 ;; same "series" as the current will be returned.
1129 (setq n (prefix-numeric-value n))
1130 (let ((backward (< n 0))
1134 (push (gnus-summary-article-number)
1136 (gnus-summary-search-forward nil nil backward))
1138 (nreverse articles)))
1139 (gnus-newsgroup-processable
1140 (reverse gnus-newsgroup-processable))
1142 (gnus-uu-find-articles-matching)))))
1144 (defun gnus-uu-string< (l1 l2)
1145 (string< (car l1) (car l2)))
1147 (defun gnus-uu-find-articles-matching
1148 (&optional subject only-unread do-not-translate)
1149 ;; Finds all articles that matches the regexp SUBJECT. If it is
1150 ;; nil, the current article name will be used. If ONLY-UNREAD is
1151 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1152 ;; non-nil, article names are not equalized before sorting.
1153 (let ((subject (or subject
1154 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1158 ;; Collect all subjects matching subject.
1159 (let ((case-fold-search t)
1160 (data gnus-newsgroup-data)
1164 (and (not (gnus-data-pseudo-p d))
1165 (or (not only-unread)
1166 (= (setq mark (gnus-data-mark d))
1168 (= mark gnus-ticked-mark)
1169 (= mark gnus-dormant-mark))
1170 (setq subj (mail-header-subject (gnus-data-header d)))
1171 (string-match subject subj)
1172 (push (cons subj (gnus-data-number d))
1173 list-of-subjects))))
1175 ;; Expand numbers, sort, and return the list of article
1177 (mapcar (lambda (sub) (cdr sub))
1178 (sort (gnus-uu-expand-numbers
1180 (not do-not-translate))
1181 'gnus-uu-string<))))))
1183 (defun gnus-uu-expand-numbers (string-list &optional translate)
1184 ;; Takes a list of strings and "expands" all numbers in all the
1185 ;; strings. That is, this function makes all numbers equal length by
1186 ;; prepending lots of zeroes before each number. This is to ease later
1187 ;; sorting to find out what sequence the articles are supposed to be
1188 ;; decoded in. Returns the list of expanded strings.
1189 (let ((out-list string-list)
1192 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1193 (buffer-disable-undo)
1196 (insert (caar string-list))
1197 ;; Translate multiple spaces to one space.
1198 (goto-char (point-min))
1199 (while (re-search-forward "[ \t]+" nil t)
1200 (replace-match " "))
1201 ;; Translate all characters to "a".
1202 (goto-char (point-min))
1204 (while (re-search-forward "[A-Za-z]" nil t)
1205 (replace-match "a" t t)))
1207 (goto-char (point-min))
1208 (while (re-search-forward "[0-9]+" nil t)
1211 (string-to-int (buffer-substring
1212 (match-beginning 0) (match-end 0))))))
1213 (setq string (buffer-substring 1 (point-max)))
1214 (setcar (car string-list) string)
1215 (setq string-list (cdr string-list))))
1219 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1220 ;; function. It takes a list of articles to be grabbed and a function
1221 ;; to apply to each article.
1223 ;; The function to be called should take two parameters. The first
1224 ;; parameter is the article buffer. The function should leave the
1225 ;; result, if any, in this buffer. Most treatment functions will just
1226 ;; generate files...
1228 ;; The second parameter is the state of the list of articles, and can
1229 ;; have four values: `first', `middle', `last' and `first-and-last'.
1231 ;; The function should return a list. The list may contain the
1232 ;; following symbols:
1233 ;; `error' if an error occurred
1234 ;; `begin' if the beginning of an encoded file has been received
1235 ;; If the list returned contains a `begin', the first element of
1236 ;; the list *must* be a string with the file name of the decoded
1238 ;; `end' if the end of an encoded file has been received
1239 ;; `middle' if the article was a body part of an encoded file
1240 ;; `wrong-type' if the article was not a part of an encoded file
1241 ;; `ok', which can be used everything is ok
1243 (defvar gnus-uu-has-been-grabbed nil)
1245 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1247 (if (not (and gnus-uu-has-been-grabbed
1248 gnus-uu-unmark-articles-not-decoded))
1250 (when dont-unmark-last-article
1251 (setq art (car gnus-uu-has-been-grabbed))
1252 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1253 (while gnus-uu-has-been-grabbed
1254 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1255 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1256 (when dont-unmark-last-article
1257 (setq gnus-uu-has-been-grabbed (list art))))))
1259 ;; This function takes a list of articles and a function to apply to
1260 ;; each article grabbed.
1262 ;; This function returns a list of files decoded if the grabbing and
1263 ;; the process-function has been successful and nil otherwise.
1264 (defun gnus-uu-grab-articles (articles process-function
1265 &optional sloppy limit no-errors)
1266 (let ((state 'first)
1267 (gnus-asynchronous nil)
1268 (gnus-inhibit-treatment t)
1269 has-been-begin article result-file result-files process-state
1270 gnus-summary-display-article-function
1271 gnus-article-prepare-hook gnus-display-mime-function
1272 article-series files)
1274 (while (and articles
1275 (not (memq 'error process-state))
1277 (not (memq 'end process-state))))
1279 (setq article (pop articles))
1280 (when (vectorp (gnus-summary-article-header article))
1281 (push article article-series)
1284 (if (eq state 'first)
1285 (setq state 'first-and-last)
1286 (setq state 'last)))
1288 (let ((part (gnus-uu-part-number article)))
1289 (gnus-message 6 "Getting article %d%s..."
1290 article (if (string= part "") "" (concat ", " part))))
1291 (gnus-summary-display-article article)
1293 ;; Push the article to the processing function.
1295 (set-buffer gnus-original-article-buffer)
1296 (let ((buffer-read-only nil))
1298 (set-buffer gnus-summary-buffer)
1300 (funcall process-function
1301 gnus-original-article-buffer state)))))
1303 (gnus-summary-remove-process-mark article)
1305 ;; If this is the beginning of a decoded file, we push it
1307 (when (or (memq 'begin process-state)
1308 (and (or (eq state 'first)
1309 (eq state 'first-and-last))
1310 (memq 'ok process-state)))
1311 (when has-been-begin
1312 ;; If there is a `result-file' here, that means that the
1313 ;; file was unsuccessfully decoded, so we delete it.
1314 (when (and result-file
1315 (file-exists-p result-file)
1316 (not gnus-uu-be-dangerous)
1317 (or (eq gnus-uu-be-dangerous t)
1319 (format "Delete unsuccessfully decoded file %s"
1321 (delete-file result-file)))
1322 (when (memq 'begin process-state)
1323 (setq result-file (car process-state)))
1324 (setq has-been-begin t))
1326 ;; Check whether we have decoded one complete file.
1327 (when (memq 'end process-state)
1328 (setq article-series nil)
1329 (setq has-been-begin nil)
1330 (if (stringp result-file)
1331 (setq files (list result-file))
1332 (setq files result-file))
1333 (setq result-file (car files))
1335 (push (list (cons 'name (pop files))
1336 (cons 'article article))
1338 ;; Allow user-defined functions to be run on this file.
1339 (when gnus-uu-grabbed-file-functions
1340 (let ((funcs gnus-uu-grabbed-file-functions))
1341 (unless (listp funcs)
1342 (setq funcs (list funcs)))
1344 (funcall (pop funcs) result-file))))
1345 (setq result-file nil)
1346 ;; Check whether we have decoded enough articles.
1347 (and limit (= (length result-files) limit)
1348 (setq articles nil)))
1350 ;; If this is the last article to be decoded, and
1351 ;; we still haven't reached the end, then we delete
1352 ;; the partially decoded file.
1353 (and (or (eq state 'last) (eq state 'first-and-last))
1354 (not (memq 'end process-state))
1356 (file-exists-p result-file)
1357 (not gnus-uu-be-dangerous)
1358 (or (eq gnus-uu-be-dangerous t)
1360 (format "Delete incomplete file %s? " result-file)))
1361 (delete-file result-file))
1363 ;; If this was a file of the wrong sort, then
1364 (when (and (or (memq 'wrong-type process-state)
1365 (memq 'error process-state))
1366 gnus-uu-unmark-articles-not-decoded)
1367 (gnus-summary-tick-article article t))
1369 ;; Set the new series state.
1370 (if (and (not has-been-begin)
1372 (or (memq 'end process-state)
1373 (memq 'middle process-state)))
1375 (setq process-state (list 'error))
1376 (gnus-message 2 "No begin part at the beginning")
1378 (setq state 'middle)))
1380 ;; When there are no result-files, then something must be wrong.
1384 ((not has-been-begin)
1385 (gnus-message 2 "Wrong type file"))
1386 ((memq 'error process-state)
1387 (gnus-message 2 "An error occurred during decoding"))
1388 ((not (or (memq 'ok process-state)
1389 (memq 'end process-state)))
1390 (gnus-message 2 "End of articles reached before end of file")))
1391 ;; Make unsuccessfully decoded articles unread.
1392 (when gnus-uu-unmark-articles-not-decoded
1393 (while article-series
1394 (gnus-summary-tick-article (pop article-series) t)))))
1398 (defun gnus-uu-grab-view (file)
1399 "View FILE using the gnus-uu methods."
1400 (let ((action (gnus-uu-get-action file)))
1401 (gnus-execute-command
1402 (if (string-match "%" action)
1403 (format action file)
1404 (concat action " " file))
1405 (eq gnus-view-pseudos 'not-confirm))))
1407 (defun gnus-uu-grab-move (file)
1408 "Move FILE to somewhere."
1409 (when gnus-uu-default-dir
1410 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1411 (file-name-nondirectory file))))
1412 (rename-file file to-file)
1413 (unless (file-exists-p file)
1414 (make-symbolic-link to-file file)))))
1416 (defun gnus-uu-part-number (article)
1417 (let* ((header (gnus-summary-article-header article))
1418 (subject (and header (mail-header-subject header)))
1421 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1423 (setq part (match-string 0 subject))
1424 (setq subject (substring subject (match-end 0)))))
1426 (while (string-match "\\([0-9]+\\)[^0-9]+\\([0-9]+\\)" subject)
1427 (setq part (match-string 0 subject))
1428 (setq subject (substring subject (match-end 0)))))
1431 (defun gnus-uu-uudecode-sentinel (process event)
1432 (delete-process (get-process process)))
1434 (defun gnus-uu-uustrip-article (process-buffer in-state)
1435 ;; Uudecodes a file asynchronously.
1437 (set-buffer process-buffer)
1438 (let ((state (list 'wrong-type))
1439 process-connection-type case-fold-search buffer-read-only
1441 (goto-char (point-min))
1443 ;; Deal with ^M at the end of the lines.
1444 (when gnus-uu-kill-carriage-return
1446 (while (search-forward "\r" nil t)
1447 (delete-backward-char 1))))
1449 (while (or (re-search-forward gnus-uu-begin-string nil t)
1450 (re-search-forward gnus-uu-body-line nil t))
1451 (setq state (list 'ok))
1452 ;; Ok, we are at the first uucoded line.
1454 (setq start-char (point))
1456 (if (not (looking-at gnus-uu-begin-string))
1457 (setq state (list 'middle))
1458 ;; This is the beginning of a uuencoded article.
1459 ;; We replace certain characters that could make things messy.
1460 (setq gnus-uu-file-name
1461 (let ((nnheader-file-name-translation-alist
1462 '((?/ . ?,) (? . ?_) (?* . ?_) (?$ . ?_))))
1463 (nnheader-translate-file-chars (match-string 1))))
1464 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1466 ;; Remove any non gnus-uu-body-line right after start.
1468 (while (and (not (eobp))
1469 (not (looking-at gnus-uu-body-line)))
1472 ;; If a process is running, we kill it.
1473 (when (and gnus-uu-uudecode-process
1474 (memq (process-status gnus-uu-uudecode-process)
1476 (delete-process gnus-uu-uudecode-process)
1477 (gnus-uu-unmark-list-of-grabbed t))
1479 ;; Start a new uudecoding process.
1480 (let ((cdir default-directory))
1483 (cd gnus-uu-work-dir)
1484 (setq gnus-uu-uudecode-process
1487 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1488 shell-file-name shell-command-switch
1489 (format "cd %s %s uudecode" gnus-uu-work-dir
1490 gnus-shell-command-separator))))
1492 (set-process-sentinel
1493 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1494 (setq state (list 'begin))
1495 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1497 ;; We look for the end of the thing to be decoded.
1498 (if (re-search-forward gnus-uu-end-string nil t)
1500 (goto-char (point-max))
1501 (re-search-backward gnus-uu-body-line nil t))
1505 (when gnus-uu-uudecode-process
1506 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1507 ;; Try to correct mishandled uucode.
1508 (when gnus-uu-correct-stripped-uucode
1509 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1510 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1512 ;; Send the text to the process.
1514 (process-send-region
1515 gnus-uu-uudecode-process start-char (point))
1518 (delete-process gnus-uu-uudecode-process)
1519 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1520 (setq state (list 'wrong-type)))))
1522 (if (memq 'end state)
1524 ;; Send an EOF, just in case.
1526 (process-send-eof gnus-uu-uudecode-process))
1527 (while (memq (process-status gnus-uu-uudecode-process)
1529 (accept-process-output gnus-uu-uudecode-process 1)))
1530 (when (or (not gnus-uu-uudecode-process)
1531 (not (memq (process-status gnus-uu-uudecode-process)
1533 (setq state (list 'wrong-type)))))))
1535 (if (memq 'begin state)
1536 (cons (if (= (length files) 1) (car files) files) state)
1539 (defvar gnus-uu-unshar-warning
1542 Shell archives are an archaic method of bundling files for distribution
1543 across computer networks. During the unpacking process, arbitrary commands
1544 are executed on your system, and all kinds of nasty things can happen.
1545 Please examine the archive very carefully before you instruct Emacs to
1546 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1548 If you are unsure what to do, please answer \"no\"."
1549 "Text of warning message displayed by `gnus-uu-unshar-article'.
1550 Make sure that this text consists only of few text lines. Otherwise,
1551 Gnus might fail to display all of it.")
1554 ;; This function is used by `gnus-uu-grab-articles' to treat
1555 ;; a shared article.
1556 (defun gnus-uu-unshar-article (process-buffer in-state)
1557 (let ((state (list 'ok))
1560 (set-buffer process-buffer)
1561 (goto-char (point-min))
1562 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1563 (setq state (list 'wrong-type))
1564 (save-window-excursion
1566 (switch-to-buffer (current-buffer))
1567 (delete-other-windows)
1568 (let ((buffer (get-buffer-create (generate-new-buffer-name
1572 (with-current-buffer buffer
1573 (insert (substitute-command-keys
1574 gnus-uu-unshar-warning))
1575 (goto-char (point-min))
1576 (display-buffer buffer)
1577 (yes-or-no-p "This is a shell archive, unshar it? "))
1578 (kill-buffer buffer))
1579 (setq state (list 'error))))))
1580 (unless (memq 'error state)
1582 (setq start-char (point))
1583 (call-process-region
1584 start-char (point-max) shell-file-name nil
1585 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1586 shell-command-switch
1587 (concat "cd " gnus-uu-work-dir " "
1588 gnus-shell-command-separator " sh")))))
1591 ;; Returns the name of what the shar file is going to unpack.
1592 (defun gnus-uu-find-name-in-shar ()
1593 (let ((oldpoint (point))
1595 (goto-char (point-min))
1596 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1597 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1598 (goto-char oldpoint)
1601 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1602 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1603 ;; found, or the name of the command to run if such a rule is found.
1604 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1605 (let ((action-list (copy-sequence file-action-list))
1606 (case-fold-search t)
1611 (and gnus-uu-ignore-files-by-name
1612 (string-match gnus-uu-ignore-files-by-name file-name)))
1614 (and gnus-uu-ignore-files-by-type
1615 (string-match gnus-uu-ignore-files-by-type
1616 (or (gnus-uu-choose-action
1617 file-name gnus-uu-ext-to-mime-list t)
1619 (while (not (or (eq action-list ()) action))
1620 (setq rule (car action-list))
1621 (setq action-list (cdr action-list))
1622 (when (string-match (car rule) file-name)
1623 (setq action (cadr rule)))))
1626 (defun gnus-uu-treat-archive (file-path)
1627 ;; Unpacks an archive. Returns t if unpacking is successful.
1628 (let ((did-unpack t)
1630 (setq action (gnus-uu-choose-action
1631 file-path (append gnus-uu-user-archive-rules
1632 (if gnus-uu-ignore-default-archive-rules
1634 gnus-uu-default-archive-rules))))
1637 (error "No unpackers for the file %s" file-path))
1639 (string-match "/[^/]*$" file-path)
1640 (setq dir (substring file-path 0 (match-beginning 0)))
1642 (when (member action gnus-uu-destructive-archivers)
1643 (copy-file file-path (concat file-path "~") t))
1645 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1648 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1651 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1653 (if (= 0 (call-process shell-file-name nil
1654 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1655 nil shell-command-switch command))
1657 (gnus-message 2 "Error during unpacking of archive")
1658 (setq did-unpack nil))
1660 (when (member action gnus-uu-destructive-archivers)
1661 (rename-file (concat file-path "~") file-path t))
1665 (defun gnus-uu-dir-files (dir)
1666 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1669 (if (file-directory-p (setq file (car dirs)))
1670 (setq files (append files (gnus-uu-dir-files file)))
1672 (setq dirs (cdr dirs)))
1675 (defun gnus-uu-unpack-files (files &optional ignore)
1676 ;; Go through FILES and look for files to unpack.
1677 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1681 (setq file (cdr (assq 'name (car files))))
1682 (when (and (not (member file ignore))
1683 (equal (gnus-uu-get-action (file-name-nondirectory file))
1685 (push file did-unpack)
1686 (unless (gnus-uu-treat-archive file)
1687 (gnus-message 2 "Error during unpacking of %s" file))
1688 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1691 (unless (member (car nfiles) totfiles)
1692 (push (list (cons 'name (car nfiles))
1693 (cons 'original file))
1695 (setq nfiles (cdr nfiles)))
1696 (setq totfiles newfiles)))
1697 (setq files (cdr files)))
1699 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1702 (defun gnus-uu-ls-r (dir)
1703 (let* ((files (gnus-uu-directory-files dir t))
1706 (when (file-directory-p (car files))
1707 (setq ofiles (delete (car files) ofiles))
1708 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1709 (setq files (cdr files)))
1714 (defun gnus-uu-directory-files (dir &optional full)
1715 (let (files out file)
1716 (setq files (directory-files dir full))
1718 (setq file (car files))
1719 (setq files (cdr files))
1720 (unless (member (file-name-nondirectory file) '("." ".."))
1722 (setq out (nreverse out))
1725 (defun gnus-uu-check-correct-stripped-uucode (start end)
1727 (let (found beg length)
1728 (if (not gnus-uu-correct-stripped-uucode)
1732 (if (re-search-forward " \\|`" end t)
1737 (when (looking-at "\n")
1742 (if (looking-at (concat gnus-uu-begin-string "\\|"
1743 gnus-uu-end-string))
1749 (setq length (- (point) beg)))
1754 (when (not (= length (- (point) beg)))
1755 (insert (make-string (- length (- (point) beg)) ? ))))
1756 (forward-line 1)))))))
1758 (defvar gnus-uu-tmp-alist nil)
1760 (defun gnus-uu-initialize (&optional scan)
1763 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1764 (if (file-exists-p (cdr entry))
1765 (setq gnus-uu-work-dir (cdr entry))
1766 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1769 (setq gnus-uu-tmp-dir (file-name-as-directory
1770 (expand-file-name gnus-uu-tmp-dir)))
1771 (if (not (file-directory-p gnus-uu-tmp-dir))
1772 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1773 (when (not (file-writable-p gnus-uu-tmp-dir))
1774 (error "Temp directory %s can't be written to"
1777 (setq gnus-uu-work-dir
1778 (make-temp-name (concat gnus-uu-tmp-dir "gnus")))
1779 (gnus-make-directory gnus-uu-work-dir)
1780 (set-file-modes gnus-uu-work-dir 448)
1781 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1782 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1783 gnus-uu-tmp-alist))))
1786 ;; Kills the temporary uu buffers, kills any processes, etc.
1787 (defun gnus-uu-clean-up ()
1789 (and gnus-uu-uudecode-process
1790 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1792 (delete-process gnus-uu-uudecode-process))
1793 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1794 (kill-buffer buf))))
1796 ;; Inputs an action and a filename and returns a full command, making sure
1797 ;; that the filename will be treated as a single argument when the shell
1798 ;; executes the command.
1799 (defun gnus-uu-command (action file)
1800 (let ((quoted-file (mm-quote-arg file)))
1801 (if (string-match "%s" action)
1802 (format action quoted-file)
1803 (concat action " " quoted-file))))
1805 (defun gnus-uu-delete-work-dir (&optional dir)
1806 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1808 (gnus-message 7 "Deleting directory %s..." dir)
1809 (setq dir gnus-uu-work-dir))
1811 (file-exists-p dir))
1812 (let ((files (directory-files dir t nil t))
1814 (while (setq file (pop files))
1815 (unless (member (file-name-nondirectory file) '("." ".."))
1816 (if (file-directory-p file)
1817 (gnus-uu-delete-work-dir file)
1818 (gnus-message 9 "Deleting file %s..." file)
1819 (delete-file file))))
1820 (delete-directory dir)))
1821 (gnus-message 7 ""))
1825 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1826 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1831 ;;; uuencoded posting
1834 ;; Any function that is to be used as and encoding method will take two
1835 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1836 ;; and "spiral.jpg", respectively.) The function should return nil if
1837 ;; the encoding wasn't successful.
1838 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1839 "Function used for encoding binary files.
1840 There are three functions supplied with gnus-uu for encoding files:
1841 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1842 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1843 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1844 uuencode and adds MIME headers."
1845 :group 'gnus-extract-post
1846 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1847 (function-item gnus-uu-post-encode-mime)
1848 (function-item gnus-uu-post-encode-mime-uuencode)
1849 (function :tag "Other")))
1851 (defcustom gnus-uu-post-include-before-composing nil
1852 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1853 If this variable is t, you can either include an encoded file with
1854 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1855 :group 'gnus-extract-post
1858 (defcustom gnus-uu-post-length 990
1859 "Maximum length of an article.
1860 The encoded file will be split into how many articles it takes to
1861 post the entire file."
1862 :group 'gnus-extract-post
1865 (defcustom gnus-uu-post-threaded nil
1866 "Non-nil means that gnus-uu will post the encoded file in a thread.
1867 This may not be smart, as no other decoder I have seen are able to
1868 follow threads when collecting uuencoded articles. (Well, I have seen
1869 one package that does that - gnus-uu, but somehow, I don't think that
1870 counts...) The default is nil."
1871 :group 'gnus-extract-post
1874 (defcustom gnus-uu-post-separate-description t
1875 "Non-nil means that the description will be posted in a separate article.
1876 The first article will typically be numbered (0/x). If this variable
1877 is nil, the description the user enters will be included at the
1878 beginning of the first article, which will be numbered (1/x). Default
1880 :group 'gnus-extract-post
1883 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1884 (defvar gnus-uu-post-message-id nil)
1885 (defvar gnus-uu-post-inserted-file-name nil)
1886 (defvar gnus-uu-winconf-post-news nil)
1888 (defun gnus-uu-post-news ()
1889 "Compose an article and post an encoded file."
1891 (setq gnus-uu-post-inserted-file-name nil)
1892 (setq gnus-uu-winconf-post-news (current-window-configuration))
1894 (gnus-summary-post-news)
1896 (let ((map (make-sparse-keymap)))
1897 (set-keymap-parent map (current-local-map))
1898 (use-local-map map))
1899 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1900 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1901 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1902 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1904 (when gnus-uu-post-include-before-composing
1905 (save-excursion (setq gnus-uu-post-inserted-file-name
1906 (gnus-uu-post-insert-binary)))))
1908 (defun gnus-uu-post-insert-binary-in-article ()
1909 "Inserts an encoded file in the buffer.
1910 The user will be asked for a file name."
1913 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1915 ;; Encodes with uuencode and substitutes all spaces with backticks.
1916 (defun gnus-uu-post-encode-uuencode (path file-name)
1917 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1918 (goto-char (point-min))
1920 (while (re-search-forward " " nil t)
1921 (replace-match "`"))
1924 ;; Encodes with uuencode and adds MIME headers.
1925 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1926 (when (gnus-uu-post-encode-uuencode path file-name)
1927 (gnus-uu-post-make-mime file-name "x-uue")
1930 ;; Encodes with base64 and adds MIME headers
1931 (defun gnus-uu-post-encode-mime (path file-name)
1932 (when (zerop (call-process shell-file-name nil t nil shell-command-switch
1933 (format "%s %s -o %s" "mmencode" path file-name)))
1934 (gnus-uu-post-make-mime file-name "base64")
1937 ;; Adds MIME headers.
1938 (defun gnus-uu-post-make-mime (file-name encoding)
1939 (goto-char (point-min))
1940 (insert (format "Content-Type: %s; name=\"%s\"\n"
1941 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1943 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1945 (set-buffer gnus-message-buffer)
1946 (goto-char (point-min))
1947 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1949 (narrow-to-region 1 (point))
1950 (unless (mail-fetch-field "mime-version")
1952 (insert "MIME-Version: 1.0\n"))
1955 ;; Encodes a file PATH with COMMAND, leaving the result in the
1957 (defun gnus-uu-post-encode-file (command path file-name)
1958 (= 0 (call-process shell-file-name nil t nil shell-command-switch
1959 (format "%s %s %s" command path file-name))))
1961 (defun gnus-uu-post-news-inews ()
1962 "Posts the composed news article and encoded file.
1963 If no file has been included, the user will be asked for a file."
1968 (if gnus-uu-post-inserted-file-name
1969 (setq file-name gnus-uu-post-inserted-file-name)
1970 (setq file-name (gnus-uu-post-insert-binary)))
1972 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1973 (setq gnus-uu-post-inserted-file-name nil)
1974 (when gnus-uu-winconf-post-news
1975 (set-window-configuration gnus-uu-winconf-post-news)))
1977 ;; Asks for a file to encode, encodes it and inserts the result in
1978 ;; the current buffer. Returns the file name the user gave.
1979 (defun gnus-uu-post-insert-binary ()
1980 (let ((uuencode-buffer-name "*uuencode buffer*")
1981 file-path uubuf file-name)
1983 (setq file-path (read-file-name
1984 "What file do you want to encode? "))
1985 (when (not (file-exists-p file-path))
1986 (error "%s: No such file" file-path))
1988 (goto-char (point-max))
1989 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1991 ;; #### Unix-specific?
1992 (when (string-match "^~/" file-path)
1993 (setq file-path (concat "$HOME" (substring file-path 1))))
1994 ;; #### Unix-specific?
1995 (if (string-match "/[^/]*$" file-path)
1996 (setq file-name (substring file-path (1+ (match-beginning 0))))
1997 (setq file-name file-path))
2001 (set-buffer (setq uubuf
2002 (gnus-get-buffer-create uuencode-buffer-name)))
2004 (funcall gnus-uu-post-encode-method file-path file-name))
2005 (insert-buffer-substring uubuf)
2006 (error "Encoding unsuccessful"))
2007 (kill-buffer uubuf))
2010 ;; Posts the article and all of the encoded file.
2011 (defun gnus-uu-post-encoded (file-name &optional threaded)
2012 (let ((send-buffer-name "*uuencode send buffer*")
2013 (encoded-buffer-name "*encoded buffer*")
2014 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
2015 (separator (concat mail-header-separator "\n\n"))
2016 uubuf length parts header i end beg
2017 beg-line minlen post-buf whole-len beg-binary end-binary)
2019 (setq post-buf (current-buffer))
2021 (goto-char (point-min))
2022 (when (not (re-search-forward
2023 (if gnus-uu-post-separate-description
2024 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2026 (concat "^" (regexp-quote mail-header-separator) "$"))
2028 (error "Internal error: No binary/header separator"))
2031 (setq beg-binary (point))
2032 (setq end-binary (point-max))
2035 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2037 (insert-buffer-substring post-buf beg-binary end-binary)
2038 (goto-char (point-min))
2039 (setq length (count-lines 1 (point-max)))
2040 (setq parts (/ length gnus-uu-post-length))
2041 (unless (< (% length gnus-uu-post-length) 4)
2044 (when gnus-uu-post-separate-description
2046 (delete-region (point) (point-max))
2048 (goto-char (point-min))
2050 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2052 (setq header (buffer-substring 1 (point)))
2054 (goto-char (point-min))
2055 (when gnus-uu-post-separate-description
2056 (when (re-search-forward "^Subject: " nil t)
2058 (insert (format " (0/%d)" parts)))
2061 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2066 (while (not (> i parts))
2067 (set-buffer (gnus-get-buffer-create send-buffer-name))
2070 (when (and threaded gnus-uu-post-message-id)
2071 (insert "References: " gnus-uu-post-message-id "\n"))
2074 (- 62 (length (format top-string "" file-name i parts ""))))
2075 (when (> 1 (setq minlen (/ whole-len 2)))
2080 (make-string minlen ?-)
2083 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2085 (goto-char (point-min))
2086 (when (re-search-forward "^Subject: " nil t)
2088 (insert (format " (%d/%d)" i parts)))
2090 (goto-char (point-max))
2095 (goto-char (point-max))
2096 (forward-line gnus-uu-post-length))
2097 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2100 (insert-buffer-substring uubuf beg end)
2101 (insert beg-line "\n")
2104 (goto-char (point-min))
2106 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2109 (when (re-search-forward
2110 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2116 (let (message-sent-message-via)
2119 (setq gnus-uu-post-message-id
2120 (concat (message-fetch-field "references") " "
2121 (message-fetch-field "message-id"))))))
2123 (gnus-kill-buffer send-buffer-name)
2124 (gnus-kill-buffer encoded-buffer-name)
2126 (when (not gnus-uu-post-separate-description)
2127 (set-buffer-modified-p nil)
2128 (when (fboundp 'bury-buffer)
2133 ;; gnus-uu.el ends here