comparison lisp/mail/pmail.el @ 100433:9c48475923d7

(pmail): Call pmail-swap-buffers-maybe. (pmail-search): Call pmail-swap-buffers-maybe.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 15 Dec 2008 14:56:06 +0000
parents 41ff1c784cee
children 52f6ee5edde1
comparison
equal deleted inserted replaced
100432:0bc687931a56 100433:9c48475923d7
869 (switch-to-buffer 869 (switch-to-buffer
870 (let ((enable-local-variables nil)) 870 (let ((enable-local-variables nil))
871 (find-file-noselect file-name)))) 871 (find-file-noselect file-name))))
872 ;; Insure that the collection and view buffers are in sync and 872 ;; Insure that the collection and view buffers are in sync and
873 ;; insure that a message is not being edited. 873 ;; insure that a message is not being edited.
874 (setq pmail-buffers-swapped-p nil) 874 (pmail-swap-buffers-maybe)
875 (if (eq major-mode 'pmail-edit-mode) 875 (if (eq major-mode 'pmail-edit-mode)
876 (error "Exit Pmail Edit mode before getting new mail")) 876 (error "Exit Pmail Edit mode before getting new mail"))
877 ;; Insure that the Rmail file is in mbox format, the buffer is in 877 ;; Insure that the Rmail file is in mbox format, the buffer is in
878 ;; Pmail mode and has been scanned to find all the messages 878 ;; Pmail mode and has been scanned to find all the messages
879 ;; (setting the global message variables in the process). 879 ;; (setting the global message variables in the process).
2793 (or n (setq n 1)) 2793 (or n (setq n 1))
2794 (message "%sPmail search for %s..." 2794 (message "%sPmail search for %s..."
2795 (if (< n 0) "Reverse " "") 2795 (if (< n 0) "Reverse " "")
2796 regexp) 2796 regexp)
2797 (set-buffer pmail-buffer) 2797 (set-buffer pmail-buffer)
2798 (pmail-maybe-set-message-counters) 2798 (let ((orig-message pmail-current-message)
2799 (let ((omin (point-min)) 2799 (msg pmail-current-message)
2800 (omax (point-max))
2801 (opoint (point))
2802 win
2803 (reversep (< n 0)) 2800 (reversep (< n 0))
2804 (msg pmail-current-message)) 2801 (opoint (if pmail-buffers-swapped-p (point)))
2802 found)
2803 (pmail-swap-buffers-maybe)
2804 (pmail-maybe-set-message-counters)
2805 (widen)
2805 (unwind-protect 2806 (unwind-protect
2806 (progn 2807 (while (/= n 0)
2807 (widen) 2808 ;; Check messages one by one, advancing message number up or
2808 (while (/= n 0) 2809 ;; down but searching forward through each message.
2809 ;; Check messages one by one, advancing message number up or down 2810 (if reversep
2810 ;; but searching forward through each message. 2811 (while (and (null found) (> msg 1))
2811 (if reversep 2812 (setq msg (1- msg)
2812 (while (and (null win) (> msg 1)) 2813 found (pmail-search-message msg regexp)))
2813 (setq msg (1- msg) 2814 (while (and (null found) (< msg pmail-total-messages))
2814 win (pmail-search-message msg regexp))) 2815 (setq msg (1+ msg)
2815 (while (and (null win) (< msg pmail-total-messages)) 2816 found (pmail-search-message msg regexp))))
2816 (setq msg (1+ msg) 2817 (setq n (+ n (if reversep 1 -1))))
2817 win (pmail-search-message msg regexp)))) 2818 (if found
2818 (setq n (+ n (if reversep 1 -1)))))
2819 (if win
2820 (progn 2819 (progn
2821 (pmail-show-message-maybe msg) 2820 (pmail-show-message-maybe msg)
2822 ;; Search forward (if this is a normal search) or backward 2821 ;; Search forward (if this is a normal search) or backward
2823 ;; (if this is a reverse search) through this message to 2822 ;; (if this is a reverse search) through this message to
2824 ;; position point. This search may fail because REGEXP 2823 ;; position point. This search may fail because REGEXP
2832 (goto-char (point-min)) 2831 (goto-char (point-min))
2833 (re-search-forward regexp nil t)) 2832 (re-search-forward regexp nil t))
2834 (message "%sPmail search for %s...done" 2833 (message "%sPmail search for %s...done"
2835 (if reversep "Reverse " "") 2834 (if reversep "Reverse " "")
2836 regexp)) 2835 regexp))
2837 (goto-char opoint) 2836 (pmail-show-message-maybe orig-message)
2838 (narrow-to-region omin omax) 2837 (if opoint (goto-char opoint))
2839 (ding) 2838 (ding)
2840 (message "Search failed: %s" regexp))))) 2839 (message "Search failed: %s" regexp)))))
2841 2840
2842 (defun pmail-search-backwards (regexp &optional n) 2841 (defun pmail-search-backwards (regexp &optional n)
2843 "Show message containing previous match for REGEXP. 2842 "Show message containing previous match for REGEXP.