From 4f83ab0f9430f0af1e6d3adbfc9a9591dddb8867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 9 Dec 2015 01:51:29 +0100 Subject: [PATCH] mu4e-headers: Add hook executed when we're opening bookmarks I'm using this for a rather nasty hack. When I open different bookmarks in the mu4e-main view I want to set options for them, currently just tweaking: * mu4e-headers-show-threads * mu4e-headers-include-related * mu4e-headers-skip-duplicates * mu4e-headers-results-limit This is because some of my searches are *really* expensive when I include related threads (huge batches of cron-generated E-Mails), but some aren't. I couldn't find another way to do this. Using mu4e-headers-mode-hook doesn't work, because we don't have access to the search (just a variable showing the last search). Also maybe we should be passing the actual key chord for the bookmark here. I don't care since I look up the search string that'll be executed and go from there, but maybe that interface would make more sense. But whatever, this works for me, and solves a real use-case. --- mu4e/mu4e-headers.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 4406283c..e7f4f4b2 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -160,6 +160,12 @@ 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." + :type 'hook + :group 'mu4e-headers) (defvar mu4e-headers-sort-field :date "Field to sort the headers by. @@ -1257,6 +1263,7 @@ 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 ()