Commit 0b44494a authored by Glenn Morris's avatar Glenn Morris
Browse files

(rmail-cease-edit): Give an error if the end of the headers cannot be

located.  Simplify, subtracting superflous save-excursions.
(See http://lists.gnu.org/archive/html/bug-gnu-emacs/2009-10/msg00182.html)
parent d5e63715
2009-10-15 Glenn Morris <rgm@gnu.org>
* mail/rmailedit.el (rmail-cease-edit): Give an error if the end of
the headers cannot be located. Simplify, subtracting superflous
save-excursions.
2009-10-15 Stefan Monnier <monnier@iro.umontreal.ca> 2009-10-15 Stefan Monnier <monnier@iro.umontreal.ca>
Replace completion-base-size by completion-base-position to fix bugs Replace completion-base-size by completion-base-position to fix bugs
......
...@@ -126,19 +126,23 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. ...@@ -126,19 +126,23 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
(with-current-buffer rmail-summary-buffer (with-current-buffer rmail-summary-buffer
(rmail-summary-enable))) (rmail-summary-enable)))
(widen) (widen)
(goto-char (point-min))
;; This is far from ideal. The edit may have inadvertently
;; removed the blank line at the end of the headers, but there
;; are almost certainly other blank lines.
(or (search-forward "\n\n" nil t)
(error "There must be a blank line at the end of the headers"))
;; Disguise any "From " lines so they don't start a new message. ;; Disguise any "From " lines so they don't start a new message.
(save-excursion
(goto-char (point-min)) (goto-char (point-min))
(or rmail-old-pruned (forward-line 1)) (or rmail-old-pruned (forward-line 1))
(while (re-search-forward "^>*From " nil t) (while (re-search-forward "^>*From " nil t)
(beginning-of-line) (beginning-of-line)
(insert ">") (insert ">")
(forward-line))) (forward-line))
;; Make sure buffer ends with a blank line so as not to run this ;; Make sure buffer ends with a blank line so as not to run this
;; message together with the following one. ;; message together with the following one.
(save-excursion
(goto-char (point-max)) (goto-char (point-max))
(rmail-ensure-blank-line)) (rmail-ensure-blank-line)
(let ((old rmail-old-text) (let ((old rmail-old-text)
(pruned rmail-old-pruned) (pruned rmail-old-pruned)
;; People who know what they are doing might have modified the ;; People who know what they are doing might have modified the
...@@ -168,7 +172,6 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. ...@@ -168,7 +172,6 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
(string= old (buffer-substring (point-min) (point-max)))) (string= old (buffer-substring (point-min) (point-max))))
(setq old nil) (setq old nil)
(goto-char (point-min)) (goto-char (point-min))
;; FIXME the edit may have inadvertently removed this.
(search-forward "\n\n") (search-forward "\n\n")
(setq headers-end (point-marker)) (setq headers-end (point-marker))
(goto-char (point-min)) (goto-char (point-min))
...@@ -204,20 +207,16 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. ...@@ -204,20 +207,16 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
(goto-char mime-end) (goto-char mime-end)
(delete-region mime-beg mime-end) (delete-region mime-beg mime-end)
(insert mime-charset))))) (insert mime-charset)))))
(goto-char headers-end)
(setq new-headers (rmail-edit-headers-alist t)) (setq new-headers (rmail-edit-headers-alist t))
(rmail-swap-buffers-maybe) (rmail-swap-buffers-maybe)
(narrow-to-region (rmail-msgbeg rmail-current-message) (narrow-to-region (rmail-msgbeg rmail-current-message)
(rmail-msgend rmail-current-message)) (rmail-msgend rmail-current-message))
(save-restriction
(setq limit
(save-excursion
(goto-char (point-min)) (goto-char (point-min))
;; FIXME this should not be using NOERROR. (setq limit (search-forward "\n\n"))
(search-forward "\n\n" nil t))) (save-restriction
;; All 3 of the functions we call below assume the buffer was ;; All 3 of the functions we call below assume the buffer was
;; narrowed to just the headers of the message. ;; narrowed to just the headers of the message.
(narrow-to-region (rmail-msgbeg rmail-current-message) limit) (narrow-to-region (point-min) limit)
(setq character-coding (setq character-coding
(mail-fetch-field "content-transfer-encoding") (mail-fetch-field "content-transfer-encoding")
is-text-message (rmail-is-text-p) is-text-message (rmail-is-text-p)
...@@ -256,9 +255,8 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. ...@@ -256,9 +255,8 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'.
;;??? BROKEN perhaps. ;;??? BROKEN perhaps.
;;; (if (boundp 'rmail-summary-vector) ;;; (if (boundp 'rmail-summary-vector)
;;; (aset rmail-summary-vector (1- rmail-current-message) nil)) ;;; (aset rmail-summary-vector (1- rmail-current-message) nil))
(save-excursion
(rmail-show-message) (rmail-show-message)
(rmail-toggle-header (if pruned 1 0)))) (rmail-toggle-header (if pruned 1 0)))
(run-hooks 'rmail-mode-hook)) (run-hooks 'rmail-mode-hook))
(defun rmail-abort-edit () (defun rmail-abort-edit ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment