Function: rmail-output-read-file-name

rmail-output-read-file-name is a byte-compiled function defined in rmailout.el.gz.

Signature

(rmail-output-read-file-name)

Documentation

Read the file name to use for rmail-output.

Set rmail-default-file to this name as well as returning it. This uses rmail-output-file-alist.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailout.el.gz
(defun rmail-output-read-file-name ()
  "Read the file name to use for `rmail-output'.
Set `rmail-default-file' to this name as well as returning it.
This uses `rmail-output-file-alist'."
  (let* ((default-file
	   (or
	    (when rmail-output-file-alist
	      (or rmail-buffer (error "There is no Rmail buffer"))
	      (save-current-buffer
		(set-buffer rmail-buffer)
		(let ((beg (rmail-msgbeg rmail-current-message))
		      (end (rmail-msgend rmail-current-message)))
		  (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
		  (save-excursion
		    (save-restriction
		      (widen)
		      (narrow-to-region beg end)
		      (let ((tail rmail-output-file-alist)
			    answer) ;; err
			;; Suggest a file based on a pattern match.
			(while (and tail (not answer))
			  (goto-char (point-min))
			  (if (re-search-forward (caar tail) nil t)
			      (setq answer
				    (condition-case err
					(eval (cdar tail) t)
				      (error
				       (display-warning
					'rmail-output
					(format-message "\
Error evaluating `rmail-output-file-alist' element:
regexp: %s
action: %s
error: %S\n"
						(caar tail) (cdar tail) err)
                                        :error)
				       nil))))
			  (setq tail (cdr tail)))
			answer))))))
	    ;; If no suggestion, use same file as last time.
	    rmail-default-file))
	 (read-file
	  (expand-file-name
	   (read-file-name
            (format-prompt "Output message to mail file"
                           (file-name-nondirectory default-file))
	    (file-name-directory default-file)
	    (abbreviate-file-name default-file))
	   (file-name-directory default-file))))
    (setq rmail-default-file
	  (if (file-directory-p read-file)
	      (expand-file-name (file-name-nondirectory default-file)
				read-file)
	    (expand-file-name
	     (or read-file (file-name-nondirectory default-file))
	     (file-name-directory default-file))))))