diff options
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/mail/rmailsum.el | 136 |
2 files changed, 78 insertions, 64 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f18d856a4dc..268a716fd09 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-05-05 Richard Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmailsum.el (rmail-summary-rmail-update): | ||
| 4 | Detect empty summary and don't change selected message. | ||
| 5 | (rmail-summary-goto-msg): Likewise. | ||
| 6 | |||
| 1 | 2013-05-05 Alan Mackenzie <acm@muc.de> | 7 | 2013-05-05 Alan Mackenzie <acm@muc.de> |
| 2 | 8 | ||
| 3 | * progmodes/cc-defs.el (c-version): Increment to 5.32.5. | 9 | * progmodes/cc-defs.el (c-version): Increment to 5.32.5. |
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el index 13cd7c3f05e..ccd76cd6ba3 100644 --- a/lisp/mail/rmailsum.el +++ b/lisp/mail/rmailsum.el | |||
| @@ -490,8 +490,7 @@ message." | |||
| 490 | ;; we "don't have" a summary. | 490 | ;; we "don't have" a summary. |
| 491 | (setq rmail-summary-buffer nil) | 491 | (setq rmail-summary-buffer nil) |
| 492 | ;; I have not a clue what this clause is doing. If you read this | 492 | ;; I have not a clue what this clause is doing. If you read this |
| 493 | ;; chunk of code and have a clue, then please email that clue to | 493 | ;; chunk of code and have a clue, then please write it here. |
| 494 | ;; pmr@pajato.com | ||
| 495 | (if rmail-enable-mime | 494 | (if rmail-enable-mime |
| 496 | (with-current-buffer rmail-buffer | 495 | (with-current-buffer rmail-buffer |
| 497 | (setq rmail-summary-buffer nil))) | 496 | (setq rmail-summary-buffer nil))) |
| @@ -1122,57 +1121,59 @@ Search, the `unseen' attribute is restored.") | |||
| 1122 | (forward-line -1)) | 1121 | (forward-line -1)) |
| 1123 | (beginning-of-line) | 1122 | (beginning-of-line) |
| 1124 | (skip-chars-forward " ") | 1123 | (skip-chars-forward " ") |
| 1125 | (let ((msg-num (string-to-number (buffer-substring | 1124 | ;; If the summary is empty, don't do anything. |
| 1126 | (point) | 1125 | (unless (eobp) |
| 1127 | (progn (skip-chars-forward "0-9") | 1126 | (let ((msg-num (string-to-number (buffer-substring |
| 1128 | (point)))))) | 1127 | (point) |
| 1129 | ;; Always leave `unseen' removed | 1128 | (progn (skip-chars-forward "0-9") |
| 1130 | ;; if we get out of isearch mode. | 1129 | (point)))))) |
| 1131 | ;; Don't let a subsequent isearch restore that `unseen'. | 1130 | ;; Always leave `unseen' removed |
| 1132 | (if (not isearch-mode) | 1131 | ;; if we get out of isearch mode. |
| 1133 | (setq rmail-summary-put-back-unseen nil)) | 1132 | ;; Don't let a subsequent isearch restore that `unseen'. |
| 1134 | 1133 | (if (not isearch-mode) | |
| 1135 | (or (eq rmail-current-message msg-num) | 1134 | (setq rmail-summary-put-back-unseen nil)) |
| 1136 | (let ((window (get-buffer-window rmail-buffer t)) | 1135 | |
| 1137 | (owin (selected-window))) | 1136 | (or (eq rmail-current-message msg-num) |
| 1138 | (if isearch-mode | 1137 | (let ((window (get-buffer-window rmail-buffer t)) |
| 1139 | (progn | 1138 | (owin (selected-window))) |
| 1140 | ;; If we first saw the previous message in this search, | 1139 | (if isearch-mode |
| 1141 | ;; and we have gone to a different message while searching, | 1140 | (progn |
| 1142 | ;; put back `unseen' on the former one. | 1141 | ;; If we first saw the previous message in this search, |
| 1143 | (when rmail-summary-put-back-unseen | 1142 | ;; and we have gone to a different message while searching, |
| 1144 | (rmail-set-attribute rmail-unseen-attr-index t | 1143 | ;; put back `unseen' on the former one. |
| 1145 | rmail-current-message) | 1144 | (when rmail-summary-put-back-unseen |
| 1146 | (save-excursion | 1145 | (rmail-set-attribute rmail-unseen-attr-index t |
| 1147 | (goto-char rmail-summary-put-back-unseen) | 1146 | rmail-current-message) |
| 1148 | (rmail-summary-mark-seen rmail-current-message t t))) | 1147 | (save-excursion |
| 1149 | ;; Arrange to do that later, for the new current message, | 1148 | (goto-char rmail-summary-put-back-unseen) |
| 1150 | ;; if it still has `unseen'. | 1149 | (rmail-summary-mark-seen rmail-current-message t t))) |
| 1151 | (setq rmail-summary-put-back-unseen | 1150 | ;; Arrange to do that later, for the new current message, |
| 1152 | (if (rmail-message-unseen-p msg-num) | 1151 | ;; if it still has `unseen'. |
| 1153 | (point)))) | 1152 | (setq rmail-summary-put-back-unseen |
| 1154 | (setq rmail-summary-put-back-unseen nil)) | 1153 | (if (rmail-message-unseen-p msg-num) |
| 1155 | ;; Go to the desired message. | 1154 | (point)))) |
| 1156 | (setq rmail-current-message msg-num) | 1155 | (setq rmail-summary-put-back-unseen nil)) |
| 1157 | ;; Update the summary to show the message has been seen. | 1156 | ;; Go to the desired message. |
| 1158 | (rmail-summary-mark-seen msg-num t) | 1157 | (setq rmail-current-message msg-num) |
| 1159 | (if window | 1158 | ;; Update the summary to show the message has been seen. |
| 1160 | ;; Using save-window-excursion would cause the new value | 1159 | (rmail-summary-mark-seen msg-num t) |
| 1161 | ;; of point to get lost. | 1160 | (if window |
| 1162 | (unwind-protect | 1161 | ;; Using save-window-excursion would cause the new value |
| 1163 | (progn | 1162 | ;; of point to get lost. |
| 1164 | (select-window window) | 1163 | (unwind-protect |
| 1165 | (rmail-show-message msg-num t)) | 1164 | (progn |
| 1166 | (select-window owin)) | 1165 | (select-window window) |
| 1167 | (if (buffer-name rmail-buffer) | 1166 | (rmail-show-message msg-num t)) |
| 1168 | (with-current-buffer rmail-buffer | 1167 | (select-window owin)) |
| 1169 | (rmail-show-message msg-num t)))) | 1168 | (if (buffer-name rmail-buffer) |
| 1170 | ;; In linum mode, the message buffer must be specially | 1169 | (with-current-buffer rmail-buffer |
| 1171 | ;; updated (Bug#4878). | 1170 | (rmail-show-message msg-num t)))) |
| 1172 | (and (fboundp 'linum-update) | 1171 | ;; In linum mode, the message buffer must be specially |
| 1173 | (buffer-name rmail-buffer) | 1172 | ;; updated (Bug#4878). |
| 1174 | (linum-update rmail-buffer)))) | 1173 | (and (fboundp 'linum-update) |
| 1175 | (rmail-summary-update-highlight nil))))) | 1174 | (buffer-name rmail-buffer) |
| 1175 | (linum-update rmail-buffer)))) | ||
| 1176 | (rmail-summary-update-highlight nil)))))) | ||
| 1176 | 1177 | ||
| 1177 | (defun rmail-summary-save-buffer () | 1178 | (defun rmail-summary-save-buffer () |
| 1178 | "Save the buffer associated with this RMAIL summary." | 1179 | "Save the buffer associated with this RMAIL summary." |
| @@ -1208,6 +1209,10 @@ Returns non-nil if message N was found." | |||
| 1208 | (buffer-substring (point) | 1209 | (buffer-substring (point) |
| 1209 | (min (point-max) (+ 6 (point)))))) | 1210 | (min (point-max) (+ 6 (point)))))) |
| 1210 | (total (with-current-buffer buf rmail-total-messages))) | 1211 | (total (with-current-buffer buf rmail-total-messages))) |
| 1212 | ;; CURMSG should be nil when there's no current summary message | ||
| 1213 | ;; (for instance, if the summary is empty). | ||
| 1214 | (if (= curmsg 0) | ||
| 1215 | (setq curmsg nil)) | ||
| 1211 | ;; If message number N was specified, find that message's line | 1216 | ;; If message number N was specified, find that message's line |
| 1212 | ;; or set message-not-found. | 1217 | ;; or set message-not-found. |
| 1213 | ;; If N wasn't specified or that message can't be found. | 1218 | ;; If N wasn't specified or that message can't be found. |
| @@ -1228,17 +1233,20 @@ Returns non-nil if message N was found." | |||
| 1228 | (setq n curmsg) | 1233 | (setq n curmsg) |
| 1229 | (setq message-not-found t) | 1234 | (setq message-not-found t) |
| 1230 | (goto-char cur)))) | 1235 | (goto-char cur)))) |
| 1231 | (rmail-summary-mark-seen n) | 1236 | ;; N can be nil now, along with CURMSG, |
| 1232 | (rmail-summary-update-highlight message-not-found) | 1237 | ;; if the summary is empty. |
| 1233 | (beginning-of-line) | 1238 | (when n |
| 1234 | (unless skip-rmail | 1239 | (rmail-summary-mark-seen n) |
| 1235 | (let ((selwin (selected-window))) | 1240 | (rmail-summary-update-highlight message-not-found) |
| 1236 | (unwind-protect | 1241 | (beginning-of-line) |
| 1237 | (progn (rmail-pop-to-buffer buf) | 1242 | (unless skip-rmail |
| 1238 | (rmail-show-message n)) | 1243 | (let ((selwin (selected-window))) |
| 1239 | (select-window selwin) | 1244 | (unwind-protect |
| 1240 | ;; The actions above can alter the current buffer. Preserve it. | 1245 | (progn (rmail-pop-to-buffer buf) |
| 1241 | (set-buffer obuf)))) | 1246 | (rmail-show-message n)) |
| 1247 | (select-window selwin) | ||
| 1248 | ;; The actions above can alter the current buffer. Preserve it. | ||
| 1249 | (set-buffer obuf))))) | ||
| 1242 | (not message-not-found))) | 1250 | (not message-not-found))) |
| 1243 | 1251 | ||
| 1244 | ;; Update the highlighted line in an rmail summary buffer. | 1252 | ;; Update the highlighted line in an rmail summary buffer. |