1 Return-Path: <imain@stemwinder.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 7159B431FD8
\r
6 for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 21:05:13 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Dz2FDUh+Chqm for <notmuch@notmuchmail.org>;
\r
16 Thu, 23 Oct 2014 21:05:08 -0700 (PDT)
\r
17 Received: from cmta13.telus.net (cmta13.telus.net [209.171.16.86])
\r
18 by olra.theworths.org (Postfix) with ESMTP id CBEBD431FBD
\r
19 for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 21:05:07 -0700 (PDT)
\r
20 Received: from ovo.mains.priv ([207.102.88.62]) by cmta13.telus.net with TELUS
\r
21 id 6s551p00J1LiWEf01s567M; Thu, 23 Oct 2014 22:05:06 -0600
\r
22 X-Authority-Analysis: v=2.0 cv=OrmRPVDt c=1 sm=2
\r
23 a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=tsa3CZZnAAAA:8 a=3htRWu4FMa_oRVYOwfYA:9
\r
24 a=EcQDfIwDZEqJA1f7rVUV8Q==:117
\r
25 X-Telus-Outbound-IP: 207.102.88.62
\r
26 From: Ian Main <imain@stemwinder.org>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH] VIM: Fix header management and fold threads
\r
29 Date: Thu, 23 Oct 2014 21:05:03 -0700
\r
30 Message-Id: <1414123503-31766-1-git-send-email-imain@stemwinder.org>
\r
31 X-Mailer: git-send-email 1.9.3
\r
32 X-BeenThere: notmuch@notmuchmail.org
\r
33 X-Mailman-Version: 2.1.13
\r
35 List-Id: "Use and development of the notmuch mail system."
\r
36 <notmuch.notmuchmail.org>
\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
40 List-Post: <mailto:notmuch@notmuchmail.org>
\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
44 X-List-Received-Date: Fri, 24 Oct 2014 04:05:13 -0000
\r
46 Yes, it's here, the patch you've all been waiting for! Well, maybe:
\r
48 - Add a variable to control which headers are displayed normally.
\r
49 - Any header that is not displayed normally will be listed in a folded
\r
50 area in the message so you can access it at will (can be turned off).
\r
51 - Add the (optional) ability to list threads using vim folding so that
\r
52 you can see at a glance the whole thread, which messages are new etc.
\r
56 vim/notmuch.vim | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
\r
57 1 file changed, 54 insertions(+), 7 deletions(-)
\r
59 diff --git a/vim/notmuch.vim b/vim/notmuch.vim
\r
60 index cad9517..affd1e2 100644
\r
61 --- a/vim/notmuch.vim
\r
62 +++ b/vim/notmuch.vim
\r
63 @@ -54,12 +54,22 @@ let s:notmuch_folders_default = [
\r
64 \ [ 'unread', 'tag:unread' ],
\r
67 +let s:notmuch_show_headers_default = [
\r
75 let s:notmuch_date_format_default = '%d.%m.%y'
\r
76 let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
\r
77 let s:notmuch_reader_default = 'mutt -f %s'
\r
78 let s:notmuch_sendmail_default = 'sendmail'
\r
79 let s:notmuch_folders_count_threads_default = 0
\r
80 let s:notmuch_compose_start_insert_default = 1
\r
81 +let s:notmuch_show_folded_full_headers_default = 1
\r
82 +let s:notmuch_show_folded_threads_default = 1
\r
84 function! s:new_file_buffer(type, fname)
\r
85 exec printf('edit %s', a:fname)
\r
86 @@ -311,6 +321,9 @@ function! s:show(thread_id)
\r
87 call s:new_buffer('show')
\r
90 + show_full_headers = VIM::evaluate('g:notmuch_show_folded_full_headers')
\r
91 + show_threads_folded = VIM::evaluate('g:notmuch_show_folded_threads_default')
\r
93 thread_id = VIM::evaluate('a:thread_id')
\r
94 $cur_thread = thread_id
\r
96 @@ -326,11 +339,22 @@ ruby << EOF
\r
97 date_fmt = VIM::evaluate('g:notmuch_datetime_format')
\r
98 date = Time.at(msg.date).strftime(date_fmt)
\r
99 nm_m.start = b.count
\r
100 - b << "%s %s (%s)" % [msg['from'], date, msg.tags]
\r
101 - b << "Subject: %s" % [msg['subject']]
\r
102 - b << "To: %s" % msg['to']
\r
103 - b << "Cc: %s" % msg['cc']
\r
104 - b << "Date: %s" % msg['date']
\r
105 + b << "From: %s %s (%s)" % [msg['from'], date, msg.tags]
\r
106 + showheaders = VIM::evaluate('g:notmuch_show_headers')
\r
107 + showheaders.each do |h|
\r
108 + b << "%s: %s" % [h, m.header[h]]
\r
110 + if show_full_headers
\r
111 + # Now show the rest in a folded area.
\r
112 + nm_m.full_header_start = b.count
\r
113 + m.header.fields.each do |k|
\r
114 + # Only show the ones we haven't already printed out.
\r
115 + if not showheaders.include?(k.name)
\r
116 + b << '%s: %s' % [k.name, k.to_s]
\r
119 + nm_m.full_header_end = b.count
\r
121 nm_m.body_start = b.count
\r
122 b << "--- %s ---" % part.mime_type
\r
123 part.convert.each_line do |l|
\r
124 @@ -343,11 +367,19 @@ ruby << EOF
\r
126 $messages.each_with_index do |msg, i|
\r
127 VIM::command("syntax region nmShowMsg#{i}Desc start='\\%%%il' end='\\%%%il' contains=@nmShowMsgDesc" % [msg.start, msg.start + 1])
\r
128 - VIM::command("syntax region nmShowMsg#{i}Head start='\\%%%il' end='\\%%%il' contains=@nmShowMsgHead" % [msg.start + 1, msg.body_start])
\r
129 + VIM::command("syntax region nmShowMsg#{i}Head start='\\%%%il' end='\\%%%il' contains=@nmShowMsgHead" % [msg.start + 1, msg.full_header_start])
\r
130 VIM::command("syntax region nmShowMsg#{i}Body start='\\%%%il' end='\\%%%dl' contains=@nmShowMsgBody" % [msg.body_start, msg.end])
\r
131 + if show_full_headers
\r
132 + VIM::command("syntax region nmFold#{i}Headers start='\\%%%il' end='\\%%%il' fold transparent contains=@nmShowMsgHead" % [msg.full_header_start, msg.full_header_end])
\r
134 + # Only fold the whole message if there are multiple emails in this thread.
\r
135 + if $messages.count > 1 and show_threads_folded
\r
136 + VIM::command("syntax region nmShowMsgFold#{i} start='\\%%%il' end='\\%%%il' fold transparent contains=ALL" % [msg.start, msg.end])
\r
140 setlocal nomodifiable
\r
141 + setlocal foldmethod=syntax
\r
142 call s:set_map(g:notmuch_show_maps)
\r
145 @@ -460,6 +492,19 @@ function! s:set_defaults()
\r
146 let g:notmuch_folders = s:notmuch_folders_default
\r
150 + if !exists('g:notmuch_show_headers')
\r
151 + let g:notmuch_show_headers = s:notmuch_show_headers_default
\r
154 + if !exists('g:notmuch_show_folded_threads')
\r
155 + let g:notmuch_show_folded_threads = s:notmuch_show_folded_threads_default
\r
158 + if !exists('g:notmuch_show_folded_full_headers')
\r
159 + let g:notmuch_show_folded_full_headers = s:notmuch_show_folded_full_headers_default
\r
164 function! s:NotMuch(...)
\r
165 @@ -723,7 +768,7 @@ ruby << EOF
\r
169 - attr_accessor :start, :body_start, :end
\r
170 + attr_accessor :start, :body_start, :end, :full_header_start, :full_header_end
\r
171 attr_reader :message_id, :filename, :mail
\r
173 def initialize(msg, mail)
\r
174 @@ -732,6 +777,8 @@ ruby << EOF
\r
178 + @full_header_start = 0
\r
179 + @full_header_end = 0
\r
180 mail.import_headers(msg) if not $mail_installed
\r