Where parallels cross

Interesting bits of life

Mu4e: jump to manual to get help in writing queries

This is a mini blog. I use the amazing Mu4e to manage my emails from Emacs. Sometimes I struggle querying them though! Often I want to filter dates in between dates and I forget how to define that predicate in the Mu query language.

This has become boring now that I have shortened my feedback loop by using helm-mu: Helm updates the result of my query in real time, so if it is broken, I feel the pain of my error!

Naturally mu has an explanation of the query language in the manual (and there is also a nice blog about that). So I decided to change my setup to add a shortcut to get to the manpage when I need to:

(defun my/mu4e-queries-help ()
    (woman "mu-query")
    (search-forward "FIELDS

After binding this to a keybinding, I can access the Mu manual on the fly.

That does not work well with helm-mu though. To fix that I redefined the source in my configuration:

(let ((system-package
       (when (eq system-type 'darwin)
         '(wn . "brew install gnu-sed --with-default-names"))))
  (eval `(use-package helm-mu
           :ensure-system-package ,system-package
           (setq helm-source-mu
                 (helm-build-async-source "Search email with mu"
                   :candidates-process #'helm-mu-init
                   '(helm-mu-candidate-parser helm-mu-candidates-formatter)
                   :multimatch nil
                   :nohighlight t
                   :requires-pattern 3
                   :persistent-action #'helm-mu-persistent-action
                   :help-message (concat "* Mu Manual\n\n" (let ((buf (current-buffer)) ; adding some help I can access with C-h m when in the Helm session
                                                                 (_ (woman "mu-query"))
                                                                 (contents (buffer-string)))
                                                             (switch-to-buffer buf)
                   :action '(("Display message in mu4e" . helm-mu-display-email)))))))

That lets me read the manual without losing my Helm session with the keys C-h m.

Happy querying!