Commit 5136e315 authored by Chong Yidong's avatar Chong Yidong
Browse files

(pmail): Call pmail-swap-buffers-maybe.

(pmail-search): Call pmail-swap-buffers-maybe.
parent f343d373
...@@ -871,7 +871,7 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file." ...@@ -871,7 +871,7 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file."
(find-file-noselect file-name)))) (find-file-noselect file-name))))
;; Insure that the collection and view buffers are in sync and ;; Insure that the collection and view buffers are in sync and
;; insure that a message is not being edited. ;; insure that a message is not being edited.
(setq pmail-buffers-swapped-p nil) (pmail-swap-buffers-maybe)
(if (eq major-mode 'pmail-edit-mode) (if (eq major-mode 'pmail-edit-mode)
(error "Exit Pmail Edit mode before getting new mail")) (error "Exit Pmail Edit mode before getting new mail"))
;; Insure that the Rmail file is in mbox format, the buffer is in ;; Insure that the Rmail file is in mbox format, the buffer is in
...@@ -2795,28 +2795,27 @@ Interactively, empty argument means use same regexp used last time." ...@@ -2795,28 +2795,27 @@ Interactively, empty argument means use same regexp used last time."
(if (< n 0) "Reverse " "") (if (< n 0) "Reverse " "")
regexp) regexp)
(set-buffer pmail-buffer) (set-buffer pmail-buffer)
(pmail-maybe-set-message-counters) (let ((orig-message pmail-current-message)
(let ((omin (point-min)) (msg pmail-current-message)
(omax (point-max))
(opoint (point))
win
(reversep (< n 0)) (reversep (< n 0))
(msg pmail-current-message)) (opoint (if pmail-buffers-swapped-p (point)))
found)
(pmail-swap-buffers-maybe)
(pmail-maybe-set-message-counters)
(widen)
(unwind-protect (unwind-protect
(progn (while (/= n 0)
(widen) ;; Check messages one by one, advancing message number up or
(while (/= n 0) ;; down but searching forward through each message.
;; Check messages one by one, advancing message number up or down (if reversep
;; but searching forward through each message. (while (and (null found) (> msg 1))
(if reversep (setq msg (1- msg)
(while (and (null win) (> msg 1)) found (pmail-search-message msg regexp)))
(setq msg (1- msg) (while (and (null found) (< msg pmail-total-messages))
win (pmail-search-message msg regexp))) (setq msg (1+ msg)
(while (and (null win) (< msg pmail-total-messages)) found (pmail-search-message msg regexp))))
(setq msg (1+ msg) (setq n (+ n (if reversep 1 -1))))
win (pmail-search-message msg regexp)))) (if found
(setq n (+ n (if reversep 1 -1)))))
(if win
(progn (progn
(pmail-show-message-maybe msg) (pmail-show-message-maybe msg)
;; Search forward (if this is a normal search) or backward ;; Search forward (if this is a normal search) or backward
...@@ -2834,8 +2833,8 @@ Interactively, empty argument means use same regexp used last time." ...@@ -2834,8 +2833,8 @@ Interactively, empty argument means use same regexp used last time."
(message "%sPmail search for %s...done" (message "%sPmail search for %s...done"
(if reversep "Reverse " "") (if reversep "Reverse " "")
regexp)) regexp))
(goto-char opoint) (pmail-show-message-maybe orig-message)
(narrow-to-region omin omax) (if opoint (goto-char opoint))
(ding) (ding)
(message "Search failed: %s" regexp))))) (message "Search failed: %s" regexp)))))
......
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