home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / emacs / bug / 1245 < prev    next >
Encoding:
Text File  |  1992-09-10  |  6.1 KB  |  163 lines

  1. Path: sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!edscom.demon.co.uk!kevin
  2. From: kevin@edscom.demon.co.uk (Kevin Broadey)
  3. Newsgroups: gnu.emacs.bug
  4. Subject: Re: rmail/sendmail bug
  5. Message-ID: <KEVIN.92Sep10113959@runningbear.edscom.demon.co.uk>
  6. Date: 10 Sep 92 11:39:59 GMT
  7. References: kevin@edscom.demon.co.uk (Kevin Broadey)
  8. Sender: gnulists@ai.mit.edu
  9. Reply-To: Kevin Broadey <kbroadey@edscom.demon.co.uk>
  10. Distribution: gnu
  11. Organization: EDS-Scicon, Milton Keynes, UK
  12. Lines: 148
  13. Approved: bug-gnu-emacs@prep.ai.mit.edu
  14.  
  15. >>>>> In article <9209092336.AA25413@ams.sunysb.edu>, "hho" ==
  16. >>>>> hanche@ams.sunysb.edu (Harald Hanche-Olsen) writes:
  17.  
  18.     hho> The following bug manifests itself when emacs tries to convert
  19.     hho> a file from mbox format to Babyl format.  Here is how to
  20.     hho> reproduce it:
  21.  
  22.     hho> [...]
  23.  
  24.     hho> I tried correcting it to allow either variant, only to discover
  25.     hho> that rmail-nuke-pinhead-header does the same.  And fixing it
  26.     hho> would be a tad more complicated, due to the replace-match using
  27.     hho> the regexp.  Rather than waste more time trying to correct
  28.     hho> this, I decided to report the bug.  I am not quite sure where
  29.     hho> is the "right" place to correct it - in mail-do-fcc or the
  30.     hho> other places.
  31.  
  32.     hho> Also, I would be very surprised if this bug has not already
  33.     hho> been reported and corrected, so maybe you have a fix ready?
  34.  
  35. You're right, it's already been found and fixed.  I posted an article
  36. about it last month.
  37.  
  38. The fault is in `mail-do-fcc' because it isn't putting the time in the
  39. correct UNIX mail format.  The fix is to use the output from the UNIX
  40. `date' command instead of (current-time-string).
  41.  
  42. In Emacs 18.58 there's already a call to `date', but this is just used
  43. to get the timezone - all the other info is discarded!
  44.  
  45. Attached is the diffs from sendmail.el in Emacs 18.58.  This also fixes
  46. another sendmail/rmail FCC problem - sendmail doesn't check to see
  47. whether the FCC file is being visited by emacs, it just appends the
  48. message to the disk file.  I've changed it so it will append it to the
  49. buffer instead, and if the buffer is in RMAIL mode, convert the message
  50. to BABYL format and update all RMAIL's info.
  51.  
  52. --Kevin
  53.  
  54. -- snip -- snip -- snip -- snip -- snip -- snip -- snip -- snip -- snip --
  55.  
  56. *** /usr/local/gnu/emacs-18.58/lisp/sendmail.el    Tue Jan 28 21:22:56 1992
  57. --- ./sendmail.el    Wed Sep  2 19:20:14 1992
  58. ***************
  59. *** 17,22 ****
  60. --- 17,34 ----
  61.   ;; along with GNU Emacs; see the file COPYING.  If not, write to
  62.   ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  63.   
  64. + ;; 02-09-92  Kevin Broadey  EDS-Scicon
  65. + ;; File Carbon Copy feature: Change mail-do-fcc to spot when the buffer
  66. + ;; visiting the FCC file is in RMAIL mode and make it append the message in
  67. + ;; BABYL format, updating rmail's variables as well.  Also, ask whether to
  68. + ;; append to a read-only buffer instead of bombing out.
  69. + ;;
  70. + ;; This has been unashamedly lifted from the GNUS `gnus-output-to-rmail'
  71. + ;; function.
  72. + ;;
  73. + ;; Also, fix longstanding bug in FCC: Use UNIX `date' instead of
  74. + ;; `current-time-string' to get timestamp so Rmail parses it successfully when
  75. + ;; converting to BABYL format.
  76.   
  77.   (provide 'sendmail)
  78.   
  79. ***************
  80. *** 259,265 ****
  81.   (defun mail-do-fcc (header-end)
  82.     (let (fcc-list
  83.       (rmailbuf (current-buffer))
  84. -     timezone
  85.       (tembuf (generate-new-buffer " rmail output"))
  86.       (case-fold-search t))
  87.       (save-excursion
  88. --- 271,276 ----
  89. ***************
  90. *** 275,289 ****
  91.                  (progn (forward-line 1) (point))))
  92.         (set-buffer tembuf)
  93.         (erase-buffer)
  94.         (call-process "date" nil t nil)
  95. -       (end-of-line)
  96. -       (forward-word -1)
  97. -       (delete-region (1- (point)) (point-max))
  98. -       (forward-word -1)
  99. -       (setq timezone (buffer-substring (point) (point-max)))
  100. -       (erase-buffer)
  101. -       (insert "\nFrom " (user-login-name) " "
  102. -           (current-time-string) " " timezone "\n")
  103.         (insert-buffer-substring rmailbuf)
  104.         ;; Make sure messages are separated.
  105.         (goto-char (point-max))
  106. --- 286,293 ----
  107.                  (progn (forward-line 1) (point))))
  108.         (set-buffer tembuf)
  109.         (erase-buffer)
  110. +       (insert "\nFrom " (user-login-name) " ")
  111.         (call-process "date" nil t nil)
  112.         (insert-buffer-substring rmailbuf)
  113.         ;; Make sure messages are separated.
  114.         (goto-char (point-max))
  115. ***************
  116. *** 302,311 ****
  117.             ;; File is present in a buffer => append to that buffer.
  118.             (let ((curbuf (current-buffer))
  119.               (beg (point-min)) (end (point-max)))
  120. !         (save-excursion
  121. !           (set-buffer buffer)
  122. !           (goto-char (point-max))
  123. !           (insert-buffer-substring curbuf beg end)))
  124.           ;; Else append to the file directly.
  125.           (write-region (point-min) (point-max) (car fcc-list) t)))
  126.       (setq fcc-list (cdr fcc-list))))
  127. --- 306,338 ----
  128.             ;; File is present in a buffer => append to that buffer.
  129.             (let ((curbuf (current-buffer))
  130.               (beg (point-min)) (end (point-max)))
  131. !         (set-buffer buffer)
  132. !         (if (eq major-mode 'rmail-mode)
  133. !             ;; buffer is in RMAIL mode - be clever with messages.
  134. !             (let ((buffer-read-only nil)
  135. !               (curmsg rmail-current-message))
  136. !               (widen)
  137. !               (narrow-to-region (point-max) (point-max))
  138. !               (insert-buffer-substring curbuf beg end)
  139. !               (rmail-convert-to-babyl-format)
  140. !               (goto-char (point-min))
  141. !               (widen)
  142. !               (search-backward "\^_")
  143. !               (narrow-to-region (point) (point-max))
  144. !               (goto-char (1+ (point-min)))
  145. !               (rmail-count-new-messages t)
  146. !               (rmail-show-message curmsg))
  147. !           ;; Else not in rmail-mode - tag message on at end.
  148. !           (if (or (not buffer-read-only)
  149. !               (y-or-n-p
  150. !                (format "Buffer %s is read-only. Append anyway? "
  151. !                    (buffer-name buffer))))
  152. !               (let ((buffer-read-only nil))
  153. !             (save-excursion
  154. !               (save-restriction
  155. !                 (goto-char (point-max))
  156. !                 (insert-buffer-substring curbuf beg end))))
  157. !             )))
  158.           ;; Else append to the file directly.
  159.           (write-region (point-min) (point-max) (car fcc-list) t)))
  160.       (setq fcc-list (cdr fcc-list))))
  161.  
  162. -- snip -- snip -- snip -- snip -- snip -- snip -- snip -- snip -- snip --
  163.