(rmail-output): If file is an Rmail file,
use rmail-output-to-rmail-file. (rmail-output-to-rmail-file): If file exists and is not an Rmail file, use rmail-output. If we find an element in rmail-output-file-alist, eval it. (rmail-file-p): New function. (rmail-output-file-alist): Now contains expressions to eval.
This commit is contained in:
parent
f920529b21
commit
dba3adb09b
1 changed files with 117 additions and 109 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file.
|
;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file.
|
||||||
|
|
||||||
;; Copyright (C) 1985, 1987 Free Software Foundation, Inc.
|
;; Copyright (C) 1985, 1987, 1993 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Maintainer: FSF
|
;; Maintainer: FSF
|
||||||
;; Keywords: mail
|
;; Keywords: mail
|
||||||
|
@ -29,7 +29,10 @@
|
||||||
|
|
||||||
(defvar rmail-output-file-alist nil
|
(defvar rmail-output-file-alist nil
|
||||||
"*Alist matching regexps to suggested output Rmail files.
|
"*Alist matching regexps to suggested output Rmail files.
|
||||||
This is a list of elements of the form (REGEXP . FILENAME).")
|
This is a list of elements of the form (REGEXP . NAME-EXP).
|
||||||
|
NAME-EXP may be a string constant giving the file name to use,
|
||||||
|
or more generally it may be any kind of expression that returns
|
||||||
|
a file name as a string.")
|
||||||
|
|
||||||
;;; There are functions elsewhere in Emacs that use this function; check
|
;;; There are functions elsewhere in Emacs that use this function; check
|
||||||
;;; them out before you change the calling method.
|
;;; them out before you change the calling method.
|
||||||
|
@ -38,6 +41,9 @@ This is a list of elements of the form (REGEXP . FILENAME).")
|
||||||
If the file does not exist, ask if it should be created.
|
If the file does not exist, ask if it should be created.
|
||||||
If file is being visited, the message is appended to the Emacs
|
If file is being visited, the message is appended to the Emacs
|
||||||
buffer visiting that file.
|
buffer visiting that file.
|
||||||
|
If the file exists and is not an Rmail file,
|
||||||
|
the message is appended in inbox format.
|
||||||
|
|
||||||
A prefix argument N says to output N consecutive messages
|
A prefix argument N says to output N consecutive messages
|
||||||
starting with the current one. Deleted messages are skipped and don't count."
|
starting with the current one. Deleted messages are skipped and don't count."
|
||||||
(interactive
|
(interactive
|
||||||
|
@ -49,7 +55,7 @@ starting with the current one. Deleted messages are skipped and don't count."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (re-search-forward (car (car tail)) nil t)
|
(if (re-search-forward (car (car tail)) nil t)
|
||||||
(setq answer (cdr (car tail))))
|
(setq answer (eval (cdr (car tail)))))
|
||||||
(setq tail (cdr tail))))
|
(setq tail (cdr tail))))
|
||||||
;; If not suggestions, use same file as last time.
|
;; If not suggestions, use same file as last time.
|
||||||
(or answer rmail-last-rmail-file))))
|
(or answer rmail-last-rmail-file))))
|
||||||
|
@ -64,6 +70,8 @@ starting with the current one. Deleted messages are skipped and don't count."
|
||||||
(setq file-name
|
(setq file-name
|
||||||
(expand-file-name file-name
|
(expand-file-name file-name
|
||||||
(file-name-directory rmail-last-rmail-file)))
|
(file-name-directory rmail-last-rmail-file)))
|
||||||
|
(if (and (file-readable-p file-name) (not (rmail-file-p file-name)))
|
||||||
|
(rmail-output file-name count)
|
||||||
(setq rmail-last-rmail-file file-name)
|
(setq rmail-last-rmail-file file-name)
|
||||||
(rmail-maybe-set-message-counters)
|
(rmail-maybe-set-message-counters)
|
||||||
(setq file-name (abbreviate-file-name file-name))
|
(setq file-name (abbreviate-file-name file-name))
|
||||||
|
@ -126,7 +134,17 @@ starting with the current one. Deleted messages are skipped and don't count."
|
||||||
(if rmail-delete-after-output
|
(if rmail-delete-after-output
|
||||||
(rmail-delete-forward)
|
(rmail-delete-forward)
|
||||||
(if (> count 0)
|
(if (> count 0)
|
||||||
(rmail-next-undeleted-message 1)))))
|
(rmail-next-undeleted-message 1))))))
|
||||||
|
|
||||||
|
;; Returns t if file FILE is an Rmail file.
|
||||||
|
(defun rmail-file-p (file)
|
||||||
|
(let ((buf (generate-new-buffer " *rmail-file-p*")))
|
||||||
|
(unwind-protect
|
||||||
|
(save-excursion
|
||||||
|
(set-buffer buf)
|
||||||
|
(insert-file-contents file nil 0 100)
|
||||||
|
(looking-at "BABYL OPTIONS:"))
|
||||||
|
(kill-buffer buf))))
|
||||||
|
|
||||||
;;; There are functions elsewhere in Emacs that use this function; check
|
;;; There are functions elsewhere in Emacs that use this function; check
|
||||||
;;; them out before you change the calling method.
|
;;; them out before you change the calling method.
|
||||||
|
@ -151,6 +169,8 @@ When called from lisp code, N may be omitted."
|
||||||
(expand-file-name file-name
|
(expand-file-name file-name
|
||||||
(and rmail-last-file
|
(and rmail-last-file
|
||||||
(file-name-directory rmail-last-file))))
|
(file-name-directory rmail-last-file))))
|
||||||
|
(if (and (file-readable-p file) (rmail-file-p file-name))
|
||||||
|
(rmail-output-to-rmail-file file-name count)
|
||||||
(setq rmail-last-file file-name)
|
(setq rmail-last-file file-name)
|
||||||
(while (> count 0)
|
(while (> count 0)
|
||||||
(let ((rmailbuf (current-buffer))
|
(let ((rmailbuf (current-buffer))
|
||||||
|
@ -159,18 +179,6 @@ When called from lisp code, N may be omitted."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(set-buffer tembuf)
|
(set-buffer tembuf)
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
;; If we can do it, read a little of the file
|
|
||||||
;; to check whether it is an RMAIL file.
|
|
||||||
;; If it is, don't mess it up.
|
|
||||||
(and (file-readable-p file-name)
|
|
||||||
(progn (insert-file-contents file-name nil 0 20)
|
|
||||||
(looking-at "BABYL OPTIONS:\n"))
|
|
||||||
(error (save-excursion
|
|
||||||
(set-buffer rmailbuf)
|
|
||||||
(substitute-command-keys
|
|
||||||
"Use \\[rmail-output-to-rmail-file] to output to Rmail file `%s'"))
|
|
||||||
(file-name-nondirectory file-name)))
|
|
||||||
(erase-buffer)
|
|
||||||
(insert-buffer-substring rmailbuf)
|
(insert-buffer-substring rmailbuf)
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue