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

2011-02-06 Thread Felipe Contreras
In order to pass it to sendmail.

Signed-off-by: Felipe Contreras 
---
 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



[PATCH 1/2] vim: use sendmail directly

2011-02-06 Thread Felipe Contreras
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 
---
 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



[PATCH 0/2] vim: improvements for sendmail

2011-02-06 Thread Felipe Contreras
Hi,

I use msmtp to send mail, and I rely on the 'from' address to be set correctly
(-f foo at 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



[PATCH] Have --format=mbox insert Status:

2011-02-06 Thread Peter John Hartman
> Hi Peter,
> 
> would this output be compatible with all mbox consumers or only with
> those who expect the Status: line? If the latter, we would probably want
> a command line option to enable this.

Hi,

As far as I've been able to tell everyone respects RO in mbox, so I don't
see this as a problem.  In any case, having the Status: line there won't 
cause problems if an MUA doesn't recognize it.  That said, it would be nice
to think of a place to allow the user to easily "map" notmuch tags to
Status: or X-Status: rules, perhaps in the notmuch config file as follows:

[mbox]
synchronize_flags=true
xstatus_A=replied
xstatus_F=flagged
xstatus_T=draft
#xstatus_D=deleted
status_R=-unread
status_O=unread

Reference: http://wiki.dovecot.org/MailboxFormat/mbox:
  Status: R (\Seen) and O (non-\Recent) flags
  X-Status: A (\Answered), F (\Flagged), T (\Draft) and D (\Deleted) flags

(I know that alpine/pine and mutt recognize at least RO, and probably AFTD.)

Peter

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh


[PATCH] test/search: add check for slightly trick search

2011-02-06 Thread Felipe Contreras
It's not really tricky, there are many addresses with a '-' in them. I
personally really want to differentiate between foo, foo-testing, and
foo-patches.

This fails, but it shouldn't:

 FAIL   Search by from (tricky):
--- search.17.expected  2011-02-06 13:16:31.871509560 +
+++ search.17.output2011-02-06 13:16:31.871509560 +
@@ -1 +1,3 @@
+thread:XXX   2000-01-01 [1/1] Search By From Name; search by from 
(name) (inbox unread)
+thread:XXX   2000-01-01 [1/1] search-by-from-trick; search by from 
(tricky trick) (inbox unread)
 thread:XXX   2000-01-01 [1/1] search-by-from; search by from (tricky) 
(inbox unread)

Signed-off-by: Felipe Contreras 
---
 test/search |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/test/search b/test/search
index b180c7f..ad5bbaa 100755
--- a/test/search
+++ b/test/search
@@ -123,4 +123,10 @@ echo -n > expected &&
 notmuch search "no-message-matches-this" > actual &&
 test_cmp expected actual'

+test_begin_subtest "Search by from (tricky):"
+add_message '[subject]="search by from (tricky trick)"' '[date]="Sat, 01 Jan 
2000 12:00:00 -"' '[from]=search-by-from-trick'
+add_message '[subject]="search by from (tricky)"' '[date]="Sat, 01 Jan 2000 
12:00:00 -"' '[from]=search-by-from'
+output=$(notmuch search from:'search-by-from' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] search-by-from; 
search by from (tricky) (inbox unread)"
+
 test_done
-- 
1.7.4.1.g4f7e4.dirty



notmuch-show-get-filename and maildir location

2011-02-06 Thread Michal Sojka
On Fri, 04 Feb 2011, micah wrote:
> 
> I recently upgraded to the newer notmuch to test out the new folder
> patch (its great!) and the new decryption/signature verification (its
> fantastic!), and noticed something odd start happening.
> 
> I think that notmuch moves a new message to the maildir cur directory,
> From the new directory when you first read it. Is that right? This is
> actually what I would expect with maildirs, but notmuch wasn't doing
> this before.
> 
> The reason why I care is because if I open a message,
> notmuch-show-get-filename tells me that the file is located in the
> 'new/' path, but it is actually not there at all, looking around it
> appears to be in the 'cur/' directory. 
> 
> This is because I made a function to let me do bayes training by putting
> mistaken emails in my Mistakes folder, so that they can be retrained:
> 
> (defun notmuch-mark-as-mistake ()
> "Moves the current message into the Mistakes folder"
>   (interactive)
> (let* ((fullpath (notmuch-show-get-filename))

Hi Micah,

Use this instead of the above line.

  (let* ((fullpath (car (process-lines notmuch-command "search"
   "--output=files" 
(notmuch-show-get-message-id


> Incidentally, does anyone know how I can do this without having to
> actually do a notmuch-show on the message? Most spam I can recognize by
> the subject in my inbox, and I dont need to open it to see that.

Look at http://notmuchmail.org/emacstips/#index5h2. This is similar to
what you want.

-Michal


Remote usage script updated

2011-02-06 Thread Michal Sojka
On Sat, 05 Feb 2011, Michal Sojka wrote:
> On Thu, 27 Jan 2011, Jesse Rosenthal wrote:
> > A future feature might be to integrate the ControlMaster feature of
> > openssh into the script, instead of having to open a connection
> > manually, but there are some complications there (dead sockets still
> > around if you go offline, etc.).
> 
> In another project I worked around the dead sockets this way:
> 
> sshgw() {
> local socket="$HOME/.ssh/cangw-connection"
> 
> if [[ ! -S $socket ]] || ! ssh -x -a -S $socket root at 192.168.2.3 true; 
> then
>   # Create master connection to speed up subsequent commands.
>   ssh -N -f -M -S $socket root at 192.168.2.3 >/dev/null 2>&1
> fi
> ssh -x -a -S $socket root at 192.168.2.3 "$@"
> }

Hmm, this code worked well with dropbear ssh server but it seems that
with openssh server the result is not that good. Namely, if the master
connection is dead, the command running true blocked for a long time. I
have always killed it before it timed out so I don't know whether it
blocks indefinitely or there is only long timeout.

I may look at this later, but I use notmuch remotely only from time to
time so this is not priority for me.

-Michal


Re: [PATCH] Have --format=mbox insert Status:

2011-02-06 Thread Peter John Hartman
 Hi Peter,
 
 would this output be compatible with all mbox consumers or only with
 those who expect the Status: line? If the latter, we would probably want
 a command line option to enable this.

Hi,

As far as I've been able to tell everyone respects RO in mbox, so I don't
see this as a problem.  In any case, having the Status: line there won't 
cause problems if an MUA doesn't recognize it.  That said, it would be nice
to think of a place to allow the user to easily map notmuch tags to
Status: or X-Status: rules, perhaps in the notmuch config file as follows:

[mbox]
synchronize_flags=true
xstatus_A=replied
xstatus_F=flagged
xstatus_T=draft
#xstatus_D=deleted
status_R=-unread
status_O=unread

Reference: http://wiki.dovecot.org/MailboxFormat/mbox:
  Status: R (\Seen) and O (non-\Recent) flags
  X-Status: A (\Answered), F (\Flagged), T (\Draft) and D (\Deleted) flags

(I know that alpine/pine and mutt recognize at least RO, and probably AFTD.)

Peter

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test/search: add check for slightly trick search

2011-02-06 Thread Felipe Contreras
On Sun, Feb 6, 2011 at 3:21 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:
 It's not really tricky, there are many addresses with a '-' in them. I
 personally really want to differentiate between foo, foo-testing, and
 foo-patches.

 This fails, but it shouldn't:

As discussed in IRC, perhaps the query should be 'search-by-from@',
but that would require notmuch to distinguish @ as something special.
Perhaps s/@/-at-/.

Cheers.

-- 
Felipe Contreras
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch