unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jason Woofenden <jason@jasonwoof.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] vim: add setting to shorten/fix sender names
Date: Mon, 11 Jul 2011 14:37:01 -0400	[thread overview]
Message-ID: <1310409421-4446-2-git-send-email-jason@jasonwoof.com> (raw)
In-Reply-To: <1310409421-4446-1-git-send-email-jason@jasonwoof.com>

Add a new setting: g:notmuch_nicknames (dictionary)

When reformatting the list of senders in the search view, replace any names
matching keys in g:notmuch_nicknames with the corresponding values.
---
 vim/plugin/notmuch.vim |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 12a0f88..5debaf6 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -103,6 +103,10 @@ let s:notmuch_compose_headers_defaults = [
         \ 'Subject'
         \ ]
 
+" To shorten/change the sender names in the search views:
+" let g:notmuch_nicknames = {'John Smith': 'me', 'Jane Smith': 'Jane'}
+
+
 " --- keyboard mapping definitions {{{1
 
 " --- --- bindings for folders mode {{{2
@@ -267,7 +271,20 @@ function! s:NM_cmd_search_fmtline(line)
                 let p = split(at, '[@.]')
                 let flist[p[0]] = 1
         endfor
-        let from = join(keys(flist), ", ")
+        if exists('g:notmuch_nicknames')
+                let from_fixed = []
+                for at in keys(flist)
+                        if has_key(g:notmuch_nicknames, at)
+                                call add(from_fixed, g:notmuch_nicknames[at])
+                        else
+                                call add(from_fixed, at)
+                        endif
+                endfor
+                let from = join(from_fixed, ', ')
+        else
+                let from = join(keys(flist), ', ')
+        endif
+
         return printf("%-12s %3s %-20.20s | %s (%s)", m[2], m[3], from, m[5], m[6])
 endfunction
 
-- 
1.7.5.4

  reply	other threads:[~2011-07-11 18:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 18:37 [PATCH] Feature request: nicknames for senders Jason Woofenden
2011-07-11 18:37 ` Jason Woofenden [this message]
2011-07-16 19:15 ` Felipe Contreras

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=1310409421-4446-2-git-send-email-jason@jasonwoof.com \
    --to=jason@jasonwoof.com \
    --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).