unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jose Antonio Ortega Ruiz <jao@gnu.org>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: configurable summary line for notmuch search
Date: Sat, 28 Aug 2021 22:30:59 +0100	[thread overview]
Message-ID: <87y28lb6jw.fsf@gnus.jao.io> (raw)
In-Reply-To: <87eead1u6c.fsf@tethera.net>

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)

  reply	other threads:[~2021-08-28 21:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 15:10 configurable summary line for notmuch search David Bremner
2021-08-28 21:30 ` Jose Antonio Ortega Ruiz [this message]
2021-08-29  0:46   ` Roger Randall
2021-09-01 16:25     ` Alexander Adolf
2021-09-01 18:52       ` Jose Antonio Ortega Ruiz
2021-08-29 14:53   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y28lb6jw.fsf@gnus.jao.io \
    --to=jao@gnu.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).