emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112460: Don't let an empty summary c


From: Richard Stallman
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112460: Don't let an empty summary change current message.
Date: Sun, 05 May 2013 09:56:54 -0400
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112460
committer: Richard Stallman <address@hidden>
branch nick: trunk
timestamp: Sun 2013-05-05 09:56:54 -0400
message:
  Don't let an empty summary change current message.
  
        * mail/rmailsum.el (rmail-summary-rmail-update):
        Detect empty summary and don't change selected message.
        (rmail-summary-goto-msg): Likewise.
modified:
  lisp/ChangeLog
  lisp/mail/rmailsum.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-05 12:17:12 +0000
+++ b/lisp/ChangeLog    2013-05-05 13:56:54 +0000
@@ -1,3 +1,9 @@
+2013-05-05  Richard Stallman  <address@hidden>
+
+       * mail/rmailsum.el (rmail-summary-rmail-update):
+       Detect empty summary and don't change selected message.
+       (rmail-summary-goto-msg): Likewise.
+
 2013-05-05  Alan Mackenzie  <address@hidden>
 
        * progmodes/cc-defs.el (c-version): Increment to 5.32.5.

=== modified file 'lisp/mail/rmailsum.el'
--- a/lisp/mail/rmailsum.el     2013-02-12 04:46:18 +0000
+++ b/lisp/mail/rmailsum.el     2013-05-05 13:56:54 +0000
@@ -490,8 +490,7 @@
     ;; we "don't have" a summary.
     (setq rmail-summary-buffer nil)
     ;; I have not a clue what this clause is doing.  If you read this
-    ;; chunk of code and have a clue, then please email that clue to
-    ;; address@hidden
+    ;; chunk of code and have a clue, then please  write it here.
     (if rmail-enable-mime
        (with-current-buffer rmail-buffer
          (setq rmail-summary-buffer nil)))
@@ -1122,57 +1121,59 @@
          (forward-line -1))
       (beginning-of-line)
       (skip-chars-forward " ")
