[gnu.emacs.bug] Bug in sendmail.el:mail-do-fcc

he@idt.unit.no (05/23/89)

In GNU Emacs 18.52.5 of Fri Mar 17 1989 on sigyn (berkeley-unix):

When mail-do-fcc is processed, and there is a buffer corresponding to the
fcc'd file, output to that buffer will fail with a "Buffer xxx is read-only"
error message. Also, the code in 18.52 inserts the contents of the message
being sent just after (point-max) in the fcc'd buffer. Since this buffer
usually is in RMAIL mode (?), a restriction on the buffer is in place, and
there is a fair chance you will see the fcc'd message appear as part of the
current message of the fcc'd buffer later on.

I think the fcc'd message should be appended at the end of the buffer, and
appear as a separate message (of course). The enclosed diff fixes that
problem, as well as the buffer-read-only problem.  By the way, sendmail.el
does not seem to have changed between 18.52 and 18.54, so it should drop in
easily on the later versions as well.

diff -c2 /local/emacs/lisp/sendmail.el sendmail.el
*** /local/emacs/lisp/sendmail.el	Sat Oct  8 18:09:58 1988
--- sendmail.el	Mon May 22 20:29:05 1989
***************
*** 294,299 ****
  		(save-excursion
  		  (set-buffer buffer)
! 		  (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)))
--- 294,303 ----
  		(save-excursion
  		  (set-buffer buffer)
! 		  (let ((buffer-read-only nil)
! 			(beg2 (point-min)) (end2 (point-max)))
! 		    (widen)
! 		    (goto-char (point-max))
! 		    (insert-buffer-substring curbuf beg end)
! 		    (narrow-to-region beg2 end2))))
  	    ;; Else append to the file directly.
  	    (write-region (point-min) (point-max) (car fcc-list) t)))

The (widen) ... (narrow-to-region...) crock is used instead of
(save-restriction), due to the warnings in the doc string for that function.
It would have been more elegant had (save-restriction) been sufficient (I
haven't tried this).


Haavard Eidnes, Division of Computer Systems and Telematics
he@idt.unit.no		Norwegian Institute of Technology

rms@AI.MIT.EDU (05/24/89)

The fcc field delivers mail in Unix format to Unix mail files.
It is not supposed to be used with rmail files.  Instead,
output to the inbox of the rmail file.

It would be a reasonable extension to allow output direct to
an rmail file, but this cannot work properly in general
unless the message is converted to rmail format when it
is output.

Otherwise, if messages are output in rmail format after
fcc messages, the file will appear to be in valid rmail
format and the fcc messages will be effectively lost.

Anyone want to do this?