emacs-helm / helm-mu

Helm sources for searching emails and contacts using mu
GNU General Public License v3.0
58 stars 9 forks source link

Support for custom headers #33

Closed andersjohansson closed 8 years ago

andersjohansson commented 8 years ago

mu4e has had custom headers for a while (not sure how long) but I started defining some right when I started using mu4e a few weeks ago. They are defined in variable mu4e-header-info-custom. In the last version, header display has been rebuilt a bit to allow customising header display further (see: https://github.com/djcb/mu/pull/735), so the function to compare helm-mu-candidate-formatter to should be mu4e~headers-field-apply-basic-properties now.

Anyway, the big problem is that my custom-defined header doesn't work in helm-mu and I get the "Unsupported header field" error.

I haven't checked exactly what should be done, but it shouldn't be to difficult to fix. I might submit a pull request with a fix if I get the time to look at it the coming week.

andersjohansson commented 8 years ago

Ok, quick fix:

(t (mu4e-error "Unsupported header field (%S)" field))

in helm-mu-candidate-transformer becomes:

(t (mu4e~headers-custom-field candidate field))

Still, maybe something more should be done to accommodate possible other customisations made possible through the changes mentioned above. Without checking, I guess that is just ignored by helm-mu now, so it works anyway.

tmalsburg commented 8 years ago

Could you give me some elisp to reproduce the problem? I'm not up-to-date with recent changes in mu4e. Thank you.

andersjohansson commented 8 years ago

Sure. I have:

(add-to-list 'mu4e-header-info-custom
             '(:othermaildir
               . (:name "Maildir"
                        :shortname "M"
                        :help "Maildir"
                        :function aj/mu4e-other-maildir)))
(setq
 mu4e-headers-fields
 '((:human-date . 12)
   (:flags . 6)
   (:from-or-to . 22)
   (:mailing-list . 10)
   (:othermaildir . 10)
   (:thread-subject)))

And this stumbles into the problem. For reference, my "other maildir"-function:

(defun aj/mu4e-other-maildir (msg)
  "Returns a possibly shortened indication of MSGs maildir
Returns the empty string if this is the \"current\" maildir."
  (let ((mmd (mu4e-message-field msg :maildir)))
    (if (string-match  "maildir:\\\"\\(.+\\)\\\"" mu4e~headers-last-query)
        (let ((smd (match-string 1 mu4e~headers-last-query)))
          (if (string= smd mmd)
              ""
            (s-chop-prefix (s-shared-start mmd smd) mmd)))
      (s-replace-all '(("/uu/" . "🅄 ") ("/gmail/" . "🄶 ")) mmd))))
tmalsburg commented 8 years ago

I pushed the change that you suggested. Thanks for reporting.