-      (let ((msg-num (string-to-number (buffer-substring
-                                        (point)
-                                        (progn (skip-chars-forward "0-9")
-                                               (point))))))
-       ;; Always leave `unseen' removed
-       ;; if we get out of isearch mode.
-       ;; Don't let a subsequent isearch restore that `unseen'.
-       (if (not isearch-mode)
-           (setq rmail-summary-put-back-unseen nil))
+      ;; If the summary is empty, don't do anything.
+      (unless (eobp)
+       (let ((msg-num (string-to-number (buffer-substring
+                                         (point)
+                                         (progn (skip-chars-forward "0-9")
+                                                (point))))))
+         ;; Always leave `unseen' removed
+         ;; if we get out of isearch mode.
+         ;; Don't let a subsequent isearch restore that `unseen'.
+         (if (not isearch-mode)
+             (setq rmail-summary-put-back-unseen nil))
 
-       (or (eq rmail-current-message msg-num)
-           (let ((window (get-buffer-window rmail-buffer t))
-                 (owin (selected-window)))
-             (if isearch-mode
-                 (progn
-                   ;; If we first saw the previous message in this search,
-                   ;; and we have gone to a different message while searching,
-                   ;; put back `unseen' on the former one.
-                   (when rmail-summary-put-back-unseen
-                     (rmail-set-attribute rmail-unseen-attr-index t
-                                          rmail-current-message)
-                     (save-excursion
-                       (goto-char rmail-summary-put-back-unseen)
-                       (rmail-summary-mark-seen rmail-current-message t t)))
-                   ;; Arrange to do that later, for the new current message,
-                   ;; if it still has `unseen'.
-                   (setq rmail-summary-put-back-unseen
-                         (if (rmail-message-unseen-p msg-num)
-                             (point))))
-               (setq rmail-summary-put-back-unseen nil))
-             ;; Go to the desired message.
-             (setq rmail-current-message msg-num)
-             ;; Update the summary to show the message has been seen.
-             (rmail-summary-mark-seen msg-num t)
-             (if window
-                 ;; Using save-window-excursion would cause the new value
-                 ;; of point to get lost.
-                 (unwind-protect
-                     (progn
-                       (select-window window)
-                       (rmail-show-message msg-num t))
-                   (select-window owin))
-               (if (buffer-name rmail-buffer)
-                   (with-current-buffer rmail-buffer
-                     (rmail-show-message msg-num t))))
-             ;; In linum mode, the message buffer must be specially
-             ;; updated (Bug#4878).
-             (and (fboundp 'linum-update)
-                  (buffer-name rmail-buffer)
-                  (linum-update rmail-buffer))))
-       (rmail-summary-update-highlight nil)))))
+         (or (eq rmail-current-message msg-num)
+             (let ((window (get-buffer-window rmail-buffer t))
+                   (owin (selected-window)))
+               (if isearch-mode
+                   (progn
+                     ;; If we first saw the previous message in this search,
+                     ;; and we have gone to a different message while 
searching,
+                     ;; put back `unseen' on the former one.
+                     (when rmail-summary-put-back-unseen
+                       (rmail-set-attribute rmail-unseen-attr-index t
+                                            rmail-current-message)
+                       (save-excursion
+                         (goto-char rmail-summary-put-back-unseen)
+                         (rmail-summary-mark-seen rmail-current-message t t)))
+                     ;; Arrange to do that later, for the new current message,
+                     ;; if it still has `unseen'.
+                     (setq rmail-summary-put-back-unseen
+                           (if (rmail-message-unseen-p msg-num)
+                               (point))))
+                 (setq rmail-summary-put-back-unseen nil))
+               ;; Go to the desired message.
+               (setq rmail-current-message msg-num)
+               ;; Update the summary to show the message has been seen.
+               (rmail-summary-mark-seen msg-num t)
+               (if window
+                   ;; Using save-window-excursion would cause the new value
+                   ;; of point to get lost.
+                   (unwind-protect
+                       (progn
+                         (select-window window)
+                         (rmail-show-message msg-num t))
+                     (select-window owin))
+                 (if (buffer-name rmail-buffer)
+                     (with-current-buffer rmail-buffer
+                       (rmail-show-message msg-num t))))
+               ;; In linum mode, the message buffer must be specially
+               ;; updated (Bug#4878).
+               (and (fboundp 'linum-update)
+                    (buffer-name rmail-buffer)
+                    (linum-update rmail-buffer))))
+         (rmail-summary-update-highlight nil))))))
 
 (defun rmail-summary-save-buffer ()
   "Save the buffer associated with this RMAIL summary."
@@ -1208,6 +1209,10 @@
                  (buffer-substring (point)
                                    (min (point-max) (+ 6 (point))))))
         (total (with-current-buffer buf rmail-total-messages)))
+    ;; CURMSG should be nil when there's no current summary message
+    ;; (for instance, if the summary is empty).
+    (if (= curmsg 0)
+       (setq curmsg nil))
     ;; If message number N was specified, find that message's line
     ;; or set message-not-found.
     ;; If N wasn't specified or that message can't be found.
@@ -1228,17 +1233,20 @@
                 (setq n curmsg)
                 (setq message-not-found t)
                 (goto-char cur))))
-    (rmail-summary-mark-seen n)
-    (rmail-summary-update-highlight message-not-found)
-    (beginning-of-line)
-    (unless skip-rmail
-      (let ((selwin (selected-window)))
-       (unwind-protect
-           (progn (rmail-pop-to-buffer buf)
-                  (rmail-show-message n))
-         (select-window selwin)
-         ;; The actions above can alter the current buffer.  Preserve it.
-         (set-buffer obuf))))
+    ;; N can be nil now, along with CURMSG,
+    ;; if the summary is empty.
+    (when n
+      (rmail-summary-mark-seen n)
+      (rmail-summary-update-highlight message-not-found)
+      (beginning-of-line)
+      (unless skip-rmail
+       (let ((selwin (selected-window)))
+         (unwind-protect
+             (progn (rmail-pop-to-buffer buf)
+                    (rmail-show-message n))
+           (select-window selwin)
+           ;; The actions above can alter the current buffer.  Preserve it.
+           (set-buffer obuf)))))
     (not message-not-found)))
 
 ;; Update the highlighted line in an rmail summary buffer.


reply via email to

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