[PATCH] VIM: Automatically refresh folder screen

2015-02-03 Thread Bartosz Telenczuk
Franz Fellner wrote:
> Hi Bartosz,
> 
> Great to see one more person interested in notmuch-vim! Hopefully this will 
> make review a little bit easier.
> 
> Bartosz Telenczuk wrote:
> > Ian Main wrote:
> > > This patch makes the folder screen refresh each time you 'enter' it.
> > > This way when you read a folder and mark items as read the changes are
> > > reflected immediately when you return to the folder view.
> > 
> > That is a good starting point, but why don't we refresh every time we mark 
> > an item in the folder screen?
> 
> Personally I don't see the benefit. It's a useless call to notmuch for every 
> cursor-move. Especially with the current inefficient implementation.

I meant that we should refresh after one tags a thread (for example archive it 
with "A" key). It is slightly annoying that the messages do not disappear after 
being archived. In my version of the plugin it also causes a wrong thread to be 
opened when I enter it.

Anyway, this is a small incremental change that can be implemented later.. It 
should not hold back the patch. These patches are already great and should 
accepted as soon as possible, so we can move forward and synchronize 
notmuch-repo with Ian's repo and possibly catch up with emacs (sic!) client.

Cheers,

Bartosz


[PATCH v3] VIM: Improve moving between messages in a thread

2015-02-03 Thread Bartosz Telenczuk
> I think the API should be clear and easy to understand, because people will 
> probably bind them to custom shortcuts. You should not have to think about 
> what that weird extra parameter (-1, false, ...) means and go read the docs.

I agree. One might replace the parameter with a string like "prev" and "next".

> But I agree that the code duplication is not optimal. The code in Ians repo 
> already has split out the ruby code. There is still code duplication. But 
> that can easily be split out into a function on its own. 

That's the way to go.

Bartosz


[PATCH] VIM: Make an option to save sent mail locally

2015-02-03 Thread Bartosz Telenczuk
> > I would appreciate an option to configure the "sent" box per provider. I
> > implemented this feature in this patch:
> > 
> > id:1420891384-992-4-git-send-email-telenczuk at unic.cnrs-gif.fr
> 
> Generally it might work. But there are other features that may rely on 
> per-account-settings (drafts, outbox, templates, ...). Setting them all that 
> way might get ugly. The best solution might be to introduce a setting for 
> account information.

Definitely, in my implementation this is done via a setting in the notmuch 
config file, which maps between accounts and provider dir. If this is not 
configure, it default to not storing sent emails. For example:

[vim]
sent_dirs=telenczb at hu-berlin.de=>HU/Sent;telenczuk at 
unic.cnrs-gif.fr=>CNRS/Sent

Cheers,

Bartosz


[PATCH 1/4] VIM: implemented message folding in thread view

2015-02-03 Thread Bartosz Telenczuk
Hi Franz,

> We already had folding via syntax in Ians fork. It turned out to be not that 
> great.
> https://github.com/imain/notmuch-vim/issues/3

Ah all right, I just thought syntax fold would be more elegant.

> In short:
> Those syntax fold marks are for one specific notmuch-show-buffer. If you open 
> a second show-buffer those
> new fold marks will overwrite the ones from the previous show-buffer. 
> Switching between those two show-buffers
> will spin up CPU for quite some time and completely lock vim.

True, I can reproduce this bug in my implementation. 

> It also would help a lot if we could reoranize the sources as in Ians fork. 
> Would simplify testing, coding (proper filetype) and backporting patches.

Agree. We should come up with a plan how to integrate the changes back into 
notmuch. Do you have any ideas?

Cheers,

Bartosz


RE: [PATCH] VIM: Automatically refresh folder screen

2015-02-02 Thread Bartosz Telenczuk
Franz Fellner wrote:
> Hi Bartosz,
> 
> Great to see one more person interested in notmuch-vim! Hopefully this will 
> make review a little bit easier.
> 
> Bartosz Telenczuk wrote:
> > Ian Main wrote:
> > > This patch makes the folder screen refresh each time you 'enter' it.
> > > This way when you read a folder and mark items as read the changes are
> > > reflected immediately when you return to the folder view.
> > 
> > That is a good starting point, but why don't we refresh every time we mark 
> > an item in the folder screen?
> 
> Personally I don't see the benefit. It's a useless call to notmuch for every 
> cursor-move. Especially with the current inefficient implementation.

I meant that we should refresh after one tags a thread (for example archive it 
with "A" key). It is slightly annoying that the messages do not disappear after 
being archived. In my version of the plugin it also causes a wrong thread to be 
opened when I enter it.

Anyway, this is a small incremental change that can be implemented later.. It 
should not hold back the patch. These patches are already great and should 
accepted as soon as possible, so we can move forward and synchronize 
notmuch-repo with Ian's repo and possibly catch up with emacs (sic!) client.

Cheers,

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


RE: [PATCH v3] VIM: Improve moving between messages in a thread

2015-02-02 Thread Bartosz Telenczuk
> I think the API should be clear and easy to understand, because people will 
> probably bind them to custom shortcuts. You should not have to think about 
> what that weird extra parameter (-1, false, ...) means and go read the docs.

I agree. One might replace the parameter with a string like "prev" and "next".

> But I agree that the code duplication is not optimal. The code in Ians repo 
> already has split out the ruby code. There is still code duplication. But 
> that can easily be split out into a function on its own. 

That's the way to go.

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] VIM: Make an option to save sent mail locally

2015-02-02 Thread Bartosz Telenczuk
> > I would appreciate an option to configure the "sent" box per provider. I
> > implemented this feature in this patch:
> > 
> > id:1420891384-992-4-git-send-email-telenc...@unic.cnrs-gif.fr
> 
> Generally it might work. But there are other features that may rely on 
> per-account-settings (drafts, outbox, templates, ...). Setting them all that 
> way might get ugly. The best solution might be to introduce a setting for 
> account information.

Definitely, in my implementation this is done via a setting in the notmuch 
config file, which maps between accounts and provider dir. If this is not 
configure, it default to not storing sent emails. For example:

[vim]
sent_dirs=telen...@hu-berlin.de=>HU/Sent;telenc...@unic.cnrs-gif.fr=>CNRS/Sent

Cheers,

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


RE: [PATCH 1/4] VIM: implemented message folding in thread view

2015-02-02 Thread Bartosz Telenczuk
Hi Franz,

> We already had folding via syntax in Ians fork. It turned out to be not that 
> great.
> https://github.com/imain/notmuch-vim/issues/3

Ah all right, I just thought syntax fold would be more elegant.

> In short:
> Those syntax fold marks are for one specific notmuch-show-buffer. If you open 
> a second show-buffer those
> new fold marks will overwrite the ones from the previous show-buffer. 
> Switching between those two show-buffers
> will spin up CPU for quite some time and completely lock vim.

True, I can reproduce this bug in my implementation. 

> It also would help a lot if we could reoranize the sources as in Ians fork. 
> Would simplify testing, coding (proper filetype) and backporting patches.

Agree. We should come up with a plan how to integrate the changes back into 
notmuch. Do you have any ideas?

Cheers,

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[DRAFT] New features in Vim interface

2015-01-20 Thread Bartosz Telenczuk
> Yeah that would be ideal.  Franz and I have been working in a github repo 
> here:
> 
> https://github.com/imain/notmuch-vim

Indeed, that is a lot of commits. It is almost an independent fork. Even more 
so we should work hard to include the changes back into upstream for "the 
benefit of the community".

> Let me know what you think of the code base and if you are willing to help out
> with merging the changes (lots of reviews I think mostly).

I would suggest to start with the patches you already sent to notmuch mailing 
list. I already reviewed three:

VIM: Automatically refresh folder screen, id:54bd89e062df1_a663fec9d49e200a3 at 
bts-MacBook-Pro.local.notmuch
Make an option to save sent mail locally, 
id:1412617904-27252-1-git-send-email-imain at stemwinder.org
Improve moving between messages in a thread, 
id:1412579537-7921-1-git-send-email-imain at stemwinder.org

The last one with only a minor comment. Let me know what you think.

Bartosz


[PATCH] VIM: Automatically refresh folder screen

2015-01-19 Thread Bartosz Telenczuk
Ian Main wrote:
> This patch makes the folder screen refresh each time you 'enter' it.
> This way when you read a folder and mark items as read the changes are
> reflected immediately when you return to the folder view.

That is a good starting point, but why don't we refresh every time we mark an 
item in the folder screen?

Bartosz


Re: [DRAFT] New features in Vim interface

2015-01-19 Thread Bartosz Telenczuk
> Yeah that would be ideal.  Franz and I have been working in a github repo 
> here:
> 
> https://github.com/imain/notmuch-vim

Indeed, that is a lot of commits. It is almost an independent fork. Even more 
so we should work hard to include the changes back into upstream for "the 
benefit of the community".

> Let me know what you think of the code base and if you are willing to help out
> with merging the changes (lots of reviews I think mostly).

I would suggest to start with the patches you already sent to notmuch mailing 
list. I already reviewed three:

VIM: Automatically refresh folder screen, 
id:54bd89e062df1_a663fec9d49e200a3@bts-MacBook-Pro.local.notmuch
Make an option to save sent mail locally, 
id:1412617904-27252-1-git-send-email-im...@stemwinder.org
Improve moving between messages in a thread, 
id:1412579537-7921-1-git-send-email-im...@stemwinder.org

The last one with only a minor comment. Let me know what you think.

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


RE: [PATCH] VIM: Automatically refresh folder screen

2015-01-19 Thread Bartosz Telenczuk
Ian Main wrote:
> This patch makes the folder screen refresh each time you 'enter' it.
> This way when you read a folder and mark items as read the changes are
> reflected immediately when you return to the folder view.

That is a good starting point, but why don't we refresh every time we mark an 
item in the folder screen?

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] VIM: Make an option to save sent mail locally

2015-01-13 Thread Bartosz Telenczuk
Great work!

> Yeah, I can add it so the folder can be changed.  I figured this was just the
> start of things.  Really we should be able to fcc it to our upstream provider
> sent mailbox too.

I would appreciate an option to configure the "sent" box per provider. I
implemented this feature in this patch:

id:1420891384-992-4-git-send-email-telenc...@unic.cnrs-gif.fr

The way it works is that it reads a mapping between the email-addresses and 
sent 
dirs from .notmuch-config. Then it parses the "from" header of the sent message
and "notmuch inserts" the message into the directory associated with the "from" 
address. 

It is not a fully polished patch. Perhaps we could merge the two to get 
something more final.

Bartosz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


RE: [PATCH v3] VIM: Improve moving between messages in a thread

2015-01-13 Thread Bartosz Telenczuk
Hi Ian,

The patch looks good. I tested it on my system and it works fine.  I just have 
one suggestion regarding coding style.

> +function! s:show_prev_msg()
>  function! s:show_next_msg()

Since these functions are almost the same, you could avoid code repetition by 
replacing them by a function which takes (positive or negative) increment as an 
argument.

Cheers,

Bartosz

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


[PATCH] VIM: Make an option to save sent mail locally

2015-01-13 Thread Bartosz Telenczuk
Great work!

> Yeah, I can add it so the folder can be changed.  I figured this was just the
> start of things.  Really we should be able to fcc it to our upstream provider
> sent mailbox too.

I would appreciate an option to configure the "sent" box per provider. I
implemented this feature in this patch:

id:1420891384-992-4-git-send-email-telenczuk at unic.cnrs-gif.fr

The way it works is that it reads a mapping between the email-addresses and 
sent 
dirs from .notmuch-config. Then it parses the "from" header of the sent message
and "notmuch inserts" the message into the directory associated with the "from" 
address. 

It is not a fully polished patch. Perhaps we could merge the two to get 
something more final.

Bartosz


[PATCH v3] VIM: Improve moving between messages in a thread

2015-01-13 Thread Bartosz Telenczuk
Hi Ian,

The patch looks good. I tested it on my system and it works fine.  I just have 
one suggestion regarding coding style.

> +function! s:show_prev_msg()
>  function! s:show_next_msg()

Since these functions are almost the same, you could avoid code repetition by 
replacing them by a function which takes (positive or negative) increment as an 
argument.

Cheers,

Bartosz



Re: [DRAFT] New features in Vim interface

2015-01-12 Thread Bartosz Telenczuk
Dear David, 
(CC Ian and Franz)

