Re: configurable summary line for notmuch search

Subject: Re: configurable summary line for notmuch search

Date: Sat, 28 Aug 2021 22:30:59 +0100

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Jose Antonio Ortega Ruiz


On Sat, Aug 28 2021, David Bremner wrote:

> I was idly thinking about how to provide custom summary formats for
> notmuch-search. I know this has been discussed a few times on IRC, but I
> can't remember the kind of things people were looking for. So if this a
> feature you're interested in, what specifically are you looking for?

I actually have a patch in my queue that implements a form of this, in
two ways.  By allowing the "field" to be a function that gets called with
the message property and returns a string, and by allowing the format
string to be a function that takes the value of the field and further
formats it.  This is the relevant patch with simple examples in the
documentation:

  https://jao.io/cgit/notmuch/commit/?h=tree-result-format&id=0d7d909aa8bc4fb8e5ab80f93bc397fbed666761

and this is an example of how i use it to have a marker in my result
lists that tells me if i'm the recipient of the displayed email and to
trunctate the subject to a maximum length:

      (setq notmuch-tree-result-format
            '(("date" . "%12s  ")
              ("authors" . "%-35s")
              (jao-notmuch-msg-ticks)
              ("subject" . jao-notmuch-truncate)
              ("tags" . "  (%s)")))

      (defun jao-notmuch-msg-ticks (msg)
        (let ((headers (plist-get msg :headers)))
          (cond ((string-match-p jao-mails-regexp (or (plist-get headers :To) ""))
                 (propertize " »" 'face 'notmuch-tree-match-tree-face))
                ((string-match-p jao-mails-regexp (or (plist-get headers :Cc) ""))
                 (propertize " ¬" 'face 'notmuch-tree-match-tree-face))
                (t "  "))))

      (defun jao-notmuch-truncate (x)
        (truncate-string-to-width (format "%-102s" x) 102 nil nil t))

what do you think?

cheers,
jao
-- 
I never lose sight of the fact that just being is fun.
  -Katharine Hepburn, actress (1907-2003)
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: