Article View: gnu.emacs.vm.bug
Article #9178Re: FCC to visited vm folder
From: Jamie Zawinski
Date: Tue, 10 Mar 1992 23:19
Date: Tue, 10 Mar 1992 23:19
99 lines
4098 bytes
4098 bytes
<This is a recording...>
;;; hacked to work on BABYL and VM buffers.
(defun mail-do-fcc (header-end)
(let (fcc-list
(rmailbuf (current-buffer))
(tembuf (generate-new-buffer " rmail output"))
(case-fold-search t))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^FCC:[ \t]*" header-end t)
(setq fcc-list (cons (buffer-substring (point)
(progn
(end-of-line)
(skip-chars-backward " \t")
(point)))
fcc-list))
(delete-region (match-beginning 0)
(progn (forward-line 1) (point))))
(set-buffer tembuf)
(erase-buffer)
(insert "\nFrom " (user-login-name) " "
(current-time-string) "\n")
(insert-buffer-substring rmailbuf)
;; Make sure messages are separated.
(goto-char (point-max))
(insert ?\n)
(goto-char 2)
;; ``Quote'' "^From " as ">From "
;; (note that this isn't really quoting, as there is no requirement
;; that "^[>]+From " be quoted in the same transparent way.)
(let ((case-fold-search nil))
(while (search-forward "\nFrom " nil t)
(forward-char -5)
(insert ?>)))
(while fcc-list
(let ((buffer (get-file-buffer (car fcc-list))))
(if buffer
;; File is present in a buffer => append to that buffer.
(let ((curbuf (current-buffer))
(beg (point-min)) (end (point-max)))
(save-excursion
(set-buffer buffer)
(cond
;;
;; Append as a message to an RMAIL buffer.
((eq major-mode 'rmail-mode)
(let ((b (point-min))
(e (point-max))
(buffer-read-only nil))
(unwind-protect
(progn
(widen)
(goto-char (point-max))
;; This forces RMAIL's message counters to be
;; recomputed when the next RMAIL operation is
;; done on the buffer.
;; See rmail-maybe-set-message-counters.
(setq rmail-total-messages nil)
(insert "\^L\n0, unseen,,\n*** EOOH ***")
;; Should only insert From: if it's not there
;; already, but...
(insert "\nFrom: " (user-login-name))
(insert "\nDate: " (current-time-string))
;; insert a comma after the day-of-week.
(beginning-of-line) (forward-word 2) (insert ?,)
(end-of-line)
(insert "\n")
(insert-buffer-substring rmailbuf)
(insert "\n\C-_"))
(narrow-to-region b e)
(rmail-maybe-set-message-counters))))
;;
;; Append a message to a VM buffer.
((eq major-mode 'vm-mode)
(let ((buffer-read-only nil))
(vm-save-restriction
(widen)
(goto-char (point-max))
(insert-buffer-substring curbuf beg end)
(vm-increment vm-messages-not-on-disk)
(vm-set-buffer-modified-p t)
(vm-clear-modification-flag-undos)
(vm-check-for-killed-summary)
(vm-assimilate-new-messages)
(vm-update-summary-and-mode-line))))
(t
;; Append to an ordinary buffer as a Unix mail message.
(goto-char (point-max))
(insert-buffer-substring curbuf beg end)))))
;; Else append to the file directly.
;; (It's OK if it is an RMAIL or VM file -- the message will be
;; parsed when the file is read in.)
(write-region
;; Include a blank line before if file already exists.
(if (file-exists-p (car fcc-list)) (point-min) (1+ (point-min)))
(point-max) (car fcc-list) t)))
(setq fcc-list (cdr fcc-list))))
(kill-buffer tembuf)))
Technical Details
Message-ID:
<9203102319.AA09795@thalidomide.lucid>Path:
arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vmReferences:
<9203102305.AA00414@geech.gnu.ai.mit.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6829,1918cebdc1c7377 X-Google-Attributes: gidf6829,public X-Google-ArrivalTime: 1992-03-10 15:24:17 PST Newsgroups: gnu.emacs.vm.bug Sender: bug-vm-request@uunet.uu.net Date: Tue, 10 Mar 92 15:19:04 PST Message-ID: <9203102319.AA09795@thalidomide.lucid> X-Windows: Dissatisfaction guaranteed. From: Jamie Zawinski <jwz@lucid.com> Subject: Re: FCC to visited vm folder References: <9203102305.AA00414@geech.gnu.ai.mit.edu> Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm