[PATCH 2/3] vim: fix get_user_email()

Subject: [PATCH 2/3] vim: fix get_user_email()

Date: Fri, 10 Dec 2010 00:16:24 +0200

To: notmuch@notmuchmail.org

Cc: Felipe Contreras

From: Felipe Contreras


From: Felipe Contreras <felipe.contreras@ngmail.com>

Signed-off-by: Felipe Contreras <felipe.contreras@ngmail.com>
---
 vim/plugin/notmuch.vim |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 6898d56..8815712 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -1027,11 +1027,9 @@ endfunction
 " --- --- compose screen helper functions {{{2
 
 function! s:NM_compose_get_user_email()
-        let name = substitute(system('id -u -n'), '\v(^\s*|\s*$|\n)', '', 'g')
-        let fqdn = substitute(system('hostname -f'), '\v(^\s*|\s*$|\n)', '', 'g')
-
-        " TODO: do this properly
-        return name . '@' . fqdn
+        let rname = system("getent passwd $USER | cut -d ':' -f 5")
+        let rname = substitute(rname, '\n*$', '', '')
+        return printf("%s <%s>", rname, $EMAIL)
 endfunction
 
 function! s:NM_compose_find_line_match(start, pattern, failure)
-- 
1.7.3.2


Thread: