From 7716e005bf6caba3bdf2e45a88c6d91b525adb2a Mon Sep 17 00:00:00 2001 From: djcb Date: Thu, 18 Feb 2016 20:59:02 +0200 Subject: [PATCH] mu4e: add mu4e-headers-search-pre-hook Just before executing a search, a hook-function `mu4e-headers-search-pre-hook` is invoked, which receives the search expression as its parameter. --- NEWS.org | 3 +++ mu4e/mu4e-headers.el | 9 ++++----- mu4e/mu4e.texi | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/NEWS.org b/NEWS.org index 90857056..f629d620 100644 --- a/NEWS.org +++ b/NEWS.org @@ -20,6 +20,9 @@ - Let `mu4e~read-char-choice' become case-insensitive if there is no exact match; small convenience that affects most the single-char option reading in mu4e. + - Now, just before executing a search, a hook-function + `mu4e-headers-search-pre-hook` is invoked, which receives the + search expression as its parameter. ** 0.9.16 diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 39c03426..c3492260 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -160,10 +160,9 @@ query have been received and are displayed." :type 'hook :group 'mu4e-headers) -(defcustom mu4e-headers-search-bookmark-hook nil - "Hook run just we're about to do a bookmarked search. The only -argument is `expr' which is the bookmarked search we're about to -execute." +(defcustom mu4e-headers-search-pre-hook nil + "Hook run just before executing a new search operation. This +function receives the query as its parameter." :type 'hook :group 'mu4e-headers) @@ -1015,6 +1014,7 @@ the query history stack." (mu4e-context-label))))) (switch-to-buffer buf) + (run-hook-with-args 'mu4e-headers-search-pre-hook expr) (mu4e~proc-find expr mu4e-headers-show-threads @@ -1300,7 +1300,6 @@ the search." (let ((expr (or expr (mu4e-ask-bookmark (if edit "Select bookmark: " "Bookmark: "))))) - (run-hook-with-args 'mu4e-headers-search-bookmark-hook expr) (mu4e-headers-search expr (when edit "Edit bookmark: ") edit))) (defun mu4e-headers-search-bookmark-edit () diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index 4b8abda1..0fa1f63e 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -827,7 +827,10 @@ Jamie Zawinski's mail threading algorithm, found during the indexing process, and if there is no current user-interaction. If you do not want such automatic updates, set @code{mu4e-headers-auto-update} to @code{nil}. -@item There is a hook-function @code{mu4e-headers-found-hook} available which +@item Just before executing a search, a hook-function +@code{mu4e-headers-search-pre-hook} is invoked, which receives the +search expression as its parameter. +@item Also, there is a hook-function @code{mu4e-headers-found-hook} available which is invoked just after @t{mu4e} has completed showing the messages in the headers-view. @end itemize