bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#2228: 23.0.90; rmail-cease-edit ignores changes to the message heade


From: Glenn Morris
Subject: bug#2228: 23.0.90; rmail-cease-edit ignores changes to the message headers
Date: Wed, 11 Feb 2009 21:36:10 -0500
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Stefan Monnier wrote:

>> Me installing the 10 line fix I have for the above problem will not
>> make it any harder for someone to write those 200 lines in the future.
>
> Can you show us that fix?


*** rmailedit.el        10 Feb 2009 03:33:48 -0000      1.50
--- rmailedit.el        12 Feb 2009 02:36:41 -0000
***************
*** 78,88 ****
  
  ;;;###autoload
  (defun rmail-edit-current-message ()
!   "Edit the contents of this message."
    (interactive)
    (if (zerop rmail-total-messages)
        (error "No messages in this buffer"))
!   (set (make-local-variable 'rmail-old-pruned) (rmail-msg-is-pruned))
    (rmail-edit-mode)
    (set (make-local-variable 'rmail-old-text)
         (save-restriction
--- 78,92 ----
  
  ;;;###autoload
  (defun rmail-edit-current-message ()
!   "Edit the contents of this message.
! Expands the header, moves point to the start of the body."
    (interactive)
    (if (zerop rmail-total-messages)
        (error "No messages in this buffer"))
!   (if (set (make-local-variable 'rmail-old-pruned) (rmail-msg-is-pruned))
!       (rmail-toggle-header 0))                ; expand headers
!   (goto-char (point-min))
!   (search-forward "\n\n" nil t)               ; move to start of body
    (rmail-edit-mode)
    (set (make-local-variable 'rmail-old-text)
         (save-restriction
***************
*** 113,119 ****
    ;; Disguise any "From " lines so they don't start a new message.
    (save-excursion
      (goto-char (point-min))
!     (or rmail-old-pruned (forward-line 1))
      (while (re-search-forward "^>*From " nil t)
        (beginning-of-line)
        (insert ">")
--- 117,123 ----
    ;; Disguise any "From " lines so they don't start a new message.
    (save-excursion
      (goto-char (point-min))
!     (forward-line 1)                 ; leave the initial ^From alone
      (while (re-search-forward "^>*From " nil t)
        (beginning-of-line)
        (insert ">")
***************
*** 126,135 ****
        (insert "\n"))
      (unless (looking-back "\n\n")
        (insert "\n")))
    (let ((old rmail-old-text)
        (pruned rmail-old-pruned)
        character-coding is-text-message coding-system
!       headers-end limit)
      ;; Go back to Rmail mode, but carefully.
      (force-mode-line-update)
      (let ((rmail-buffer-swapped nil)) ; Prevent change-major-mode-hook
--- 130,140 ----
        (insert "\n"))
      (unless (looking-back "\n\n")
        (insert "\n")))
+   ;; FIXME should also ensure \n\n still ends the headers.
    (let ((old rmail-old-text)
        (pruned rmail-old-pruned)
        character-coding is-text-message coding-system
!       start limit)
      ;; Go back to Rmail mode, but carefully.
      (force-mode-line-update)
      (let ((rmail-buffer-swapped nil)) ; Prevent change-major-mode-hook
***************
*** 143,152 ****
      ;; If text has really changed, mark message as edited.
      (unless (and (= (length old) (- (point-max) (point-min)))
                 (string= old (buffer-substring (point-min) (point-max))))
!       (setq old nil)
!       (goto-char (point-min))
!       (search-forward "\n\n")
!       (setq headers-end (point))
        (rmail-swap-buffers-maybe)
        (narrow-to-region (rmail-msgbeg rmail-current-message)
                        (rmail-msgend rmail-current-message))
--- 148,155 ----
      ;; If text has really changed, mark message as edited.
      (unless (and (= (length old) (- (point-max) (point-min)))
                 (string= old (buffer-substring (point-min) (point-max))))
!       (setq old nil
!           start (goto-char (point-min)))
        (rmail-swap-buffers-maybe)
        (narrow-to-region (rmail-msgbeg rmail-current-message)
                        (rmail-msgend rmail-current-message))
***************
*** 165,176 ****
        (if character-coding
          (setq character-coding (downcase character-coding)))
  
!       (goto-char limit)
        (let ((inhibit-read-only t))
        (let ((data-buffer (current-buffer))
              (end (copy-marker (point) t)))
          (with-current-buffer rmail-view-buffer
!           (encode-coding-region headers-end (point-max) coding-system
                                  data-buffer))
          (delete-region end (point-max)))
  
--- 168,179 ----
        (if character-coding
          (setq character-coding (downcase character-coding)))
  
!       (goto-char (point-min))
        (let ((inhibit-read-only t))
        (let ((data-buffer (current-buffer))
              (end (copy-marker (point) t)))
          (with-current-buffer rmail-view-buffer
!           (encode-coding-region start (point-max) coding-system
                                  data-buffer))
          (delete-region end (point-max)))
  






reply via email to

[Prev in Thread] Current Thread [Next in Thread]