unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 0/3] vim plugin updates
@ 2014-05-01 22:57 Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 1/3] vim: fix count_threads variable check Felipe Contreras
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-01 22:57 UTC (permalink / raw)
  To: notmuch

A few trivial updates, and an important fix.

Changes since v1: improved commit messages.

Felipe Contreras (2):
  vim: fix count_threads variable check
  vim: improve the way messages are sent

Paul Roberts (1):
  vim: make the html handler configurable

 vim/notmuch.vim | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

-- 
1.9.2+fc1.19.g85b6256

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

* [PATCH v2 1/3] vim: fix count_threads variable check
  2014-05-01 22:57 [PATCH v2 0/3] vim plugin updates Felipe Contreras
@ 2014-05-01 22:57 ` Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 2/3] vim: make the html handler configurable Felipe Contreras
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-01 22:57 UTC (permalink / raw)
  To: notmuch

It never really worked; in Ruby only 'nil' and 'false' evaluate to
false, therefore the statement '0 : true ? false' returns true, so it
doesn't matter if notmuch_folders_count_threads = 0, count_threads would
be true.

We need to check specifically if the value is 1 or 0.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 vim/notmuch.vim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index d7b310c..25a16e9 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -633,7 +633,7 @@ ruby << EOF
 	def folders_render()
 		$curbuf.render do |b|
 			folders = VIM::evaluate('g:notmuch_folders')
-			count_threads = VIM::evaluate('g:notmuch_folders_count_threads')
+			count_threads = VIM::evaluate('g:notmuch_folders_count_threads') == 1
 			$searches.clear
 			folders.each do |name, search|
 				q = $curbuf.query(search)
-- 
1.9.2+fc1.19.g85b6256

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

* [PATCH v2 2/3] vim: make the html handler configurable
  2014-05-01 22:57 [PATCH v2 0/3] vim plugin updates Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 1/3] vim: fix count_threads variable check Felipe Contreras
@ 2014-05-01 22:57 ` Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 3/3] vim: improve the way messages are sent Felipe Contreras
  2014-05-03 23:38 ` [PATCH v2 0/3] vim plugin updates David Bremner
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-01 22:57 UTC (permalink / raw)
  To: notmuch; +Cc: Paul Roberts

From: Paul Roberts <pmr@stelo.org.uk>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 vim/notmuch.vim | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 25a16e9..0cb94f6 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -919,7 +919,8 @@ ruby << EOF
 				if mime_type != "text/html"
 					text = decoded
 				else
-					IO.popen("elinks --dump", "w+") do |pipe|
+					IO.popen(VIM::evaluate('exists("g:notmuch_html_converter") ? ' +
+							'g:notmuch_html_converter : "elinks --dump"'), "w+") do |pipe|
 						pipe.write(decode_body)
 						pipe.close_write
 						text = pipe.read
-- 
1.9.2+fc1.19.g85b6256

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

* [PATCH v2 3/3] vim: improve the way messages are sent
  2014-05-01 22:57 [PATCH v2 0/3] vim plugin updates Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 1/3] vim: fix count_threads variable check Felipe Contreras
  2014-05-01 22:57 ` [PATCH v2 2/3] vim: make the html handler configurable Felipe Contreras
@ 2014-05-01 22:57 ` Felipe Contreras
  2014-05-03 23:38 ` [PATCH v2 0/3] vim plugin updates David Bremner
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-01 22:57 UTC (permalink / raw)
  To: notmuch

We want the proper encoding and content-type to be set when sending the
mail, but human-readable plain-text for composing. So split the code in
two parts: the presentation and the transport conversion.

This fixes an issue while sending non-ascii mails to strict servers; the
mail needs to be encoded.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 vim/notmuch.vim | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 0cb94f6..331e930 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -86,17 +86,22 @@ endfunction
 function! s:compose_send()
 	let b:compose_done = 1
 	let fname = expand('%')
+	let lines = getline(5, '$')
 
-	" remove headers
-	0,4d
-	write
+ruby << EOF
+	# Generate proper mail to send
+	text = VIM::evaluate('lines').join("\n")
+	fname = VIM::evaluate('fname')
+	transport = Mail.new(text)
+	transport.message_id = generate_message_id
+	transport.charset = 'utf-8'
+	File.write(fname, transport.to_s)
+EOF
 
 	let cmdtxt = g:notmuch_sendmail . ' -t -f ' . s:reply_from . ' < ' . fname
 	let out = system(cmdtxt)
 	let err = v:shell_error
 	if err
-		undo
-		write
 		echohl Error
 		echo 'Eeek! unable to send mail'
 		echo out
@@ -572,9 +577,7 @@ ruby << EOF
 			end
 			m.cc = orig[:cc]
 			m.from = $email
-			m.message_id = generate_message_id
 			m.charset = 'utf-8'
-			m.content_transfer_encoding = '7bit'
 		end
 
 		lines = []
@@ -600,7 +603,7 @@ ruby << EOF
 
 		reply.body = body_lines.join("\n")
 
-		lines += reply.to_s.lines.map { |e| e.chomp }
+		lines += reply.present.lines.map { |e| e.chomp }
 		lines << ""
 
 		cur = lines.count - 1
@@ -611,18 +614,13 @@ ruby << EOF
 	def open_compose()
 		lines = []
 
-		lines << "Date: #{Time.now().strftime('%a, %-d %b %Y %T %z')}"
 		lines << "From: #{$email}"
 		lines << "To: "
 		cur = lines.count
 
 		lines << "Cc: "
 		lines << "Bcc: "
-		lines << "Message-Id: #{generate_message_id}"
 		lines << "Subject: "
-		lines << "Mime-Version: 1.0"
-		lines << "Content-Type: text/plain; charset=utf-8"
-		lines << "Content-Transfer-Encoding: 7bit"
 		lines << ""
 		lines << ""
 		lines << ""
@@ -928,6 +926,16 @@ ruby << EOF
 				end
 				text
 			end
+
+			def present
+				buffer = ''
+				header.fields.each do |f|
+					buffer << "%s: %s\r\n" % [f.name, f.to_s]
+				end
+				buffer << "\r\n"
+				buffer << body.to_s
+				buffer
+			end
 		end
 	end
 
-- 
1.9.2+fc1.19.g85b6256

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

* Re: [PATCH v2 0/3] vim plugin updates
  2014-05-01 22:57 [PATCH v2 0/3] vim plugin updates Felipe Contreras
                   ` (2 preceding siblings ...)
  2014-05-01 22:57 ` [PATCH v2 3/3] vim: improve the way messages are sent Felipe Contreras
@ 2014-05-03 23:38 ` David Bremner
  3 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2014-05-03 23:38 UTC (permalink / raw)
  To: Felipe Contreras, notmuch

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

Felipe Contreras <felipe.contreras@gmail.com> writes:

> A few trivial updates, and an important fix.
>
> Changes since v1: improved commit messages.

I have pushed these to release and master.

d

[-- Attachment #2: Type: application/pgp-signature, Size: 647 bytes --]

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

end of thread, other threads:[~2014-05-03 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 22:57 [PATCH v2 0/3] vim plugin updates Felipe Contreras
2014-05-01 22:57 ` [PATCH v2 1/3] vim: fix count_threads variable check Felipe Contreras
2014-05-01 22:57 ` [PATCH v2 2/3] vim: make the html handler configurable Felipe Contreras
2014-05-01 22:57 ` [PATCH v2 3/3] vim: improve the way messages are sent Felipe Contreras
2014-05-03 23:38 ` [PATCH v2 0/3] vim plugin updates David Bremner

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