unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] vim: improvements for sendmail
@ 2011-02-06 13:29 Felipe Contreras
  2011-02-06 13:29 ` [PATCH 1/2] vim: use sendmail directly Felipe Contreras
  2011-02-06 13:29 ` [PATCH 2/2] vim: parse 'from' address Felipe Contreras
  0 siblings, 2 replies; 3+ messages in thread
From: Felipe Contreras @ 2011-02-06 13:29 UTC (permalink / raw)
  To: notmuch

Hi,

I use msmtp to send mail, and I rely on the 'from' address to be set correctly
(-f foo@bar.com) in order to pick the right account to send mail from. Postfix
and other MTA's can be configured in similar ways.

It's impossible to use this functionality with mailx, so let's use sendmail
directly.

Felipe Contreras (2):
  vim: use sendmail directly
  vim: parse 'from' address

 vim/plugin/notmuch.vim |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

-- 
1.7.4.1.g4f7e4.dirty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] vim: use sendmail directly
  2011-02-06 13:29 [PATCH 0/2] vim: improvements for sendmail Felipe Contreras
@ 2011-02-06 13:29 ` Felipe Contreras
  2011-02-06 13:29 ` [PATCH 2/2] vim: parse 'from' address Felipe Contreras
  1 sibling, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2011-02-06 13:29 UTC (permalink / raw)
  To: notmuch

The problem with 'mailx' is that it's not standardized, and it doesn't
allow the -f option, which is pretty important on many sendmail
configurations.

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

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 3375a96..002b771 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -24,6 +24,7 @@
 
 let s:notmuch_defaults = {
         \ 'g:notmuch_cmd':                           'notmuch'                    ,
+        \ 'g:notmuch_sendmail':                      'sendmail'                   ,
         \ 'g:notmuch_debug':                         0                            ,
         \
         \ 'g:notmuch_search_newest_first':           1                            ,
@@ -948,18 +949,19 @@ function! s:NM_compose_send()
         let line = getline(lnum)
         let lst_hdr = ''
         while match(line, '^$') == -1
-                if match(line, '^Notmuch-Help:') == -1
+                if !exists("hdr_starts") && match(line, '^Notmuch-Help:') == -1
                         let hdr_starts = lnum - 1
-                        break
                 endif
                 let lnum = lnum + 1
                 let line = getline(lnum)
         endwhile
+        let body_starts = lnum - 1
 
+        call append(body_starts, 'Date: ' . strftime('%a, %d %b %Y %H:%M:%S %z'))
         exec printf(':0,%dd', hdr_starts)
         write
 
-        let cmdtxt = 'mailx -t < ' . fname
+        let cmdtxt = g:notmuch_sendmail . ' -t < ' . fname
         let out = system(cmdtxt)
         let err = v:shell_error
         if err
-- 
1.7.4.1.g4f7e4.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] vim: parse 'from' address
  2011-02-06 13:29 [PATCH 0/2] vim: improvements for sendmail Felipe Contreras
  2011-02-06 13:29 ` [PATCH 1/2] vim: use sendmail directly Felipe Contreras
@ 2011-02-06 13:29 ` Felipe Contreras
  1 sibling, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2011-02-06 13:29 UTC (permalink / raw)
  To: notmuch

In order to pass it to sendmail.

Signed-off-by: Felipe Contreras <felipe.contreras@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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-06 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-06 13:29 [PATCH 0/2] vim: improvements for sendmail Felipe Contreras
2011-02-06 13:29 ` [PATCH 1/2] vim: use sendmail directly Felipe Contreras
2011-02-06 13:29 ` [PATCH 2/2] vim: parse 'from' address Felipe Contreras

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).