> Before Christmas we had a flurry of patches from Ian Main (in copy). I
> think there is some functionality overlap with what you proposed. As far
> as I know Ian has mainly been working on his private fork of the vim
> client, but maybe if the two (or three, including Franz) of you can work
> together to review each other's patches and polish things we can get
> some of these things upstream.

Thanks a lot for pointing me to Ian's patches. Indeed, some of the 
functionality overlaps; this only means that these features are on everyone 
wishlist. I will be happy to help Ian and Franz get these patches upstream.

I am not familiar with the review process at NM. If someone could help me to 
get started, I will be much obliged.

Yours,

Bartoz
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[DRAFT] New features in Vim interface

2015-01-11 Thread Bartosz Telenczuk
Dear David, 
(CC Ian and Franz)

> Before Christmas we had a flurry of patches from Ian Main (in copy). I
> think there is some functionality overlap with what you proposed. As far
> as I know Ian has mainly been working on his private fork of the vim
> client, but maybe if the two (or three, including Franz) of you can work
> together to review each other's patches and polish things we can get
> some of these things upstream.

Thanks a lot for pointing me to Ian's patches. Indeed, some of the 
functionality overlaps; this only means that these features are on everyone 
wishlist. I will be happy to help Ian and Franz get these patches upstream.

I am not familiar with the review process at NM. If someone could help me to 
get started, I will be much obliged.

Yours,

Bartoz


[PATCH 4/4] VIM: adding attachments

2015-01-10 Thread Bartosz
files to be attached are listed at the end of composed message as
paths prefixed by "Attachment:"
---
 vim/notmuch.vim | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index e95db4d..d999aef 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -92,9 +92,16 @@ function! s:compose_send()

 ruby << EOF
# Generate proper mail to send
-   text = VIM::evaluate('lines').join("\n")
-   fname = VIM::evaluate('fname')
+   text = VIM::evaluate('lines')
+   attached_filenames = text.reverse.take_while { |line| 
line.start_with?("Attachment:") }
+   text = text.reverse.drop_while { |line| line.start_with?("Attachment:") 
} . reverse
+   text = text.join("\n")
transport = Mail.new(text)
+   attached_filenames.each do |afname|
+   transport.add_file(afname[11..-1].strip)
+   end
+   
+   fname = VIM::evaluate('fname')
transport.message_id = generate_message_id
transport.charset = 'utf-8'
File.write(fname, transport.to_s)
-- 
1.9.3 (Apple Git-50)



[PATCH 3/4] VIM: save sent message to maildir

2015-01-10 Thread Bartosz
maildir folder is slected based on the address in
from header and it is configurable via notmuch
config.
---
 vim/notmuch.vim | 20 
 1 file changed, 20 insertions(+)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 4f90d79..e95db4d 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -110,6 +110,9 @@ EOF
echohl None
return
endif
+
+   call s:save_to_sent(fname)
+
call delete(fname)
echo 'Mail sent successfully.'
call s:kill_this_buffer()
@@ -257,6 +260,20 @@ function! s:folders_refresh()
setlocal nomodifiable
 endfunction

+function! s:save_to_sent(fname)
+ruby << EOF
+if $sent_dirs
+   fname = VIM::evaluate('a:fname')
+   m = Mail.read(fname)
+   from_address = m.from[0]
+   sent_box = $sent_dirs[from_address]
+   if sent_box
+   system "notmuch insert --folder:#{sent_box} +sent < 
#{fname}"
+   end
+   end
+EOF
+endfunction
+
 "" basic

 function! s:show_cursor_moved()
@@ -505,6 +522,8 @@ ruby << EOF
$email_address = get_config_item('user.primary_email')
$email_name = get_config_item('user.name')
$email = "%s <%s>" % [$email_name, $email_address]
+   sent_dirs_config = get_config_item('vim.sent_dirs')
+   $sent_dirs = Hash[sent_dirs_config.split("\n").collect{|x| 
x.strip.split("=>")}]
end

def vim_puts(s)
@@ -698,6 +717,7 @@ ruby << EOF
end
end

+
module DbHelper
def init(name)
@name = name
-- 
1.9.3 (Apple Git-50)



[PATCH 2/4] VIM: move backward trough messages in thread mode

