+2006-05-17 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * gnus-sum.el (gnus-summary-save-article-coding-system): New
+ variable.
+ (gnus-summary-save-article): Add optional `decode' argument. If
+ it is set and gnus-summary-save-article-coding-system is non-nil,
+ save decoded article.
+ (gnus-summary-write-article-file): Save decoded article if
+ gnus-summary-save-article-coding-system is non-nil.
+
+ * ecomplete.el (ecomplete-database-file-coding-system): Fix custom
+ type.
+
2006-05-16 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-art.el (easy-menu-define): Use :active instead of :enable.
;; Summary saving commands.
-(defun gnus-summary-save-article (&optional n not-saved)
+(defcustom gnus-summary-save-article-coding-system nil
+ "Coding system used to save a decoded article to a file.
+This is used when the `gnus-summary-write-article-file' command is run.
+The recommended coding systems include `utf-8', `iso-2022-7bit', and so
+forth. Note that buttonized MIME parts will be lost in a saved file.
+If it is nil, raw articles will be saved."
+ :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
+ (const :tag "Save raw articles")
+ (symbol :tag "Coding system"))
+ :group 'gnus-article-saving)
+
+(defun gnus-summary-save-article (&optional n not-saved decode)
"Save the current article using the default saver function.
If N is a positive number, save the N next articles.
If N is a negative number, save the N previous articles.
save those articles instead.
The variable `gnus-default-article-saver' specifies the saver function."
(interactive "P")
+ (unless gnus-summary-save-article-coding-system
+ (setq decode nil))
(let* ((articles (gnus-summary-work-articles n))
(save-buffer (save-excursion
(nnheader-set-temp-buffer " *Gnus Save*")))
(gnus-message 1 "Article %d is unsaveable" article))
;; This is a real article.
(save-window-excursion
- (let ((gnus-display-mime-function nil)
- (gnus-article-prepare-hook nil))
+ (let ((gnus-display-mime-function (when decode
+ gnus-display-mime-function))
+ (gnus-article-prepare-hook (when decode
+ gnus-article-prepare-hook)))
(gnus-summary-select-article t nil nil article)))
(save-excursion
(set-buffer save-buffer)
(erase-buffer)
- (insert-buffer-substring gnus-original-article-buffer))
- (setq file (gnus-article-save save-buffer file num))
+ (if decode
+ (progn
+ (insert "X-Coding-System: -*- coding: "
+ (symbol-name gnus-summary-save-article-coding-system)
+ "; -*-\n")
+ (insert-buffer-substring gnus-article-buffer))
+ (insert-buffer-substring gnus-original-article-buffer)))
+ (let ((mm-text-coding-system-for-write
+ (if decode
+ gnus-summary-save-article-coding-system
+ mm-text-coding-system-for-write)))
+ (setq file (gnus-article-save save-buffer file num)))
(gnus-summary-remove-process-mark article)
(unless not-saved
(gnus-summary-set-saved-mark article))))
(interactive "P")
(require 'gnus-art)
(let ((gnus-default-article-saver 'gnus-summary-write-to-file))
- (gnus-summary-save-article arg)))
+ (gnus-summary-save-article arg nil t)))
(defun gnus-summary-save-article-body-file (&optional arg)
"Append the current article body to a file.