Function: rmail-search
rmail-search is an interactive and byte-compiled function defined in
rmail.el.gz.
Signature
(rmail-search REGEXP &optional N)
Documentation
Show message containing next match for REGEXP (but not the current msg).
Prefix argument gives repeat count; negative argument means search backwards (through earlier messages). Interactively, empty argument means use same regexp used last time.
Probably introduced at or before Emacs version 17.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-search (regexp &optional n)
"Show message containing next match for REGEXP (but not the current msg).
Prefix argument gives repeat count; negative argument means search
backwards (through earlier messages).
Interactively, empty argument means use same regexp used last time."
(interactive
(let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
(prompt
(concat (if reversep "Reverse " "") "Rmail search (regexp"))
regexp)
(setq prompt
(concat prompt
(if rmail-search-last-regexp
(concat ", default "
rmail-search-last-regexp "): ")
"): ")))
(setq regexp (read-string prompt))
(cond ((not (equal regexp ""))
(setq rmail-search-last-regexp regexp))
((not rmail-search-last-regexp)
(error "No previous Rmail search string")))
(list rmail-search-last-regexp
(prefix-numeric-value current-prefix-arg))))
(or n (setq n 1))
(message "%sRmail search for %s..."
(if (< n 0) "Reverse " "")
regexp)
(set-buffer rmail-buffer)
(let ((orig-message rmail-current-message)
(msg rmail-current-message)
(reversep (< n 0))
(opoint (if (rmail-buffers-swapped-p) (point)))
found)
(rmail-swap-buffers-maybe)
(rmail-maybe-set-message-counters)
(widen)
(unwind-protect
(while (/= n 0)
;; Check messages one by one, advancing message number up or
;; down but searching forward through each message.
(if reversep
(while (and (null found) (> msg 1))
(setq msg (1- msg)
found (rmail-search-message msg regexp)))
(while (and (null found) (< msg rmail-total-messages))
(setq msg (1+ msg)
found (rmail-search-message msg regexp))))
(setq n (+ n (if reversep 1 -1))))
(if found
(progn
(rmail-show-message msg)
;; Search forward (if this is a normal search) or backward
;; (if this is a reverse search) through this message to
;; position point. This search may fail because REGEXP
;; was found in the hidden portion of this message. In
;; that case, move point to the beginning of visible
;; portion.
(if reversep
(progn
(goto-char (point-max))
(re-search-backward regexp nil 'move))
(goto-char (point-min))
(re-search-forward regexp nil t))
(message "%sRmail search for %s...done"
(if reversep "Reverse " "")
regexp))
(rmail-show-message orig-message)
(if opoint (goto-char opoint))
(ding)
(message "Search failed: %s" regexp)))))