[PATCH 2/2] vim: parse 'from' address

Felipe Contreras felipe.contreras at gmail.com
Sun Feb 6 05:29:07 PST 2011


In order to pass it to sendmail.

Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 vim/plugin/notmuch.vim |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 002b771..08832cc 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -961,7 +961,16 @@ function! s:NM_compose_send()
         exec printf(':0,%dd', hdr_starts)
         write
 
-        let cmdtxt = g:notmuch_sendmail . ' -t < ' . fname
+        let line = getline(1)
+        let m = matchlist(line, '^From:\s*\(.*\)\s*<\(.*\)>$')
+        if (len(m) >= 2)
+                let from = m[2]
+        else
+                let m = matchlist(line, '^From:\s*\(.*\)$')
+                let from = m[1]
+        endif
+
+        let cmdtxt = g:notmuch_sendmail . ' -t -f ' . from . ' < ' . fname
         let out = system(cmdtxt)
         let err = v:shell_error
         if err
-- 
1.7.4.1.g4f7e4.dirty



More information about the notmuch mailing list