mirror of https://github.com/djcb/mu.git
mu4e: add mu4e-headers-find-if
This function can be used to jump to some message in the headers list that matches a certain pattern.
This commit is contained in:
parent
ddc3297ce9
commit
7eac4ac918
|
@ -982,6 +982,24 @@ header."
|
|||
(when msg
|
||||
(funcall func msg))))))
|
||||
|
||||
(defun mu4e-headers-find-if (func &optional backward)
|
||||
"Move to the next header for which FUNC returns non-`nil',
|
||||
starting from the current position. FUNC takes one argument, the
|
||||
msg s-expression for the corresponding header. If BACKWARD is
|
||||
non-`nil', search backwards."
|
||||
(let ((pos) (search-func (if backward 'search-backward 'search-forward)))
|
||||
(save-excursion
|
||||
(while (and (null pos)
|
||||
(funcall search-func mu4e~headers-docid-pre nil t))
|
||||
;; not really sure why we need to jump to bol; we do need to, otherwise we
|
||||
;; miss lines sometimes...
|
||||
(let ((msg (get-text-property (line-beginning-position) 'msg)))
|
||||
(when (and msg (funcall func msg))
|
||||
(setq pos (point))))))
|
||||
(when pos
|
||||
(goto-char pos))))
|
||||
|
||||
|
||||
(defvar mu4e~headers-regexp-hist nil
|
||||
"History list of regexps used.")
|
||||
|
||||
|
|
Loading…
Reference in New Issue