;;; gnus-uu.el --- extract (uu)encoded files in Gnus
-;; Copyright (C) 1985,86,87,93,94,95,96 Free Software Foundation, Inc.
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Copyright (C) 1985-1987, 1993-1998, 2000-2016 Free Software
+;; Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Created: 2 Oct 1993
;; Keyword: news
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
-;;; Code:
+;;; Code:
+
+(eval-when-compile (require 'cl))
(require 'gnus)
+(require 'gnus-art)
+(require 'message)
(require 'gnus-msg)
-(eval-when-compile (require 'cl))
+(require 'mm-decode)
+(require 'yenc)
+
+(defgroup gnus-extract nil
+ "Extracting encoded files."
+ :prefix "gnus-uu-"
+ :group 'gnus)
+
+(defgroup gnus-extract-view nil
+ "Viewing extracted files."
+ :group 'gnus-extract)
+
+(defgroup gnus-extract-archive nil
+ "Extracting encoded archives."
+ :group 'gnus-extract)
+
+(defgroup gnus-extract-post nil
+ "Extracting encoded archives."
+ :prefix "gnus-uu-post"
+ :group 'gnus-extract)
;; Default viewing action rules
-(defvar gnus-uu-default-view-rules
- '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed s/\r//g")
- ("\\.pas$" "cat %s | sed s/\r//g")
+(defcustom gnus-uu-default-view-rules
+ '(("\\.te?xt$\\|\\.doc$\\|read.*me\\|\\.c?$\\|\\.h$\\|\\.bat$\\|\\.asm$\\|makefile" "cat %s | sed 's/\r$//'")
+ ("\\.pas$" "cat %s | sed 's/\r$//'")
("\\.[1-9]$" "groff -mandoc -Tascii %s | sed s/\b.//g")
- ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "xv")
- ("\\.tga$" "tgatoppm %s | xv -")
- ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
+ ("\\.\\(jpe?g\\|gif\\|tiff?\\|p[pgb]m\\|xwd\\|xbm\\|pcx\\)$" "display")
+ ("\\.tga$" "tgatoppm %s | ee -")
+ ("\\.\\(wav\\|aiff\\|hcom\\|u[blw]\\|s[bfw]\\|voc\\|smp\\)$"
"sox -v .5 %s -t .au -u - > /dev/audio")
("\\.au$" "cat %s > /dev/audio")
("\\.midi?$" "playmidi -f")
("\\.html$" "xmosaic")
("\\.mpe?g$" "mpeg_play")
("\\.\\(flc\\|fli\\|rle\\|iff\\|pfx\\|avi\\|sme\\|rpza\\|dl\\|qt\\|rsrc\\|mov\\)$" "xanim")
- ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
+ ("\\.\\(tar\\|arj\\|zip\\|zoo\\|arc\\|gz\\|Z\\|lzh\\|ar\\|lha\\)$"
"gnus-uu-archive"))
- "*Default actions to be taken when the user asks to view a file.
-To change the behaviour, you can either edit this variable or set
+ "*Default actions to be taken when the user asks to view a file.
+To change the behavior, you can either edit this variable or set
`gnus-uu-user-view-rules' to something useful.
For example:
-To make gnus-uu use 'xli' to display JPEG and GIF files, put the
+To make gnus-uu use `xli' to display JPEG and GIF files, put the
following in your .emacs file:
- (setq gnus-uu-user-view-rules '((\"jpg$\\\\|gif$\" \"xli\")))
+ (setq gnus-uu-user-view-rules \\='((\"jpg$\\\\|gif$\" \"xli\")))
-Both these variables are lists of lists with two string elements. The
-first string is a regular expression. If the file name matches this
+Both these variables are lists of lists with two string elements. The
+first string is a regular expression. If the file name matches this
regular expression, the command in the second string is executed with
the file as an argument.
If the command string contains \"%s\", the file name will be inserted
-at that point in the command string. If there's no \"%s\" in the
+at that point in the command string. If there's no \"%s\" in the
command string, the file name will be appended to the command string
before executing.
-There are several user variables to tailor the behaviour of gnus-uu to
-your needs. First we have `gnus-uu-user-view-rules', which is the
+There are several user variables to tailor the behavior of gnus-uu to
+your needs. First we have `gnus-uu-user-view-rules', which is the
variable gnus-uu first consults when trying to decide how to view a
-file. If this variable contains no matches, gnus-uu examines the
-default rule variable provided in this package. If gnus-uu finds no
+file. If this variable contains no matches, gnus-uu examines the
+default rule variable provided in this package. If gnus-uu finds no
match here, it uses `gnus-uu-user-view-rules-end' to try to make a
-match.")
-
-(defvar gnus-uu-user-view-rules nil
- "*Variable detailing what actions are to be taken to view a file.
-See the documentation on the `gnus-uu-default-view-rules' variable for
-details.")
-
-(defvar gnus-uu-user-view-rules-end
+match."
+ :group 'gnus-extract-view
+ :type '(repeat (group regexp (string :tag "Command"))))
+
+(defcustom gnus-uu-user-view-rules nil
+ "What actions are to be taken to view a file.
+See the documentation on the `gnus-uu-default-view-rules' variable for
+details."
+ :group 'gnus-extract-view
+ :type '(repeat (group regexp (string :tag "Command"))))
+
+(defcustom gnus-uu-user-view-rules-end
'(("" "file"))
- "*Variable saying what actions are to be taken if no rule matched the file name.
-See the documentation on the `gnus-uu-default-view-rules' variable for
-details.")
+ "*What actions are to be taken if no rule matched the file name.
+See the documentation on the `gnus-uu-default-view-rules' variable for
+details."
+ :group 'gnus-extract-view
+ :type '(repeat (group regexp (string :tag "Command"))))
;; Default unpacking commands
-(defvar gnus-uu-default-archive-rules
+(defcustom gnus-uu-default-archive-rules
'(("\\.tar$" "tar xf")
("\\.zip$" "unzip -o")
("\\.ar$" "ar x")
("\\.\\(lzh\\|lha\\)$" "lha x")
("\\.Z$" "uncompress")
("\\.gz$" "gunzip")
- ("\\.arc$" "arc -x")))
+ ("\\.arc$" "arc -x"))
+ "*See `gnus-uu-user-archive-rules'."
+ :group 'gnus-extract-archive
+ :type '(repeat (group regexp (string :tag "Command"))))
-(defvar gnus-uu-destructive-archivers
+(defvar gnus-uu-destructive-archivers
(list "uncompress" "gunzip"))
-(defvar gnus-uu-user-archive-rules nil
- "*A list that can be set to override the default archive unpacking commands.
-To use, for instance, 'untar' to unpack tar files and 'zip -x' to
+(defcustom gnus-uu-user-archive-rules nil
+ "A list that can be set to override the default archive unpacking commands.
+To use, for instance, `untar' to unpack tar files and `zip -x' to
unpack zip files, say the following:
- (setq gnus-uu-user-archive-rules
- '((\"\\\\.tar$\" \"untar\")
- (\"\\\\.zip$\" \"zip -x\")))")
+ (setq gnus-uu-user-archive-rules
+ \\='((\"\\\\.tar$\" \"untar\")
+ (\"\\\\.zip$\" \"zip -x\")))"
+ :group 'gnus-extract-archive
+ :type '(repeat (group regexp (string :tag "Command"))))
-(defvar gnus-uu-ignore-files-by-name nil
+(defcustom gnus-uu-ignore-files-by-name nil
"*A regular expression saying what files should not be viewed based on name.
-If, for instance, you want gnus-uu to ignore all .au and .wav files,
+If, for instance, you want gnus-uu to ignore all .au and .wav files,
you could say something like
(setq gnus-uu-ignore-files-by-name \"\\\\.au$\\\\|\\\\.wav$\")
Note that this variable can be used in conjunction with the
-`gnus-uu-ignore-files-by-type' variable.")
+`gnus-uu-ignore-files-by-type' variable."
+ :group 'gnus-extract
+ :type '(choice (const :tag "off" nil)
+ (regexp :format "%v")))
-(defvar gnus-uu-ignore-files-by-type nil
+(defcustom gnus-uu-ignore-files-by-type nil
"*A regular expression saying what files that shouldn't be viewed, based on MIME file type.
-If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
+If, for instance, you want gnus-uu to ignore all audio files and all mpegs,
you could say something like
(setq gnus-uu-ignore-files-by-type \"audio/\\\\|video/mpeg\")
Note that this variable can be used in conjunction with the
-`gnus-uu-ignore-files-by-name' variable.")
+`gnus-uu-ignore-files-by-name' variable."
+ :group 'gnus-extract
+ :type '(choice (const :tag "off" nil)
+ (regexp :format "%v")))
;; Pseudo-MIME support
("\\.rsrc$" "video/rsrc")
("\\..*$" "unknown/unknown")))
-;; Various variables users may set
+;; Various variables users may set
-(defvar gnus-uu-tmp-dir "/tmp/"
+(defcustom gnus-uu-tmp-dir
+ (cond ((fboundp 'temp-directory) (temp-directory))
+ ((boundp 'temporary-file-directory) temporary-file-directory)
+ ("/tmp/"))
"*Variable saying where gnus-uu is to do its work.
-Default is \"/tmp/\".")
+Default is \"/tmp/\"."
+ :group 'gnus-extract
+ :type 'directory)
-(defvar gnus-uu-do-not-unpack-archives nil
- "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
-Default is nil.")
+(defcustom gnus-uu-do-not-unpack-archives nil
+ "*Non-nil means that gnus-uu won't peek inside archives looking for files to display.
+Default is nil."
+ :group 'gnus-extract-archive
+ :type 'boolean)
-(defvar gnus-uu-view-and-save nil
- "*Non-nil means that the user will always be asked to save a file after viewing it.
-If the variable is nil, the user will only be asked to save if the
-viewing is unsuccessful. Default is nil.")
-
-(defvar gnus-uu-ignore-default-view-rules nil
+(defcustom gnus-uu-ignore-default-view-rules nil
"*Non-nil means that gnus-uu will ignore the default viewing rules.
-Only the user viewing rules will be consulted. Default is nil.")
+Only the user viewing rules will be consulted. Default is nil."
+ :group 'gnus-extract-view
+ :type 'boolean)
-(defvar gnus-uu-grabbed-file-functions nil
- "*Functions run on each file after successful decoding.
+(defcustom gnus-uu-grabbed-file-functions nil
+ "Functions run on each file after successful decoding.
They will be called with the name of the file as the argument.
-Likely functions you can use in this list are `gnus-uu-grab-view'
-and `gnus-uu-grab-move'.")
-
-(defvar gnus-uu-ignore-default-archive-rules nil
- "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
-Only the user unpacking commands will be consulted. Default is nil.")
-
-(defvar gnus-uu-kill-carriage-return t
+Likely functions you can use in this list are `gnus-uu-grab-view'
+and `gnus-uu-grab-move'."
+ :group 'gnus-extract
+ :options '(gnus-uu-grab-view gnus-uu-grab-move)
+ :type 'hook)
+
+(defcustom gnus-uu-ignore-default-archive-rules nil
+ "*Non-nil means that gnus-uu will ignore the default archive unpacking commands.
+Only the user unpacking commands will be consulted. Default is nil."
+ :group 'gnus-extract-archive
+ :type 'boolean)
+
+(defcustom gnus-uu-kill-carriage-return t
"*Non-nil means that gnus-uu will strip all carriage returns from articles.
-Default is t.")
+Default is t."
+ :group 'gnus-extract
+ :type 'boolean)
-(defvar gnus-uu-view-with-metamail nil
+(defcustom gnus-uu-view-with-metamail nil
"*Non-nil means that files will be viewed with metamail.
The gnus-uu viewing functions will be ignored and gnus-uu will try
-to guess at a content-type based on file name suffixes. Default
-it nil.")
-
-(defvar gnus-uu-unmark-articles-not-decoded nil
- "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
-Default is nil.")
-
-(defvar gnus-uu-correct-stripped-uucode nil
- "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
-Default is nil.")
-
-(defvar gnus-uu-save-in-digest nil
+to guess at a content-type based on file name suffixes. Default
+it nil."
+ :group 'gnus-extract
+ :type 'boolean)
+
+(defcustom gnus-uu-unmark-articles-not-decoded nil
+ "*Non-nil means that gnus-uu will mark articles that were unsuccessfully decoded as unread.
+Default is nil."
+ :group 'gnus-extract
+ :type 'boolean)
+
+(defcustom gnus-uu-correct-stripped-uucode nil
+ "*Non-nil means that gnus-uu will *try* to fix uuencoded files that have had trailing spaces deleted.
+Default is nil."
+ :group 'gnus-extract
+ :type 'boolean)
+
+(defcustom gnus-uu-save-in-digest nil
"*Non-nil means that gnus-uu, when asked to save without decoding, will save in digests.
-If this variable is nil, gnus-uu will just save everything in a
-file without any embellishments. The digesting almost conforms to RFC1153 -
-no easy way to specify any meaningful volume and issue numbers were found,
-so I simply dropped them.")
-
-(defvar gnus-uu-digest-headers
+If this variable is nil, gnus-uu will just save everything in a
+file without any embellishments. The digesting almost conforms to RFC1153 -
+no easy way to specify any meaningful volume and issue numbers were found,
+so I simply dropped them."
+ :group 'gnus-extract
+ :type 'boolean)
+
+(defcustom gnus-uu-pre-uudecode-hook nil
+ "Hook run before sending a message to uudecode."
+ :group 'gnus-extract
+ :type 'hook)
+
+(defcustom gnus-uu-digest-headers
'("^Date:" "^From:" "^To:" "^Cc:" "^Subject:" "^Message-ID:" "^Keywords:"
- "^Summary:" "^References:")
+ "^Summary:" "^References:" "^Content-Type:" "^Content-Transfer-Encoding:"
+ "^MIME-Version:" "^Content-Disposition:" "^Content-Description:"
+ "^Content-ID:")
"*List of regexps to match headers included in digested messages.
-The headers will be included in the sequence they are matched.")
-
-(defvar gnus-uu-save-separate-articles nil
- "*Non-nil means that gnus-uu will save articles in separate files.")
+The headers will be included in the sequence they are matched. If nil
+include all headers."
+ :group 'gnus-extract
+ :type '(repeat regexp))
+
+(defcustom gnus-uu-save-separate-articles nil
+ "*Non-nil means that gnus-uu will save articles in separate files."
+ :group 'gnus-extract
+ :type 'boolean)
+
+(defcustom gnus-uu-be-dangerous 'ask
+ "*Specifies what to do if unusual situations arise during decoding.
+If nil, be as conservative as possible. If t, ignore things that
+didn't work, and overwrite existing files. Otherwise, ask each time."
+ :group 'gnus-extract
+ :type '(choice (const :tag "conservative" nil)
+ (const :tag "ask" ask)
+ (const :tag "liberal" t)))
;; Internal variables
(defvar gnus-uu-saved-article-name nil)
-(defconst gnus-uu-begin-string "^begin[ \t]+[0-7][0-7][0-7][ \t]+\\(.*\\)$")
-(defconst gnus-uu-end-string "^end[ \t]*$")
+(defvar gnus-uu-begin-string "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+\\(.*\\)$")
+(defvar gnus-uu-end-string "^end[ \t]*$")
-(defconst gnus-uu-body-line "^M")
+(defvar gnus-uu-body-line "^M")
(let ((i 61))
(while (> (setq i (1- i)) 0)
(setq gnus-uu-body-line (concat gnus-uu-body-line "[^a-z]")))
;"^M.............................................................?$"
-(defconst gnus-uu-shar-begin-string "^#! */bin/sh")
+(defvar gnus-uu-shar-begin-string "^#! */bin/sh")
-(defvar gnus-uu-shar-file-name nil)
-(defconst gnus-uu-shar-name-marker "begin [0-7][0-7][0-7][ \t]+\\(\\(\\w\\|\\.\\)*\\b\\)")
+(defvar gnus-uu-shar-name-marker
+ "begin 0?[0-7][0-7][0-7][ \t]+\\(\\(\\w\\|[.\\:]\\)*\\b\\)")
-(defconst gnus-uu-postscript-begin-string "^%!PS-")
-(defconst gnus-uu-postscript-end-string "^%%EOF$")
+(defvar gnus-uu-postscript-begin-string "^%!PS-")
+(defvar gnus-uu-postscript-end-string "^%%EOF$")
(defvar gnus-uu-file-name nil)
-(defconst gnus-uu-uudecode-process nil)
+(defvar gnus-uu-uudecode-process nil)
(defvar gnus-uu-binhex-article-name nil)
+(defvar gnus-uu-yenc-article-name nil)
-(defvar gnus-uu-generated-file-list nil)
(defvar gnus-uu-work-dir nil)
-(defconst gnus-uu-output-buffer-name " *Gnus UU Output*")
+(defvar gnus-uu-output-buffer-name " *Gnus UU Output*")
(defvar gnus-uu-default-dir gnus-article-save-directory)
(defvar gnus-uu-digest-from-subject nil)
-
-;; Keymaps
-
-(gnus-define-keys
- (gnus-uu-mark-map "P" gnus-summary-mark-map)
- "p" gnus-summary-mark-as-processable
- "u" gnus-summary-unmark-as-processable
- "U" gnus-summary-unmark-all-processable
- "v" gnus-uu-mark-over
- "s" gnus-uu-mark-series
- "r" gnus-uu-mark-region
- "R" gnus-uu-mark-by-regexp
- "t" gnus-uu-mark-thread
- "T" gnus-uu-unmark-thread
- "a" gnus-uu-mark-all
- "b" gnus-uu-mark-buffer
- "S" gnus-uu-mark-sparse)
-
-(gnus-define-keys
- (gnus-uu-extract-map "X" gnus-summary-mode-map)
- ;;"x" gnus-uu-extract-any
- ;;"m" gnus-uu-extract-mime
- "u" gnus-uu-decode-uu
- "U" gnus-uu-decode-uu-and-save
- "s" gnus-uu-decode-unshar
- "S" gnus-uu-decode-unshar-and-save
- "o" gnus-uu-decode-save
- "O" gnus-uu-decode-save
- "b" gnus-uu-decode-binhex
- "B" gnus-uu-decode-binhex
- "p" gnus-uu-decode-postscript
- "P" gnus-uu-decode-postscript-and-save)
-
-(gnus-define-keys
- (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
- "u" gnus-uu-decode-uu-view
- "U" gnus-uu-decode-uu-and-save-view
- "s" gnus-uu-decode-unshar-view
- "S" gnus-uu-decode-unshar-and-save-view
- "o" gnus-uu-decode-save-view
- "O" gnus-uu-decode-save-view
- "b" gnus-uu-decode-binhex-view
- "B" gnus-uu-decode-binhex-view
- "p" gnus-uu-decode-postscript-view
- "P" gnus-uu-decode-postscript-and-save-view)
-
+(defvar gnus-uu-digest-buffer nil)
;; Commands.
-(defun gnus-uu-decode-uu (n)
+(defun gnus-uu-decode-uu (&optional n)
"Uudecodes the current article."
- (interactive "P")
+ (interactive "P")
(gnus-uu-decode-with-method 'gnus-uu-uustrip-article n))
(defun gnus-uu-decode-uu-and-save (n dir)
(interactive
(list current-prefix-arg
(file-name-as-directory
- (read-file-name "Uudecode and save in dir: "
+ (read-directory-name "Uudecode and save in dir: "
gnus-uu-default-dir
gnus-uu-default-dir t))))
(gnus-uu-decode-with-method 'gnus-uu-uustrip-article n dir nil nil t))
-(defun gnus-uu-decode-unshar (n)
+(defun gnus-uu-decode-unshar (&optional n)
"Unshars the current article."
(interactive "P")
(gnus-uu-decode-with-method 'gnus-uu-unshar-article n nil nil 'scan t))
(interactive
(list current-prefix-arg
(file-name-as-directory
- (read-file-name "Unshar and save in dir: "
+ (read-directory-name "Unshar and save in dir: "
gnus-uu-default-dir
gnus-uu-default-dir t))))
(gnus-uu-decode-with-method 'gnus-uu-unshar-article n dir nil 'scan t))
"Saves the current article."
(interactive
(list current-prefix-arg
- (read-file-name
- (if gnus-uu-save-separate-articles
- "Save articles is dir: "
- "Save articles in file: ")
- gnus-uu-default-dir
- gnus-uu-default-dir)))
+ (if gnus-uu-save-separate-articles
+ (read-directory-name
+ "Save articles in dir: " gnus-uu-default-dir gnus-uu-default-dir)
+ (read-file-name
+ "Save article in file: " gnus-uu-default-dir gnus-uu-default-dir))))
(setq gnus-uu-saved-article-name file)
- (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t)
- (setq gnus-uu-generated-file-list
- (delete file gnus-uu-generated-file-list)))
+ (gnus-uu-decode-with-method 'gnus-uu-save-article n nil t))
(defun gnus-uu-decode-binhex (n dir)
"Unbinhexes the current article."
(interactive
(list current-prefix-arg
(file-name-as-directory
- (read-file-name "Unbinhex and save in dir: "
+ (read-directory-name "Unbinhex and save in dir: "
gnus-uu-default-dir
gnus-uu-default-dir))))
- (setq gnus-uu-binhex-article-name
- (make-temp-name (concat gnus-uu-work-dir "binhex")))
+ (gnus-uu-initialize)
+ (setq gnus-uu-binhex-article-name
+ (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
(gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
-(defun gnus-uu-decode-uu-view (n)
- "Uudecodes and views the current article."
+(defun gnus-uu-decode-yenc (n dir)
+ "Decode the yEnc-encoded current article."
+ (interactive
+ (list current-prefix-arg
+ (file-name-as-directory
+ (read-directory-name "yEnc decode and save in dir: "
+ gnus-uu-default-dir
+ gnus-uu-default-dir))))
+ (setq gnus-uu-yenc-article-name nil)
+ (gnus-uu-decode-with-method 'gnus-uu-yenc-article n dir nil t))
+
+(defun gnus-uu-decode-uu-view (&optional n)
+ "Uudecodes and views the current article."
(interactive "P")
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-uu n)))
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-uu-and-save n dir)))
-(defun gnus-uu-decode-unshar-view (n)
+(defun gnus-uu-decode-unshar-view (&optional n)
"Unshars and views the current article."
(interactive "P")
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
"Saves and views the current article."
(interactive
(list current-prefix-arg
- (read-file-name (if gnus-uu-save-separate-articles
- "Save articles is dir: "
- "Save articles in file: ")
- gnus-uu-default-dir gnus-uu-default-dir)))
+ (if gnus-uu-save-separate-articles
+ (read-directory-name "Save articles in dir: "
+ gnus-uu-default-dir gnus-uu-default-dir)
+ (read-file-name "Save articles in file: "
+ gnus-uu-default-dir gnus-uu-default-dir))))
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-save n file)))
(list current-prefix-arg
(read-file-name "Unbinhex, view and save in dir: "
gnus-uu-default-dir gnus-uu-default-dir)))
- (setq gnus-uu-binhex-article-name
- (make-temp-name (concat gnus-uu-work-dir "binhex")))
+ (gnus-uu-initialize)
+ (setq gnus-uu-binhex-article-name
+ (mm-make-temp-file (expand-file-name "binhex" gnus-uu-work-dir)))
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-binhex n file)))
;; Digest and forward articles
-(defun gnus-uu-digest-mail-forward (n &optional post)
+(defun gnus-uu-digest-mail-forward (&optional n post)
"Digests and forwards all articles in this series."
(interactive "P")
+ (gnus-uu-initialize)
(let ((gnus-uu-save-in-digest t)
- (file (make-temp-name (concat gnus-uu-tmp-dir "forward")))
- buf subject from)
- (setq gnus-uu-digest-from-subject nil)
- (gnus-uu-decode-save n file)
- (gnus-uu-add-file file)
- (setq buf (switch-to-buffer (get-buffer-create " *gnus-uu-forward*")))
- (gnus-add-current-to-buffer-list)
- (erase-buffer)
- (delete-other-windows)
- (insert-file file)
- (let ((fs gnus-uu-digest-from-subject))
- (if (not fs)
- ()
- (setq from (caar fs)
- subject (gnus-simplify-subject-fuzzy (cdar fs))
- fs (cdr fs))
- (while (and fs (or from subject))
- (and from
- (or (string= from (caar fs))
- (setq from nil)))
- (and subject
- (or (string= (gnus-simplify-subject-fuzzy (cdar fs))
- subject)
- (setq subject nil)))
- (setq fs (cdr fs))))
- (or subject (setq subject "Digested Articles"))
- (or from (setq from "Various")))
- (goto-char (point-min))
- (and (re-search-forward "^Subject: ")
- (progn
- (delete-region (point) (gnus-point-at-eol))
- (insert subject)))
- (goto-char (point-min))
- (and (re-search-forward "^From: ")
- (progn
- (delete-region (point) (gnus-point-at-eol))
- (insert from)))
- (if post
- (gnus-forward-using-post)
- (gnus-mail-forward))
- (delete-file file)
- (kill-buffer buf)
+ (file (mm-make-temp-file (nnheader-concat gnus-uu-work-dir "forward")))
+ (message-forward-as-mime message-forward-as-mime)
+ (mail-parse-charset gnus-newsgroup-charset)
+ (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
+ gnus-uu-digest-buffer subject from)
+ (if (and n (not (numberp n)))
+ (setq message-forward-as-mime (not message-forward-as-mime)
+ n nil))
+ (let ((gnus-article-reply (gnus-summary-work-articles n)))
+ (when (and (not n)
+ (= (length gnus-article-reply) 1))
+ ;; The case where neither a number of articles nor a region is
+ ;; specified.
+ (gnus-summary-top-thread)
+ (setq gnus-article-reply (nreverse (gnus-uu-find-articles-matching))))
+ (gnus-setup-message 'forward
+ (setq gnus-uu-digest-from-subject nil)
+ (setq gnus-uu-digest-buffer
+ (gnus-get-buffer-create " *gnus-uu-forward*"))
+ ;; Specify articles to be forwarded. Note that they should be
+ ;; reversed; see `gnus-uu-get-list-of-articles'.
+ (let ((gnus-newsgroup-processable (reverse gnus-article-reply)))
+ (gnus-uu-decode-save n file)
+ (setq gnus-article-reply gnus-newsgroup-processable))
+ ;; Restore the value of `gnus-newsgroup-processable' to which
+ ;; it should be set when it is not `let'-bound.
+ (setq gnus-newsgroup-processable (reverse gnus-article-reply))
+ (switch-to-buffer gnus-uu-digest-buffer)
+ (let ((fs gnus-uu-digest-from-subject))
+ (when fs
+ (setq from (caar fs)
+ subject (gnus-simplify-subject-fuzzy (cdar fs))
+ fs (cdr fs))
+ (while (and fs (or from subject))
+ (when from
+ (unless (string= from (caar fs))
+ (setq from nil)))
+ (when subject
+ (unless (string= (gnus-simplify-subject-fuzzy (cdar fs))
+ subject)
+ (setq subject nil)))
+ (setq fs (cdr fs))))
+ (unless subject
+ (setq subject "Digested Articles"))
+ (unless from
+ (setq from
+ (if (gnus-news-group-p gnus-newsgroup-name)
+ gnus-newsgroup-name
+ "Various"))))
+ (goto-char (point-min))
+ (when (re-search-forward "^Subject: ")
+ (delete-region (point) (point-at-eol))
+ (insert subject))
+ (goto-char (point-min))
+ (when (re-search-forward "^From:")
+ (delete-region (point) (point-at-eol))
+ (insert " " from))
+ (let ((message-forward-decoded-p t))
+ (message-forward post t))))
(setq gnus-uu-digest-from-subject nil)))
-(defun gnus-uu-digest-post-forward (n)
+(defun gnus-uu-digest-post-forward (&optional n)
"Digest and forward to a newsgroup."
(interactive "P")
(gnus-uu-digest-mail-forward n t))
;; Process marking.
+(defun gnus-message-process-mark (unmarkp new-marked)
+ (let ((old (- (length gnus-newsgroup-processable) (length new-marked))))
+ (gnus-message 6 "%d mark%s %s%s"
+ (length new-marked)
+ (if (= (length new-marked) 1) "" "s")
+ (if unmarkp "removed" "added")
+ (cond
+ ((and (zerop old)
+ (not unmarkp))
+ "")
+ (unmarkp
+ (format ", %d remain marked"
+ (length gnus-newsgroup-processable)))
+ (t
+ (format ", %d already marked" old))))))
+
+(defun gnus-new-processable (unmarkp articles)
+ (if unmarkp
+ (gnus-intersection gnus-newsgroup-processable articles)
+ (gnus-set-difference articles gnus-newsgroup-processable)))
+
(defun gnus-uu-mark-by-regexp (regexp &optional unmark)
- "Ask for a regular expression and set the process mark on all articles that match."
- (interactive (list (read-from-minibuffer "Mark (regexp): ")))
- (gnus-set-global-variables)
- (let ((articles (gnus-uu-find-articles-matching regexp)))
- (while articles
- (if unmark
- (gnus-summary-remove-process-mark (pop articles))
- (gnus-summary-set-process-mark (pop articles))))
- (message ""))
+ "Set the process mark on articles whose subjects match REGEXP.
+When called interactively, prompt for REGEXP.
+Optional UNMARK non-nil means unmark instead of mark."
+ (interactive "sMark (regexp): \nP")
+ (save-excursion
+ (let* ((articles (gnus-uu-find-articles-matching regexp))
+ (new-marked (gnus-new-processable unmark articles)))
+ (while articles
+ (if unmark
+ (gnus-summary-remove-process-mark (pop articles))
+ (gnus-summary-set-process-mark (pop articles))))
+ (gnus-message-process-mark unmark new-marked)))
(gnus-summary-position-point))
-(defun gnus-uu-unmark-by-regexp (regexp &optional unmark)
- "Ask for a regular expression and remove the process mark on all articles that match."
- (interactive (list (read-from-minibuffer "Mark (regexp): ")))
+(defun gnus-uu-unmark-by-regexp (regexp)
+ "Remove the process mark from articles whose subjects match REGEXP.
+When called interactively, prompt for REGEXP."
+ (interactive "sUnmark (regexp): ")
(gnus-uu-mark-by-regexp regexp t))
-(defun gnus-uu-mark-series ()
+(defun gnus-uu-mark-series (&optional silent)
"Mark the current series with the process mark."
(interactive)
- (gnus-set-global-variables)
- (let ((articles (gnus-uu-find-articles-matching)))
+ (let* ((articles (gnus-uu-find-articles-matching))
+ (l (length articles)))
(while articles
(gnus-summary-set-process-mark (car articles))
(setq articles (cdr articles)))
- (message ""))
- (gnus-summary-position-point))
+ (unless silent
+ (gnus-message 6 "Marked %d articles" l))
+ (gnus-summary-position-point)
+ l))
(defun gnus-uu-mark-region (beg end &optional unmark)
"Set the process mark on all articles between point and mark."
(interactive "r")
- (gnus-set-global-variables)
(save-excursion
(goto-char beg)
(while (< (point) end)
"Set the process mark on all articles in the buffer."
(interactive)
(gnus-uu-mark-region (point-min) (point-max)))
-
+
(defun gnus-uu-unmark-buffer ()
"Remove the process mark on all articles in the buffer."
(interactive)
(gnus-uu-mark-region (point-min) (point-max) t))
-
+
(defun gnus-uu-mark-thread ()
"Marks all articles downwards in this thread."
(interactive)
- (gnus-set-global-variables)
- (let ((level (gnus-summary-thread-level)))
- (while (and (gnus-summary-set-process-mark (gnus-summary-article-number))
- (zerop (gnus-summary-next-subject 1))
- (> (gnus-summary-thread-level) level))))
+ (gnus-save-hidden-threads
+ (let ((level (gnus-summary-thread-level)))
+ (while (and (gnus-summary-set-process-mark
+ (gnus-summary-article-number))
+ (zerop (forward-line 1))
+ (> (gnus-summary-thread-level) level)))))
(gnus-summary-position-point))
(defun gnus-uu-unmark-thread ()
"Unmarks all articles downwards in this thread."
(interactive)
- (gnus-set-global-variables)
(let ((level (gnus-summary-thread-level)))
(while (and (gnus-summary-remove-process-mark
(gnus-summary-article-number))
- (zerop (gnus-summary-next-subject 1))
+ (zerop (forward-line 1))
(> (gnus-summary-thread-level) level))))
(gnus-summary-position-point))
-(defun gnus-uu-mark-over (score)
- "Mark all articles with a score over SCORE (the prefix.)"
+(defun gnus-uu-invert-processable ()
+ "Invert the list of process-marked articles."
+ (interactive)
+ (let ((data gnus-newsgroup-data)
+ number)
+ (save-excursion
+ (while data
+ (if (memq (setq number (gnus-data-number (pop data)))
+ gnus-newsgroup-processable)
+ (gnus-summary-remove-process-mark number)
+ (gnus-summary-set-process-mark number)))))
+ (gnus-summary-position-point))
+
+(defun gnus-uu-mark-over (&optional score)
+ "Mark all articles with a score over SCORE (the prefix)."
(interactive "P")
- (let ((score (gnus-score-default score))
+ (let ((score (or score gnus-summary-default-score 0))
(data gnus-newsgroup-data))
(save-excursion
(while data
- (when (> (or (cdr (assq (gnus-data-number (caar data))
+ (when (> (or (cdr (assq (gnus-data-number (car data))
gnus-newsgroup-scored))
gnus-summary-default-score 0)
score)
(defun gnus-uu-mark-sparse ()
"Mark all series that have some articles marked."
(interactive)
- (gnus-set-global-variables)
(let ((marked (nreverse gnus-newsgroup-processable))
subject articles total headers)
- (or marked (error "No articles marked with the process mark"))
+ (unless marked
+ (error "No articles marked with the process mark"))
(setq gnus-newsgroup-processable nil)
(save-excursion
(while marked
- (and (setq headers (gnus-summary-article-header (car marked)))
+ (and (vectorp (setq headers
+ (gnus-summary-article-header (car marked))))
(setq subject (mail-header-subject headers)
- articles (gnus-uu-find-articles-matching
+ articles (gnus-uu-find-articles-matching
(gnus-uu-reginize-string subject))
total (nconc total articles)))
(while articles
(defun gnus-uu-mark-all ()
"Mark all articles in \"series\" order."
(interactive)
- (gnus-set-global-variables)
(setq gnus-newsgroup-processable nil)
(save-excursion
(let ((data gnus-newsgroup-data)
+ (count 0)
number)
(while data
- (unless (memq (setq number (gnus-data-number (car data)))
- gnus-newsgroup-processable)
+ (when (and (not (memq (setq number (gnus-data-number (car data)))
+ gnus-newsgroup-processable))
+ (vectorp (gnus-data-header (car data))))
(gnus-summary-goto-subject number)
- (gnus-uu-mark-series))
- (setq data (cdr data)))))
+ (setq count (+ count (gnus-uu-mark-series t))))
+ (setq data (cdr data)))
+ (gnus-message 6 "Marked %d articles" count)))
(gnus-summary-position-point))
-;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
+;; All PostScript functions written by Erik Selberg <speed@cs.washington.edu>.
-(defun gnus-uu-decode-postscript (n)
- "Gets postscript of the current article."
+(defun gnus-uu-decode-postscript (&optional n)
+ "Gets PostScript of the current article."
(interactive "P")
(gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article n))
-(defun gnus-uu-decode-postscript-view (n)
+(defun gnus-uu-decode-postscript-view (&optional n)
"Gets and views the current article."
(interactive "P")
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-postscript n)))
(defun gnus-uu-decode-postscript-and-save (n dir)
- "Extracts postscript and saves the current article."
+ "Extracts PostScript and saves the current article."
(interactive
(list current-prefix-arg
(file-name-as-directory
- (read-file-name "Save in dir: "
+ (read-directory-name "Save in dir: "
gnus-uu-default-dir
gnus-uu-default-dir t))))
- (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
+ (gnus-uu-decode-with-method 'gnus-uu-decode-postscript-article
n dir nil nil t))
(defun gnus-uu-decode-postscript-and-save-view (n dir)
;; Internal functions.
-(defun gnus-uu-decode-with-method (method n &optional save not-insert
+(defun gnus-uu-decode-with-method (method n &optional save not-insert
scan cdir)
(gnus-uu-initialize scan)
- (if save (setq gnus-uu-default-dir save))
+ (when save
+ (setq gnus-uu-default-dir save))
;; Create the directory we save to.
- (when (and scan cdir
+ (when (and scan cdir save
(not (file-exists-p save)))
(make-directory save t))
(let ((articles (gnus-uu-get-list-of-articles n))
files)
(setq files (gnus-uu-grab-articles articles method t))
(let ((gnus-current-article (car articles)))
- (and scan (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
- (and save (gnus-uu-save-files files save))
- (if (eq gnus-uu-do-not-unpack-archives nil)
+ (when scan
+ (setq files (gnus-uu-scan-directory gnus-uu-work-dir))))
+ (when save
+ (gnus-uu-save-files files save))
+ (when (eq gnus-uu-do-not-unpack-archives nil)
(setq files (gnus-uu-unpack-files files)))
- (gnus-uu-add-file (mapcar (lambda (file) (cdr (assq 'name file))) files))
(setq files (nreverse (gnus-uu-get-actions files)))
(or not-insert (not gnus-insert-pseudo-articles)
(gnus-summary-insert-pseudos files save))))
(let ((files (directory-files dir t))
out file)
(while (setq file (pop files))
- (unless (string-match "/\\.\\.?$" file)
+ (unless (member (file-name-nondirectory file) '("." ".."))
(push (list (cons 'name file)
(cons 'article gnus-current-article))
out)
(when (file-directory-p file)
(setq out (nconc (gnus-uu-scan-directory file t) out)))))
- (if rec
+ (if rec
out
(nreverse out))))
(string-match reg file)
(setq fromdir (substring file (match-end 0)))
(if (file-directory-p file)
- (unless (file-exists-p (concat dir fromdir))
- (make-directory (concat dir fromdir) t))
+ (gnus-make-directory (concat dir fromdir))
(setq to-file (concat dir fromdir))
(when (or (not (file-exists-p to-file))
- (gnus-y-or-n-p (format "%s exists; overwrite? " to-file)))
+ (eq gnus-uu-be-dangerous t)
+ (and gnus-uu-be-dangerous
+ (gnus-y-or-n-p (format "%s exists; overwrite? "
+ to-file))))
(copy-file file to-file t t)))))
- (message "Saved %d file%s" len (if (> len 1) "s" ""))))
+ (gnus-message 5 "Saved %d file%s" len (if (= len 1) "" "s"))))
;; Functions for saving and possibly digesting articles without
;; any decoding.
;; Function called by gnus-uu-grab-articles to treat each article.
(defun gnus-uu-save-article (buffer in-state)
- (cond
+ (cond
(gnus-uu-save-separate-articles
- (save-excursion
- (set-buffer buffer)
- (write-region 1 (point-max) (concat gnus-uu-saved-article-name
- gnus-current-article))
+ (with-current-buffer buffer
+ (let ((coding-system-for-write mm-text-coding-system))
+ (gnus-write-buffer
+ (concat gnus-uu-saved-article-name gnus-current-article)))
(cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
- ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
+ ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
'begin 'end))
((eq in-state 'last) (list 'end))
(t (list 'middle)))))
((not gnus-uu-save-in-digest)
- (save-excursion
- (set-buffer buffer)
- (write-region 1 (point-max) gnus-uu-saved-article-name t)
+ (with-current-buffer buffer
+ (write-region (point-min) (point-max) gnus-uu-saved-article-name t)
(cond ((eq in-state 'first) (list gnus-uu-saved-article-name 'begin))
- ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
+ ((eq in-state 'first-and-last) (list gnus-uu-saved-article-name
'begin 'end))
((eq in-state 'last) (list 'end))
(t (list 'middle)))))
(t
(let ((header (gnus-summary-article-header)))
- (setq gnus-uu-digest-from-subject
- (cons (cons (mail-header-from header)
- (mail-header-subject header))
- gnus-uu-digest-from-subject)))
+ (push (cons (mail-header-from header)
+ (mail-header-subject header))
+ gnus-uu-digest-from-subject))
(let ((name (file-name-nondirectory gnus-uu-saved-article-name))
- (delim (concat "^" (make-string 30 ?-) "$"))
beg subj headers headline sorthead body end-string state)
- (if (or (eq in-state 'first)
+ (if (or (eq in-state 'first)
(eq in-state 'first-and-last))
- (progn
+ (progn
(setq state (list 'begin))
- (save-excursion (set-buffer (get-buffer-create "*gnus-uu-body*"))
- (erase-buffer))
- (save-excursion
- (set-buffer (get-buffer-create "*gnus-uu-pre*"))
+ (with-current-buffer (gnus-get-buffer-create "*gnus-uu-body*")
+ (erase-buffer))
+ (with-current-buffer (gnus-get-buffer-create "*gnus-uu-pre*")
(erase-buffer)
- (insert (format
- "Date: %s\nFrom: %s\nSubject: %s Digest\n\nTopics:\n"
- (current-time-string) name name))))
- (if (not (eq in-state 'end))
- (setq state (list 'middle))))
- (save-excursion
- (set-buffer (get-buffer "*gnus-uu-body*"))
+ (insert (format
+ "Date: %s\nFrom: %s\nSubject: %s Digest\n\n"
+ (message-make-date) name name))
+ (when (and message-forward-as-mime gnus-uu-digest-buffer)
+ (insert
+ "<#mml type=message/rfc822>\nSubject: Topics\n\n<#/mml>\n")
+ (forward-line -1))
+ (insert "Topics:\n")))
+ (when (not (eq in-state 'end))
+ (setq state (list 'middle))))
+ (with-current-buffer "*gnus-uu-body*"
(goto-char (setq beg (point-max)))
- (save-excursion
+ (with-current-buffer buffer
(save-restriction
- (set-buffer buffer)
- (let (buffer-read-only)
- (gnus-set-text-properties (point-min) (point-max) nil)
+ (let ((inhibit-read-only t))
+ (set-text-properties (point-min) (point-max) nil)
;; These two are necessary for XEmacs 19.12 fascism.
(put-text-property (point-min) (point-max) 'invisible nil)
(put-text-property (point-min) (point-max) 'intangible nil))
+ (when (and message-forward-as-mime
+ message-forward-show-mml
+ gnus-uu-digest-buffer)
+ (mm-enable-multibyte)
+ (mime-to-mml))
(goto-char (point-min))
- (re-search-forward "\n\n")
- ;; Quote all 30-dash lines.
- (save-excursion
- (while (re-search-forward delim nil t)
- (beginning-of-line)
- (delete-char 1)
- (insert " ")))
+ (search-forward "\n\n")
+ (unless (and message-forward-as-mime gnus-uu-digest-buffer)
+ ;; Quote all 30-dash lines.
+ (save-excursion
+ (while (re-search-forward "^-" nil t)
+ (beginning-of-line)
+ (delete-char 1)
+ (insert "- "))))
(setq body (buffer-substring (1- (point)) (point-max)))
(narrow-to-region (point-min) (point))
(if (not (setq headers gnus-uu-digest-headers))
- (setq sorthead (buffer-substring (point-min) (point-max)))
+ (setq sorthead (buffer-string))
(while headers
(setq headline (car headers))
(setq headers (cdr headers))
(goto-char (point-min))
- (if (re-search-forward headline nil t)
- (setq sorthead
- (concat sorthead
- (buffer-substring
- (match-beginning 0)
- (or (and (re-search-forward "^[^ \t]" nil t)
- (1- (point)))
- (progn (forward-line 1) (point)))))))))
- (widen)))
- (insert sorthead) (goto-char (point-max))
- (insert body) (goto-char (point-max))
- (insert (concat "\n" (make-string 30 ?-) "\n\n"))
+ (while (re-search-forward headline nil t)
+ (setq sorthead
+ (concat sorthead
+ (buffer-substring
+ (match-beginning 0)
+ (or (and (re-search-forward "^[^ \t]" nil t)
+ (1- (point)))
+ (progn (forward-line 1) (point)))))))))))
+ (if (and message-forward-as-mime gnus-uu-digest-buffer)
+ (if message-forward-show-mml
+ (progn
+ (insert "\n<#mml type=message/rfc822>\n")
+ (insert sorthead) (goto-char (point-max))
+ (insert body) (goto-char (point-max))
+ (insert "\n<#/mml>\n"))
+ (let ((buf (mml-generate-new-buffer " *mml*")))
+ (with-current-buffer buf
+ (insert sorthead)
+ (goto-char (point-min))
+ (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
+ (setq subj (buffer-substring (match-beginning 1)
+ (match-end 1))))
+ (goto-char (point-max))
+ (insert body))
+ (insert "\n<#part type=message/rfc822"
+ " buffer=\"" (buffer-name buf) "\">\n")))
+ (insert sorthead) (goto-char (point-max))
+ (insert body) (goto-char (point-max))
+ (insert (concat "\n" (make-string 30 ?-) "\n\n")))
(goto-char beg)
- (if (re-search-forward "^Subject: \\(.*\\)$" nil t)
- (progn
- (setq subj (buffer-substring (match-beginning 1) (match-end 1)))
- (save-excursion
- (set-buffer (get-buffer "*gnus-uu-pre*"))
- (insert (format " %s\n" subj))))))
- (if (or (eq in-state 'last)
- (eq in-state 'first-and-last))
- (progn
- (save-excursion
- (set-buffer (get-buffer "*gnus-uu-pre*"))
- (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
- (write-region 1 (point-max) gnus-uu-saved-article-name))
- (save-excursion
- (set-buffer (get-buffer "*gnus-uu-body*"))
+ (when (re-search-forward "^Subject: \\(.*\\)$" nil t)
+ (setq subj (buffer-substring (match-beginning 1) (match-end 1))))
+ (when subj
+ (with-current-buffer "*gnus-uu-pre*"
+ (insert (format " %s\n" subj)))))
+ (when (or (eq in-state 'last)
+ (eq in-state 'first-and-last))
+ (if (and message-forward-as-mime gnus-uu-digest-buffer)
+ (with-current-buffer gnus-uu-digest-buffer
+ (erase-buffer)
+ (insert-buffer-substring "*gnus-uu-pre*")
(goto-char (point-max))
- (insert
- (concat (setq end-string (format "End of %s Digest" name))
- "\n"))
- (insert (concat (make-string (length end-string) ?*) "\n"))
- (write-region 1 (point-max) gnus-uu-saved-article-name t))
- (kill-buffer (get-buffer "*gnus-uu-pre*"))
- (kill-buffer (get-buffer "*gnus-uu-body*"))
- (setq state (cons 'end state))))
+ (insert-buffer-substring "*gnus-uu-body*"))
+ (with-current-buffer "*gnus-uu-pre*"
+ (insert (format "\n\n%s\n\n" (make-string 70 ?-)))
+ (if gnus-uu-digest-buffer
+ (with-current-buffer gnus-uu-digest-buffer
+ (erase-buffer)
+ (insert-buffer-substring "*gnus-uu-pre*"))
+ (let ((coding-system-for-write mm-text-coding-system))
+ (gnus-write-buffer gnus-uu-saved-article-name))))
+ (with-current-buffer "*gnus-uu-body*"
+ (goto-char (point-max))
+ (insert
+ (concat (setq end-string (format "End of %s Digest" name))
+ "\n"))
+ (insert (concat (make-string (length end-string) ?*) "\n"))
+ (if gnus-uu-digest-buffer
+ (with-current-buffer gnus-uu-digest-buffer
+ (goto-char (point-max))
+ (insert-buffer-substring "*gnus-uu-body*"))
+ (let ((coding-system-for-write mm-text-coding-system)
+ (file-name-coding-system nnmail-pathname-coding-system))
+ (write-region
+ (point-min) (point-max) gnus-uu-saved-article-name t)))))
+ (gnus-kill-buffer "*gnus-uu-pre*")
+ (gnus-kill-buffer "*gnus-uu-body*")
+ (push 'end state))
(if (memq 'begin state)
(cons gnus-uu-saved-article-name state)
state)))))
-;; Binhex treatment - not very advanced.
+;; Binhex treatment - not very advanced.
-(defconst gnus-uu-binhex-body-line
+(defvar gnus-uu-binhex-body-line
"^[^:]...............................................................$")
-(defconst gnus-uu-binhex-begin-line
+(defvar gnus-uu-binhex-begin-line
"^:...............................................................$")
-(defconst gnus-uu-binhex-end-line
+(defvar gnus-uu-binhex-end-line
":$")
(defun gnus-uu-binhex-article (buffer in-state)
(let (state start-char)
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(widen)
(goto-char (point-min))
- (if (not (re-search-forward gnus-uu-binhex-begin-line nil t))
- (if (not (re-search-forward gnus-uu-binhex-body-line nil t))
- (setq state (list 'wrong-type))))
+ (when (not (re-search-forward gnus-uu-binhex-begin-line nil t))
+ (when (not (re-search-forward gnus-uu-binhex-body-line nil t))
+ (setq state (list 'wrong-type))))
(if (memq 'wrong-type state)
()
(if (looking-at gnus-uu-binhex-begin-line)
(progn
(setq state (list 'begin))
- (write-region 1 1 gnus-uu-binhex-article-name))
+ (write-region (point-min) (point-min)
+ gnus-uu-binhex-article-name))
(setq state (list 'middle)))
(goto-char (point-max))
- (re-search-backward (concat gnus-uu-binhex-body-line "\\|"
- gnus-uu-binhex-end-line) nil t)
- &n