├── .gitignore
├── License.txt
├── README.markdown
├── autoload
├── vimmail.vim
└── vimmail
│ ├── contacts.vim
│ ├── contacts
│ ├── khard.vim
│ ├── mu.vim
│ └── pc_query.vim
│ ├── sendmail.vim
│ └── spelllang.vim
├── doc
└── vim-mail.txt
├── ftplugin
└── mail.vim
└── plugin
├── getfullname.sh
└── vim-mail.vim
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.swo
3 | *.html
4 | doc/tags
5 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | **This repository is only a mirror, all developpment happens at [gitlab](https://gitlab.com/dbeniamine/vim-mail)**
2 |
3 | # Readme
4 |
5 | ## Anounces
6 |
7 | + Since v1.0.0 the `g:VimMailSendCmd` has been replaced by a couple of
8 | more flexible configuration options, see [Sending mails](#sending-mails)
9 |
10 | + Since v0.3.2 it is possible to change the flags used for sendmail depending
11 | on the current filetype see [Mail client](#mail-client)
12 |
13 | + v0.3 provides the possibility to set startflags depending on the contents of
14 | the mail, see [issue #6](https://gitlab.com/dbeniamine/vim-mail/issues/6) and
15 | [start position](#cursor-initial-position).
16 |
17 |
18 | + v0.2.9 adds a mapping to switch from address from a predefined list see
19 | [switch from](#switch-from).
20 |
21 | + Since v0.2.7 Vim-mail can handle (virtually) any contact providers, this implies
22 | a few configuration changes.
23 |
24 | see
25 | [contacts completion](#contacts-completion)
26 | and
27 | [Address book configuration](#address-book-coniguration)
28 | and maybe
29 | [Adding a contact provider](adding-a-contact-provider).
30 |
31 | ## What is this plugin ?
32 |
33 | This plugin is a small helper for writing mail from vim, I designed it using
34 | mutt but it should work with other clients. I recommend to use it in
35 | combination with [CheckAttach](https://github.com/chrisbra/CheckAttach).
36 |
37 |
38 | ## Install
39 |
40 | ### Vizardry
41 |
42 | If you have [Vizardry](https://github.com/dbeniamine/vizardry) installed, you
43 | can run from vim:
44 |
45 | :Invoke -u dbeniamine vim-mail
46 |
47 | ### Pathogen install
48 |
49 | git clone https://github.com/dbeniamine/vim-mail.git ~/.vim/bundle/vim-mail
50 |
51 | ### Quick install
52 |
53 | git clone https://github.com/dbeniamine/vim-mail.git
54 | cd vim-mail/
55 | cp -r ./* ~/.vim
56 |
57 | ## Features
58 |
59 | This plugin provides the following features
60 |
61 | ### Contact completion
62 |
63 | The following providers are currently supported :
64 |
65 | + `pc_query` (pycard)
66 | + `khard`
67 | + `mu` (maildir-utils, requires specific [configuration](#mu-configuration))
68 |
69 | see [address book configuration](#address-book-configuration) and
70 | [Adding a contact provider](adding-a-contact-provider).
71 |
72 | To search your address book from vim:
73 |
74 | + While writing a mail, in insert mode, type:
75 |
76 | a
77 |
78 | or (using omnifunc)
79 |
80 |
81 |
82 | + While editing any other file:
83 |
84 | As the previous mapping are only set for mail files, you need to set the
85 | completefunc (using omnifunc would be a bad idea):
86 |
87 | set completefunc=vimmail#contacts#CompleteAddr
88 |
89 | Then use `` (in insert mode) to trigger contact completion.
90 |
91 | It will search for the word under the cursor in your contact list.
92 |
93 | If you are currently in a From,To,CC or Bcc line, only mail addresses will
94 | be proposed, else all the match will appear. More details will appear in
95 | the preview window including contact name, type of the entry (mail, cell,
96 | phone etc.).
97 |
98 | To synchronise your address book, in a mail, in normal mode, type:
99 |
100 | a
101 |
102 | ### Redaction
103 |
104 | #### Cursor initial position
105 |
106 | By default vim-mail place your cursor at the beginning of the mail (right
107 | after the headers) adds a blank line and switch to insert mode. This
108 | behavior can be modified through a series of flags:
109 |
110 | The available flags are:
111 |
112 | Flag | Meaning
113 | -----|----------------------------------------------------------------------
114 | `r` | Remove quoted signatures from reply
115 | `i` | insert mode
116 | `o` | Add new line after cursor
117 | `O` | Add new line before cursor
118 | `A` | Place cursor at the end of the line
119 | `W` | Start on second word (a.k.a first address of field / word of subject)
120 | `I` | Intelligent start: If two replies, start above or below, as the last replier, else default to other flags
121 | `t` | top (Right after headers)
122 | `b` | Bottom (After last message)
123 | `F` | From field
124 | `T` | To field
125 | `C` | Cc field
126 | `B` | Bcc field
127 | `S` | Subject field
128 |
129 | The flags can be set globally or by type of mail using the variable
130 | VimMail detects 4 types of mail :
131 |
132 | Type | When
133 | ------------|------
134 | `blank` | `To:` field is empty
135 | `nosubject` | `To:` field is not empty but `Subject:` is
136 | `new` | Neither `To:` or `Subject:` is empty and there is no quote
137 | `reply` | Neither `To:` or `Subject:` is empty and there is a quote
138 |
139 | ##### Examples
140 |
141 | Adding the following line to your vimrc will make you start at the end of
142 | the subject line when subject is empy:
143 |
144 | ```viml
145 | let g:VimMailStartFlags={'nosubject' :"SAi" }
146 | ```
147 |
148 | You can do somthing more complex for instance :
149 |
150 | ```viml
151 | let g:VimMailStartFlags={
152 | \'blank': 'TAi',
153 | \'nosubject': 'SAi',
154 | \'default' : "boi"}
155 | ```
156 |
157 | *Notes*:
158 |
159 | + `default` key is special, in the above case it means either `new` or `reply`.
160 | + For retro compatibility with version 0.2.x, `let g:VimMailStartFlags='toi'` is
161 | the same as `let g:VimMailStartFlags = { 'default': 'toi'}`.
162 |
163 | #### Easy spelllang switch
164 |
165 | While writing mails, I often need to do switch the spell lang which can be
166 | annoying, so this plugin provide an easy way to do it. Just type:
167 |
168 | l
169 |
170 | and the plugin will switch the spelllang using a list of allowed languages.
171 | If the current spellang is the last allowed, it will disable spell, hit
172 |
173 | l
174 |
175 | once more and you will restart with the first lang.
176 | You can set the list of allowed langs in your vimrc:
177 |
178 | let g:VimMailSpellLangs=['fr', 'en', 'sp']
179 |
180 | The default langs are french, english.
181 |
182 | This will work for any filetype as it can be usefull for many other kind of
183 | files.
184 |
185 | #### Switch from
186 |
187 | You can easliy from address just by hitting `F`.
188 | By default vimmal will search the email addresses for a contact with the same
189 | full name as your unix user. You can also specify a contact (or a search
190 | string) with by adding the following to your vimrc :
191 |
192 | let g:VimMailFromContact="John doe"
193 |
194 | or directly specify a list of addresses :
195 |
196 | let g:VimMailFromList = [
197 | \'John doe ',
198 | \'Ano nymous f` | Go to the From field
216 | `b` | Go to the Bcc field
217 | `c` | Go to the Cc field
218 | `s` | Go to the SUbject field
219 | `R` | Go to the Reply-To field
220 | `t` | Go to the Reply-To field
221 |
222 | + Conversation
223 |
224 | Mapping | Effect
225 | -----------------|----------------------------------------------
226 | `B` | Go to the first line (after headers)
227 | `E` | Go to the first line after the conversation
228 | `r` | Go to the first message of the conversation
229 | `r2`| Go to the second message of the conversation
230 | `r3`| Go to the third message of the conversation
231 | `r4`| Go to the fourth message of the conversation
232 | `S` | Go to your signature
233 |
234 |
235 | ### Launch mail client
236 |
237 | One of Mutt main drawbacks is that you can't access your mailbox while
238 | writing mails, good news everyone, with vim-mail you can open mutt in RO
239 | mode easily by typing
240 |
241 | M
242 |
243 | ### Send file from Vim
244 |
245 | When you are vimming at one point, you might want to send the file you are
246 | working on. Leaving vim to send a mail from vim is so annoying, happily there
247 | is the solution just type: `m` and VimMail will pipe the file to
248 | mutt.
249 |
250 | ## Mappings
251 |
252 | All mappings can be disabled by adding the following line to your vimrc:
253 |
254 | let g:VimMailDoNotMap=1
255 |
256 |
257 | + On any file
258 |
259 | Mapping | Effect
260 | -----------------|----------------------------------------------
261 | `m` | Send the current buffer
262 | `l` | Switch spelllang
263 | `M` | Open the mail client
264 |
265 | + On mail only
266 |
267 | Mapping | Effect
268 | -------------------|----------------------------------------------
269 | `a` | Search the word before cursor as a contact
270 | `F` | Switch From address
271 | `f` | Go to the From field
272 | `b` | Go to the Bcc field
273 | `c` | Go to the Cc field
274 | `s` | Go to the SUbject field
275 | `R` | Go to the Reply-To field
276 | `t` | Go to the Reply-To field
277 | `r` | Go to the first message of the conversation
278 | `r2` | Go to the second message of the conversation
279 | `r3` | Go to the third message of the conversation
280 | `r4` | Go to the fourth message of the conversation
281 | `S` | Go to your signature
282 |
283 | ## CONFIGURATION
284 |
285 | `kqs` | Kill Quoted Signatures
286 | ### Address book configuration
287 |
288 | The following providers are currently supported :
289 |
290 | + `pc_query` (pycard)
291 | + `khard`
292 | + `mu` (maildir-utils, requires specific [configuration](#mu-configuration))
293 |
294 | You can set one or several providers using:
295 |
296 | let g:VimMailContactsProvider=['pc_query', 'mu']
297 |
298 | You can also change query and sync commandsby adding the following to your
299 | vimrc (adapting the commands) :
300 |
301 | if(!exists("g:VimMailContactsCommands"))
302 | let g:VimMailContactsCommands = {}
303 | endif
304 | let g:VimMailContactsCommands['pc_query']={ 'query' : "pc_query",
305 | \'sync': "pycardsyncer"}
306 |
307 |
308 | If you don't see the preview while using contact completion, add the following
309 | to your vimrc (see |completeopt| |preview| ):
310 |
311 | set completeopt=preview
312 |
313 | If you don't want this completion you can either not use the plugin or add
314 | the following line to your vimrc:
315 |
316 | let g:VimMailDontUseComplete=1
317 |
318 | By default, the contact completion appends the query to the result list, you
319 | can disable this feature:
320 |
321 | let g:VimMailDoNotAppendQueryToResults
322 |
323 | #### Mu configuration
324 |
325 | Mu stores an email index by account, to use mu contact completion, you need to
326 | tel for each email address two settings :
327 |
328 | + the mu home (where mu index is stored)
329 | + the maildir directorory (where the emails are stored, only if you want to be
330 | able to sync contacts)
331 |
332 | This can be done via the `g:VimMailContactsCommands` dictionnary, there is an
333 | example :
334 |
335 | let g:VimMailContactsCommands={'mu' :
336 | \{ 'query' : "mu cfind",
337 | \'sync': "mu index",
338 | \'config': {
339 | \'sommeaddr': {
340 | \'home': '$HOME/mu/someaccount',
341 | \'maildir': '$HOME/mail/someaccount',
342 | \},
343 | \'default': {
344 | \'home': '$HOME/mu/otheraccount',
345 | \'maildir': '$HOME/mail/otheraccount',
346 | \}
347 | \}
348 | \}
349 | \}
350 |
351 | ### Spell
352 |
353 | Setting the list of possible spell langs:
354 |
355 | let g:VimMailSpellLangs=['fr', 'en', 'sp']
356 |
357 | ### Folds
358 |
359 | To disable message folds, add the following line to your vimrc:
360 |
361 | let g:VimMailDoNotFold=1
362 |
363 | ### Mail Client
364 |
365 | #### Launching mail client
366 |
367 | You can set the mail client command to your launcher script by adding to your
368 | vimrc something like:
369 |
370 | let g:VimMailClient="/path/to/your/launcher"
371 |
372 |
373 | #### Sending mails
374 |
375 | By default, this plugin searches for neomutt and mutt as client and treats the
376 | file as attachment to the mail unless it has filetype `mail`, in which case it
377 | uses the file as a draft.
378 |
379 | This behavior can be customized with the following variables, where the example
380 | shows the default values:
381 |
382 | " If does not exist then neomutt or mutt is used
383 | let g:VimMailBin="..."
384 | " Arguments to g:VimMailBin specific to the filetype
385 | let g:VimMailArgsByFiletype={"mail" : "-H %"}
386 | " Arguments to g:VimMailBin if filetype is not known to g:VimMailArgsByFiletype
387 | let g:VimMailArgsDefault="-a %"
388 |
389 | If you run traditional vim then the mail program is launched by `:!`, but on
390 | neovim and gvim it is launched by `:terminal`. (Note that neovim has no
391 | interactive `:!` and gvim has troubles displaying mutt via `:!`.) However, you
392 | can overrule this behavior by simply setting `g:VimMailUseTerminal`.
393 |
394 | The following settings could be used for thunderbird as mail client:
395 |
396 | let g:VimMailBin="thunderbird"
397 | let g:VimMailArgsDefault="-compose attachment=%:p"
398 | let g:VimMailArgsByFiletype={"mail" : "-compose \"body=`cat %:p`\""}
399 | let g:VimMailUseTerminal=0
400 |
401 |
402 | ## Adding a contact provider
403 |
404 | Adding a contact provider is now a simple task for anyone who already wrote
405 | some vimscript. To add a provider for the command `my_abook`, one needs to
406 |
407 | 1. Copy `autoload/vimmail/contacts/pc_query.vim` to
408 | `autoload/vimmail/contacts/my_abook.vim`
409 | 2. Rename the functions replacing `pc_query` by `my_abook`
410 | 3. Same for the dictionnary at the beginnig
411 | 4. Adapts both functions
412 | + To write the complete function see `:help completefunc`, it should return
413 | a list of results, each results being a dictionnaty, containing :
414 | + `word` : the replacement to write
415 | + `kind` : the kind of result itis (`M` mail, `C` for `T` for
416 | Telephone)
417 | + `menu` : a bit more info like `cell`, `work`, `personnal`
418 | + `abbr` for email adresses, only the email (instead of `first last `)
419 | + `info` : supplementary field info (usually the name of the contact
420 | and the full line of the provider command)
421 | + The sync function is trivial
422 |
423 |
424 | ## License
425 |
426 | This plugin is distributed under GPL Licence v3.0, see
427 | https://www.gnu.org/licenses/gpl.txt
428 |
--------------------------------------------------------------------------------
/autoload/vimmail.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | " Prompt {{{1
7 |
8 | " Should be used for every messages
9 | " Type can be:
10 | " e for error
11 | " w for warning
12 | " q for asking a question
13 | " s to tell the user Vizardry is doing something (searching for instance)
14 | " D to print only in debug mode
15 | " If extra argument is >0, then return the user answer
16 | function! vimmail#echo(msg,type,...)
17 | let ret=''
18 | if a:type=='e'
19 | let group='ErrorMsg'
20 | elseif a:type=='w'
21 | let group='WarningMsg'
22 | elseif a:type=='q'
23 | let group='Question'
24 | elseif a:type=='s'
25 | let group='Define'
26 | elseif a:type=='D'
27 | if !exists("g:VizardryDebug")
28 | return
29 | else
30 | let group='WarningMsg'
31 | endif
32 | else
33 | let group='Normal'
34 | endif
35 | execute 'echohl '.group
36 | if a:0 > 0 && a:1 > 0
37 | let ret=input(a:msg)
38 | else
39 | echo a:msg
40 | endif
41 | echohl None
42 | return ret
43 | endfunction
44 |
45 | function! vimmail#switchFrom()
46 |
47 | let fromLine=search('^From:', 'cn')
48 | let curFrom = substitute(getline(fromLine), '^From:\s*\(.*\)\s*$', '\1', '')
49 |
50 | " Generate contact list from addressbook
51 | if(!exists("g:VimMailFromList"))
52 | let g:VimMailFromList = []
53 | let g:VimMailCompleteOnlyMail =1
54 | if(exists("g:VimMailFromContact"))
55 | let contact=g:VimMailFromContact
56 | else
57 | let contact=system(g:VimMailDirectory."/plugin/getfullname.sh")
58 | endif
59 | let contacts = vimmail#contacts#CompleteAddr(0, "'".contact."'")
60 | for entry in contacts
61 | if entry.kind != 'Q'
62 | let g:VimMailFromList += [entry.word]
63 | endif
64 | endfor
65 | endif
66 |
67 | let newPos = (index(g:VimMailFromList, curFrom)+1)%len(g:VimMailFromList)
68 | let newFrom = g:VimMailFromList[newPos]
69 |
70 | let oldPos=getcurpos()
71 | execute ":".fromLine."s/".curFrom."/".newFrom."/"
72 | call setpos('.', oldPos)
73 | endfunction
74 |
75 | function! vimmail#runcmd(cmd)
76 | let out=systemlist(a:cmd)
77 | if(v:shell_error==0)
78 | return out
79 | else
80 | call vimmail#echo(join(out, '\n'), 'e')
81 | " Let the user see the error
82 | sleep 1
83 | return []
84 | endif
85 | endfunction
86 |
87 |
88 | " vim:set et sw=4:
89 |
--------------------------------------------------------------------------------
/autoload/vimmail/contacts.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | if(!exists("g:VimMailContactsProvider"))
7 | let g:VimMailContactsProvider = ["pc_query"]
8 | endif
9 |
10 | try
11 | call join(g:VimMailContactsProvider, ' ')
12 | catch /^Vim\%((\a\+)\)\=:E714/
13 | " Retro compatibility
14 | let g:VimMailContactsProvider = [g:VimMailContactsProvider]
15 | endtry
16 |
17 |
18 | if(!exists("g:VimMailContactsCommands"))
19 | let g:VimMailContactsCommands = {}
20 | endif
21 |
22 | if(!exists('s:scriptdir'))
23 | let s:scriptdir=expand(':h:p')
24 | endif
25 |
26 | function! s:CheckContactProvider(provider)
27 | if(!filereadable(s:scriptdir.'/contacts/'.a:provider.'.vim'))
28 | call vimmail#echo("Unsupported provider : '".a:provider."'",
29 | \"e")
30 | return 0
31 | endif
32 | return 1
33 | endfunction
34 |
35 | function! vimmail#contacts#sync()
36 | for provider in g:VimMailContactsProvider
37 | if(s:CheckContactProvider(provider))
38 | call function('vimmail#contacts#'.provider.'#sync')()
39 | endif
40 | endfor
41 | endfunction
42 |
43 | " Complete function
44 | function! vimmail#contacts#CompleteAddr(findstart, base)
45 | if(a:findstart) "first call {{{3
46 | return vimmail#contacts#startComplete()
47 | else "Find complete {{{3
48 | let records=[]
49 | let records_dic = {}
50 | for provider in g:VimMailContactsProvider
51 | if(s:CheckContactProvider(provider))
52 | let sub_records = function('vimmail#contacts#'.provider.'#complete')
53 | \(a:findstart, a:base)
54 | for rec in sub_records
55 | if(!has_key(records_dic, rec.word))
56 | let records_dic[rec.word]=1
57 | let rec.info.="\nProvider: ".provider
58 | call add(records, rec)
59 | endif
60 | endfor
61 | endif
62 | endfor
63 | if(!a:findstart && ! exists("g:VimMailDoNotAppendQueryToResults"))
64 | " Append the query to the records
65 | let l:item={}
66 | let l:item.word=a:base
67 | let l:item.kind='Q'
68 | let l:item.info="query: ".a:base
69 | call add(records, item)
70 | endif
71 | " TODO : remove duplicates
72 | endif
73 | return records
74 | endfunction
75 |
76 | function vimmail#contacts#startComplete()
77 | let line=getline('.')
78 | " Are we in a header field ?
79 | if line=~ '^\(From\|To\|Cc\|Bcc\|Reply-To\):'
80 | let g:VimMailCompleteOnlyMail=1
81 | else
82 | let g:VimMailCompleteOnlyMail=0
83 | endif
84 | " Find the start
85 | let start=col('.')-1
86 | while start > 0 && line[start - 1] =~ '\a'
87 | let start -= 1
88 | endwhile
89 | return start
90 | endfunction
91 |
92 | " vim:set et sw=4:
93 |
--------------------------------------------------------------------------------
/autoload/vimmail/contacts/khard.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: Ricardo Gonzalez
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | if(!has_key(g:VimMailContactsCommands, "khard"))
7 | let g:VimMailContactsCommands['khard']={ 'query' : "khard email --parsable --search-in-source-files",
8 | \'sync': "vdirsyncer sync"}
9 | endif
10 |
11 | function! vimmail#contacts#khard#sync()
12 | execute ":! ".g:VimMailContactsCommands['khard']['sync']
13 | endfunction
14 |
15 | " Complete function
16 | " If we are on a header field provides only mail information
17 | " Else provides each fields contains in the matched vcards
18 | function! vimmail#contacts#khard#complete(findstart, base)
19 | if(a:findstart) "first call {{{3
20 | return vimmail#contacts#startComplete()
21 | else "Find complete {{{3
22 | let records=[]
23 | " Do the query {{{4
24 | let output=vimmail#runcmd(g:VimMailContactsCommands['khard']['query'].
25 | \" ".a:base)
26 | for line in output
27 | if line!~ "searching"
28 | let l:item={}
29 | let ans=split(line,'\t')
30 | let l:name=ans[1]
31 | let l:item.info=l:name.":\n ".line
32 | let l:item.word=l:name." <".ans[0].">"
33 | let l:item.abbr=ans[0]
34 | if len(ans) > 2
35 | let l:item.menu=ans[2]
36 | endif
37 | let l:item.kind="M"
38 | call add(records, item)
39 | endif
40 | endfor
41 | return records
42 | endif
43 | endfunction
44 |
45 |
46 | " vim:set et sw=4:
47 |
--------------------------------------------------------------------------------
/autoload/vimmail/contacts/mu.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | if(!has_key(g:VimMailContactsCommands, "mu"))
7 | let g:VimMailContactsCommands['mu']={ 'query' : "mu cfind",
8 | \'sync': "mu index",
9 | \'config': {
10 | \'default': {
11 | \'home': '$HOME/mu',
12 | \'maildir': '$HOME/mail',
13 | \}
14 | \}
15 | \}
16 | endif
17 |
18 | " Returns from address
19 | function s:getFromAddr()
20 | return substitute(split(getline(search('^From:', 'n')),' ')[-1],
21 | \'[<>]', '', 'g')
22 | endfunction
23 |
24 | " Return mu directories from config
25 | function s:getMuDir(type)
26 | let from=s:getFromAddr()
27 | let account='default'
28 | if(has_key(g:VimMailContactsCommands['mu']['config'], from))
29 | let account=from
30 | endif
31 | return g:VimMailContactsCommands['mu']['config'][account][a:type]
32 | endfunction
33 |
34 | " Return mu configstring
35 | function s:getConfigString(type)
36 | let ret =' --muhome='.s:getMuDir('home')
37 | if(a:type == 'sync')
38 | let ret.=' --maildir='.s:getMuDir('maildir')
39 | endif
40 | return ret
41 | endfunction
42 |
43 | function! vimmail#contacts#mu#sync()
44 | execute ":! ".g:VimMailContactsCommands['mu']['sync'].getConfigString('sync')
45 | endfunction
46 |
47 | " Complete function
48 | " If we are on a header field provides only mail information
49 | " Else provides each fields contains in the matched vcards
50 | function! vimmail#contacts#mu#complete(findstart, base)
51 | if(a:findstart) "first call {{{3
52 | return vimmail#contacts#startComplete()
53 | else "Find complete {{{3
54 | let records=[]
55 | " Do the query {{{4
56 | let output=vimmail#runcmd(g:VimMailContactsCommands['mu']['query'].
57 | \' --nocolor '.s:getConfigString('find').' '.a:base)
58 | for line in output
59 | let ans=split(line, ' ')
60 | let l:item={}
61 | if (len(ans) > 1)
62 | let l:item.info=join(ans[0:len(ans)-2], ' ')
63 | let l:item.word=l:item.info.' <'.ans[-1].'>'
64 | else
65 | let l:item.info=ans[0]
66 | let l:item.word=ans[0]
67 | endif
68 | let l:item.kind="M"
69 | call add(records, item)
70 | endfor
71 | return records
72 | endif
73 | endfunction
74 |
75 |
76 | " vim:set et sw=4:
77 |
--------------------------------------------------------------------------------
/autoload/vimmail/contacts/pc_query.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | if(!has_key(g:VimMailContactsCommands, "pc_query"))
7 | let g:VimMailContactsCommands['pc_query']={ 'query' : "pc_query",
8 | \'sync': "pycardsyncer"}
9 | endif
10 |
11 | function! vimmail#contacts#pc_query#sync()
12 | execute ":! ".g:VimMailContactsCommands['pc_query']['sync']
13 | endfunction
14 |
15 | " Complete function
16 | " If we are on a header field provides only mail information
17 | " Else provides each fields contains in the matched vcards
18 | function! vimmail#contacts#pc_query#complete(findstart, base)
19 | if(a:findstart) "first call {{{3
20 | return vimmail#contacts#startComplete()
21 | else "Find complete {{{3
22 | " Set the grep function {{{4
23 | if (g:VimMailCompleteOnlyMail)
24 | let l:grep="egrep \"(Name|MAIL)\""
25 | else
26 | let l:grep="grep :"
27 | endif
28 | let records=[]
29 | " Do the query {{{4
30 | let out=vimmail#runcmd(g:VimMailContactsCommands['pc_query']['query'].
31 | \" ".a:base." | ".l:grep)
32 | for line in out
33 | if line=~ "Name" "Recover the name {{{5
34 | let l:name=substitute(split(line, ':')[1],"^[ ]*","","")
35 | else " parse the answer {{{5
36 | " pc_query answer look like this
37 | " EMAIL (WORK): foo@bar.com
38 | let ans=split(line,':')
39 | " Remove useless whitespace
40 | let ans[1]=substitute(ans[1], "^[ ]*","","")
41 | let l:item={}
42 | " Full information for preview window name + pc_query line
43 | let l:item.info=l:name.":\n ".line
44 | if ans[0]=~"^EMAIL"
45 | " Put email addresses in '<' '>'
46 | let l:item.word=l:name." <".ans[1].">"
47 | let l:item.abbr=ans[1]
48 | let l:item.kind="M"
49 | else
50 | let l:item.word=ans[1]
51 | "Use the first letter of the pc_query type for the kind
52 | let l:item.kind=strpart(ans[0],0,1)
53 | endif
54 | " If there are a precise info (aka '(WORK)') add it
55 | if ans[0]=~"(.*)"
56 | let l:item.menu=substitute(ans[0],'\(.*(\|).*\)',"","g")
57 | endif
58 | call add(records, item)
59 | endif
60 | endfor
61 | return records
62 | endif
63 | endfunction
64 |
65 |
66 | " vim:set et sw=4:
67 |
--------------------------------------------------------------------------------
/autoload/vimmail/sendmail.vim:
--------------------------------------------------------------------------------
1 | " Author: David Beniamine
2 | " License: Gpl v3.0
3 | " Website: http://github.com/dbeniamine/vim-mail.vim
4 |
5 | if exists("g:VimMailSendCmd")
6 | echo "Deprecated g:VimMailSendCmd set. Use g:VimMailBin and friends instead."
7 | endif
8 |
9 | if !exists("g:VimMailBin")
10 | if executable("neomutt")
11 | let g:VimMailBin="neomutt"
12 | elseif executable("mutt")
13 | let g:VimMailBin="mutt"
14 | else
15 | echoerr "No g:VimMailBin set and no neomutt or mutt found."
16 | endif
17 | endif
18 |
19 | " Assigns arguments to the mail program depending on the filetype of the
20 | " buffer.
21 | if !exists("g:VimMailArgsByFiletype")
22 | let g:VimMailArgsByFiletype={"mail" : "-H %"}
23 | endif
24 | if !exists("g:VimMailArgsDefault")
25 | let g:VimMailArgsDefault="-a %"
26 | endif
27 |
28 | if !exists("g:VimMailUseTerminal")
29 | if has('nvim') || has ('gui_running')
30 | " A difference between neovim and vim is that :! does not support
31 | " interactive commands and this is leads to a complaint of
32 | " (neo)mutt of not sending empty mails.
33 | " Although the reasons differ, also gvim has troubles running mutt
34 | " within itself using the bang command.
35 | let g:VimMailUseTerminal=1
36 | else
37 | let g:VimMailUseTerminal=0
38 | endif
39 | endif
40 |
41 | function! vimmail#sendmail#Sendmail()
42 | if !exists("g:VimMailBin")
43 | echoerr "No g:VimMailBin set."
44 | return
45 | endif
46 |
47 | " If there are filetype specific settings, use them, otherwise use the
48 | " default.
49 | if has_key(g:VimMailArgsByFiletype, &filetype)
50 | let l:mailerarg=g:VimMailArgsByFiletype[&filetype]
51 | else
52 | let l:mailerarg=g:VimMailArgsDefault
53 | endif
54 |
55 | if g:VimMailUseTerminal
56 | let l:cmdprefix=":terminal "
57 | else
58 | let l:cmdprefix=":!"
59 | endif
60 |
61 | let l:cmd=l:cmdprefix . g:VimMailBin . " " . expandcmd(l:mailerarg)
62 | execute l:cmd
63 | endfunction
64 |
65 | " vim:set et sw=4:
66 |
--------------------------------------------------------------------------------
/autoload/vimmail/spelllang.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | if(!exists("g:VimMailSpellLangs"))
7 | let g:VimMailSpellLangs=['fr','en']
8 | endif
9 |
10 | function! vimmail#spelllang#SwitchSpellLangs()
11 | if &spell==0
12 | let l:index=0
13 | set spell
14 | else
15 | let l:curlang=index(g:VimMailSpellLangs,&spelllang)
16 | if l:curlang == len(g:VimMailSpellLangs)-1
17 | set nospell
18 | echo "Spell disabled"
19 | return
20 | endif
21 | let l:index=l:curlang+1
22 | endif
23 | let l:nlang=get(g:VimMailSpellLangs,l:index)
24 | echo "Setting spelllang: ".l:nlang
25 | let &spelllang=l:nlang
26 | endfunction
27 |
28 | " vim:set et sw=4:
29 |
--------------------------------------------------------------------------------
/doc/vim-mail.txt:
--------------------------------------------------------------------------------
1 | *VimMail.txt*
2 |
3 | This plugin is a small helper for writing mail from vim, I designed it using
4 | mutt but it should work with other clients. I recommend to use it in
5 | combination with [CheckAttach](https://github.com/chrisbra/CheckAttach).
6 |
7 | ===============================================================================
8 | Anounces *VimMail-Announces* ~
9 |
10 | + Since v1.0.0 the `g:VimMailSendCmd` is deprecated, see
11 | |VimMail-mail-client-configuration|
12 |
13 | + Since v0.3.2 it is possible to change the flags used for sendmail depending
14 | on the current filetype see |VimMail-mail-client-configuration|
15 |
16 | + v0.3.1 adds a contact provider for mu-cfind see |VimMail-mu-configuration|
17 | and the ability to combine several contacts providers
18 |
19 | + v0.3 provides the possibility to set startflags depending on the contents of
20 | the mail, see issue #6 (https://gitlab.com/dbeniamine/vim-mail/issues/6) and
21 | |VimMail-start-position|.
22 |
23 | + v0.2.9 adds a mapping to switch from address from a predefined list see
24 | |VimMail-switchfrom|.
25 |
26 | + Since v0.2.7 Vim-mail can handle (virtually) any contact providers, this
27 | implies a few configuration changes.
28 |
29 | see |VimMail-Completion| and |VimMail-address-book-configuration| and maybe
30 | |VimMail-adding-a-contact-provider|.
31 |
32 | ==============================================================================
33 | Features *VimMail-features*
34 |
35 | This plugin provides the following features
36 |
37 | Contact completion *VimMail-Completion* ~
38 |
39 | The following providers are currently supported :
40 |
41 | + `pc_query` (pycard)
42 | + `khard`
43 | + `mu` (maildir-utils, requires specific configuration see |VimMail-mu-configuration|)
44 |
45 | see |VimMail-address-book-configuration| and |VimMail-adding-a-contact-provider|.
46 |
47 | To search your address book from vim:
48 |
49 | + While writing a mail, in insert mode, type:
50 | >
51 | a
52 | <
53 | or (using |omnifunc|)
54 | >
55 |
56 | <
57 | + While editing any other file:
58 | As the previous mapping are only set for mail files, you need to set the
59 | |completefunc| (using |omnifunc| would be a bad idea):
60 | >
61 | set completefunc=vimmail#contacts#CompleteAddr
62 | <
63 |
64 | Then use `` (in insert mode) to trigger contact completion. It will
65 | search for the word under the cursor in your contact list.
66 |
67 | If you are currently in a From,To,CC or Bcc line, only mail addresses will
68 | be proposed, else all the match will appear. More details will appear in
69 | the preview window including contact name, type of the entry (mail, cell,
70 | phone etc.).
71 |
72 | To synchronise your address book, in normal mode, type:
73 | >
74 | a
75 | <
76 |
77 | Redaction *VimMail-redaction* ~
78 |
79 | + Cursor initial position *VimMail-start-position*
80 |
81 | By default vim-mail place your cursor at the beginning of the mail (right
82 | after the headers) adds a blank line and switch to insert mode. This
83 | behavior can be modified through a series of flags:
84 |
85 | The available flags are:
86 |
87 | Flag | Meaning
88 | -----|----------------------------------------------------------------------
89 | `r` | Remove quoted signatures from reply
90 | `i` | insert mode
91 | `o` | Add new line after cursor
92 | `O` | Add new line before cursor
93 | `A` | Place cursor at the end of the line
94 | `W` | Start on second word (a.k.a first address of field / word of subject)
95 | `I` | Intelligent start: If two replies, start above or below, as the last
96 | | replier, else default to other flags
97 | `t` | top (Right after headers)
98 | `b` | Bottom (After last message)
99 | `F` | From field
100 | `T` | To field
101 | `C` | Cc field
102 | `B` | Bcc field
103 | `S` | Subject field
104 |
105 | The flags can be set globally or by type of mail using the variable
106 | VimMail detects 4 types of mail :
107 |
108 | Type | When
109 | ------------|------
110 | `blank` | `To:` field is empty
111 | `nosubject` | `To:` field is not empty but `Subject:` is
112 | `new` | Neither `To:` or `Subject:` is empty and there is no quote
113 | `reply` | Neither `To:` or `Subject:` is empty and there is a quote
114 |
115 | Examples
116 |
117 | Adding the following line to your vimrc will make you start at the end of
118 | the subject line when subject is empy:
119 |
120 | >
121 | let g:VimMailStartFlags={'nosubject' :"SAi" }
122 |
123 | You can do somthing more complex for instance :
124 |
125 | >
126 | let g:VimMailStartFlags={
127 | \'blank': 'TAi',
128 | \'nosubject': 'SAi',
129 | \'default' : "boi"}
130 |
131 | Notes
132 |
133 | + `default` key is special, in the above case it means either `new` or `reply`.
134 | + For retro compatibility with version 0.2.x, `let g:VimMailStartFlags='toi'` is
135 |
136 | + Easy spelllang switch *VimMail-spell*
137 |
138 | While writting mails, I often need to do switch the spell lang which can be
139 | annoying, so this plugin provide an easy way to do it. Just type:
140 | >
141 | l
142 | <
143 | and the plugin will switch the spelllang using a list of allowed languages.
144 | If the current spellang is the last allowed, it will disable spell, hit
145 | >
146 | l
147 | <
148 | once more and you will restart with the first lang.
149 | You can set the list of allowed langs in your vimrc:
150 | >
151 | let g:VimMailSpellLangs=['fr', 'en', 'sp']
152 | <
153 | The default langs are french, english
154 | This will work for any filetype as it can be usefull for many other kind of
155 | files.
156 |
157 | + Switch from *VimMail-switchfrom*
158 |
159 | You can easliy from address just by hitting `F`.
160 | By default vimmal will search the email addresses for a contact with the same
161 | full name as your unix user. You can also specify a contact (or a search
162 | string) with by adding the following to your vimrc :
163 | >
164 | let g:VimMailFromContact="John doe"
165 |
166 | or directly specify a list of addresses :
167 | >
168 | let g:VimMailFromList = [
169 | \'John doe ',
170 | \'Ano nymous f` | Go to the From field
188 | `b` | Go to the Bcc field
189 | `c` | Go to the Cc field
190 | `s` | Go to the SUbject field
191 | `R` | Go to the Reply-To field
192 | `t` | Go to the Reply-To field
193 |
194 | Conversation: *VimMail-navigation-conversation*
195 |
196 | Mapping | Effect
197 | -----------------|----------------------------------------------
198 | `B` | Go to the first line (after headers)
199 | `E` | Go to the first line after the conversation
200 | `r` | Go to the first message of the conversation
201 | `r2` | Go to the second message of the conversation
202 | `r3` | Go to the third message of the conversation
203 | `r4` | Go to the fourth message of the conversation
204 | `S` | Go to your signature
205 | `kqs` | Kill Quoted Signatures
206 |
207 | Launch mail client *VimMail-mailclient* ~
208 |
209 | One of Mutt main drawbacks is that you can't access your mailbox while
210 | writing mails, good news everyone, with vim-mail you can open mutt in RO
211 | mode easily by typing
212 | >
213 | M
214 |
215 | Send file from Vim *VimMail-send*~
216 |
217 | When you are vimming at one point, you might want to send the file you are
218 | working on. Leaving vim to send a mail from vim is so annoying, happily there
219 | is the solution just type:
220 | >
221 | m
222 | <
223 | and VimMail will pipe the file to mutt.
224 |
225 | ==============================================================================
226 | MAPPINGS *VimMail-mappings*
227 |
228 | On any file *VimMail-global-mappings*~
229 |
230 | Mapping | Effect
231 | -----------------|----------------------------------------------
232 | `m` | Send the current buffer
233 | `l` | Switch spelllang
234 | `M` | Open the mail client
235 |
236 | On mail only *VimMail-mail-mappings*~
237 |
238 | Mapping | Effect
239 | -----------------|----------------------------------------------
240 | `a` | Search the word before cursor as a contact
241 | `F` | Switch the from address
242 | `f` | Go to the From field
243 | `b` | Go to the Bcc field
244 | `c` | Go to the Cc field
245 | `s` | Go to the SUbject field
246 | `R` | Go to the Reply-To field
247 | `t` | Go to the Reply-To field
248 | `r` | Go to the first message of the conversation
249 | `r2`| Go to the second message of the conversation
250 | `r3`| Go to the third message of the conversation
251 | `r4`| Go to the fourth message of the conversation
252 | `S` | Go to your signature
253 |
254 | ==============================================================================
255 | CONFIGURATION *VimMail-configuration*
256 |
257 | Address book configuration *VimMail-address-book-configuration*~
258 |
259 | The following providers are currently supported :
260 |
261 | + `pc_query` (pycard)
262 | + `khard`
263 | + `mu` (maildir-utils, requires specific configuration see |VimMail-mu-configuration|)
264 |
265 | You can set one or several providers using:
266 | >
267 | let g:VimMailContactsProvider=['pc_query', 'mu']
268 |
269 | You can also change query and sync commandsby adding the following to your
270 | vimrc (adapting the commands) :
271 | >
272 | if(!exists("g:VimMailContactsCommands"))
273 | let g:VimMailContactsCommands = {}
274 | endif
275 | let g:VimMailContactsCommands['pc_query']={ 'query' : "pc_query",
276 | \'sync': "pycardsyncer"}
277 |
278 |
279 | If you don't see the preview while using contact completion, add the following
280 | to your vimrc (see |completeopt| |preview| ):
281 | >
282 | set completeopt=preview
283 | <
284 | If you don't want this completion you can either not use the plugin or add
285 | the following line to your vimrc:
286 | >
287 | let g:VimMailDontUseComplete=1
288 | <
289 | By default, the contact completion appends the query to the result list, you
290 | can disable this feature:
291 | >
292 | let g:VimMailDoNotAppendQueryToResults
293 |
294 | <
295 | Mu Configuration *VimMail-mu-configuration*~
296 |
297 | Mu stores an email index by account, to use mu contact completion, you need to
298 | tel for each email address two settings :
299 |
300 | + the mu home (where mu index is stored)
301 | + the maildir directorory (where the emails are stored, only if you want to be
302 | able to sync contacts)
303 |
304 | This can be done via the `g:VimMailContactsCommands` dictionnary, there is an
305 | example :
306 | >
307 | let g:VimMailContactsCommands={'mu' :
308 | \{ 'query' : "mu cfind",
309 | \'sync': "mu index",
310 | \'config': {
311 | \'sommeaddr': {
312 | \'home': '$HOME/mu/someaccount',
313 | \'maildir': '$HOME/mail/someaccount',
314 | \},
315 | \'default': {
316 | \'home': '$HOME/mu/otheraccount',
317 | \'maildir': '$HOME/mail/otheraccount',
318 | \}
319 | \}
320 | \}
321 | \}
322 |
323 |
324 | Spell *VimMail-spell-configuration*~
325 |
326 | Setting the list of possible spell langs:
327 | >
328 | let g:VimMailSpellLangs=['fr', 'en', 'sp']
329 | <
330 | Folds *VimMail-folds-configuration*~
331 |
332 | To disable message folds, add the following line to your vimrc:
333 | >
334 | let g:VimMailDoNotFold=1
335 | <
336 | Mail Client *VimMail-mail-client-configuration*~
337 |
338 | You can set the mail client command to your launcher script by adding to your
339 | vimrc something like:
340 | >
341 | let g:VimMailClient="/path/to/your/launcher"
342 | <
343 |
344 | By default, this plugin searches for neomutt and mutt as client and treats the
345 | file as attachment to the mail unless it has filetype `mail`, in which case it
346 | uses the file as a draft.
347 |
348 | This behavior can be customized with the following variables, where the example
349 | shows the default values:
350 | >
351 | " If does not exist then neomutt or mutt is used
352 | let g:VimMailBin="..."
353 | " Arguments to g:VimMailBin specific to the filetype
354 | let g:VimMailArgsByFiletype={"mail" : "-H %"}
355 | " Arguments to g:VimMailBin if filetype is not known to g:VimMailArgsByFiletype
356 | let g:VimMailArgsDefault="-a %"
357 | >
358 |
359 | If you run traditional vim then the mail program is launched by `:!`, but on
360 | neovim and gvim it is launched by `:terminal`. (Note that neovim has no
361 | interactive `:!` and gvim has troubles displaying mutt via `:!`.) However, you
362 | can overrule this behavior by simply setting `g:VimMailUseTerminal`.
363 |
364 | The following settings could be used for thunderbird as mail client:
365 | >
366 | let g:VimMailBin="thunderbird"
367 | let g:VimMailArgsDefault="-compose attachment=%:p"
368 | let g:VimMailArgsByFiletype={"mail" : "-compose \"body=`cat %:p`\""}
369 | let g:VimMailUseTerminal=0
370 | >
371 |
372 | Adding a contact provider *VimMail-adding-a-contact-provider* ~
373 |
374 | Adding a contact provider is now a simple task for anyone who already wrote
375 | some vimscript. To add a provider for the command `my_abook`, one needs to
376 |
377 | 1. Copy `autoload/vimmail/contacts/pc_query.vim` to
378 | `autoload/vimmail/contacts/my_abook.vim`
379 | 2. Rename the functions replacing `pc_query` by `my_abook`
380 | 3. Same for the dictionnary at the beginnig
381 | 4. Adapts both functions
382 | + To write the complete function see `:help completefunc`, it should return
383 | a list of results, each results being a dictionnaty, containing :
384 | + `word` : the replacement to write
385 | + `kind` : the kind of result itis (`M` mail, `C` for `T` for
386 | Telephone)
387 | + `menu` : a bit more info like `cell`, `work`, `personnal`
388 | + `abbr` for email adresses, only the email (instead of `first last `)
389 | + `info` : supplementary field info (usually the name of the contact
390 | and the full line of the provider command)
391 | + The sync function is trivial
392 |
393 | ===============================================================================
394 | License *VimMail License*~
395 |
396 | This plugin is distributed under GPL License v3.0, see
397 | https://www.gnu.org/licenses/gpl.txt
398 |
--------------------------------------------------------------------------------
/ftplugin/mail.vim:
--------------------------------------------------------------------------------
1 | " Description: Plugin for writing mail from vim (mutt or others)
2 | " Author: David Beniamine
3 | " License: Gpl v3.0
4 | " Website: http://github.com/dbeniamine/vim-mail.vim
5 |
6 | " Don't load twice {{{1
7 | if exists("g:loaded_VimMail")
8 | finish
9 | endif
10 | let g:loaded_VimMail=0.3.1
11 |
12 | " Save context {{{1
13 | let s:save_cpo = &cpo
14 | set cpo&vim
15 |
16 | " Go to a part of the message {{{2
17 | function! VimMailGoto(pattern,post)
18 | normal gg
19 | if a:pattern != ''
20 | execute a:pattern
21 | endif
22 | if a:post != ''
23 | execute "normal ".a:post
24 | endif
25 | endfunction
26 |
27 | function! VimMailKillQuotedSig()
28 | normal! gg
29 | try
30 | " Look for first quoted sig
31 | /^ *>[> ]* -- *$/
32 | catch
33 | " No quoted sig get out
34 | return
35 | endtry
36 | try
37 | " Remove everything until our signature
38 | execute "normal! d/^-- $/\"
39 | catch
40 | " Oups we don't have a signature => remove untill the next empty line
41 | execute "normal! d}"
42 | endtry
43 | endfunction
44 |
45 | " Configuration {{{1
46 |
47 | " Set start position {{{2
48 | " Start flags:
49 | " i : insert mode
50 | " o : Add new line after cursor
51 | " O : Add new line before cursor
52 | " A : Place cursor at the end of the line
53 | " W : Start on second word (a.k.a first address of field / word of subject)
54 | " I : Intelligent start: If two replies, start above on below, as the last
55 | " replier, else default to other flags
56 | " t : top (Right after headers)
57 | " b : Bottom (After last message)
58 | " F : From field
59 | " T : To field
60 | " C : Cc field
61 | " B : Bcc field
62 | " S : Subject field
63 | " r : Remove quoted signatures
64 | if !exists("g:VimMailStartFlags")
65 | let g:VimMailStartFlags={'default': "toi"}
66 | else
67 | " Ensure default is set
68 | try
69 | if !has_key(g:VimMailStartFlags, 'default')
70 | let g:VimMailStartFlags['default']="toi"
71 | endif
72 | catch /^Vim\%((\a\+)\)\=:E715/
73 | " Retro compatibility
74 | let g:VimMailStartFlags={'default': g:VimMailStartFlags}
75 | endtry
76 | endif
77 |
78 | " Determine mail type
79 | if( search('^To:$', 'cn'))
80 | let mailtype='blank'
81 | else
82 | if search('^Subject:$', 'cn')
83 | let mailtype='nosubject'
84 | elseif(search('^>', 'cn'))
85 | let mailtype='reply'
86 | else
87 | let mailtype='new'
88 | endif
89 | endif
90 |
91 | " Get flags or default
92 | if has_key(g:VimMailStartFlags, mailtype)
93 | let startFlags=g:VimMailStartFlags[mailtype]
94 | else
95 | let startFlags=g:VimMailStartFlags['default']
96 | endif
97 |
98 | " Start position {{{2
99 | " Remove quoted signatures
100 | if startFlags =~# "r"
101 | call VimMailKillQuotedSig()
102 | endif
103 |
104 | " Start mode
105 | if startFlags =~# "o"
106 | let s:StartMode='o'
107 | elseif startFlags =~# "O"
108 | let s:StartMode='O'
109 | elseif startFlags =~# "A"
110 | let s:StartMode='A'
111 | elseif startFlags =~# "W"
112 | let s:StartMode='W'
113 | else
114 | let s:StartMode=''
115 | endif
116 |
117 | function IntelligentStartPos()
118 | call search('^>[ ]*\(Le\|On\).*:','e')
119 | let rep1=search('^>[ ]*[^ >]','W')
120 | let rep2=search('^>[ ]*>','W')
121 | if rep1 == 0 || rep2 ==0
122 | return 0
123 | endif
124 | return rep2-rep1
125 | endfunction
126 |
127 | function StartTop()
128 | let s:StartPos='/^$'
129 | endfunction
130 |
131 | function StartBottom()
132 | if search('^--') != 0
133 | let s:StartPos='/^--'
134 | let s:StartMode='k'.s:StartMode
135 | else
136 | let s:StartPos=''
137 | let s:StartMode='G'.s:StartMode
138 | endif
139 | endfunction
140 |
141 | " Start pattern
142 | let pos=IntelligentStartPos()
143 | if startFlags =~# "I" && pos !=0
144 | if pos > 0
145 | call StartTop()
146 | else
147 | call StartBottom()
148 | endif
149 | elseif startFlags =~# "t"
150 | call StartTop()
151 | elseif startFlags =~# "b"
152 | call StartBottom()
153 | elseif startFlags =~# "F"
154 | let s:StartPos='/^From'
155 | elseif startFlags =~# "T"
156 | let s:StartPos='/^To'
157 | elseif startFlags =~# "C"
158 | let s:StartPos='/^Cc'
159 | elseif startFlags =~# "B"
160 | let s:StartPos='/^Bcc'
161 | elseif startFlags =~# "S"
162 | let s:StartPos='/^Subject'
163 | endif
164 |
165 | " Place cursor
166 | " Insert mode
167 | let cmd='au BufWinEnter *mutt-* call VimMailGoto(s:StartPos,s:StartMode)'
168 | if startFlags =~# "i"
169 | let cmd.=' | :start'
170 | if startFlags =~# "A"
171 | let cmd.="!"
172 | endif
173 | endif
174 | execute cmd
175 |
176 | " Set fold method {{{2
177 | if(!exists("g:VimMailDoNotFold"))
178 | setlocal foldexpr=VimMaiFoldLevel() foldmethod=expr
179 | endif
180 |
181 | " Mappings {{{1
182 |
183 | " Start mutt in RO mode {{{2
184 | if !exists("g:VimMailDoNotMap")
185 | map M :call VimMailStartClientRO()
186 |
187 | " Go to different parts of the mail {{{2
188 | map F :call vimmail#switchFrom()
189 | map f :call VimMailGoto('/^From','A')
190 | map b :call VimMailGoto('/^Bcc','A')
191 | map c :call VimMailGoto('/^Cc','A')
192 | map s :call VimMailGoto('/^Subject','A')
193 | map R :call VimMailGoto('/^Reply-To','A')
194 | map t :call VimMailGoto('/^To','A')
195 | map r :call VimMailGoto('/^>','I')
196 | map r2 :call VimMailGoto('/^>\s*>','I')
197 | map r3 :call VimMailGoto('/^>\s*>\s*>','I')
198 | map r4 :call VimMailGoto('/^>\s*>\s*>\s*>','I')
199 | map S :call VimMailGoto('/^-- ','j')
200 | map B :call VimMailGoto('/^$','I')
201 | map E :call VimMailGoto('/^>','Nj')
202 | map kqs :call VimMailKillQuotedSig()
203 | endif
204 |
205 |
206 |
207 |
208 | " Functions {{{1
209 |
210 | " Start the mail client in RO mode {{{2
211 | function! VimMailStartClientRO()
212 | if (!exists("g:VimMailClient"))
213 | let g:VimMailClient="xterm -e 'mutt -R'"
214 | endif
215 | execute ":silent !".g:VimMailClient
216 | endfunction
217 |
218 | " Fold Method {{{2
219 | function! VimMaiFoldLevel()
220 | return s:FoldLevel(v:lnum)
221 | endfunction
222 |
223 | function! s:FoldLevel(lnum)
224 | let l:line = matchstr(getline(a:lnum),'^>[> ]*')
225 | if !empty(l:line)
226 | return len(substitute(l:line,' ',"","g"))
227 | else
228 | return 0
229 | endif
230 | endfunction
231 |
232 | " pc_query completion {{{2
233 | if(!exists("g:VimMailDontUseComplete"))
234 | if !exists("g:VimMailDoNotMap")
235 | imap a
236 | nmap a :call vimmail#contacts#sync()
237 | endif
238 | " Contact completion
239 | set omnifunc=vimmail#contacts#CompleteAddr
240 | endif
241 |
242 | " Prepare markdown quotes {{{2
243 | function! VimMailPandocQuotes()
244 | normal zRG
245 | " Iterates lines
246 | let oldLevel=0
247 | let l:lnum=getcurpos()[1]
248 | while l:lnum > 0
249 | let currentLevel=s:FoldLevel(l:lnum)
250 | let line=getline(l:lnum)
251 | if( currentLevel != oldLevel && match(line, '^[>\s]*$') == -1 &&
252 | \match(getline(l:lnum+1), '^[>\s]*$') == -1 )
253 | " Separate blocks
254 | normal o
255 | if(oldLevel > currentLevel)
256 | exec 'normal i'.repeat('>', min([currentLevel, oldLevel]))
257 | endif
258 | normal k
259 | endif
260 | if(currentLevel > 0 )
261 | " Remove spaces between > >
262 | let res = substitute(matchstr(line,'^>[> ]*'),' ',"","g")
263 | execute ':s/^[> ]* /'.res.' /e'
264 | endif
265 | normal k
266 | let l:lnum=l:lnum-1
267 | let oldLevel=currentLevel
268 | endwhile
269 | endfunction
270 |
271 | " Restore context {{{1
272 | let &cpo = s:save_cpo
273 |
274 | " vim:set et sw=4:
275 |
--------------------------------------------------------------------------------
/plugin/getfullname.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # From https://stackoverflow.com/questions/6619277/how-to-get-the-logged-in-users-real-name-in-unix
3 | if [ "Darwin" = $(uname) ]; then
4 | FULLNAME=$(id -P $USER | awk -F '[:]' '{print $8}')
5 | else
6 | FULLNAME=$(getent passwd $USER | cut -d: -f5 | cut -d, -f1)
7 | fi
8 | echo $FULLNAME | tr -d '\n'
9 |
10 |
--------------------------------------------------------------------------------
/plugin/vim-mail.vim:
--------------------------------------------------------------------------------
1 | " Author: David Beniamine
2 | " License: Gpl v3.0
3 | " Website: http://github.com/dbeniamine/vim-mail.vim
4 |
5 | "Don't load twice {{{1
6 | if exists("g:loaded_VimMail")
7 | finish
8 | endif
9 | " Save context {{{1
10 | let s:save_cpo = &cpo
11 | set cpo&vim
12 |
13 | let g:VimMailDirectory=expand(':p:h')."/.."
14 |
15 | " Toggle spelllang
16 | if !exists("g:VimMailDoNotMap")
17 | noremap l :call vimmail#spelllang#SwitchSpellLangs()
18 | noremap m :call vimmail#sendmail#Sendmail()
19 | endif
20 |
21 | " Restore context {{{1
22 | let &cpo = s:save_cpo
23 |
24 | " vim:set et sw=4:
25 |
--------------------------------------------------------------------------------