Changeset 4098 for trunk/lisp/gnus/gnus-art.el
- Timestamp:
- 07/01/06 08:27:06 (3 years ago)
- Files:
-
- trunk/lisp/gnus/gnus-art.el (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/gnus/gnus-art.el
r4079 r4098 493 493 494 494 (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. 496 This will be overridden by the `:headers' property that the symbol of 497 the saver function, which is specified by `gnus-default-article-saver', 498 might have." 496 499 :group 'gnus-article-saving 497 500 :type 'boolean) … … 514 517 If `gnus-save-all-headers' is non-nil, this variable will be ignored. 515 518 If that variable is nil, however, all headers that match this regexp 516 will be kept while the rest will be deleted before saving." 519 will be kept while the rest will be deleted before saving. This and 520 `gnus-save-all-headers' will be overridden by the `:headers' property 521 that the symbol of the saver function, which is specified by 522 `gnus-default-article-saver', might have." 517 523 :group 'gnus-article-saving 518 524 :type 'regexp) … … 520 526 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail 521 527 "A function to save articles in your favourite format. 522 The function must be interactively callable (in other words, it must523 be an Emacs command).528 The function will be called by way of the `gnus-summary-save-article' 529 command, and friends such as `gnus-summary-save-article-rmail'. 524 530 525 531 Gnus provides the following functions: … … 531 537 * gnus-summary-save-body-in-file (article body) 532 538 * 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 542 The symbol of each function may have the following properties: 543 544 * :decode 545 The value non-nil means save decoded articles. This is meaningful 546 only 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 550 The value specifies an alternative function which appends, not 551 overwrites, articles to a file. This implies that when saving many 552 articles at a time, `gnus-prompt-before-saving' is bound to t and all 553 articles 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 557 The value specifies the symbol of a variable of which the value 558 specifies headers to be saved. If it is omitted, 559 `gnus-save-all-headers' and `gnus-saved-headers' control what 560 headers should be saved." 534 561 :group 'gnus-article-saving 535 562 :type '(radio (function-item gnus-summary-save-in-rmail) … … 540 567 (function-item gnus-summary-save-in-vm) 541 568 (function-item gnus-summary-write-to-file) 569 (function-item gnus-summary-write-body-to-file) 542 570 (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 579 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on, 580 which can safely encode any characters in text. This is used by the 581 commands 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 588 and 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 595 Those commands and functions save just text displayed in the article 596 buffer to a file if the value of this variable is non-nil. Note that 597 buttonized MIME parts will be lost in a saved file in that case. 598 Otherwise, 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"))) 543 611 544 612 (defcustom gnus-rmail-save-name 'gnus-plain-save-name … … 3250 3318 (defun gnus-article-save (save-buffer file &optional num) 3251 3319 "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. 3254 3324 (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)) 3256 3327 (gnus-article-buffer save-buffer)) 3257 3328 (save-excursion … … 3278 3349 3279 3350 (defun gnus-read-save-file-name (prompt &optional filename 3280 function group headers variable) 3351 function group headers variable 3352 dir-var) 3281 3353 (let ((default-name 3282 3354 (funcall function group headers (symbol-value variable))) … … 3291 3363 (filename filename) 3292 3364 (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)))) 3293 3369 (let* ((split-name (gnus-get-split-value gnus-split-methods)) 3294 3370 (prompt … … 3355 3431 (nnheader-translate-file-chars file)))))) 3356 3432 (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)) 3358 3438 3359 3439 (defun gnus-article-archive-name (group) … … 3403 3483 filename) 3404 3484 3485 (put 'gnus-summary-save-in-file :decode t) 3486 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers) 3405 3487 (defun gnus-summary-save-in-file (&optional filename overwrite) 3406 3488 "Append this article to file. … … 3421 3503 filename) 3422 3504 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) 3423 3508 (defun gnus-summary-write-to-file (&optional filename) 3424 3509 "Write this article to a file, overwriting it if the file exists. 3425 3510 Optional argument FILENAME specifies file name. 3426 3511 The 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) 3430 3520 "Append this article body to a file. 3431 3521 Optional argument FILENAME specifies file name. … … 3441 3531 (when (article-goto-body) 3442 3532 (narrow-to-region (point) (point-max))) 3533 (when (and overwrite 3534 (file-exists-p filename)) 3535 (delete-file filename)) 3443 3536 (gnus-output-to-file filename)))) 3444 3537 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. 3544 Optional argument FILENAME specifies file name. 3545 The 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)) 3445 3551 3446 3552 (defun gnus-summary-save-in-pipe (&optional command) … … 4822 4928 (narrow-to-region (point-min) (point)) 4823 4929 (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")))) 4825 4935 4826 4936 (defcustom gnus-mime-display-multipart-as-mixed nil … … 5183 5293 5184 5294 (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. 5296 If `gnus-article-save-coding-system' is non-nil, it is used to encode 5297 text and used as the value of the coding cookie which is added to the 5298 top of a file. Otherwise, this function saves a raw article without 5299 the 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))) 5187 5310 (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)) 5188 5318 (insert-buffer-substring artbuf) 5189 5319 ;; Append newline at end of the buffer as separator, and then … … 5191 5321 (goto-char (point-max)) 5192 5322 (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) 5196 5344 5197 5345 (defun gnus-narrow-to-page (&optional arg)
