@lisp
(defun split-on-body ()
(save-excursion
- (widen)
- (goto-char (point-min))
- (when (re-search-forward "Some.*string" nil t)
- "string.group")))
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (when (re-search-forward "Some.*string" nil t)
+ "string.group"))))
@end lisp
The buffer is narrowed to the message in question when @var{function}
is run. That's why @code{(widen)} needs to be called after
-@code{save-excursion} in the example above. Also note that with the
-nnimap backend, message bodies will not be downloaded by default. You
-need to set @code{nnimap-split-download-body} to t to do that
-(@pxref{Splitting in IMAP}).
+@code{save-excursion} and @code{save-restriction} in the example
+above. Also note that with the nnimap backend, message bodies will
+not be downloaded by default. You need to set
+@code{nnimap-split-download-body} to t to do that (@pxref{Splitting in
+IMAP}).
@item (! @var{func} @var{split})
If the split is a list, and the first element is @code{!}, then
...))
(defun kevin-spamassassin ()
(save-excursion
- (widen)
- (if (eq 1 (call-process-region (point-min) (point-max)
- "spamc" nil nil nil "-c"))
- "spam")))
+ (save-restriction
+ (widen)
+ (if (eq 1 (call-process-region (point-min) (point-max)
+ "spamc" nil nil nil "-c"))
+ "spam"))))
@end lisp
Note that with the nnimap backend, message bodies will not be