2015-01-10 Thread Bartosz
---
 vim/notmuch.vim | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 34d4f92..4f90d79 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -39,7 +39,8 @@ let g:notmuch_show_maps = {
\ 'p':  'show_save_patches()',
\ 'r':  'show_reply()',
\ '?':  'show_info()',
-   \ '':  'show_next_msg()',
+   \ '':  'show_next_msg(1)',
+   \ '':'show_next_msg(-1)',
\ 'c':  'compose()',
\ }

@@ -114,15 +115,18 @@ EOF
call s:kill_this_buffer()
 endfunction

-function! s:show_next_msg()
+function! s:show_next_msg(inc)
 ruby << EOF
+   inc = VIM::evaluate('a:inc')
r, c = $curwin.cursor
n = $curbuf.line_number
i = $messages.index { |m| n >= m.start && n <= m.end }
-   m = $messages[i + 1]
-   if m
+   m = $messages[i + inc]
+   if m and !((i + inc)<0) 
r = m.body_start + 1
+   VIM::command("normal zM")
VIM::command("normal #{m.start}zt")
+   VIM::command("normal zo")
$curwin.cursor = r, c
end
 EOF
-- 
1.9.3 (Apple Git-50)



[PATCH 1/4] VIM: implemented message folding in thread view

2015-01-10 Thread Bartosz
---
 vim/notmuch.vim | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index cad9517..34d4f92 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -345,8 +345,13 @@ ruby << EOF
