* [PATCH] VIM: Make an option to save sent mail locally
@ 2014-10-06 17:51 Ian Main
2014-10-06 18:10 ` Ian Main
2014-10-20 17:58 ` [PATCH v2] " Ian Main
0 siblings, 2 replies; 13+ messages in thread
From: Ian Main @ 2014-10-06 17:51 UTC (permalink / raw)
To: notmuch
Add an option to use 'notmuch insert' to save your sent mail.
---
vim/notmuch.vim | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..cb280c3 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
let s:notmuch_reader_default = 'mutt -f %s'
let s:notmuch_sendmail_default = 'sendmail'
+let s:notmuch_save_sent_locally_default = 1
let s:notmuch_folders_count_threads_default = 0
function! s:new_file_buffer(type, fname)
@@ -108,6 +109,18 @@ EOF
echohl None
return
endif
+
+ if g:notmuch_save_sent_locally
+ let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread')
+ let err = v:shell_error
+ if err
+ echohl Error
+ echo 'Eeek! unable to save sent mail'
+ echo out
+ echohl None
+ return
+ endif
+ endif
call delete(fname)
echo 'Mail sent successfully.'
call s:kill_this_buffer()
@@ -388,6 +401,10 @@ endfunction
"" root
function! s:set_defaults()
+ if !exists('g:notmuch_save_sent_locally')
+ let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
+ endif
+
if !exists('g:notmuch_date_format')
if exists('g:notmuch_rb_date_format')
let g:notmuch_date_format = g:notmuch_rb_date_format
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] VIM: Make an option to save sent mail locally
2014-10-06 17:51 [PATCH] VIM: Make an option to save sent mail locally Ian Main
@ 2014-10-06 18:10 ` Ian Main
2014-10-06 18:28 ` Tomi Ollila
2014-10-14 13:45 ` Franz Fellner
2014-10-20 17:58 ` [PATCH v2] " Ian Main
1 sibling, 2 replies; 13+ messages in thread
From: Ian Main @ 2014-10-06 18:10 UTC (permalink / raw)
To: notmuch
Add an option to use 'notmuch insert' to save your sent mail.
---
Add -inbox as well.
vim/notmuch.vim | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..a9044c4 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
let s:notmuch_reader_default = 'mutt -f %s'
let s:notmuch_sendmail_default = 'sendmail'
+let s:notmuch_save_sent_locally_default = 1
let s:notmuch_folders_count_threads_default = 0
function! s:new_file_buffer(type, fname)
@@ -108,6 +109,18 @@ EOF
echohl None
return
endif
+
+ if g:notmuch_save_sent_locally
+ let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
+ let err = v:shell_error
+ if err
+ echohl Error
+ echo 'Eeek! unable to save sent mail'
+ echo out
+ echohl None
+ return
+ endif
+ endif
call delete(fname)
echo 'Mail sent successfully.'
call s:kill_this_buffer()
@@ -388,6 +401,10 @@ endfunction
"" root
function! s:set_defaults()
+ if !exists('g:notmuch_save_sent_locally')
+ let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
+ endif
+
if !exists('g:notmuch_date_format')
if exists('g:notmuch_rb_date_format')
let g:notmuch_date_format = g:notmuch_rb_date_format
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-06 18:10 ` Ian Main
@ 2014-10-06 18:28 ` Tomi Ollila
2014-10-07 4:16 ` Ian Main
2014-10-14 13:45 ` Franz Fellner
1 sibling, 1 reply; 13+ messages in thread
From: Tomi Ollila @ 2014-10-06 18:28 UTC (permalink / raw)
To: Ian Main, notmuch
On Mon, Oct 06 2014, Ian Main <imain@stemwinder.org> wrote:
> Add an option to use 'notmuch insert' to save your sent mail.
> ---
>
> Add -inbox as well.
>
> vim/notmuch.vim | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 331e930..a9044c4 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
> let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
> let s:notmuch_reader_default = 'mutt -f %s'
> let s:notmuch_sendmail_default = 'sendmail'
> +let s:notmuch_save_sent_locally_default = 1
> let s:notmuch_folders_count_threads_default = 0
>
> function! s:new_file_buffer(type, fname)
> @@ -108,6 +109,18 @@ EOF
> echohl None
> return
> endif
AFAIU looks mmm. readable ;)
> +
> + if g:notmuch_save_sent_locally
> + let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
as this is (looks like) shell invocation, this could be in format
let out = system('notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
or even
let out = system('exec notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
(well, the latter would be out of the status quo)
Ok, I looked a bit into the notmuch.vim -code, and noticed sometimes
system() command lines use "notmuch" and sometimes g:notmuch_cmd
-- I think the latter should be used in new code and the previous ones
should be fixed.
i.e. system ( g:notmuch_cmd . ' insert ... ' < . fname)
Totally untested from my part...
When the change alike this lands to the notmuch repository this needs NEWS
item which informs that from now sent mails are notmuch-inserted to
user's mail store (as this seems to be the default...) -- well, let's see
that when there are real reviewers (i.e. those who are interested to and can
test this).
Tomi
> + let err = v:shell_error
> + if err
> + echohl Error
> + echo 'Eeek! unable to save sent mail'
> + echo out
> + echohl None
> + return
> + endif
> + endif
> call delete(fname)
> echo 'Mail sent successfully.'
> call s:kill_this_buffer()
> @@ -388,6 +401,10 @@ endfunction
> "" root
>
> function! s:set_defaults()
> + if !exists('g:notmuch_save_sent_locally')
> + let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
> + endif
> +
> if !exists('g:notmuch_date_format')
> if exists('g:notmuch_rb_date_format')
> let g:notmuch_date_format = g:notmuch_rb_date_format
> --
> 1.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-06 18:28 ` Tomi Ollila
@ 2014-10-07 4:16 ` Ian Main
2014-10-19 9:53 ` Tomi Ollila
0 siblings, 1 reply; 13+ messages in thread
From: Ian Main @ 2014-10-07 4:16 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila wrote:
> On Mon, Oct 06 2014, Ian Main <imain@stemwinder.org> wrote:
>
> > Add an option to use 'notmuch insert' to save your sent mail.
> > ---
> >
> > Add -inbox as well.
> >
> > vim/notmuch.vim | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> > index 331e930..a9044c4 100644
> > --- a/vim/notmuch.vim
> > +++ b/vim/notmuch.vim
> > @@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
> > let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
> > let s:notmuch_reader_default = 'mutt -f %s'
> > let s:notmuch_sendmail_default = 'sendmail'
> > +let s:notmuch_save_sent_locally_default = 1
> > let s:notmuch_folders_count_threads_default = 0
> >
> > function! s:new_file_buffer(type, fname)
> > @@ -108,6 +109,18 @@ EOF
> > echohl None
> > return
> > endif
>
> AFAIU looks mmm. readable ;)
>
> > +
> > + if g:notmuch_save_sent_locally
> > + let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
>
> as this is (looks like) shell invocation, this could be in format
>
> let out = system('notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
You are right, that's better.
> or even
>
> let out = system('exec notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
>
> (well, the latter would be out of the status quo)
>
> Ok, I looked a bit into the notmuch.vim -code, and noticed sometimes
> system() command lines use "notmuch" and sometimes g:notmuch_cmd
> -- I think the latter should be used in new code and the previous ones
> should be fixed.
>
> i.e. system ( g:notmuch_cmd . ' insert ... ' < . fname)
>
> Totally untested from my part...
>
> When the change alike this lands to the notmuch repository this needs NEWS
> item which informs that from now sent mails are notmuch-inserted to
> user's mail store (as this seems to be the default...) -- well, let's see
> that when there are real reviewers (i.e. those who are interested to and can
> test this).
Also a good suggestion. From what I see they always use 'notmuch' straight up
which is probably a reasonable assumption. I do think the actual init code for
vim could have a few more checks, such as verifying that 'notmuch' is in $PATH
etc.
Thanks for the review!! I'll send out a new rev tomorrow - very tired right now.
Ian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-07 4:16 ` Ian Main
@ 2014-10-19 9:53 ` Tomi Ollila
0 siblings, 0 replies; 13+ messages in thread
From: Tomi Ollila @ 2014-10-19 9:53 UTC (permalink / raw)
To: Ian Main, notmuch
On Tue, Oct 07 2014, Ian Main <imain@stemwinder.org> wrote:
> Tomi Ollila wrote:
>> On Mon, Oct 06 2014, Ian Main <imain@stemwinder.org> wrote:
>>
>> > Add an option to use 'notmuch insert' to save your sent mail.
>> > ---
>> >
>> > Add -inbox as well.
>> >
>> > vim/notmuch.vim | 17 +++++++++++++++++
>> > 1 file changed, 17 insertions(+)
>> >
>> > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
>> > index 331e930..a9044c4 100644
>> > --- a/vim/notmuch.vim
>> > +++ b/vim/notmuch.vim
>> > @@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
>> > let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
>> > let s:notmuch_reader_default = 'mutt -f %s'
>> > let s:notmuch_sendmail_default = 'sendmail'
>> > +let s:notmuch_save_sent_locally_default = 1
>> > let s:notmuch_folders_count_threads_default = 0
>> >
>> > function! s:new_file_buffer(type, fname)
>> > @@ -108,6 +109,18 @@ EOF
>> > echohl None
>> > return
>> > endif
>>
>> AFAIU looks mmm. readable ;)
>>
>> > +
>> > + if g:notmuch_save_sent_locally
>> > + let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
>>
>> as this is (looks like) shell invocation, this could be in format
>>
>> let out = system('notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
>
> You are right, that's better.
>
>> or even
>>
>> let out = system('exec notmuch insert --create-folder --folder=Sent +sent -unread -inbox < ' . fname)
>>
>> (well, the latter would be out of the status quo)
>>
>> Ok, I looked a bit into the notmuch.vim -code, and noticed sometimes
>> system() command lines use "notmuch" and sometimes g:notmuch_cmd
>> -- I think the latter should be used in new code and the previous ones
>> should be fixed.
>>
>> i.e. system ( g:notmuch_cmd . ' insert ... ' < . fname)
>>
>> Totally untested from my part...
>>
>> When the change alike this lands to the notmuch repository this needs NEWS
>> item which informs that from now sent mails are notmuch-inserted to
>> user's mail store (as this seems to be the default...) -- well, let's see
>> that when there are real reviewers (i.e. those who are interested to and can
>> test this).
>
> Also a good suggestion. From what I see they always use 'notmuch' straight up
> which is probably a reasonable assumption. I do think the actual init code for
> vim could have a few more checks, such as verifying that 'notmuch' is in $PATH
> etc.
>
> Thanks for the review!! I'll send out a new rev tomorrow - very tired
> right now.
I never seen the new rev... :D
>
> Ian
Tomi
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-06 18:10 ` Ian Main
2014-10-06 18:28 ` Tomi Ollila
@ 2014-10-14 13:45 ` Franz Fellner
2014-10-14 17:32 ` Ian Main
1 sibling, 1 reply; 13+ messages in thread
From: Franz Fellner @ 2014-10-14 13:45 UTC (permalink / raw)
To: Ian Main; +Cc: notmuch
Why not simply use Notmuch::Database.add_message? Would save a
system-call.
One could easily copy the sent mail into nm_db_path/sent/cur, add it to the db, tag it.
Though I don't know enough about maildir handling, but probably rubys
Mail module could help here.
Another issue is configuration. Hardcoding "Sent" probably won't fit
everyones needs. And (if I understand DOCS correctly) db.add_message
doesn't even force you to keep sent mail folder inside db_path; correct
me if I'm wrong :) notmuch --insert will put it into folder relative to
db_path.
All in all the feature and the the rest of your work is very much
appreciated!
Franz
On Mon, 6 Oct 2014 11:10:36 -0700, Ian Main <imain@stemwinder.org> wrote:
> Add an option to use 'notmuch insert' to save your sent mail.
> ---
>
> Add -inbox as well.
>
> vim/notmuch.vim | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> index 331e930..a9044c4 100644
> --- a/vim/notmuch.vim
> +++ b/vim/notmuch.vim
> @@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
> let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
> let s:notmuch_reader_default = 'mutt -f %s'
> let s:notmuch_sendmail_default = 'sendmail'
> +let s:notmuch_save_sent_locally_default = 1
> let s:notmuch_folders_count_threads_default = 0
>
> function! s:new_file_buffer(type, fname)
> @@ -108,6 +109,18 @@ EOF
> echohl None
> return
> endif
> +
> + if g:notmuch_save_sent_locally
> + let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
> + let err = v:shell_error
> + if err
> + echohl Error
> + echo 'Eeek! unable to save sent mail'
> + echo out
> + echohl None
> + return
> + endif
> + endif
> call delete(fname)
> echo 'Mail sent successfully.'
> call s:kill_this_buffer()
> @@ -388,6 +401,10 @@ endfunction
> "" root
>
> function! s:set_defaults()
> + if !exists('g:notmuch_save_sent_locally')
> + let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
> + endif
> +
> if !exists('g:notmuch_date_format')
> if exists('g:notmuch_rb_date_format')
> let g:notmuch_date_format = g:notmuch_rb_date_format
> --
> 1.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-14 13:45 ` Franz Fellner
@ 2014-10-14 17:32 ` Ian Main
2014-10-18 20:27 ` Franz Fellner
2015-01-13 0:08 ` Bartosz Telenczuk
0 siblings, 2 replies; 13+ messages in thread
From: Ian Main @ 2014-10-14 17:32 UTC (permalink / raw)
To: Franz Fellner; +Cc: notmuch
Franz Fellner wrote:
> Why not simply use Notmuch::Database.add_message? Would save a
> system-call.
> One could easily copy the sent mail into nm_db_path/sent/cur, add it to the db, tag it.
> Though I don't know enough about maildir handling, but probably rubys
> Mail module could help here.
So you are saying I'd have to copy the message to the database and then call
Notmuch::Database.add_message()? If so I think I'd rather stick with the
system call..
> Another issue is configuration. Hardcoding "Sent" probably won't fit
> everyones needs. And (if I understand DOCS correctly) db.add_message
> doesn't even force you to keep sent mail folder inside db_path; correct
> me if I'm wrong :) notmuch --insert will put it into folder relative to
> db_path.
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.
The notmuch --insert with --create-folder takes care of making sure the folder
exists locally. I think this is why using the CLI is pretty compelling. You
know it will do the right thing.
> All in all the feature and the the rest of your work is very much
> appreciated!
>
> Franz
Thanks for the review Franz! I'll do another round of patch fixing soon I'm sure.
Ian
> On Mon, 6 Oct 2014 11:10:36 -0700, Ian Main <imain@stemwinder.org> wrote:
> > Add an option to use 'notmuch insert' to save your sent mail.
> > ---
> >
> > Add -inbox as well.
> >
> > vim/notmuch.vim | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/vim/notmuch.vim b/vim/notmuch.vim
> > index 331e930..a9044c4 100644
> > --- a/vim/notmuch.vim
> > +++ b/vim/notmuch.vim
> > @@ -58,6 +58,7 @@ let s:notmuch_date_format_default = '%d.%m.%y'
> > let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
> > let s:notmuch_reader_default = 'mutt -f %s'
> > let s:notmuch_sendmail_default = 'sendmail'
> > +let s:notmuch_save_sent_locally_default = 1
> > let s:notmuch_folders_count_threads_default = 0
> >
> > function! s:new_file_buffer(type, fname)
> > @@ -108,6 +109,18 @@ EOF
> > echohl None
> > return
> > endif
> > +
> > + if g:notmuch_save_sent_locally
> > + let out = system('cat ' . fname . ' | notmuch insert --create-folder --folder=Sent +sent -unread -inbox')
> > + let err = v:shell_error
> > + if err
> > + echohl Error
> > + echo 'Eeek! unable to save sent mail'
> > + echo out
> > + echohl None
> > + return
> > + endif
> > + endif
> > call delete(fname)
> > echo 'Mail sent successfully.'
> > call s:kill_this_buffer()
> > @@ -388,6 +401,10 @@ endfunction
> > "" root
> >
> > function! s:set_defaults()
> > + if !exists('g:notmuch_save_sent_locally')
> > + let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
> > + endif
> > +
> > if !exists('g:notmuch_date_format')
> > if exists('g:notmuch_rb_date_format')
> > let g:notmuch_date_format = g:notmuch_rb_date_format
> > --
> > 1.9.3
> >
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-14 17:32 ` Ian Main
@ 2014-10-18 20:27 ` Franz Fellner
2015-01-13 0:08 ` Bartosz Telenczuk
1 sibling, 0 replies; 13+ messages in thread
From: Franz Fellner @ 2014-10-18 20:27 UTC (permalink / raw)
To: Ian Main, Ian Main; +Cc: notmuch
Ian Main wrote:
> Franz Fellner wrote:
> > Why not simply use Notmuch::Database.add_message? Would save a
> > system-call.
> > One could easily copy the sent mail into nm_db_path/sent/cur, add it to the db, tag it.
> > Though I don't know enough about maildir handling, but probably rubys
> > Mail module could help here.
>
> So you are saying I'd have to copy the message to the database and then call
> Notmuch::Database.add_message()? If so I think I'd rather stick with the
> system call..
Yes, that was my intention. I usually prefer using a stable API rather then realying on CLI.
But that's just preference ;)
All in all it works. So LGTM.
>
> > Another issue is configuration. Hardcoding "Sent" probably won't fit
> > everyones needs. And (if I understand DOCS correctly) db.add_message
> > doesn't even force you to keep sent mail folder inside db_path; correct
> > me if I'm wrong :) notmuch --insert will put it into folder relative to
> > db_path.
>
> 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.
That MIGHT get hard.
All accounts I use store the mails I send to their smtp-server locally, I could sync them again through IMAP.
GMail for example does that. Pushing those mails upstream again is useless.
But there might be setups where it is neccessary to manually store mails inside a sent folder that get's afterwards synced with the IMAP server.
So if you want that to work in any case we might need to introduce settings for user accounts...
Franz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2014-10-14 17:32 ` Ian Main
2014-10-18 20:27 ` Franz Fellner
@ 2015-01-13 0:08 ` Bartosz Telenczuk
2015-01-21 19:05 ` Franz Fellner
1 sibling, 1 reply; 13+ messages in thread
From: Bartosz Telenczuk @ 2015-01-13 0:08 UTC (permalink / raw)
To: notmuch
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@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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2015-01-13 0:08 ` Bartosz Telenczuk
@ 2015-01-21 19:05 ` Franz Fellner
2015-02-02 23:42 ` Bartosz Telenczuk
0 siblings, 1 reply; 13+ messages in thread
From: Franz Fellner @ 2015-01-21 19:05 UTC (permalink / raw)
To: Bartosz Telenczuk; +Cc: notmuch
Bartosz Telenczuk wrote:
> 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@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.
I see this patch as a first step. Having sent mails stored locally is iportant to keep track of threads. Storing them in a proper provider-specific way (some providers don't put your mails automatically in a SENT folder when you use their SMTP server for delivery, like GMAIL does) would be nice to have, yes, but we really should agree on how we store the settings.
Franz
>
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2015-01-21 19:05 ` Franz Fellner
@ 2015-02-02 23:42 ` Bartosz Telenczuk
2015-02-05 10:34 ` Franz Fellner
0 siblings, 1 reply; 13+ messages in thread
From: Bartosz Telenczuk @ 2015-02-02 23:42 UTC (permalink / raw)
To: Franz Fellner, Bartosz Telenczuk; +Cc: notmuch
> > 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@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@hu-berlin.de=>HU/Sent;telenczuk@unic.cnrs-gif.fr=>CNRS/Sent
Cheers,
Bartosz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] VIM: Make an option to save sent mail locally
2015-02-02 23:42 ` Bartosz Telenczuk
@ 2015-02-05 10:34 ` Franz Fellner
0 siblings, 0 replies; 13+ messages in thread
From: Franz Fellner @ 2015-02-05 10:34 UTC (permalink / raw)
To: Bartosz Telenczuk; +Cc: notmuch, Bartosz Telenczuk
Bartosz Telenczuk wrote:
> > > 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@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@hu-berlin.de=>HU/Sent;telenczuk@unic.cnrs-gif.fr=>CNRS/Sent
That's what I called "ugly": Using a probably long and/or unreadable mail address as identifier is errorprone, if you have several accounts those things tend to get unreadable. Especially if you need to write them over and over again for different folders/features (sent, drafts, ...).
I thought of one string to store the whole account manager config, just like
[default] # or call it "local" - not bound to any real account
sent=Sent
drafts=Drafts
[account1]
mail=account1@mail.com
sent=account1/sent
drafts=account1/drafts
[account2]
mail=account2@gmail.com
sent=Sent # gmail specific: using gmails smtp server stores sent mails automatically on the server
drafts=account2/drafts
// and so on
(used an ini format, but might be done in any other way like ruby hashes or yaml or...)
The default settings get default values by our vim plugin. They get used automatically if a user-defined account does not specifically set a folder - that way account2 could just have left out the "sent" setting.
If the user overwrites the default-account and leaves out a folder, such as sent, he might want that feature to be deactivated. Though I still think it is dangerous: it applies well for sent, but deactivating drafts (probably as automatic temporary storage for mails that are currently written and should be restorable after a crash) can cause issues, e.g. lost mails. So I would vote for a different solution. E.g. a separate boolean setting. Or we could treat an empty string for non-default accounts as "deactivate":
[account2]
drafts=""
I can start implementing this, but I currently have other important things to do, so it can take some time.
Franz
>
> Cheers,
>
> Bartosz
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] VIM: Make an option to save sent mail locally
2014-10-06 17:51 [PATCH] VIM: Make an option to save sent mail locally Ian Main
2014-10-06 18:10 ` Ian Main
@ 2014-10-20 17:58 ` Ian Main
1 sibling, 0 replies; 13+ messages in thread
From: Ian Main @ 2014-10-20 17:58 UTC (permalink / raw)
To: notmuch
Add an option to use 'notmuch insert' to save your sent mail.
---
This update changes the 'system' line and adds a sent mailbox
option.
vim/notmuch.vim | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..b0c6ebd 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -58,6 +58,8 @@ let s:notmuch_date_format_default = '%d.%m.%y'
let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
let s:notmuch_reader_default = 'mutt -f %s'
let s:notmuch_sendmail_default = 'sendmail'
+let s:notmuch_save_sent_locally_default = 1
+let s:notmuch_save_sent_mailbox_default = 'Sent'
let s:notmuch_folders_count_threads_default = 0
function! s:new_file_buffer(type, fname)
@@ -108,6 +110,18 @@ EOF
echohl None
return
endif
+
+ if g:notmuch_save_sent_locally
+ let out = system('notmuch insert --create-folder --folder=' . g:notmuch_save_sent_mailbox . ' +sent -unread -inbox < ' . fname)
+ let err = v:shell_error
+ if err
+ echohl Error
+ echo 'Eeek! unable to save sent mail'
+ echo out
+ echohl None
+ return
+ endif
+ endif
call delete(fname)
echo 'Mail sent successfully.'
call s:kill_this_buffer()
@@ -388,6 +402,14 @@ endfunction
"" root
function! s:set_defaults()
+ if !exists('g:notmuch_save_sent_locally')
+ let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
+ endif
+
+ if !exists('g:notmuch_save_sent_mailbox')
+ let g:notmuch_save_sent_mailbox = s:notmuch_save_sent_mailbox_default
+ endif
+
if !exists('g:notmuch_date_format')
if exists('g:notmuch_rb_date_format')
let g:notmuch_date_format = g:notmuch_rb_date_format
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-02-05 10:34 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-06 17:51 [PATCH] VIM: Make an option to save sent mail locally Ian Main
2014-10-06 18:10 ` Ian Main
2014-10-06 18:28 ` Tomi Ollila
2014-10-07 4:16 ` Ian Main
2014-10-19 9:53 ` Tomi Ollila
2014-10-14 13:45 ` Franz Fellner
2014-10-14 17:32 ` Ian Main
2014-10-18 20:27 ` Franz Fellner
2015-01-13 0:08 ` Bartosz Telenczuk
2015-01-21 19:05 ` Franz Fellner
2015-02-02 23:42 ` Bartosz Telenczuk
2015-02-05 10:34 ` Franz Fellner
2014-10-20 17:58 ` [PATCH v2] " Ian Main
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).