summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-uu.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-12-06 00:21:00 +0000
committerMiles Bader <miles@gnu.org>2007-12-06 00:21:00 +0000
commitb890d447fb56bfe9f2e4742eda4b3ab4b5f4b32a (patch)
treeb97d8b30984a8884b61d54b056a4aabf852ecbbe /lisp/gnus/gnus-uu.el
parentf6e7ec024870e8ccaaed5bc2e0d92fde7554e16b (diff)
downloademacs-b890d447fb56bfe9f2e4742eda4b3ab4b5f4b32a.tar.gz
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-941
Diffstat (limited to 'lisp/gnus/gnus-uu.el')
-rw-r--r--lisp/gnus/gnus-uu.el46
1 files changed, 46 insertions, 0 deletions
diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el
index d3b13f3843a..3a045c2c234 100644
--- a/lisp/gnus/gnus-uu.el
+++ b/lisp/gnus/gnus-uu.el
@@ -35,6 +35,7 @@
(require 'message)
(require 'gnus-msg)
(require 'mm-decode)
+(require 'yenc)
(defgroup gnus-extract nil
"Extracting encoded files."
@@ -346,6 +347,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
(defvar gnus-uu-file-name nil)
(defvar gnus-uu-uudecode-process nil)
(defvar gnus-uu-binhex-article-name nil)
+(defvar gnus-uu-yenc-article-name nil)
(defvar gnus-uu-work-dir nil)
@@ -412,6 +414,17 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
(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-yenc (n dir)
+ "Decode the yEnc-encoded current article."
+ (interactive
+ (list current-prefix-arg
+ (file-name-as-directory
+ (read-file-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")
@@ -1016,6 +1029,39 @@ When called interactively, prompt for REGEXP."
(cons gnus-uu-binhex-article-name state)
state)))
+;; yEnc
+
+(defun gnus-uu-yenc-article (buffer in-state)
+ (save-excursion
+ (set-buffer gnus-original-article-buffer)
+ (widen)
+ (let ((file-name (yenc-extract-filename))
+ state start-char)
+ (when (not file-name)
+ (setq state (list 'wrong-type)))
+
+ (if (memq 'wrong-type state)
+ ()
+ (when (yenc-first-part-p)
+ (setq gnus-uu-yenc-article-name
+ (expand-file-name file-name gnus-uu-work-dir))
+ (push 'begin state))
+ (when (yenc-last-part-p)
+ (push 'end state))
+ (unless state
+ (push 'middle state))
+ (mm-with-unibyte-buffer
+ (insert-buffer gnus-original-article-buffer)
+ (yenc-decode-region (point-min) (point-max))
+ (when (and (member 'begin state)
+ (file-exists-p gnus-uu-yenc-article-name))
+ (delete-file gnus-uu-yenc-article-name))
+ (mm-append-to-file (point-min) (point-max)
+ gnus-uu-yenc-article-name)))
+ (if (memq 'begin state)
+ (cons file-name state)
+ state))))
+
;; PostScript
(defun gnus-uu-decode-postscript-article (process-buffer in-state)