Show
Ignore:
Timestamp:
07/01/06 08:27:06 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/gnus/gnus-art.el

    r4079 r4098  
    493493 
    494494(defcustom gnus-save-all-headers t 
    495   "*If non-nil, don't remove any headers before saving." 
     495  "*If non-nil, don't remove any headers before saving. 
     496This will be overridden by the `:headers' property that the symbol of 
     497the saver function, which is specified by `gnus-default-article-saver', 
     498might have." 
    496499  :group 'gnus-article-saving 
    497500  :type 'boolean) 
     
    514517If `gnus-save-all-headers' is non-nil, this variable will be ignored. 
    515518If that variable is nil, however, all headers that match this regexp 
    516 will be kept while the rest will be deleted before saving." 
     519will be kept while the rest will be deleted before saving.  This and 
     520`gnus-save-all-headers' will be overridden by the `:headers' property 
     521that the symbol of the saver function, which is specified by 
     522`gnus-default-article-saver', might have." 
    517523  :group 'gnus-article-saving 
    518524  :type 'regexp) 
     
    520526(defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail 
    521527  "A function to save articles in your favourite format. 
    522 The function must be interactively callable (in other words, it must 
    523 be an Emacs command)
     528The function will be called by way of the `gnus-summary-save-article' 
     529command, and friends such as `gnus-summary-save-article-rmail'
    524530 
    525531Gnus provides the following functions: 
     
    531537* gnus-summary-save-body-in-file (article body) 
    532538* gnus-summary-save-in-vm (use VM's folder format) 
    533 * gnus-summary-write-to-file (article format -- overwrite)." 
     539* gnus-summary-write-to-file (article format -- overwrite) 
     540* gnus-summary-write-body-to-file (article body -- overwrite) 
     541 
     542The symbol of each function may have the following properties: 
     543 
     544* :decode 
     545The value non-nil means save decoded articles.  This is meaningful 
     546only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file', 
     547`gnus-summary-write-to-file', and `gnus-summary-write-body-to-file'. 
     548 
     549* :function 
     550The value specifies an alternative function which appends, not 
     551overwrites, articles to a file.  This implies that when saving many 
     552articles at a time, `gnus-prompt-before-saving' is bound to t and all 
     553articles are saved in a single file.  This is meaningful only with 
     554`gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'. 
     555 
     556* :headers 
     557The value specifies the symbol of a variable of which the value 
     558specifies headers to be saved.  If it is omitted, 
     559`gnus-save-all-headers' and `gnus-saved-headers' control what 
     560headers should be saved." 
    534561  :group 'gnus-article-saving 
    535562  :type '(radio (function-item gnus-summary-save-in-rmail) 
     
    540567                (function-item gnus-summary-save-in-vm) 
    541568                (function-item gnus-summary-write-to-file) 
     569                (function-item gnus-summary-write-body-to-file) 
    542570                (function))) 
     571 
     572(defcustom gnus-article-save-coding-system 
     573  (or (and (mm-coding-system-p 'utf-8) 'utf-8) 
     574      (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit) 
     575      (and (mm-coding-system-p 'emacs-mule) 'emacs-mule) 
     576      (and (mm-coding-system-p 'escape-quoted) 'escape-quoted)) 
     577  "Coding system used to save decoded articles to a file. 
     578 
     579The recommended coding systems are `utf-8', `iso-2022-7bit' and so on, 
     580which can safely encode any characters in text.  This is used by the 
     581commands including: 
     582 
     583* gnus-summary-save-article-file 
     584* gnus-summary-save-article-body-file 
     585* gnus-summary-write-article-file 
     586* gnus-summary-write-article-body-file 
     587 
     588and the functions to which you may set `gnus-default-article-saver': 
     589 
     590* gnus-summary-save-in-file 
     591* gnus-summary-save-body-in-file 
     592* gnus-summary-write-to-file 
     593* gnus-summary-write-body-to-file 
     594 
     595Those commands and functions save just text displayed in the article 
     596buffer to a file if the value of this variable is non-nil.  Note that 
     597buttonized MIME parts will be lost in a saved file in that case. 
     598Otherwise, raw articles will be saved." 
     599  :group 'gnus-article-saving 
     600  :type `(choice 
     601          :format "%{%t%}:\n %[Value Menu%] %v" 
     602          (const :tag "Save raw articles" nil) 
     603          ,@(delq nil 
     604                  (mapcar 
     605                   (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg)) 
     606                   '((const :tag "UTF-8" utf-8) 
     607                     (const :tag "iso-2022-7bit" iso-2022-7bit) 
     608                     (const :tag "Emacs internal" emacs-mule) 
     609                     (const :tag "escape-quoted" escape-quoted)))) 
     610          (symbol :tag "Coding system"))) 
    543611 
    544612(defcustom gnus-rmail-save-name 'gnus-plain-save-name 
     
    32503318(defun gnus-article-save (save-buffer file &optional num) 
    32513319  "Save the currently selected article." 
    3252   (unless gnus-save-all-headers 
    3253     ;; Remove headers according to `gnus-saved-headers'. 
     3320  (when (or (get gnus-default-article-saver :headers) 
     3321            (not gnus-save-all-headers)) 
     3322    ;; Remove headers according to `gnus-saved-headers' or the value 
     3323    ;; of the `:headers' property that the saver function might have. 
    32543324    (let ((gnus-visible-headers 
    3255            (or gnus-saved-headers gnus-visible-headers)) 
     3325           (or (symbol-value (get gnus-default-article-saver :headers)) 
     3326               gnus-saved-headers gnus-visible-headers)) 
    32563327          (gnus-article-buffer save-buffer)) 
    32573328      (save-excursion 
     
    32783349 
    32793350(defun gnus-read-save-file-name (prompt &optional filename 
    3280                                         function group headers variable) 
     3351                                        function group headers variable 
     3352                                        dir-var) 
    32813353  (let ((default-name 
    32823354          (funcall function group headers (symbol-value variable))) 
     
    32913363            (filename filename) 
    32923364            (t 
     3365             (when (symbol-value dir-var) 
     3366               (setq default-name (expand-file-name 
     3367                                   (file-name-nondirectory default-name) 
     3368                                   (symbol-value dir-var)))) 
    32933369             (let* ((split-name (gnus-get-split-value gnus-split-methods)) 
    32943370                    (prompt 
     
    33553431               (nnheader-translate-file-chars file)))))) 
    33563432    (gnus-make-directory (file-name-directory result)) 
    3357     (set variable result))) 
     3433    (when variable 
     3434      (set variable result)) 
     3435    (when dir-var 
     3436      (set dir-var (file-name-directory result))) 
     3437    result)) 
    33583438 
    33593439(defun gnus-article-archive-name (group) 
     
    34033483  filename) 
    34043484 
     3485(put 'gnus-summary-save-in-file :decode t) 
     3486(put 'gnus-summary-save-in-file :headers 'gnus-saved-headers) 
    34053487(defun gnus-summary-save-in-file (&optional filename overwrite) 
    34063488  "Append this article to file. 
     
    34213503  filename) 
    34223504 
     3505(put 'gnus-summary-write-to-file :decode t) 
     3506(put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file) 
     3507(put 'gnus-summary-write-to-file :headers 'gnus-saved-headers) 
    34233508(defun gnus-summary-write-to-file (&optional filename) 
    34243509  "Write this article to a file, overwriting it if the file exists. 
    34253510Optional argument FILENAME specifies file name. 
    34263511The directory to save in defaults to `gnus-article-save-directory'." 
    3427   (gnus-summary-save-in-file nil t)) 
    3428  
    3429 (defun gnus-summary-save-body-in-file (&optional filename) 
     3512  (setq filename (gnus-read-save-file-name 
     3513                  "Save %s in file" filename 
     3514                  gnus-file-save-name gnus-newsgroup-name 
     3515                  gnus-current-headers nil 'gnus-newsgroup-last-directory)) 
     3516  (gnus-summary-save-in-file filename t)) 
     3517 
     3518(put 'gnus-summary-save-body-in-file :decode t) 
     3519(defun gnus-summary-save-body-in-file (&optional filename overwrite) 
    34303520  "Append this article body to a file. 
    34313521Optional argument FILENAME specifies file name. 
     
    34413531        (when (article-goto-body) 
    34423532          (narrow-to-region (point) (point-max))) 
     3533        (when (and overwrite 
     3534                   (file-exists-p filename)) 
     3535          (delete-file filename)) 
    34433536        (gnus-output-to-file filename)))) 
    34443537  filename) 
     3538 
     3539(put 'gnus-summary-write-body-to-file :decode t) 
     3540(put 'gnus-summary-write-body-to-file 
     3541     :function 'gnus-summary-save-body-in-file) 
     3542(defun gnus-summary-write-body-to-file (&optional filename) 
     3543  "Write this article body to a file, overwriting it if the file exists. 
     3544Optional argument FILENAME specifies file name. 
     3545The directory to save in defaults to `gnus-article-save-directory'." 
     3546  (setq filename (gnus-read-save-file-name 
     3547                  "Save %s body in file" filename 
     3548                  gnus-file-save-name gnus-newsgroup-name 
     3549                  gnus-current-headers nil 'gnus-newsgroup-last-directory)) 
     3550  (gnus-summary-save-body-in-file filename t)) 
    34453551 
    34463552(defun gnus-summary-save-in-pipe (&optional command) 
     
    48224928              (narrow-to-region (point-min) (point)) 
    48234929              (gnus-article-save-original-date 
    4824                (gnus-treat-article 'head))))))))) 
     4930               (gnus-treat-article 'head))))))) 
     4931    ;; Cope with broken MIME messages. 
     4932    (goto-char (point-max)) 
     4933    (unless (bolp) 
     4934      (insert "\n")))) 
    48254935 
    48264936(defcustom gnus-mime-display-multipart-as-mixed nil 
     
    51835293 
    51845294(defun gnus-output-to-file (file-name) 
    5185   "Append the current article to a file named FILE-NAME." 
    5186   (let ((artbuf (current-buffer))) 
     5295  "Append the current article to a file named FILE-NAME. 
     5296If `gnus-article-save-coding-system' is non-nil, it is used to encode 
     5297text and used as the value of the coding cookie which is added to the 
     5298top of a file.  Otherwise, this function saves a raw article without 
     5299the coding cookie." 
     5300  (let* ((artbuf (current-buffer)) 
     5301         (file-name-coding-system nnmail-pathname-coding-system) 
     5302         (coding gnus-article-save-coding-system) 
     5303         (coding-system-for-read (if coding 
     5304                                     nil ;; Rely on the coding cookie. 
     5305                                   mm-text-coding-system)) 
     5306         (coding-system-for-write (or coding 
     5307                                      mm-text-coding-system-for-write 
     5308                                      mm-text-coding-system)) 
     5309         (exists (file-exists-p file-name))) 
    51875310    (with-temp-buffer 
     5311      (when exists 
     5312        (insert-file-contents file-name) 
     5313        (goto-char (point-min)) 
     5314        ;; Remove the existing coding cookie. 
     5315        (when (looking-at "X-Gnus-Coding-System: .+\n\n") 
     5316          (delete-region (match-beginning 0) (match-end 0)))) 
     5317      (goto-char (point-max)) 
    51885318      (insert-buffer-substring artbuf) 
    51895319      ;; Append newline at end of the buffer as separator, and then 
     
    51915321      (goto-char (point-max)) 
    51925322      (insert "\n") 
    5193       (let ((file-name-coding-system nnmail-pathname-coding-system)) 
    5194         (mm-append-to-file (point-min) (point-max) file-name)) 
    5195       t))) 
     5323      (when coding 
     5324        ;; If the coding system is not suitable to encode the text, 
     5325        ;; ask a user for a proper one. 
     5326        (when (fboundp 'select-safe-coding-system) 
     5327          (setq coding (coding-system-base 
     5328                        (save-window-excursion 
     5329                          (select-safe-coding-system (point-min) (point-max) 
     5330                                                     coding)))) 
     5331          (setq coding-system-for-write 
     5332                (or (cdr (assq coding '((mule-utf-8 . utf-8)))) 
     5333                    coding))) 
     5334        (goto-char (point-min)) 
     5335        ;; Add the coding cookie. 
     5336        (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n" 
     5337                        coding-system-for-write))) 
     5338      (if exists 
     5339          (progn 
     5340            (write-region (point-min) (point-max) file-name nil 'no-message) 
     5341            (message "Appended to %s" file-name)) 
     5342        (write-region (point-min) (point-max) file-name)))) 
     5343  t) 
    51965344 
    51975345(defun gnus-narrow-to-page (&optional arg)