1 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
31 (eval-when-compile (require 'cl))
39 (defgroup gnus-extract nil
40 "Extracting encoded files."
44 (defgroup gnus-extract-view nil
45 "Viewwing extracted files."
48 (defgroup gnus-extract-archive nil
49 "Extracting encoded archives."
52 (defgroup gnus-extract-post nil
53 "Extracting encoded archives."
54 :prefix "gnus-uu-post"
57 ;; Default viewing action rules
59 (defcustom gnus-uu-default-view-rules
60 '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
61 ("\\.pas$" "cat %s | sed 's/\r$//'")
62 ("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
63 ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
64 ("\\.tga$" "tgatoppm %s | ee -")
65 ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
66 "sox -v .5 %s -t .au -u - > /dev/audio")
67 ("\\.au$" "cat %s > /dev/audio")
68 ("\\.midi?$" "playmidi -f")
70 ("\\.ps$" "ghostview")
72 ("\\.html$" "xmosaic")
73 ("\\.mpe?g$" "mpeg_play")
74 ("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
75 ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
77 "*Default actions to be taken when the user asks to view a file.
78 To change the behaviour, you can either edit this variable or set
79 `gnus-uu-user-view-rules' to something useful.
83 To make gnus-uu use 'xli' to display JPEG and GIF files, put the
84 following in your .emacs file:
86 (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
88 Both these variables are lists of lists with two string elements. The
89 first string is a regular expression. If the file name matches this
90 regular expression, the command in the second string is executed with
91 the file as an argument.
93 If the command string contains \"%s\", the file name will be inserted
94 at that point in the command string. If there's no \"%s\" in the
95 command string, the file name will be appended to the command string
98 There are several user variables to tailor the behaviour of gnus-uu to
99 your needs. First we have `gnus-uu-user-view-rules', which is the
100 variable gnus-uu first consults when trying to decide how to view a
101 file. If this variable contains no matches, gnus-uu examines the
102 default rule variable provided in this package. If gnus-uu finds no
103 match here, it uses `gnus-uu-user-view-rules-end' to try to make a
105 :group 'gnus-extract-view
106 :type '(repeat (group regexp (string :tag "Command"))))
108 (defcustom gnus-uu-user-view-rules nil
109 "What actions are to be taken to view a file.
110 See the documentation on the `gnus-uu-default-view-rules' variable for
112 :group 'gnus-extract-view
113 :type '(repeat (group regexp (string :tag "Command"))))
115 (defcustom gnus-uu-user-view-rules-end
117 "*What actions are to be taken if no rule matched the file name.
118 See the documentation on the `gnus-uu-default-view-rules' variable for
120 :group 'gnus-extract-view
121 :type '(repeat (group regexp (string :tag "Command"))))
123 ;; Default unpacking commands
125 (defcustom gnus-uu-default-archive-rules
126 '(("\\.tar$" "tar xf")
127 ("\\.zip$" "unzip -o")
129 ("\\.arj$" "unarj x")
131 ("\\.\\(lzh\\|lha\\)$" "lha x")
132 ("\\.Z$" "uncompress")
134 ("\\.arc$" "arc -x"))
135 "*See `gnus-uu-user-archive-rules'."
136 :group 'gnus-extract-archive
137 :type '(repeat (group regexp (string :tag "Command"))))
139 (defvar gnus-uu-destructive-archivers
140 (list "uncompress" "gunzip"))
142 (defcustom gnus-uu-user-archive-rules nil
143 "A list that can be set to override the default archive unpacking commands.
144 To use, for instance, 'untar' to unpack tar files and 'zip -x' to
145 unpack zip files, say the following:
146 (setq gnus-uu-user-archive-rules
147 '((\"\\\\.tar$\" \"untar\")
148 (\"\\\\.zip$\" \"zip -x\")))"
149 :group 'gnus-extract-archive
150 :type '(repeat (group regexp (string :tag "Command"))))
152 (defcustom gnus-uu-ignore-files-by-name nil
153 "*A regular expression saying what files should not be viewed based on name.
154 If, for instance, you want gnus-uu to ignore all .au and .wav files,
155 you could say something like
157 (setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
159 Note that this variable can be used in conjunction with the
160 `gnus-uu-ignore-files-by-type' variable."
162 :type '(choice (const :tag "off" nil)
163 (regexp :format "%v")))
165 (defcustom gnus-uu-ignore-files-by-type nil
166 "*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
167 If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
168 you could say something like
170 (setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
172 Note that this variable can be used in conjunction with the
173 `gnus-uu-ignore-files-by-name' variable."
175 :type '(choice (const :tag "off" nil)
176 (regexp :format "%v")))
178 ;; Pseudo-MIME support
180 (defconst gnus-uu-ext-to-mime-list
181 '(("\\.gif$" "image/gif")
182 ("\\.jpe?g$" "image/jpeg")
183 ("\\.tiff?$" "image/tiff")
184 ("\\.xwd$" "image/xwd")
185 ("\\.pbm$" "image/pbm")
186 ("\\.pgm$" "image/pgm")
187 ("\\.ppm$" "image/ppm")
188 ("\\.xbm$" "image/xbm")
189 ("\\.pcx$" "image/pcx")
190 ("\\.tga$" "image/tga")
191 ("\\.ps$" "image/postscript")
192 ("\\.fli$" "video/fli")
193 ("\\.wav$" "audio/wav")
194 ("\\.aiff$" "audio/aiff")
195 ("\\.hcom$" "audio/hcom")
196 ("\\.voc$" "audio/voc")
197 ("\\.smp$" "audio/smp")
198 ("\\.mod$" "audio/mod")
199 ("\\.dvi$" "image/dvi")
200 ("\\.mpe?g$" "video/mpeg")
201 ("\\.au$" "audio/basic")
202 ("\\.\\(te?xt\\|doc\\|c\\|h\\)$" "text/plain")
203 ("\\.\\(c\\|h\\)$" "text/source")
204 ("read.*me" "text/plain")
205 ("\\.html$" "text/html")
206 ("\\.bat$" "text/bat")
207 ("\\.[1-6]$" "text/man")
208 ("\\.flc$" "video/flc")
209 ("\\.rle$" "video/rle")
210 ("\\.pfx$" "video/pfx")
211 ("\\.avi$" "video/avi")
212 ("\\.sme$" "video/sme")
213 ("\\.rpza$" "video/prza")
214 ("\\.dl$" "video/dl")
215 ("\\.qt$" "video/qt")
216 ("\\.rsrc$" "video/rsrc")
217 ("\\..*$" "unknown/unknown")))
219 ;; Various variables users may set
221 (defcustom gnus-uu-tmp-dir
222 (cond ((fboundp 'temp-directory) (temp-directory))
223 ((boundp 'temporary-file-directory) temporary-file-directory)
225 "*Variable saying where gnus-uu is to do its work.
226 Default is \"/tmp/\"."
230 (defcustom gnus-uu-do-not-unpack-archives nil
231 "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
233 :group 'gnus-extract-archive
236 (defcustom gnus-uu-ignore-default-view-rules nil
237 "*Non-nil means that gnus-uu will ignore the default viewing rules.
238 Only the user viewing rules will be consulted. Default is nil."
239 :group 'gnus-extract-view
242 (defcustom gnus-uu-grabbed-file-functions nil
243 "Functions run on each file after successful decoding.
244 They will be called with the name of the file as the argument.
245 Likely functions you can use in this list are `gnus-uu-grab-view'
246 and `gnus-uu-grab-move'."
248 :options '(gnus-uu-grab-view gnus-uu-grab-move)
251 (defcustom gnus-uu-ignore-default-archive-rules nil
252 "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
253 Only the user unpacking commands will be consulted. Default is nil."
254 :group 'gnus-extract-archive
257 (defcustom gnus-uu-kill-carriage-return t
258 "*Non-nil means that gnus-uu will strip all carriage returns from articles.
263 (defcustom gnus-uu-view-with-metamail nil
264 "*Non-nil means that files will be viewed with metamail.
265 The gnus-uu viewing functions will be ignored and gnus-uu will try
266 to guess at a content-type based on file name suffixes. Default
271 (defcustom gnus-uu-unmark-articles-not-decoded nil
272 "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
277 (defcustom gnus-uu-correct-stripped-uucode nil
278 "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
283 (defcustom gnus-uu-save-in-digest nil
284 "*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
285 If this variable is nil, gnus-uu will just save everything in a
286 file without any embellishments. The digesting almost conforms to RFC1153 -
287 no easy way to specify any meaningful volume and issue numbers were found,
288 so I simply dropped them."
292 (defcustom gnus-uu-pre-uudecode-hook nil
293 "Hook run before sending a message to uudecode."
297 (defcustom gnus-uu-digest-headers
298 '("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
299 "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
300 "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
302 "*List of regexps to match headers included in digested messages.
303 The headers will be included in the sequence they are matched. If nil
304 include all headers."
306 :type '(repeat regexp))
308 (defcustom gnus-uu-save-separate-articles nil
309 "*Non-nil means that gnus-uu will save articles in separate files."
313 (defcustom gnus-uu-be-dangerous 'ask
314 "*Specifies what to do if unusual situations arise during decoding.
315 If nil, be as conservative as possible. If t, ignore things that
316 didn't work, and overwrite existing files. Otherwise, ask each time."
318 :type '(choice (const :tag "conservative" nil)
319 (const :tag "ask" ask)
320 (const :tag "liberal" t)))
322 ;; Internal variables
324 (defvar gnus-uu-saved-article-name nil)
326 (defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
327 (defvar gnus-uu-end-string "^end[ \t]*$")
329 (defvar gnus-uu-body-line "^M")
331 (while (> (setq i (1- i)) 0)
332 (setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
333 (setq gnus-uu-body-line (concat gnus-uu-body-line ".?$")))
335 ;"^M.............................................................?$"
337 (defvar gnus-uu-shar-begin-string "^#! */bin/sh")
339 (defvar gnus-uu-shar-file-name nil)
340 (defvar gnus-uu-shar-name-marker
341 "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
343 (defvar gnus-uu-postscript-begin-string "^%!PS-")
344 (defvar gnus-uu-postscript-end-string "^%%EOF$")
346 (defvar gnus-uu-file-name nil)
347 (defvar gnus-uu-uudecode-process nil)
348 (defvar gnus-uu-binhex-article-name nil)
350 (defvar gnus-uu-work-dir nil)
352 (defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
354 (defvar gnus-uu-default-dir gnus-article-save-directory)
355 (defvar gnus-uu-digest-from-subject nil)
356 (defvar gnus-uu-digest-buffer nil)
360 (defun gnus-uu-decode-uu (&optional n)
361 "Uudecodes the current article."
363 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
365 (defun gnus-uu-decode-uu-and-save (n dir)
366 "Decodes and saves the resulting file."
368 (list current-prefix-arg
369 (file-name-as-directory
370 (read-file-name "Uudecode and save in dir: "
372 gnus-uu-default-dir t))))
373 (gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
375 (defun gnus-uu-decode-unshar (&optional n)
376 "Unshars the current article."
378 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
380 (defun gnus-uu-decode-unshar-and-save (n dir)
381 "Unshars and saves the current article."
383 (list current-prefix-arg
384 (file-name-as-directory
385 (read-file-name "Unshar and save in dir: "
387 gnus-uu-default-dir t))))
388 (gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
390 (defun gnus-uu-decode-save (n file)
391 "Saves the current article."
393 (list current-prefix-arg
395 (if gnus-uu-save-separate-articles
396 "Save articles is dir: "
397 "Save articles in file: ")
399 gnus-uu-default-dir)))
400 (setq gnus-uu-saved-article-name file)
401 (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
403 (defun gnus-uu-decode-binhex (n dir)
404 "Unbinhexes the current article."
406 (list current-prefix-arg
407 (file-name-as-directory
408 (read-file-name "Unbinhex and save in dir: "
410 gnus-uu-default-dir))))
411 (setq gnus-uu-binhex-article-name
412 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
413 (gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
415 (defun gnus-uu-decode-uu-view (&optional n)
416 "Uudecodes and views the current article."
418 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
419 (gnus-uu-decode-uu n)))
421 (defun gnus-uu-decode-uu-and-save-view (n dir)
422 "Decodes, views and saves the resulting file."
424 (list current-prefix-arg
425 (read-file-name "Uudecode, view and save in dir: "
427 gnus-uu-default-dir t)))
428 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
429 (gnus-uu-decode-uu-and-save n dir)))
431 (defun gnus-uu-decode-unshar-view (&optional n)
432 "Unshars and views the current article."
434 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
435 (gnus-uu-decode-unshar n)))
437 (defun gnus-uu-decode-unshar-and-save-view (n dir)
438 "Unshars and saves the current article."
440 (list current-prefix-arg
441 (read-file-name "Unshar, view and save in dir: "
443 gnus-uu-default-dir t)))
444 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
445 (gnus-uu-decode-unshar-and-save n dir)))
447 (defun gnus-uu-decode-save-view (n file)
448 "Saves and views the current article."
450 (list current-prefix-arg
451 (read-file-name (if gnus-uu-save-separate-articles
452 "Save articles is dir: "
453 "Save articles in file: ")
454 gnus-uu-default-dir gnus-uu-default-dir)))
455 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
456 (gnus-uu-decode-save n file)))
458 (defun gnus-uu-decode-binhex-view (n file)
459 "Unbinhexes and views the current article."
461 (list current-prefix-arg
462 (read-file-name "Unbinhex, view and save in dir: "
463 gnus-uu-default-dir gnus-uu-default-dir)))
464 (setq gnus-uu-binhex-article-name
465 (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
466 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
467 (gnus-uu-decode-binhex n file)))
470 ;; Digest and forward articles
472 (defun gnus-uu-digest-mail-forward (&optional n post)
473 "Digests and forwards all articles in this series."
475 (let ((gnus-uu-save-in-digest t)
476 (file (mm-make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
477 (message-forward-as-mime message-forward-as-mime)
478 (mail-parse-charset gnus-newsgroup-charset)
479 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
480 gnus-uu-digest-buffer subject from)
481 (if (and n (not (numberp n)))
482 (setq message-forward-as-mime (not message-forward-as-mime)
484 (let ((gnus-article-reply (gnus-summary-work-articles n))
485 gnus-newsgroup-processable)
487 (= (length gnus-article-reply) 1))
488 ;; The case where neither a number of articles nor a region is
490 (gnus-summary-top-thread)
491 (setq gnus-article-reply (gnus-uu-get-list-of-articles nil)))
492 ;; Specify articles to be forwarded.
493 (setq gnus-newsgroup-processable (copy-sequence gnus-article-reply))
494 (gnus-setup-message 'forward
495 (setq gnus-uu-digest-from-subject nil)
496 (setq gnus-uu-digest-buffer
497 (gnus-get-buffer-create " *gnus-uu-forward*"))
498 (gnus-uu-decode-save n file)
499 (switch-to-buffer gnus-uu-digest-buffer)
500 (let ((fs gnus-uu-digest-from-subject))
503 subject (gnus-simplify-subject-fuzzy (cdar fs))
505 (while (and fs (or from subject))
507 (unless (string= from (caar fs))
510 (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
515 (setq subject "Digested Articles"))
518 (if (gnus-news-group-p gnus-newsgroup-name)
521 (goto-char (point-min))
522 (when (re-search-forward "^Subject: ")
523 (delete-region (point) (point-at-eol))
525 (goto-char (point-min))
526 (when (re-search-forward "^From:")
527 (delete-region (point) (point-at-eol))
529 (let ((message-forward-decoded-p t))
530 (message-forward post t))))
531 (setq gnus-uu-digest-from-subject nil)))
533 (defun gnus-uu-digest-post-forward (&optional n)
534 "Digest and forward to a newsgroup."
536 (gnus-uu-digest-mail-forward n t))
540 (defun gnus-message-process-mark (unmarkp new-marked)
541 (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
542 (gnus-message 6 "%d mark%s %s%s"
544 (if (= (length new-marked) 1) "" "s")
545 (if unmarkp "removed" "added")
551 (format ", %d remain marked"
552 (length gnus-newsgroup-processable)))
554 (format ", %d already marked" old))))))
556 (defun gnus-new-processable (unmarkp articles)
558 (gnus-intersection gnus-newsgroup-processable articles)
559 (gnus-set-difference articles gnus-newsgroup-processable)))
561 (defun gnus-uu-mark-by-regexp (regexp &optional unmark)
562 "Set the process mark on articles whose subjects match REGEXP.
563 When called interactively, prompt for REGEXP.
564 Optional UNMARK non-nil means unmark instead of mark."
565 (interactive "sMark (regexp): \nP")
567 (let* ((articles (gnus-uu-find-articles-matching regexp))
568 (new-marked (gnus-new-processable unmark articles)))
571 (gnus-summary-remove-process-mark (pop articles))
572 (gnus-summary-set-process-mark (pop articles))))
573 (gnus-message-process-mark unmark new-marked)))
574 (gnus-summary-position-point))
576 (defun gnus-uu-unmark-by-regexp (regexp)
577 "Remove the process mark from articles whose subjects match REGEXP.
578 When called interactively, prompt for REGEXP."
579 (interactive "sUnmark (regexp): ")
580 (gnus-uu-mark-by-regexp regexp t))
582 (defun gnus-uu-mark-series (&optional silent)
583 "Mark the current series with the process mark."
585 (let* ((articles (gnus-uu-find-articles-matching))
586 (l (length articles)))
588 (gnus-summary-set-process-mark (car articles))
589 (setq articles (cdr articles)))
591 (gnus-message 6 "Marked %d articles" l))
592 (gnus-summary-position-point)
595 (defun gnus-uu-mark-region (beg end &optional unmark)
596 "Set the process mark on all articles between point and mark."
600 (while (< (point) end)
602 (gnus-summary-remove-process-mark (gnus-summary-article-number))
603 (gnus-summary-set-process-mark (gnus-summary-article-number)))
605 (gnus-summary-position-point))
607 (defun gnus-uu-unmark-region (beg end)
608 "Remove the process mark from all articles between point and mark."
610 (gnus-uu-mark-region beg end t))
612 (defun gnus-uu-mark-buffer ()
613 "Set the process mark on all articles in the buffer."
615 (gnus-uu-mark-region (point-min) (point-max)))
617 (defun gnus-uu-unmark-buffer ()
618 "Remove the process mark on all articles in the buffer."
620 (gnus-uu-mark-region (point-min) (point-max) t))
622 (defun gnus-uu-mark-thread ()
623 "Marks all articles downwards in this thread."
625 (gnus-save-hidden-threads
626 (let ((level (gnus-summary-thread-level)))
627 (while (and (gnus-summary-set-process-mark
628 (gnus-summary-article-number))
629 (zerop (gnus-summary-next-subject 1 nil t))
630 (> (gnus-summary-thread-level) level)))))
631 (gnus-summary-position-point))
633 (defun gnus-uu-unmark-thread ()
634 "Unmarks all articles downwards in this thread."
636 (let ((level (gnus-summary-thread-level)))
637 (while (and (gnus-summary-remove-process-mark
638 (gnus-summary-article-number))
639 (zerop (gnus-summary-next-subject 1))
640 (> (gnus-summary-thread-level) level))))
641 (gnus-summary-position-point))
643 (defun gnus-uu-invert-processable ()
644 "Invert the list of process-marked articles."
646 (let ((data gnus-newsgroup-data)
650 (if (memq (setq number (gnus-data-number (pop data)))
651 gnus-newsgroup-processable)
652 (gnus-summary-remove-process-mark number)
653 (gnus-summary-set-process-mark number)))))
654 (gnus-summary-position-point))
656 (defun gnus-uu-mark-over (&optional score)
657 "Mark all articles with a score over SCORE (the prefix)."
659 (let ((score (or score gnus-summary-default-score 0))
660 (data gnus-newsgroup-data))
663 (when (> (or (cdr (assq (gnus-data-number (car data))
664 gnus-newsgroup-scored))
665 gnus-summary-default-score 0)
667 (gnus-summary-set-process-mark (caar data)))
668 (setq data (cdr data))))
669 (gnus-summary-position-point)))
671 (defun gnus-uu-mark-sparse ()
672 "Mark all series that have some articles marked."
674 (let ((marked (nreverse gnus-newsgroup-processable))
675 subject articles total headers)
677 (error "No articles marked with the process mark"))
678 (setq gnus-newsgroup-processable nil)
681 (and (vectorp (setq headers
682 (gnus-summary-article-header (car marked))))
683 (setq subject (mail-header-subject headers)
684 articles (gnus-uu-find-articles-matching
685 (gnus-uu-reginize-string subject))
686 total (nconc total articles)))
688 (gnus-summary-set-process-mark (car articles))
689 (setcdr marked (delq (car articles) (cdr marked)))
690 (setq articles (cdr articles)))
691 (setq marked (cdr marked)))
692 (setq gnus-newsgroup-processable (nreverse total)))
693 (gnus-summary-position-point)))
695 (defun gnus-uu-mark-all ()
696 "Mark all articles in \"series\" order."
698 (setq gnus-newsgroup-processable nil)
700 (let ((data gnus-newsgroup-data)
704 (when (and (not (memq (setq number (gnus-data-number (car data)))
705 gnus-newsgroup-processable))
706 (vectorp (gnus-data-header (car data))))
707 (gnus-summary-goto-subject number)
708 (setq count (+ count (gnus-uu-mark-series t))))
709 (setq data (cdr data)))
710 (gnus-message 6 "Marked %d articles" count)))
711 (gnus-summary-position-point))
713 ;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
715 (defun gnus-uu-decode-postscript (&optional n)
716 "Gets postscript of the current article."
718 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
720 (defun gnus-uu-decode-postscript-view (&optional n)
721 "Gets and views the current article."
723 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
724 (gnus-uu-decode-postscript n)))
726 (defun gnus-uu-decode-postscript-and-save (n dir)
727 "Extracts postscript and saves the current article."
729 (list current-prefix-arg
730 (file-name-as-directory
731 (read-file-name "Save in dir: "
733 gnus-uu-default-dir t))))
734 (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
737 (defun gnus-uu-decode-postscript-and-save-view (n dir)
738 "Decodes, views and saves the resulting file."
740 (list current-prefix-arg
741 (read-file-name "Where do you want to save the file(s)? "
743 gnus-uu-default-dir t)))
744 (let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
745 (gnus-uu-decode-postscript-and-save n dir)))
748 ;; Internal functions.
750 (defun gnus-uu-decode-with-method (method n &optional save not-insert
752 (gnus-uu-initialize scan)
754 (setq gnus-uu-default-dir save))
755 ;; Create the directory we save to.
756 (when (and scan cdir save
757 (not (file-exists-p save)))
758 (make-directory save t))
759 (let ((articles (gnus-uu-get-list-of-articles n))
761 (setq files (gnus-uu-grab-articles articles method t))
762 (let ((gnus-current-article (car articles)))
764 (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
766 (gnus-uu-save-files files save))
767 (when (eq gnus-uu-do-not-unpack-archives nil)
768 (setq files (gnus-uu-unpack-files files)))
769 (setq files (nreverse (gnus-uu-get-actions files)))
770 (or not-insert (not gnus-insert-pseudo-articles)
771 (gnus-summary-insert-pseudos files save))))
773 (defun gnus-uu-scan-directory (dir &optional rec)
774 "Return a list of all files under DIR."
775 (let ((files (directory-files dir t))
777 (while (setq file (pop files))
778 (unless (member (file-name-nondirectory file) '("." ".."))
779 (push (list (cons 'name file)
780 (cons 'article gnus-current-article))
782 (when (file-directory-p file)
783 (setq out (nconc (gnus-uu-scan-directory file t) out)))))
788 (defun gnus-uu-save-files (files dir)
790 (let ((len (length files))
791 (reg (concat "^" (regexp-quote gnus-uu-work-dir)))
792 to-file file fromdir)
793 (while (setq file (cdr (assq 'name (pop files))))
794 (when (file-exists-p file)
795 (string-match reg file)
796 (setq fromdir (substring file (match-end 0)))
797 (if (file-directory-p file)
798 (gnus-make-directory (concat dir fromdir))
799 (setq to-file (concat dir fromdir))
800 (when (or (not (file-exists-p to-file))
801 (eq gnus-uu-be-dangerous t)
802 (and gnus-uu-be-dangerous
803 (gnus-y-or-n-p (format "%s exists; overwrite? "
805 (copy-file file to-file t t)))))
806 (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
808 ;; Functions for saving and possibly digesting articles without
811 ;; Function called by gnus-uu-grab-articles to treat each article.
812 (defun gnus-uu-save-article (buffer in-state)
814 (gnus-uu-save-separate-articles
817 (let ((coding-system-for-write mm-text-coding-system))
819 (concat gnus-uu-saved-article-name gnus-current-article)))
820 (cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
821 ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
823 ((eq in-state 'last) (list 'end))
824 (t (list 'middle)))))
825 ((not gnus-uu-save-in-digest)
828 (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
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)))))
835 (let ((header (gnus-summary-article-header)))
836 (push (cons (mail-header-from header)
837 (mail-header-subject header))
838 gnus-uu-digest-from-subject))
839 (let ((name (file-name-nondirectory gnus-uu-saved-article-name))
840 beg subj headers headline sorthead body end-string state)
841 (if (or (eq in-state 'first)
842 (eq in-state 'first-and-last))
844 (setq state (list 'begin))
846 (set-buffer (gnus-get-buffer-create "*gnus-uu-body*"))
849 (set-buffer (gnus-get-buffer-create "*gnus-uu-pre*"))
852 "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
853 (message-make-date) name name))
854 (when (and message-forward-as-mime gnus-uu-digest-buffer)
855 (insert "<#part type=message/rfc822>\nSubject: Topics\n\n"))
856 (insert "Topics:\n")))
857 (when (not (eq in-state 'end))
858 (setq state (list 'middle))))
860 (set-buffer "*gnus-uu-body*")
861 (goto-char (setq beg (point-max)))
865 (let (buffer-read-only)
866 (set-text-properties (point-min) (point-max) nil)
867 ;; These two are necessary for XEmacs 19.12 fascism.
868 (put-text-property (point-min) (point-max) 'invisible nil)
869 (put-text-property (point-min) (point-max) 'intangible nil))
870 (when (and message-forward-as-mime
871 message-forward-show-mml
872 gnus-uu-digest-buffer)
873 (mm-enable-multibyte)
875 (goto-char (point-min))
876 (search-forward "\n\n")
877 (unless (and message-forward-as-mime gnus-uu-digest-buffer)
878 ;; Quote all 30-dash lines.
880 (while (re-search-forward "^-" nil t)
884 (setq body (buffer-substring (1- (point)) (point-max)))
885 (narrow-to-region (point-min) (point))
886 (if (not (setq headers gnus-uu-digest-headers))
887 (setq sorthead (buffer-string))
889 (setq headline (car headers))
890 (setq headers (cdr headers))
891 (goto-char (point-min))
892 (while (re-search-forward headline nil t)
897 (or (and (re-search-forward "^[^ \t]" nil t)
899 (progn (forward-line 1) (point)))))))))
901 (if (and message-forward-as-mime gnus-uu-digest-buffer)
902 (if message-forward-show-mml
904 (insert "\n<#mml type=message/rfc822>\n")
905 (insert sorthead) (goto-char (point-max))
906 (insert body) (goto-char (point-max))
907 (insert "\n<#/mml>\n"))
908 (let ((buf (mml-generate-new-buffer " *mml*")))
909 (with-current-buffer buf
911 (goto-char (point-min))
912 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
913 (setq subj (buffer-substring (match-beginning 1)
915 (goto-char (point-max))
917 (insert "\n<#part type=message/rfc822"
918 " buffer=\"" (buffer-name buf) "\">\n")))
919 (insert sorthead) (goto-char (point-max))
920 (insert body) (goto-char (point-max))
921 (insert (concat "\n" (make-string 30 ?-) "\n\n")))
923 (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
924 (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
927 (set-buffer "*gnus-uu-pre*")
928 (insert (format " %s\n" subj)))))
929 (when (or (eq in-state 'last)
930 (eq in-state 'first-and-last))
931 (if (and message-forward-as-mime gnus-uu-digest-buffer)
932 (with-current-buffer gnus-uu-digest-buffer
934 (insert-buffer-substring "*gnus-uu-pre*")
935 (goto-char (point-max))
936 (insert-buffer-substring "*gnus-uu-body*"))
938 (set-buffer "*gnus-uu-pre*")
939 (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
940 (if gnus-uu-digest-buffer
941 (with-current-buffer gnus-uu-digest-buffer
943 (insert-buffer-substring "*gnus-uu-pre*"))
944 (let ((coding-system-for-write mm-text-coding-system))
945 (gnus-write-buffer gnus-uu-saved-article-name))))
947 (set-buffer "*gnus-uu-body*")
948 (goto-char (point-max))
950 (concat (setq end-string (format "End of %s Digest" name))
952 (insert (concat (make-string (length end-string) ?*) "\n"))
953 (if gnus-uu-digest-buffer
954 (with-current-buffer gnus-uu-digest-buffer
955 (goto-char (point-max))
956 (insert-buffer-substring "*gnus-uu-body*"))
957 (let ((coding-system-for-write mm-text-coding-system)
958 (file-name-coding-system nnmail-pathname-coding-system))
960 (point-min) (point-max) gnus-uu-saved-article-name t)))))
961 (gnus-kill-buffer "*gnus-uu-pre*")
962 (gnus-kill-buffer "*gnus-uu-body*")
964 (if (memq 'begin state)
965 (cons gnus-uu-saved-article-name state)
968 ;; Binhex treatment - not very advanced.
970 (defvar gnus-uu-binhex-body-line
971 "^[^:]...............................................................$")
972 (defvar gnus-uu-binhex-begin-line
973 "^:...............................................................$")
974 (defvar gnus-uu-binhex-end-line
977 (defun gnus-uu-binhex-article (buffer in-state)
978 (let (state start-char)
982 (goto-char (point-min))
983 (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
984 (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
985 (setq state (list 'wrong-type))))
987 (if (memq 'wrong-type state)
990 (setq start-char (point))
991 (if (looking-at gnus-uu-binhex-begin-line)
993 (setq state (list 'begin))
994 (write-region (point-min) (point-min)
995 gnus-uu-binhex-article-name))
996 (setq state (list 'middle)))
997 (goto-char (point-max))
998 (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
999 gnus-uu-binhex-end-line)
1001 (when (looking-at gnus-uu-binhex-end-line)
1002 (setq state (if (memq 'begin state)
1007 (when (file-exists-p gnus-uu-binhex-article-name)
1008 (mm-append-to-file start-char (point) gnus-uu-binhex-article-name))))
1009 (if (memq 'begin state)
1010 (cons gnus-uu-binhex-article-name state)
1015 (defun gnus-uu-decode-postscript-article (process-buffer in-state)
1016 (let ((state (list 'ok))
1017 start-char end-char file-name)
1019 (set-buffer process-buffer)
1020 (goto-char (point-min))
1021 (if (not (re-search-forward gnus-uu-postscript-begin-string nil t))
1022 (setq state (list 'wrong-type))
1024 (setq start-char (point))
1025 (if (not (re-search-forward gnus-uu-postscript-end-string nil t))
1026 (setq state (list 'wrong-type))
1027 (setq end-char (point))
1028 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1029 (insert-buffer-substring process-buffer start-char end-char)
1030 (setq file-name (concat gnus-uu-work-dir
1031 (cdr gnus-article-current) ".ps"))
1032 (write-region (point-min) (point-max) file-name)
1033 (setq state (list file-name 'begin 'end)))))
1039 (defun gnus-uu-get-actions (files)
1040 (let ((ofiles files)
1043 (setq name (cdr (assq 'name (car files))))
1045 (setq action (gnus-uu-get-action name))
1046 (setcar files (nconc (list (if (string= action "gnus-uu-archive")
1047 (cons 'action "file")
1048 (cons 'action action))
1049 (cons 'execute (gnus-uu-command
1052 (setq files (cdr files)))
1055 (defun gnus-uu-get-action (file-name)
1058 (gnus-uu-choose-action
1061 gnus-uu-user-view-rules
1062 (if gnus-uu-ignore-default-view-rules
1064 gnus-uu-default-view-rules)
1065 gnus-uu-user-view-rules-end)))
1066 (when (and (not (string= (or action "") "gnus-uu-archive"))
1067 gnus-uu-view-with-metamail)
1069 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list))
1070 (setq action (format "metamail -d -b -c \"%s\"" action))))
1074 ;; Functions for treating subjects and collecting series.
1076 (defun gnus-uu-reginize-string (string)
1077 ;; Takes a string and puts a \ in front of every special character;
1078 ;; replaces the last thing that looks like "2/3" with "[0-9]+/3"
1079 ;; or, if it can't find something like that, tries "2 of 3", then
1080 ;; finally just replaces the next to last number with "[0-9]+".
1082 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1083 (buffer-disable-undo)
1085 (insert (regexp-quote string))
1087 (setq case-fold-search nil)
1090 (if (re-search-backward "\\([^0-9]\\)[0-9]+/\\([0-9]+\\)" nil t)
1091 (replace-match "\\1[0-9]+/\\2")
1094 (if (re-search-backward "\\([^0-9]\\)[0-9]+[ \t]*of[ \t]*\\([0-9]+\\)"
1096 (replace-match "\\1[0-9]+ of \\2")
1099 (if (re-search-backward "\\([^0-9]\\)[0-9]+\\([^0-9]+\\)[0-9]+"
1101 (replace-match "\\1[0-9]+\\2[0-9]+" t nil nil nil))))
1104 (while (re-search-forward "[ \t]+" nil t)
1105 (replace-match "[ \t]+" t t))
1109 (defun gnus-uu-get-list-of-articles (n)
1110 ;; If N is non-nil, the article numbers of the N next articles
1111 ;; will be returned.
1112 ;; If any articles have been marked as processable, they will be
1114 ;; Failing that, articles that have subjects that are part of the
1115 ;; same "series" as the current will be returned.
1119 (setq n (prefix-numeric-value n))
1120 (let ((backward (< n 0))
1124 (push (gnus-summary-article-number)
1126 (gnus-summary-search-forward nil nil backward))
1128 (nreverse articles)))
1129 (gnus-newsgroup-processable
1130 (reverse gnus-newsgroup-processable))
1132 (gnus-uu-find-articles-matching)))))
1134 (defun gnus-uu-string< (l1 l2)
1135 (string< (car l1) (car l2)))
1137 (defun gnus-uu-find-articles-matching
1138 (&optional subject only-unread do-not-translate)
1139 ;; Finds all articles that matches the regexp SUBJECT. If it is
1140 ;; nil, the current article name will be used. If ONLY-UNREAD is
1141 ;; non-nil, only unread articles are chosen. If DO-NOT-TRANSLATE is
1142 ;; non-nil, article names are not equalized before sorting.
1143 (let ((subject (or subject
1144 (gnus-uu-reginize-string (gnus-summary-article-subject))))
1148 ;; Collect all subjects matching subject.
1149 (let ((case-fold-search t)
1150 (data gnus-newsgroup-data)
1154 (and (not (gnus-data-pseudo-p d))
1155 (or (not only-unread)
1156 (= (setq mark (gnus-data-mark d))
1158 (= mark gnus-ticked-mark)
1159 (= mark gnus-dormant-mark))
1160 (setq subj (mail-header-subject (gnus-data-header d)))
1161 (string-match subject subj)
1162 (push (cons subj (gnus-data-number d))
1163 list-of-subjects))))
1165 ;; Expand numbers, sort, and return the list of article
1168 (sort (gnus-uu-expand-numbers
1170 (not do-not-translate))
1171 'gnus-uu-string<))))))
1173 (defun gnus-uu-expand-numbers (string-list &optional translate)
1174 ;; Takes a list of strings and "expands" all numbers in all the
1175 ;; strings. That is, this function makes all numbers equal length by
1176 ;; prepending lots of zeroes before each number. This is to ease later
1177 ;; sorting to find out what sequence the articles are supposed to be
1178 ;; decoded in. Returns the list of expanded strings.
1179 (let ((out-list string-list)
1182 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1183 (buffer-disable-undo)
1186 (insert (caar string-list))
1187 ;; Translate multiple spaces to one space.
1188 (goto-char (point-min))
1189 (while (re-search-forward "[ \t]+" nil t)
1190 (replace-match " "))
1191 ;; Translate all characters to "a".
1192 (goto-char (point-min))
1194 (while (re-search-forward "[A-Za-z]" nil t)
1195 (replace-match "a" t t)))
1197 (goto-char (point-min))
1198 (while (re-search-forward "[0-9]+" nil t)
1202 (string-to-number (buffer-substring
1203 (match-beginning 0) (match-end 0)))))))
1204 (setq string (buffer-substring 1 (point-max)))
1205 (setcar (car string-list) string)
1206 (setq string-list (cdr string-list))))
1210 ;; `gnus-uu-grab-articles' is the general multi-article treatment
1211 ;; function. It takes a list of articles to be grabbed and a function
1212 ;; to apply to each article.
1214 ;; The function to be called should take two parameters. The first
1215 ;; parameter is the article buffer. The function should leave the
1216 ;; result, if any, in this buffer. Most treatment functions will just
1217 ;; generate files...
1219 ;; The second parameter is the state of the list of articles, and can
1220 ;; have four values: `first', `middle', `last' and `first-and-last'.
1222 ;; The function should return a list. The list may contain the
1223 ;; following symbols:
1224 ;; `error' if an error occurred
1225 ;; `begin' if the beginning of an encoded file has been received
1226 ;; If the list returned contains a `begin', the first element of
1227 ;; the list *must* be a string with the file name of the decoded
1229 ;; `end' if the end of an encoded file has been received
1230 ;; `middle' if the article was a body part of an encoded file
1231 ;; `wrong-type' if the article was not a part of an encoded file
1232 ;; `ok', which can be used everything is ok
1234 (defvar gnus-uu-has-been-grabbed nil)
1236 (defun gnus-uu-unmark-list-of-grabbed (&optional dont-unmark-last-article)
1238 (if (not (and gnus-uu-has-been-grabbed
1239 gnus-uu-unmark-articles-not-decoded))
1241 (when dont-unmark-last-article
1242 (setq art (car gnus-uu-has-been-grabbed))
1243 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1244 (while gnus-uu-has-been-grabbed
1245 (gnus-summary-tick-article (car gnus-uu-has-been-grabbed) t)
1246 (setq gnus-uu-has-been-grabbed (cdr gnus-uu-has-been-grabbed)))
1247 (when dont-unmark-last-article
1248 (setq gnus-uu-has-been-grabbed (list art))))))
1250 ;; This function takes a list of articles and a function to apply to
1251 ;; each article grabbed.
1253 ;; This function returns a list of files decoded if the grabbing and
1254 ;; the process-function has been successful and nil otherwise.
1255 (defun gnus-uu-grab-articles (articles process-function
1256 &optional sloppy limit no-errors)
1257 (let ((state 'first)
1258 (gnus-asynchronous nil)
1259 (gnus-inhibit-treatment t)
1260 has-been-begin article result-file result-files process-state
1261 gnus-summary-display-article-function
1262 gnus-article-prepare-hook gnus-display-mime-function
1263 article-series files)
1265 (while (and articles
1266 (not (memq 'error process-state))
1268 (not (memq 'end process-state))))
1270 (setq article (pop articles))
1271 (when (vectorp (gnus-summary-article-header article))
1272 (push article article-series)
1275 (if (eq state 'first)
1276 (setq state 'first-and-last)
1277 (setq state 'last)))
1279 (let ((part (gnus-uu-part-number article)))
1280 (gnus-message 6 "Getting article %d%s..."
1281 article (if (string= part "") "" (concat ", " part))))
1282 (gnus-summary-display-article article)
1284 ;; Push the article to the processing function.
1286 (set-buffer gnus-original-article-buffer)
1287 (let ((buffer-read-only nil))
1289 (set-buffer gnus-summary-buffer)
1291 (funcall process-function
1292 gnus-original-article-buffer state)))))
1294 (gnus-summary-remove-process-mark article)
1296 ;; If this is the beginning of a decoded file, we push it
1298 (when (or (memq 'begin process-state)
1299 (and (or (eq state 'first)
1300 (eq state 'first-and-last))
1301 (memq 'ok process-state)))
1302 (when has-been-begin
1303 ;; If there is a `result-file' here, that means that the
1304 ;; file was unsuccessfully decoded, so we delete it.
1305 (when (and result-file
1306 (file-exists-p result-file)
1307 (not gnus-uu-be-dangerous)
1308 (or (eq gnus-uu-be-dangerous t)
1310 (format "Delete unsuccessfully decoded file %s? "
1312 (delete-file result-file)))
1313 (when (memq 'begin process-state)
1314 (setq result-file (car process-state)))
1315 (setq has-been-begin t))
1317 ;; Check whether we have decoded one complete file.
1318 (when (memq 'end process-state)
1319 (setq article-series nil)
1320 (setq has-been-begin nil)
1321 (if (stringp result-file)
1322 (setq files (list result-file))
1323 (setq files result-file))
1324 (setq result-file (car files))
1326 (push (list (cons 'name (pop files))
1327 (cons 'article article))
1329 ;; Allow user-defined functions to be run on this file.
1330 (when gnus-uu-grabbed-file-functions
1331 (let ((funcs gnus-uu-grabbed-file-functions))
1332 (unless (listp funcs)
1333 (setq funcs (list funcs)))
1335 (funcall (pop funcs) result-file))))
1336 (setq result-file nil)
1337 ;; Check whether we have decoded enough articles.
1338 (and limit (= (length result-files) limit)
1339 (setq articles nil)))
1341 ;; If this is the last article to be decoded, and
1342 ;; we still haven't reached the end, then we delete
1343 ;; the partially decoded file.
1344 (and (or (eq state 'last) (eq state 'first-and-last))
1345 (not (memq 'end process-state))
1347 (file-exists-p result-file)
1348 (not gnus-uu-be-dangerous)
1349 (or (eq gnus-uu-be-dangerous t)
1351 (format "Delete incomplete file %s? " result-file)))
1352 (delete-file result-file))
1354 ;; If this was a file of the wrong sort, then
1355 (when (and (or (memq 'wrong-type process-state)
1356 (memq 'error process-state))
1357 gnus-uu-unmark-articles-not-decoded)
1358 (gnus-summary-tick-article article t))
1360 ;; Set the new series state.
1361 (if (and (not has-been-begin)
1363 (or (memq 'end process-state)
1364 (memq 'middle process-state)))
1366 (setq process-state (list 'error))
1367 (gnus-message 2 "No begin part at the beginning")
1369 (setq state 'middle))))
1371 ;; When there are no result-files, then something must be wrong.
1375 ((not has-been-begin)
1376 (gnus-message 2 "Wrong type file"))
1377 ((memq 'error process-state)
1378 (gnus-message 2 "An error occurred during decoding"))
1379 ((not (or (memq 'ok process-state)
1380 (memq 'end process-state)))
1381 (gnus-message 2 "End of articles reached before end of file")))
1382 ;; Make unsuccessfully decoded articles unread.
1383 (when gnus-uu-unmark-articles-not-decoded
1384 (while article-series
1385 (gnus-summary-tick-article (pop article-series) t))))
1387 ;; The original article buffer is hosed, shoot it down.
1388 (gnus-kill-buffer gnus-original-article-buffer)
1389 (setq gnus-current-article nil)
1392 (defun gnus-uu-grab-view (file)
1393 "View FILE using the gnus-uu methods."
1394 (let ((action (gnus-uu-get-action file)))
1395 (gnus-execute-command
1396 (if (string-match "%" action)
1397 (format action file)
1398 (concat action " " file))
1399 (eq gnus-view-pseudos 'not-confirm))))
1401 (defun gnus-uu-grab-move (file)
1402 "Move FILE to somewhere."
1403 (when gnus-uu-default-dir
1404 (let ((to-file (concat (file-name-as-directory gnus-uu-default-dir)
1405 (file-name-nondirectory file))))
1406 (rename-file file to-file)
1407 (unless (file-exists-p file)
1408 (make-symbolic-link to-file file)))))
1410 (defun gnus-uu-part-number (article)
1411 (let* ((header (gnus-summary-article-header article))
1412 (subject (and header (mail-header-subject header)))
1415 (while (string-match "[0-9]+/[0-9]+\\|[0-9]+[ \t]+of[ \t]+[0-9]+"
1417 (setq part (match-string 0 subject))
1418 (setq subject (substring subject (match-end 0)))))
1420 (while (string-match "[0-9]+[^0-9]+[0-9]+" subject)
1421 (setq part (match-string 0 subject))
1422 (setq subject (substring subject (match-end 0)))))
1425 (defun gnus-uu-uudecode-sentinel (process event)
1426 (delete-process (get-process process)))
1428 (defun gnus-uu-uustrip-article (process-buffer in-state)
1429 ;; Uudecodes a file asynchronously.
1431 (set-buffer process-buffer)
1432 (let ((state (list 'wrong-type))
1433 process-connection-type case-fold-search buffer-read-only
1435 (goto-char (point-min))
1437 ;; Deal with ^M at the end of the lines.
1438 (when gnus-uu-kill-carriage-return
1440 (while (search-forward "\r" nil t)
1441 (delete-backward-char 1))))
1443 (while (or (re-search-forward gnus-uu-begin-string nil t)
1444 (re-search-forward gnus-uu-body-line nil t))
1445 (setq state (list 'ok))
1446 ;; Ok, we are at the first uucoded line.
1448 (setq start-char (point))
1450 (if (not (looking-at gnus-uu-begin-string))
1451 (setq state (list 'middle))
1452 ;; This is the beginning of a uuencoded article.
1453 ;; We replace certain characters that could make things messy.
1454 (setq gnus-uu-file-name
1456 mm-file-name-rewrite-functions
1457 (file-name-nondirectory (match-string 1))))
1458 (replace-match (concat "begin 644 " gnus-uu-file-name) t t)
1460 ;; Remove any non gnus-uu-body-line right after start.
1462 (while (and (not (eobp))
1463 (not (looking-at gnus-uu-body-line)))
1466 ;; If a process is running, we kill it.
1467 (when (and gnus-uu-uudecode-process
1468 (memq (process-status gnus-uu-uudecode-process)
1470 (delete-process gnus-uu-uudecode-process)
1471 (gnus-uu-unmark-list-of-grabbed t))
1473 ;; Start a new uudecoding process.
1474 (let ((cdir default-directory))
1477 (cd gnus-uu-work-dir)
1478 (setq gnus-uu-uudecode-process
1481 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1482 shell-file-name shell-command-switch
1483 (format "cd %s %s uudecode" gnus-uu-work-dir
1484 gnus-shell-command-separator))))
1486 (set-process-sentinel
1487 gnus-uu-uudecode-process 'gnus-uu-uudecode-sentinel)
1488 (setq state (list 'begin))
1489 (push (concat gnus-uu-work-dir gnus-uu-file-name) files))
1491 ;; We look for the end of the thing to be decoded.
1492 (if (re-search-forward gnus-uu-end-string nil t)
1494 (goto-char (point-max))
1495 (re-search-backward gnus-uu-body-line nil t))
1499 (when gnus-uu-uudecode-process
1500 (when (memq (process-status gnus-uu-uudecode-process) '(run stop))
1501 ;; Try to correct mishandled uucode.
1502 (when gnus-uu-correct-stripped-uucode
1503 (gnus-uu-check-correct-stripped-uucode start-char (point)))
1504 (gnus-run-hooks 'gnus-uu-pre-uudecode-hook)
1506 ;; Send the text to the process.
1508 (process-send-region
1509 gnus-uu-uudecode-process start-char (point))
1512 (delete-process gnus-uu-uudecode-process)
1513 (gnus-message 2 "gnus-uu: Couldn't uudecode")
1514 (setq state (list 'wrong-type)))))
1516 (if (memq 'end state)
1518 ;; Send an EOF, just in case.
1520 (process-send-eof gnus-uu-uudecode-process))
1521 (while (memq (process-status gnus-uu-uudecode-process)
1523 (accept-process-output gnus-uu-uudecode-process 1)))
1524 (when (or (not gnus-uu-uudecode-process)
1525 (not (memq (process-status gnus-uu-uudecode-process)
1527 (setq state (list 'wrong-type)))))))
1529 (if (memq 'begin state)
1530 (cons (if (= (length files) 1) (car files) files) state)
1533 (defvar gnus-uu-unshar-warning
1536 Shell archives are an archaic method of bundling files for distribution
1537 across computer networks. During the unpacking process, arbitrary commands
1538 are executed on your system, and all kinds of nasty things can happen.
1539 Please examine the archive very carefully before you instruct Emacs to
1540 unpack it. You can browse the archive buffer using \\[scroll-other-window].
1542 If you are unsure what to do, please answer \"no\"."
1543 "Text of warning message displayed by `gnus-uu-unshar-article'.
1544 Make sure that this text consists only of few text lines. Otherwise,
1545 Gnus might fail to display all of it.")
1548 ;; This function is used by `gnus-uu-grab-articles' to treat
1549 ;; a shared article.
1550 (defun gnus-uu-unshar-article (process-buffer in-state)
1551 (let ((state (list 'ok))
1554 (set-buffer process-buffer)
1555 (goto-char (point-min))
1556 (if (not (re-search-forward gnus-uu-shar-begin-string nil t))
1557 (setq state (list 'wrong-type))
1558 (save-window-excursion
1560 (switch-to-buffer (current-buffer))
1561 (delete-other-windows)
1562 (let ((buffer (get-buffer-create (generate-new-buffer-name
1566 (with-current-buffer buffer
1567 (insert (substitute-command-keys
1568 gnus-uu-unshar-warning))
1569 (goto-char (point-min))
1570 (display-buffer buffer)
1571 (yes-or-no-p "This is a shell archive, unshar it? "))
1572 (kill-buffer buffer))
1573 (setq state (list 'error))))))
1574 (unless (memq 'error state)
1576 (setq start-char (point))
1577 (call-process-region
1578 start-char (point-max) shell-file-name nil
1579 (gnus-get-buffer-create gnus-uu-output-buffer-name) nil
1580 shell-command-switch
1581 (concat "cd " gnus-uu-work-dir " "
1582 gnus-shell-command-separator " sh")))))
1585 ;; Returns the name of what the shar file is going to unpack.
1586 (defun gnus-uu-find-name-in-shar ()
1587 (let ((oldpoint (point))
1589 (goto-char (point-min))
1590 (when (re-search-forward gnus-uu-shar-name-marker nil t)
1591 (setq res (buffer-substring (match-beginning 1) (match-end 1))))
1592 (goto-char oldpoint)
1595 ;; `gnus-uu-choose-action' chooses what action to perform given the name
1596 ;; and `gnus-uu-file-action-list'. Returns either nil if no action is
1597 ;; found, or the name of the command to run if such a rule is found.
1598 (defun gnus-uu-choose-action (file-name file-action-list &optional no-ignore)
1599 (let ((action-list (copy-sequence file-action-list))
1600 (case-fold-search t)
1605 (and gnus-uu-ignore-files-by-name
1606 (string-match gnus-uu-ignore-files-by-name file-name)))
1608 (and gnus-uu-ignore-files-by-type
1609 (string-match gnus-uu-ignore-files-by-type
1610 (or (gnus-uu-choose-action
1611 file-name gnus-uu-ext-to-mime-list t)
1613 (while (not (or (eq action-list ()) action))
1614 (setq rule (car action-list))
1615 (setq action-list (cdr action-list))
1616 (when (string-match (car rule) file-name)
1617 (setq action (cadr rule)))))
1620 (defun gnus-uu-treat-archive (file-path)
1621 ;; Unpacks an archive. Returns t if unpacking is successful.
1622 (let ((did-unpack t)
1624 (setq action (gnus-uu-choose-action
1625 file-path (append gnus-uu-user-archive-rules
1626 (if gnus-uu-ignore-default-archive-rules
1628 gnus-uu-default-archive-rules))))
1631 (error "No unpackers for the file %s" file-path))
1633 (string-match "/[^/]*$" file-path)
1634 (setq dir (substring file-path 0 (match-beginning 0)))
1636 (when (member action gnus-uu-destructive-archivers)
1637 (copy-file file-path (concat file-path "~") t))
1639 (setq command (format "cd %s ; %s" dir (gnus-uu-command action file-path)))
1642 (set-buffer (gnus-get-buffer-create gnus-uu-output-buffer-name))
1645 (gnus-message 5 "Unpacking: %s..." (gnus-uu-command action file-path))
1647 (if (eq 0 (call-process shell-file-name nil
1648 (gnus-get-buffer-create gnus-uu-output-buffer-name)
1649 nil shell-command-switch command))
1651 (gnus-message 2 "Error during unpacking of archive")
1652 (setq did-unpack nil))
1654 (when (member action gnus-uu-destructive-archivers)
1655 (rename-file (concat file-path "~") file-path t))
1659 (defun gnus-uu-dir-files (dir)
1660 (let ((dirs (directory-files dir t "[^/][^\\.][^\\.]?$"))
1663 (if (file-directory-p (setq file (car dirs)))
1664 (setq files (append files (gnus-uu-dir-files file)))
1666 (setq dirs (cdr dirs)))
1669 (defun gnus-uu-unpack-files (files &optional ignore)
1670 ;; Go through FILES and look for files to unpack.
1671 (let* ((totfiles (gnus-uu-ls-r gnus-uu-work-dir))
1675 (setq file (cdr (assq 'name (car files))))
1676 (when (and (not (member file ignore))
1677 (equal (gnus-uu-get-action (file-name-nondirectory file))
1679 (push file did-unpack)
1680 (unless (gnus-uu-treat-archive file)
1681 (gnus-message 2 "Error during unpacking of %s" file))
1682 (let* ((newfiles (gnus-uu-ls-r gnus-uu-work-dir))
1685 (unless (member (car nfiles) totfiles)
1686 (push (list (cons 'name (car nfiles))
1687 (cons 'original file))
1689 (setq nfiles (cdr nfiles)))
1690 (setq totfiles newfiles)))
1691 (setq files (cdr files)))
1693 (gnus-uu-unpack-files ofiles (append did-unpack ignore))
1696 (defun gnus-uu-ls-r (dir)
1697 (let* ((files (gnus-uu-directory-files dir t))
1700 (when (file-directory-p (car files))
1701 (setq ofiles (delete (car files) ofiles))
1702 (setq ofiles (append ofiles (gnus-uu-ls-r (car files)))))
1703 (setq files (cdr files)))
1708 (defun gnus-uu-directory-files (dir &optional full)
1709 (let (files out file)
1710 (setq files (directory-files dir full))
1712 (setq file (car files))
1713 (setq files (cdr files))
1714 (unless (member (file-name-nondirectory file) '("." ".."))
1716 (setq out (nreverse out))
1719 (defun gnus-uu-check-correct-stripped-uucode (start end)
1721 (let (found beg length)
1722 (unless gnus-uu-correct-stripped-uucode
1725 (if (re-search-forward " \\|`" end t)
1730 (when (looking-at "\n")
1735 (unless (looking-at (concat gnus-uu-begin-string "\\|"
1736 gnus-uu-end-string))
1738 (setq length (- (point-at-eol) (point-at-bol))))
1743 (unless (= length (- (point) beg))
1744 (insert (make-string (- length (- (point) beg)) ? ))))
1745 (forward-line 1)))))))
1747 (defvar gnus-uu-tmp-alist nil)
1749 (defun gnus-uu-initialize (&optional scan)
1752 (when (setq entry (assoc gnus-newsgroup-name gnus-uu-tmp-alist))
1753 (if (file-exists-p (cdr entry))
1754 (setq gnus-uu-work-dir (cdr entry))
1755 (setq gnus-uu-tmp-alist (delq entry gnus-uu-tmp-alist))
1758 (setq gnus-uu-tmp-dir (file-name-as-directory
1759 (expand-file-name gnus-uu-tmp-dir)))
1760 (if (not (file-directory-p gnus-uu-tmp-dir))
1761 (error "Temp directory %s doesn't exist" gnus-uu-tmp-dir)
1762 (when (not (file-writable-p gnus-uu-tmp-dir))
1763 (error "Temp directory %s can't be written to"
1766 (setq gnus-uu-work-dir
1767 (mm-make-temp-file (concat gnus-uu-tmp-dir "gnus") 'dir))
1768 (gnus-set-file-modes gnus-uu-work-dir 448)
1769 (setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
1770 (push (cons gnus-newsgroup-name gnus-uu-work-dir)
1771 gnus-uu-tmp-alist))))
1774 ;; Kills the temporary uu buffers, kills any processes, etc.
1775 (defun gnus-uu-clean-up ()
1777 (and gnus-uu-uudecode-process
1778 (memq (process-status (or gnus-uu-uudecode-process "nevair"))
1780 (delete-process gnus-uu-uudecode-process))
1781 (when (setq buf (get-buffer gnus-uu-output-buffer-name))
1782 (kill-buffer buf))))
1784 ;; Inputs an action and a filename and returns a full command, making sure
1785 ;; that the filename will be treated as a single argument when the shell
1786 ;; executes the command.
1787 (defun gnus-uu-command (action file)
1788 (let ((quoted-file (shell-quote-argument file)))
1789 (if (string-match "%s" action)
1790 (format action quoted-file)
1791 (concat action " " quoted-file))))
1793 (defun gnus-uu-delete-work-dir (&optional dir)
1794 "Delete recursively all files and directories under `gnus-uu-work-dir'."
1796 (gnus-message 7 "Deleting directory %s..." dir)
1797 (setq dir gnus-uu-work-dir))
1799 (file-exists-p dir))
1800 (let ((files (directory-files dir t nil t))
1802 (while (setq file (pop files))
1803 (unless (member (file-name-nondirectory file) '("." ".."))
1804 (if (file-directory-p file)
1805 (gnus-uu-delete-work-dir file)
1806 (gnus-message 9 "Deleting file %s..." file)
1809 (error (gnus-message 3 "Deleting file %s failed... %s" file err))))))
1811 (delete-directory dir)
1812 (error (gnus-message 3 "Deleting directory %s failed... %s" file err))))
1813 (gnus-message 7 "")))
1817 (add-hook 'gnus-exit-group-hook 'gnus-uu-clean-up)
1818 (add-hook 'gnus-exit-group-hook 'gnus-uu-delete-work-dir)
1823 ;;; uuencoded posting
1826 ;; Any function that is to be used as and encoding method will take two
1827 ;; parameters: PATH-NAME and FILE-NAME. (E.g. "/home/gaga/spiral.jpg"
1828 ;; and "spiral.jpg", respectively.) The function should return nil if
1829 ;; the encoding wasn't successful.
1830 (defcustom gnus-uu-post-encode-method 'gnus-uu-post-encode-uuencode
1831 "Function used for encoding binary files.
1832 There are three functions supplied with gnus-uu for encoding files:
1833 `gnus-uu-post-encode-uuencode', which does straight uuencoding;
1834 `gnus-uu-post-encode-mime', which encodes with base64 and adds MIME
1835 headers; and `gnus-uu-post-encode-mime-uuencode', which encodes with
1836 uuencode and adds MIME headers."
1837 :group 'gnus-extract-post
1838 :type '(radio (function-item gnus-uu-post-encode-uuencode)
1839 (function-item gnus-uu-post-encode-mime)
1840 (function-item gnus-uu-post-encode-mime-uuencode)
1841 (function :tag "Other")))
1843 (defcustom gnus-uu-post-include-before-composing nil
1844 "Non-nil means that gnus-uu will ask for a file to encode before you compose the article.
1845 If this variable is t, you can either include an encoded file with
1846 \\[gnus-uu-post-insert-binary-in-article] or have one included for you when you post the article."
1847 :group 'gnus-extract-post
1850 (defcustom gnus-uu-post-length 990
1851 "Maximum length of an article.
1852 The encoded file will be split into how many articles it takes to
1853 post the entire file."
1854 :group 'gnus-extract-post
1857 (defcustom gnus-uu-post-threaded nil
1858 "Non-nil means that gnus-uu will post the encoded file in a thread.
1859 This may not be smart, as no other decoder I have seen are able to
1860 follow threads when collecting uuencoded articles. (Well, I have seen
1861 one package that does that - gnus-uu, but somehow, I don't think that
1862 counts...) The default is nil."
1863 :group 'gnus-extract-post
1866 (defcustom gnus-uu-post-separate-description t
1867 "Non-nil means that the description will be posted in a separate article.
1868 The first article will typically be numbered (0/x). If this variable
1869 is nil, the description the user enters will be included at the
1870 beginning of the first article, which will be numbered (1/x). Default
1872 :group 'gnus-extract-post
1875 (defvar gnus-uu-post-binary-separator "--binary follows this line--")
1876 (defvar gnus-uu-post-message-id nil)
1877 (defvar gnus-uu-post-inserted-file-name nil)
1878 (defvar gnus-uu-winconf-post-news nil)
1880 (defun gnus-uu-post-news ()
1881 "Compose an article and post an encoded file."
1883 (setq gnus-uu-post-inserted-file-name nil)
1884 (setq gnus-uu-winconf-post-news (current-window-configuration))
1886 (gnus-summary-post-news)
1888 (let ((map (make-sparse-keymap)))
1889 (set-keymap-parent map (current-local-map))
1890 (use-local-map map))
1891 ;;(local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
1892 (local-set-key "\C-c\C-c" 'gnus-uu-post-news-inews)
1893 (local-set-key "\C-c\C-s" 'gnus-uu-post-news-inews)
1894 (local-set-key "\C-c\C-i" 'gnus-uu-post-insert-binary-in-article)
1896 (when gnus-uu-post-include-before-composing
1897 (save-excursion (setq gnus-uu-post-inserted-file-name
1898 (gnus-uu-post-insert-binary)))))
1900 (defun gnus-uu-post-insert-binary-in-article ()
1901 "Inserts an encoded file in the buffer.
1902 The user will be asked for a file name."
1905 (setq gnus-uu-post-inserted-file-name (gnus-uu-post-insert-binary))))
1907 ;; Encodes with uuencode and substitutes all spaces with backticks.
1908 (defun gnus-uu-post-encode-uuencode (path file-name)
1909 (when (gnus-uu-post-encode-file "uuencode" path file-name)
1910 (goto-char (point-min))
1912 (while (search-forward " " nil t)
1913 (replace-match "`"))
1916 ;; Encodes with uuencode and adds MIME headers.
1917 (defun gnus-uu-post-encode-mime-uuencode (path file-name)
1918 (when (gnus-uu-post-encode-uuencode path file-name)
1919 (gnus-uu-post-make-mime file-name "x-uue")
1922 ;; Encodes with base64 and adds MIME headers
1923 (defun gnus-uu-post-encode-mime (path file-name)
1924 (when (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1925 (format "%s %s -o %s" "mmencode" path file-name)))
1926 (gnus-uu-post-make-mime file-name "base64")
1929 ;; Adds MIME headers.
1930 (defun gnus-uu-post-make-mime (file-name encoding)
1931 (goto-char (point-min))
1932 (insert (format "Content-Type: %s; name=\"%s\"\n"
1933 (gnus-uu-choose-action file-name gnus-uu-ext-to-mime-list)
1935 (insert (format "Content-Transfer-Encoding: %s\n\n" encoding))
1937 (set-buffer gnus-message-buffer)
1938 (goto-char (point-min))
1939 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
1941 (narrow-to-region (point-min) (point))
1942 (unless (mail-fetch-field "mime-version")
1944 (insert "MIME-Version: 1.0\n"))
1947 ;; Encodes a file PATH with COMMAND, leaving the result in the
1949 (defun gnus-uu-post-encode-file (command path file-name)
1950 (eq 0 (call-process shell-file-name nil t nil shell-command-switch
1951 (format "%s %s %s" command path file-name))))
1953 (defun gnus-uu-post-news-inews ()
1954 "Posts the composed news article and encoded file.
1955 If no file has been included, the user will be asked for a file."
1960 (if gnus-uu-post-inserted-file-name
1961 (setq file-name gnus-uu-post-inserted-file-name)
1962 (setq file-name (gnus-uu-post-insert-binary)))
1964 (gnus-uu-post-encoded file-name gnus-uu-post-threaded))
1965 (setq gnus-uu-post-inserted-file-name nil)
1966 (when gnus-uu-winconf-post-news
1967 (set-window-configuration gnus-uu-winconf-post-news)))
1969 ;; Asks for a file to encode, encodes it and inserts the result in
1970 ;; the current buffer. Returns the file name the user gave.
1971 (defun gnus-uu-post-insert-binary ()
1972 (let ((uuencode-buffer-name "*uuencode buffer*")
1973 file-path uubuf file-name)
1975 (setq file-path (read-file-name
1976 "What file do you want to encode? "))
1977 (when (not (file-exists-p file-path))
1978 (error "%s: No such file" file-path))
1980 (goto-char (point-max))
1981 (insert (format "\n%s\n" gnus-uu-post-binary-separator))
1983 ;; #### Unix-specific?
1984 (when (string-match "^~/" file-path)
1985 (setq file-path (concat "$HOME" (substring file-path 1))))
1986 ;; #### Unix-specific?
1987 (if (string-match "/[^/]*$" file-path)
1988 (setq file-name (substring file-path (1+ (match-beginning 0))))
1989 (setq file-name file-path))
1993 (set-buffer (setq uubuf
1994 (gnus-get-buffer-create uuencode-buffer-name)))
1996 (funcall gnus-uu-post-encode-method file-path file-name))
1997 (insert-buffer-substring uubuf)
1998 (error "Encoding unsuccessful"))
1999 (kill-buffer uubuf))
2002 ;; Posts the article and all of the encoded file.
2003 (defun gnus-uu-post-encoded (file-name &optional threaded)
2004 (let ((send-buffer-name "*uuencode send buffer*")
2005 (encoded-buffer-name "*encoded buffer*")
2006 (top-string "[ cut here %s (%s %d/%d) %s gnus-uu ]")
2007 (separator (concat mail-header-separator "\n\n"))
2008 uubuf length parts header i end beg
2009 beg-line minlen post-buf whole-len beg-binary end-binary)
2011 (setq post-buf (current-buffer))
2013 (goto-char (point-min))
2014 (when (not (re-search-forward
2015 (if gnus-uu-post-separate-description
2016 (concat "^" (regexp-quote gnus-uu-post-binary-separator)
2018 (concat "^" (regexp-quote mail-header-separator) "$"))
2020 (error "Internal error: No binary/header separator"))
2023 (setq beg-binary (point))
2024 (setq end-binary (point-max))
2027 (set-buffer (setq uubuf (gnus-get-buffer-create encoded-buffer-name)))
2029 (insert-buffer-substring post-buf beg-binary end-binary)
2030 (goto-char (point-min))
2031 (setq length (count-lines (point-min) (point-max)))
2032 (setq parts (/ length gnus-uu-post-length))
2033 (unless (< (% length gnus-uu-post-length) 4)
2036 (when gnus-uu-post-separate-description
2038 (delete-region (point) (point-max))
2040 (goto-char (point-min))
2042 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2043 (setq header (buffer-substring (point-min) (point-at-bol)))
2045 (goto-char (point-min))
2046 (when gnus-uu-post-separate-description
2047 (when (re-search-forward "^Subject: " nil t)
2049 (insert (format " (0/%d)" parts)))
2052 (setq gnus-uu-post-message-id (message-fetch-field "message-id")))
2057 (while (not (> i parts))
2058 (set-buffer (gnus-get-buffer-create send-buffer-name))
2061 (when (and threaded gnus-uu-post-message-id)
2062 (insert "References: " gnus-uu-post-message-id "\n"))
2065 (- 62 (length (format top-string "" file-name i parts ""))))
2066 (when (> 1 (setq minlen (/ whole-len 2)))
2071 (make-string minlen ?-)
2074 (if (= 0 (% whole-len 2)) (1- minlen) minlen) ?-)))
2076 (goto-char (point-min))
2077 (when (re-search-forward "^Subject: " nil t)
2079 (insert (format " (%d/%d)" i parts)))
2081 (goto-char (point-max))
2086 (goto-char (point-max))
2087 (forward-line gnus-uu-post-length))
2088 (when (and (= (1+ i) parts) (< (count-lines (point) (point-max)) 4))
2091 (insert-buffer-substring uubuf beg end)
2092 (insert beg-line "\n")
2095 (goto-char (point-min))
2097 (concat "^" (regexp-quote mail-header-separator) "$") nil t)
2100 (when (re-search-forward
2101 (concat "^" (regexp-quote gnus-uu-post-binary-separator) "$")
2107 (let (message-sent-message-via)
2110 (setq gnus-uu-post-message-id
2111 (concat (message-fetch-field "references") " "
2112 (message-fetch-field "message-id"))))))
2114 (gnus-kill-buffer send-buffer-name)
2115 (gnus-kill-buffer encoded-buffer-name)
2117 (when (not gnus-uu-post-separate-description)
2118 (set-buffer-modified-p nil)
2123 ;;; arch-tag: 05312384-0a83-4720-9a58-b3160b888853
2124 ;;; gnus-uu.el ends here