home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / emacs / 3937 < prev    next >
Encoding:
Text File  |  1993-01-08  |  4.2 KB  |  121 lines

  1. Newsgroups: comp.emacs
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!ucivax!megatek!hollen
  3. From: hollen@megatek.UUCP (Dion Hollenbeck)
  4. Subject: Re: Sending mail while the file ~/outfold is visited
  5. In-Reply-To: hancu@crim.ca's message of 8 Jan 93 20: 20:56 GMT
  6. Message-ID: <HOLLEN.93Jan8183310@peg.megatek.UUCP>
  7. Sender: hollen@megatek.com (Dion Hollenbeck)
  8. Organization: Megatek Corporation, San Diego, California
  9. References: <hancu.726524456@clouso>
  10. Date: Sat, 9 Jan 1993 02:33:10 GMT
  11. Lines: 108
  12.  
  13. >>>>> On 8 Jan 93 20:20:56 GMT, hancu@crim.ca (Marius Hancu) said:
  14. Marius> Nntp-Posting-Host: drebin.crim.ca
  15.  
  16. Marius> My outgoing mail is saved in the ~/outfold file. However, I seemes
  17. Marius> troubles are generated when I try C-c C-s or C-c C-c while this file
  18. Marius> has been previously been visited and the corresponding buffer is open.
  19. Marius> Emacs tells me the buffer is read-only.
  20.  
  21. Marius> I found this in the emacs FAQ:
  22. Marius>  
  23.  
  24. Marius>  WARNING: If you are visiting the file ~/outgoing at the time you send
  25. Marius>      the mail, this can cause a variety of horrible problems.  Jamie
  26. Marius>      Zawinski has written a solution for this.
  27.  
  28. Marius> I wonder if you have this solution or if you have Jamie's Zawinski
  29. Marius> email address. 
  30.  
  31. Here is a solution which has been previously posted.  I don't know if
  32. it is Jamie's.  
  33.  
  34.  
  35.  
  36. ;;  modified version of mail-do-fcc
  37.  
  38. (defun mail-do-fcc (header-end)
  39.   (let (fcc-list
  40.     (rmailbuf (current-buffer))
  41.     timezone
  42.     (tembuf (generate-new-buffer " rmail output"))
  43.     (case-fold-search t))
  44.     (save-excursion
  45.       (goto-char (point-min))
  46.       (while (re-search-forward "^FCC:[ \t]*" header-end t)
  47.     (setq fcc-list (cons (buffer-substring (point)
  48.                            (progn
  49.                          (end-of-line)
  50.                          (skip-chars-backward " \t")
  51.                          (point)))
  52.                  fcc-list))
  53.     (delete-region (match-beginning 0)
  54.                (progn (forward-line 1) (point))))
  55.       (set-buffer tembuf)
  56.       (erase-buffer)
  57.       (call-process "date" nil t nil)
  58.       (end-of-line)
  59.       (forward-word -1)
  60.       (delete-region (1- (point)) (point-max))
  61.       (forward-word -1)
  62.       (setq timezone (buffer-substring (point) (point-max)))
  63.       (erase-buffer)
  64.       (insert "\nFrom " (user-login-name) " ")
  65.       (call-process "date" nil t nil)
  66.       (insert-buffer-substring rmailbuf)
  67.       ;; Make sure messages are separated.
  68.       (goto-char (point-max))
  69.       (insert ?\n)
  70.       (goto-char 2)
  71.       ;; ``Quote'' "^From " as ">From "
  72.       ;;  (note that this isn't really quoting, as there is no requirement
  73.       ;;   that "^[>]+From " be quoted in the same transparent way.)
  74.       (let ((case-fold-search nil))
  75.     (while (search-forward "\nFrom " nil t)
  76.       (forward-char -5)
  77.       (insert ?>)))
  78.       (while fcc-list
  79.     (let ((buffer (get-file-buffer (car fcc-list))))
  80.       (if buffer
  81.           ;; File is present in a buffer => append to that buffer.
  82.             (let ((curbuf (current-buffer))
  83.               (beg (point-min)) (end (point-max)))
  84.         (set-buffer buffer)
  85.         (if (eq major-mode 'rmail-mode)
  86.             ;; buffer is in RMAIL mode - be clever with messages.
  87.             (let ((buffer-read-only nil)
  88.               (curmsg rmail-current-message))
  89.               (widen)
  90.               (narrow-to-region (point-max) (point-max))
  91.               (insert-buffer-substring curbuf beg end)
  92.               (rmail-convert-to-babyl-format)
  93.               (goto-char (point-min))
  94.               (widen)
  95.               (search-backward "\^_")
  96.               (narrow-to-region (point) (point-max))
  97.               (goto-char (1+ (point-min)))
  98.               (rmail-count-new-messages t)
  99.               (rmail-show-message curmsg)
  100.               (save-buffer))
  101.           ;; Else not in rmail-mode - tag message on at end.
  102.           (if (or (not buffer-read-only)
  103.               (y-or-n-p
  104.                (format "Buffer %s is read-only. Append anyway? "
  105.                    (buffer-name buffer))))
  106.               (let ((buffer-read-only nil))
  107.             (save-excursion
  108.               (save-restriction
  109.                 (goto-char (point-max))
  110.                 (insert-buffer-substring curbuf beg end))))
  111.             )))
  112.         ;; Else append to the file directly.
  113.         (write-region (point-min) (point-max) (car fcc-list) t)))
  114.     (setq fcc-list (cdr fcc-list))))
  115.     (kill-buffer tembuf)))
  116.  
  117. -- 
  118. Dion Hollenbeck                        Email: hollen@megatek.com
  119. Senior Software Engineer                      megatek!hollen@uunet.uu.net
  120. Megatek Corporation, San Diego, California    ucsd!megatek.uucp!hollen
  121.