diff options
| author | Glenn Morris | 2009-10-15 06:00:20 +0000 |
|---|---|---|
| committer | Glenn Morris | 2009-10-15 06:00:20 +0000 |
| commit | 0b44494a3c0f8bf9d2889c76956e49dcea24a20f (patch) | |
| tree | 30ca3fe5298a604c7fec7abc64e6fe11b0216474 | |
| parent | d5e637154f5084076b1a348155fc68139747acca (diff) | |
| download | emacs-0b44494a3c0f8bf9d2889c76956e49dcea24a20f.tar.gz emacs-0b44494a3c0f8bf9d2889c76956e49dcea24a20f.zip | |
(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)
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/mail/rmailedit.el | 40 |
2 files changed, 25 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 48b456371d3..a564eabfbd4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2009-10-15 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmailedit.el (rmail-cease-edit): Give an error if the end of | ||
| 4 | the headers cannot be located. Simplify, subtracting superflous | ||
| 5 | save-excursions. | ||
| 6 | |||
| 1 | 2009-10-15 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2009-10-15 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | Replace completion-base-size by completion-base-position to fix bugs | 9 | Replace completion-base-size by completion-base-position to fix bugs |
diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el index 48df2c2e951..36e5d79a160 100644 --- a/lisp/mail/rmailedit.el +++ b/lisp/mail/rmailedit.el | |||
| @@ -126,19 +126,23 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. | |||
| 126 | (with-current-buffer rmail-summary-buffer | 126 | (with-current-buffer rmail-summary-buffer |
| 127 | (rmail-summary-enable))) | 127 | (rmail-summary-enable))) |
| 128 | (widen) | 128 | (widen) |
| 129 | (goto-char (point-min)) | ||
| 130 | ;; This is far from ideal. The edit may have inadvertently | ||
| 131 | ;; removed the blank line at the end of the headers, but there | ||
| 132 | ;; are almost certainly other blank lines. | ||
| 133 | (or (search-forward "\n\n" nil t) | ||
| 134 | (error "There must be a blank line at the end of the headers")) | ||
| 129 | ;; Disguise any "From " lines so they don't start a new message. | 135 | ;; Disguise any "From " lines so they don't start a new message. |
| 130 | (save-excursion | 136 | (goto-char (point-min)) |
| 131 | (goto-char (point-min)) | 137 | (or rmail-old-pruned (forward-line 1)) |
| 132 | (or rmail-old-pruned (forward-line 1)) | 138 | (while (re-search-forward "^>*From " nil t) |
| 133 | (while (re-search-forward "^>*From " nil t) | 139 | (beginning-of-line) |
| 134 | (beginning-of-line) | 140 | (insert ">") |
| 135 | (insert ">") | 141 | (forward-line)) |
| 136 | (forward-line))) | ||
| 137 | ;; Make sure buffer ends with a blank line so as not to run this | 142 | ;; Make sure buffer ends with a blank line so as not to run this |
| 138 | ;; message together with the following one. | 143 | ;; message together with the following one. |
| 139 | (save-excursion | 144 | (goto-char (point-max)) |
| 140 | (goto-char (point-max)) | 145 | (rmail-ensure-blank-line) |
| 141 | (rmail-ensure-blank-line)) | ||
| 142 | (let ((old rmail-old-text) | 146 | (let ((old rmail-old-text) |
| 143 | (pruned rmail-old-pruned) | 147 | (pruned rmail-old-pruned) |
| 144 | ;; People who know what they are doing might have modified the | 148 | ;; 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 | (string= old (buffer-substring (point-min) (point-max)))) | 172 | (string= old (buffer-substring (point-min) (point-max)))) |
| 169 | (setq old nil) | 173 | (setq old nil) |
| 170 | (goto-char (point-min)) | 174 | (goto-char (point-min)) |
| 171 | ;; FIXME the edit may have inadvertently removed this. | ||
| 172 | (search-forward "\n\n") | 175 | (search-forward "\n\n") |
| 173 | (setq headers-end (point-marker)) | 176 | (setq headers-end (point-marker)) |
| 174 | (goto-char (point-min)) | 177 | (goto-char (point-min)) |
| @@ -204,20 +207,16 @@ This function runs the hooks `text-mode-hook' and `rmail-edit-mode-hook'. | |||
| 204 | (goto-char mime-end) | 207 | (goto-char mime-end) |
| 205 | (delete-region mime-beg mime-end) | 208 | (delete-region mime-beg mime-end) |
| 206 | (insert mime-charset))))) | 209 | (insert mime-charset))))) |
| 207 | (goto-char headers-end) | ||
| 208 | (setq new-headers (rmail-edit-headers-alist t)) | 210 | (setq new-headers (rmail-edit-headers-alist t)) |
| 209 | (rmail-swap-buffers-maybe) | 211 | (rmail-swap-buffers-maybe) |
| 210 | (narrow-to-region (rmail-msgbeg rmail-current-message) | 212 | (narrow-to-region (rmail-msgbeg rmail-current-message) |
| 211 | (rmail-msgend rmail-current-message)) | 213 | (rmail-msgend rmail-current-message)) |
| 214 | (goto-char (point-min)) | ||
| 215 | (setq limit (search-forward "\n\n")) | ||
| 212 | (save-restriction | 216 | (save-restriction |
| 213 | (setq limit | ||
| 214 | (save-excursion | ||
| 215 | (goto-char (point-min)) | ||
| 216 | ;; FIXME this should not be using NOERROR. | ||
| 217 | (search-forward "\n\n" nil t))) | ||
| 218 | ;; All 3 of the functions we call below assume the buffer was | 217 | ;; All 3 of the functions we call below assume the buffer was |
| 219 | ;; narrowed to just the headers of the message. | 218 | ;; narrowed to just the headers of the message. |
| 220 | (narrow-to-region (rmail-msgbeg rmail-current-message) limit) | 219 | (narrow-to-region (point-min) limit) |
| 221 | (setq character-coding | 220 | (setq character-coding |
| 222 | (mail-fetch-field "content-transfer-encoding") | 221 | (mail-fetch-field "content-transfer-encoding") |
| 223 | is-text-message (rmail-is-text-p) | 222 | 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 | ;;??? BROKEN perhaps. | 255 | ;;??? BROKEN perhaps. |
| 257 | ;;; (if (boundp 'rmail-summary-vector) | 256 | ;;; (if (boundp 'rmail-summary-vector) |
| 258 | ;;; (aset rmail-summary-vector (1- rmail-current-message) nil)) | 257 | ;;; (aset rmail-summary-vector (1- rmail-current-message) nil)) |
| 259 | (save-excursion | 258 | (rmail-show-message) |
| 260 | (rmail-show-message) | 259 | (rmail-toggle-header (if pruned 1 0))) |
| 261 | (rmail-toggle-header (if pruned 1 0)))) | ||
| 262 | (run-hooks 'rmail-mode-hook)) | 260 | (run-hooks 'rmail-mode-hook)) |
| 263 | 261 | ||
| 264 | (defun rmail-abort-edit () | 262 | (defun rmail-abort-edit () |