+a file name as a string."
+ :type '(repeat (cons regexp
+ (choice :value ""
+ (string :tag "File Name")
+ sexp)))
+ :group 'rmail-output)
+
+(defun rmail-output-read-rmail-file-name ()
+ "Read the file name to use for `rmail-output-to-rmail-file'.
+Set `rmail-default-rmail-file' to this name as well as returning it."
+ (let ((default-file
+ (let (answer tail)
+ (setq tail rmail-output-file-alist)
+ ;; Suggest a file based on a pattern match.
+ (while (and tail (not answer))
+ (save-excursion
+ (set-buffer rmail-buffer)
+ (goto-char (point-min))
+ (if (re-search-forward (car (car tail)) nil t)
+ (setq answer (eval (cdr (car tail)))))
+ (setq tail (cdr tail))))
+ ;; If no suggestions, use same file as last time.
+ (expand-file-name (or answer rmail-default-rmail-file)))))
+ (let ((read-file
+ (expand-file-name
+ (read-file-name
+ (concat "Output message to Rmail file: (default "
+ (file-name-nondirectory default-file)
+ ") ")
+ (file-name-directory default-file)
+ (abbreviate-file-name default-file))
+ (file-name-directory default-file))))
+ ;; If the user enters just a directory,
+ ;; use the name within that directory chosen by the default.
+ (setq rmail-default-rmail-file
+ (if (file-directory-p read-file)
+ (expand-file-name (file-name-nondirectory default-file)
+ read-file)
+ read-file)))))