Hi Dirk,
>>> You can influence those properties indeed, through mu4e-search-hook
>>> and mu4e-search-bookmark-hook. mu4e-headers-hide-predicate can be
>>> useful as well, perhaps in combination with those hooks.
>>
>> So basically, I would invent a new query keyword
>> "!RELATED_AND_UNREAD!" which would result in setting
>>
>> (setq mu4e-search-include-related t)
>> (setq mu4e-search-hide-predicate
>> (lambda (msg)
>> (member 'unread (mu4e-message-field msg :flags))))
>>
>> in mu4e-search-hook if it's in the query and then remove that custom
>> keyword again in mu4e-query-rewrite-function? Do you mean something
>> like that?
>
> That's one way, but you could use those hooks I mentioned; i.e., for
> mu4e-search-hook
>
> have some (cond (...)) for the various queries for which you need
> non-default settings for mu4e-search-include-related etc., with the
> 'all the rest' clause with your default settings.
That's what I have tried now: I have a new bookmark
(:name "Unread messages of threads with me"
:query "flag:personal !RELATED !HIDE_UNREAD"
:key ?p)
and added this to my config:
--8<---------------cut here---------------start------------->8---
(defun th/mu4e-search-hook--set-props-for-custom-query-keywords (query)
(when (string-match-p "!RELATED" query)
(setq-local mu4e-search-include-related t))
(when (string-match-p "!HIDE_UNREAD" query)
(setq-local mu4e-search-hide-predicate
(lambda (msg)
(not (member 'unread (mu4e-message-field msg :flags)))))))
(add-hook 'mu4e-search-hook
#'th/mu4e-search-hook--set-props-for-custom-query-keywords)
(defun th/mu4e-query-rewrite-function (query)
;; Remove custom keywords which we use to set `mu4e-search-include-related'
;; and `mu4e-search-hide-predicate' in `mu4e-search-hook'.
(setq query (replace-regexp-in-string "!\\(RELATED\\|HIDE_UNREAD\\)"
"" query)))
--8<---------------cut here---------------end--------------->8---
And it works, I just had your reply in that bookmark which goes only to
the mailinglist! And since the mu4e-search-hook runs with the new
headers buffer current, setq-local also works. Excellent!
There's one annoying issue: since I have a mu4e-search-hide-predicate
which hides messages which aren't unread anymore, as soon as I select a
message, it vanishes from the header view. Can I do something about
that?
Thanks,
Tassilo