VIM::command("syntax region nmShowMsg#{i}Desc start='\\%%%il' 
end='\\%%%il' contains=@nmShowMsgDesc" % [msg.start, msg.start + 1])
VIM::command("syntax region nmShowMsg#{i}Head start='\\%%%il' 
end='\\%%%il' contains=@nmShowMsgHead" % [msg.start + 1, msg.body_start])
VIM::command("syntax region nmShowMsg#{i}Body start='\\%%%il' 
end='\\%%%dl' contains=@nmShowMsgBody" % [msg.body_start, msg.end])
+   VIM::command("syntax region nmShowMsg#{i}Fold start='\\%%%il' 
end='\\%%%dl' contains=nmShowMsg#{i}Body,nmShowMsg#{i}Head,nmShowMsg#{i}Desc 
fold" % [msg.start, msg.end])
end
+   VIM::command("g/^.*(.*unread.*)$/normal zo")
+   VIM::command("nohl")
+   VIM::command("normal gg/unread/1") 
 EOF
+set foldmethod=syntax
setlocal nomodifiable
call s:set_map(g:notmuch_show_maps)
 endfunction
@@ -957,5 +962,6 @@ EOF
 endfunction

 command -nargs=* NotMuch call s:NotMuch()
+set foldtext=v:folddashes.substitute(getline(v:foldstart),'{{{','','g')

 " vim: set noexpandtab:
-- 
1.9.3 (Apple Git-50)



[DRAFT] New features in Vim interface

2015-01-10 Thread Bartosz
Hi,

I really like to use notmuch for organising my emails. However, I noticed that 
vim interface is slightly lagging behind emacs. Some of the most important 
features still missing are:

- adding attachments (PATCH 4)
- saving sent emails to "Sent" box in maildir (PATCH 3)
- forwarding messages (not implemented yet)
- folding read messages in thread view (PATCH 1 and 2)

This patch series attempts to implement some of the features. It is not a 
finished product, but rather a prototype of the interface. If you consider it 
worthwhile I will try to polish the patches.

[PATCH 1/4] VIM: implemented message folding in thread view

This patch automatically folds all read messages in thread view and jumps to 
the first unread message (if present). It uses vim folding mechanisms (based on 
syntax definition), so folds can be easily opened/closed.

[PATCH 2/4] VIM: move backward trough messages in thread mode

Currently, vim frontend allows to jump forward through messages in a thread 
using Tab key. This patch introduces Shift-Tab shortcut to move backwards. In 
addition, jumping to a new message automatically unfolds it.

[PATCH 3/4] VIM: save sent message to maildir

This patch uses "notmuch insert" for adding a message to a sent folder in mail 
archives after it is sent. The path to "sent" folder is configurable through 
.notmuch-config, by defining a section called [vim]. So far there is a single 
parameter in the section "sent_dirs" that should define a mapping between email 
addresses and folders. For example:

  [vim]
  sent_dirs=telenczb at hu-berlin.de=>HU/Sent;telenczuk at 
unic.cnrs-gif.fr=>CNRS/Sent

Email address is parsed from the "From" header of the sent email.

[PATCH 4/4] VIM: adding attachments

Paths to files to be attached should be listed as the final lines of the 
composed message and prefixed by "Attachment:" (one line per file). For example:

   

   

   Attachment: /home/bartosz/test.pdf
   Attachment: /home/bartosz/test.txt

I will be glad to hear your opinion about the design and implementation.

Yours,

Bartosz



[PATCH 4/4] VIM: adding attachments

2015-01-10 Thread Bartosz
files to be attached are listed at the end of composed message as
paths prefixed by "Attachment:"
---
 vim/notmuch.vim | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index e95db4d..d999aef 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -92,9 +92,16 @@ function! s:compose_send()
 
 ruby << EOF
# Generate proper mail to send
-   text = VIM::evaluate('lines').join("\n")
-   fname = VIM::evaluate('fname')
+   text = VIM::evaluate('lines')
+   attached_filenames = text.reverse.take_while { |line| 
line.start_with?("Attachment:") }
+   text = text.reverse.drop_while { |line| line.start_with?("Attachment:") 
} . reverse
+   text = text.join("\n")
transport = Mail.new(text)
+   attached_filenames.each do |afname|
+   transport.add_file(afname[11..-1].strip)
+   end
+   
+   fname = VIM::evaluate('fname')
transport.message_id = generate_message_id
transport.charset = 'utf-8'
File.write(fname, transport.to_s)
-- 
1.9.3 (Apple Git-50)

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


[PATCH 2/4] VIM: move backward trough messages in thread mode

2015-01-10 Thread Bartosz
---
 vim/notmuch.vim | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 34d4f92..4f90d79 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -39,7 +39,8 @@ let g:notmuch_show_maps = {
\ 'p':  'show_save_patches()',
\ 'r':  'show_reply()',
\ '?':  'show_info()',
-   \ '':  'show_next_msg()',
+   \ '':  'show_next_msg(1)',
+   \ '':'show_next_msg(-1)',
\ 'c':  'compose()',
\ }
 
@@ -114,15 +115,18 @@ EOF
call s:kill_this_buffer()
 endfunction
 
-function! s:show_next_msg()
+function! s:show_next_msg(inc)
 ruby << EOF
+   inc = VIM::evaluate('a:inc')
r, c = $curwin.cursor
n = $curbuf.line_number
i = $messages.index { |m| n >= m.start && n <= m.end }
-   m = $messages[i + 1]
-   if m
+   m = $messages[i + inc]
+   if m and !((i + inc)<0) 
r = m.body_start + 1
+   VIM::command("normal zM")
VIM::command("normal #{m.start}zt")
+   VIM::command("normal zo")
$curwin.cursor = r, c
end
 EOF
-- 
1.9.3 (Apple Git-50)

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


[PATCH 1/4] VIM: implemented message folding in thread view

2015-01-10 Thread Bartosz
---
 vim/notmuch.vim | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index cad9517..34d4f92 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -345,8 +345,13 @@ ruby << EOF
VIM::command("syntax region nmShowMsg#{i}Desc start='\\%%%il' 
end='\\%%%il' contains=@nmShowMsgDesc" % [msg.start, msg.start + 1])
VIM::command("syntax region nmShowMsg#{i}Head start='\\%%%il' 
end='\\%%%il' contains=@nmShowMsgHead" % [msg.start + 1, msg.body_start])
VIM::command("syntax region nmShowMsg#{i}Body start='\\%%%il' 
end='\\%%%dl' contains=@nmShowMsgBody" % [msg.body_start, msg.end])
+   VIM::command("syntax region nmShowMsg#{i}Fold start='\\%%%il' 
end='\\%%%dl' contains=nmShowMsg#{i}Body,nmShowMsg#{i}Head,nmShowMsg#{i}Desc 
fold" % [msg.start, msg.end])
end
+   VIM::command("g/^.*(.*unread.*)$/normal zo")
+   VIM::command("nohl")
+   VIM::command("normal gg/unread/1") 
 EOF
+set foldmethod=syntax
setlocal nomodifiable
call s:set_map(g:notmuch_show_maps)
 endfunction
@@ -957,5 +962,6 @@ EOF
 endfunction
 
 command -nargs=* NotMuch call s:NotMuch()
+set foldtext=v:folddashes.substitute(getline(v:foldstart),'{{{','','g')
 
 " vim: set noexpandtab:
-- 
1.9.3 (Apple Git-50)

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


[DRAFT] New features in Vim interface

2015-01-10 Thread Bartosz
Hi,

I really like to use notmuch for organising my emails. However, I noticed that 
vim interface is slightly lagging behind emacs. Some of the most important 
features still missing are:

- adding attachments (PATCH 4)
- saving sent emails to "Sent" box in maildir (PATCH 3)
- forwarding messages (not implemented yet)
- folding read messages in thread view (PATCH 1 and 2)

This patch series attempts to implement some of the features. It is not a 
finished product, but rather a prototype of the interface. If you consider it 
worthwhile I will try to polish the patches.

[PATCH 1/4] VIM: implemented message folding in thread view

This patch automatically folds all read messages in thread view and jumps to 
the first unread message (if present). It uses vim folding mechanisms (based on 
syntax definition), so folds can be easily opened/closed.

[PATCH 2/4] VIM: move backward trough messages in thread mode

Currently, vim frontend allows to jump forward through messages in a thread 
using Tab key. This patch introduces Shift-Tab shortcut to move backwards. In 
addition, jumping to a new message automatically unfolds it.

[PATCH 3/4] VIM: save sent message to maildir

This patch uses "notmuch insert" for adding a message to a sent folder in mail 
archives after it is sent. The path to "sent" folder is configurable through 
.notmuch-config, by defining a section called [vim]. So far there is a single 
parameter in the section "sent_dirs" that should define a mapping between email 
addresses and folders. For example:

  [vim]
  sent_dirs=telen...@hu-berlin.de=>HU/Sent;telenc...@unic.cnrs-gif.fr=>CNRS/Sent

Email address is parsed from the "From" header of the sent email.

[PATCH 4/4] VIM: adding attachments

Paths to files to be attached should be listed as the final lines of the 
composed message and prefixed by "Attachment:" (one line per file). For example:
   
   

   

   Attachment: /home/bartosz/test.pdf
   Attachment: /home/bartosz/test.txt

I will be glad to hear your opinion about the design and implementation.

Yours,

Bartosz

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


[PATCH 3/4] VIM: save sent message to maildir

2015-01-10 Thread Bartosz
maildir folder is slected based on the address in
from header and it is configurable via notmuch
config.
---
 vim/notmuch.vim | 20 
 1 file changed, 20 insertions(+)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 4f90d79..e95db4d 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -110,6 +110,9 @@ EOF
echohl None
return
endif
+
+   call s:save_to_sent(fname)
+
call delete(fname)
echo 'Mail sent successfully.'
call s:kill_this_buffer()
@@ -257,6 +260,20 @@ function! s:folders_refresh()
setlocal nomodifiable
 endfunction
 
+function! s:save_to_sent(fname)
+ruby << EOF
+if $sent_dirs
+   fname = VIM::evaluate('a:fname')
+   m = Mail.read(fname)
+   from_address = m.from[0]
+   sent_box = $sent_dirs[from_address]
+   if sent_box
+   system "notmuch insert --folder:#{sent_box} +sent < 
#{fname}"
+   end
+   end
+EOF
+endfunction
+
 "" basic
 
 function! s:show_cursor_moved()
@@ -505,6 +522,8 @@ ruby << EOF
$email_address = get_config_item('user.primary_email')
$email_name = get_config_item('user.name')
$email = "%s <%s>" % [$email_name, $email_address]
+   sent_dirs_config = get_config_item('vim.sent_dirs')
+   $sent_dirs = Hash[sent_dirs_config.split("\n").collect{|x| 
x.strip.split("=>")}]
end
 
def vim_puts(s)
@@ -698,6 +717,7 @@ ruby << EOF
end
end
 
+
module DbHelper
def init(name)
@name = name
-- 
1.9.3 (Apple Git-50)

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