home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.emacs
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!ucivax!megatek!hollen
- From: hollen@megatek.UUCP (Dion Hollenbeck)
- Subject: Re: Sending mail while the file ~/outfold is visited
- In-Reply-To: hancu@crim.ca's message of 8 Jan 93 20: 20:56 GMT
- Message-ID: <HOLLEN.93Jan8183310@peg.megatek.UUCP>
- Sender: hollen@megatek.com (Dion Hollenbeck)
- Organization: Megatek Corporation, San Diego, California
- References: <hancu.726524456@clouso>
- Date: Sat, 9 Jan 1993 02:33:10 GMT
- Lines: 108
-
- >>>>> On 8 Jan 93 20:20:56 GMT, hancu@crim.ca (Marius Hancu) said:
- Marius> Nntp-Posting-Host: drebin.crim.ca
-
- Marius> My outgoing mail is saved in the ~/outfold file. However, I seemes
- Marius> troubles are generated when I try C-c C-s or C-c C-c while this file
- Marius> has been previously been visited and the corresponding buffer is open.
- Marius> Emacs tells me the buffer is read-only.
-
- Marius> I found this in the emacs FAQ:
- Marius>
-
- Marius> WARNING: If you are visiting the file ~/outgoing at the time you send
- Marius> the mail, this can cause a variety of horrible problems. Jamie
- Marius> Zawinski has written a solution for this.
-
- Marius> I wonder if you have this solution or if you have Jamie's Zawinski
- Marius> email address.
-
- Here is a solution which has been previously posted. I don't know if
- it is Jamie's.
-
-
-
- ;; modified version of mail-do-fcc
-
- (defun mail-do-fcc (header-end)
- (let (fcc-list
- (rmailbuf (current-buffer))
- timezone
- (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)
- (call-process "date" nil t nil)
- (end-of-line)
- (forward-word -1)
- (delete-region (1- (point)) (point-max))
- (forward-word -1)
- (setq timezone (buffer-substring (point) (point-max)))
- (erase-buffer)
- (insert "\nFrom " (user-login-name) " ")
- (call-process "date" nil t nil)
- (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)))
- (set-buffer buffer)
- (if (eq major-mode 'rmail-mode)
- ;; buffer is in RMAIL mode - be clever with messages.
- (let ((buffer-read-only nil)
- (curmsg rmail-current-message))
- (widen)
- (narrow-to-region (point-max) (point-max))
- (insert-buffer-substring curbuf beg end)
- (rmail-convert-to-babyl-format)
- (goto-char (point-min))
- (widen)
- (search-backward "\^_")
- (narrow-to-region (point) (point-max))
- (goto-char (1+ (point-min)))
- (rmail-count-new-messages t)
- (rmail-show-message curmsg)
- (save-buffer))
- ;; Else not in rmail-mode - tag message on at end.
- (if (or (not buffer-read-only)
- (y-or-n-p
- (format "Buffer %s is read-only. Append anyway? "
- (buffer-name buffer))))
- (let ((buffer-read-only nil))
- (save-excursion
- (save-restriction
- (goto-char (point-max))
- (insert-buffer-substring curbuf beg end))))
- )))
- ;; Else append to the file directly.
- (write-region (point-min) (point-max) (car fcc-list) t)))
- (setq fcc-list (cdr fcc-list))))
- (kill-buffer tembuf)))
-
- --
- Dion Hollenbeck Email: hollen@megatek.com
- Senior Software Engineer megatek!hollen@uunet.uu.net
- Megatek Corporation, San Diego, California ucsd!megatek.uucp!hollen
-