Mercurial > index.cgi > dotfiles
annotate .vim/plugin/gnupg.vim @ 199:6bfec0d0d020
Start an agent in there too, though I wonder if this would be better as a function...
author | Steve Huston <huston@astro.princeton.edu> |
---|---|
date | Wed, 30 Sep 2020 11:22:35 -0400 |
parents | 3470659ff1ed |
children |
rev | line source |
---|---|
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1 " Name: gnupg.vim |
95
3470659ff1ed
Doesn't like the ID tag in there.
Steve Huston <huston@astro.princeton.edu>
parents:
94
diff
changeset
|
2 " Version: $Id$ |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
3 " Author: Markus Braun <markus.braun@krawel.de> |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
4 " Summary: Vim plugin for transparent editing of gpg encrypted files. |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
5 " Licence: This program is free software; you can redistribute it and/or |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
6 " modify it under the terms of the GNU General Public License. |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
7 " See http://www.gnu.org/copyleft/gpl.txt |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
8 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
9 " Section: Documentation {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
10 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
11 " Description: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
12 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
13 " This script implements transparent editing of gpg encrypted files. The |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
14 " filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
15 " a file the content is decrypted, when opening a new file the script will |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
16 " ask for the recipients of the encrypted file. The file content will be |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
17 " encrypted to all recipients before it is written. The script turns off |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
18 " viminfo and swapfile to increase security. |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
19 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
20 " Installation: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
21 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
22 " Copy the gnupg.vim file to the $HOME/.vim/plugin directory. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
23 " Refer to ':help add-plugin', ':help add-global-plugin' and ':help |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
24 " runtimepath' for more details about Vim plugins. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
25 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
26 " From "man 1 gpg-agent": |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
27 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
28 " ... |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
29 " You should always add the following lines to your .bashrc or whatever |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
30 " initialization file is used for all shell invocations: |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
31 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
32 " GPG_TTY=`tty` |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
33 " export GPG_TTY |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
34 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
35 " It is important that this environment variable always reflects the out‐ |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
36 " put of the tty command. For W32 systems this option is not required. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
37 " ... |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
38 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
39 " Most distributions provide software to ease handling of gpg and gpg-agent. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
40 " Examples are keychain or seahorse. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
41 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
42 " Commands: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
43 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
44 " :GPGEditRecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
45 " Opens a scratch buffer to change the list of recipients. Recipients that |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
46 " are unknown (not in your public key) are highlighted and have |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
47 " a prepended "!". Closing the buffer makes the changes permanent. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
48 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
49 " :GPGViewRecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
50 " Prints the list of recipients. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
51 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
52 " :GPGEditOptions |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
53 " Opens a scratch buffer to change the options for encryption (symmetric, |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
54 " asymmetric, signing). Closing the buffer makes the changes permanent. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
55 " WARNING: There is no check of the entered options, so you need to know |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
56 " what you are doing. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
57 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
58 " :GPGViewOptions |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
59 " Prints the list of options. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
60 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
61 " Variables: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
62 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
63 " g:GPGExecutable |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
64 " If set used as gpg executable, otherwise the system chooses what is run |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
65 " when "gpg" is called. Defaults to "gpg". |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
66 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
67 " g:GPGUseAgent |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
68 " If set to 0 a possible available gpg-agent won't be used. Defaults to 1. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
69 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
70 " g:GPGPreferSymmetric |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
71 " If set to 1 symmetric encryption is preferred for new files. Defaults to 0. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
72 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
73 " g:GPGPreferArmor |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
74 " If set to 1 armored data is preferred for new files. Defaults to 0. |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
75 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
76 " g:GPGPreferSign |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
77 " If set to 1 signed data is preferred for new files. Defaults to 0. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
78 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
79 " g:GPGDefaultRecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
80 " If set, these recipients are used as defaults when no other recipient is |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
81 " defined. This variable is a Vim list. Default is unset. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
82 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
83 " Known Issues: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
84 " |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
85 " In some cases gvim can't decryt files |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
86 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
87 " This is caused by the fact that a running gvim has no TTY and thus gpg is |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
88 " not able to ask for the passphrase by itself. This is a problem for Windows |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
89 " and Linux versions of gvim and could not be solved unless a "terminal |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
90 " emulation" is implemented for gvim. To circumvent this you have to use any |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
91 " combination of gpg-agent and a graphical pinentry program: |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
92 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
93 " - gpg-agent only: |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
94 " you need to provide the passphrase for the needed key to gpg-agent |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
95 " in a terminal before you open files with gvim which require this key. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
96 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
97 " - pinentry only: |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
98 " you will get a popup window every time you open a file that needs to |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
99 " be decrypted. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
100 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
101 " - gpgagent and pinentry: |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
102 " you will get a popup window the first time you open a file that |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
103 " needs to be decrypted. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
104 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
105 " Credits: {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
106 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
107 " - Mathieu Clabaut for inspirations through his vimspell.vim script. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
108 " - Richard Bronosky for patch to enable ".pgp" suffix. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
109 " - Erik Remmelzwaal for patch to enable windows support and patient beta |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
110 " testing. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
111 " - Lars Becker for patch to make gpg2 working. |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
112 " - Thomas Arendsen Hein for patch to convert encoding of gpg output |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
113 " - Karl-Heinz Ruskowski for patch to fix unknown recipients and trust model |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
114 " and patient beta testing. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
115 " - Giel van Schijndel for patch to get GPG_TTY dynamically. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
116 " - Sebastian Luettich for patch to fix issue with symmetric encryption an set |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
117 " recipients. |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
118 " - Tim Swast for patch to generate signed files |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
119 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
120 " Section: Plugin header {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
121 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
122 " guard against multiple loads {{{2 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
123 if (exists("g:loaded_gnupg") || &cp || exists("#BufReadPre#*.\(gpg\|asc\|pgp\)")) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
124 finish |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
125 endif |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
126 let g:loaded_gnupg = "$Revision: 3026 $" |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
127 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
128 " check for correct vim version {{{2 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
129 if (v:version < 700) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
130 echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim version >= 7.0' | echohl None |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
131 finish |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
132 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
133 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
134 " Section: Autocmd setup {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
135 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
136 augroup GnuPG |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
137 autocmd! |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
138 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
139 " initialize the internal variables |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
140 autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) call s:GPGInit() |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
141 " force the user to edit the recipient list if he opens a new file and public |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
142 " keys are preferred |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
143 autocmd BufNewFile *.\(gpg\|asc\|pgp\) if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 0) | call s:GPGEditRecipients() | endif |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
144 " do the decryption |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
145 autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) call s:GPGDecrypt() |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
146 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
147 " convert all text to encrypted text before writing |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
148 autocmd BufWritePre,FileWritePre *.\(gpg\|asc\|pgp\) call s:GPGEncrypt() |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
149 " undo the encryption so we are back in the normal text, directly |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
150 " after the file has been written. |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
151 autocmd BufWritePost,FileWritePost *.\(gpg\|asc\|pgp\) call s:GPGEncryptPost() |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
152 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
153 " cleanup on leaving vim |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
154 autocmd VimLeave *.\(gpg\|asc\|pgp\) call s:GPGCleanup() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
155 augroup END |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
156 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
157 " Section: Constants {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
158 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
159 let s:GPGMagicString = "\t \t" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
160 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
161 " Section: Highlight setup {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
162 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
163 highlight default link GPGWarning WarningMsg |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
164 highlight default link GPGError ErrorMsg |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
165 highlight default link GPGHighlightUnknownRecipient ErrorMsg |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
166 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
167 " Section: Functions {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
168 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
169 " Function: s:GPGInit() {{{2 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
170 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
171 " initialize the plugin |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
172 " |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
173 function s:GPGInit() |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
174 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGInit()") |
92 | 175 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
176 " first make sure nothing is written to ~/.viminfo while editing |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
177 " an encrypted file. |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
178 set viminfo= |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
179 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
180 " we don't want a swap file, as it writes unencrypted data to disk |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
181 set noswapfile |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
182 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
183 " check what gpg command to use |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
184 if (!exists("g:GPGExecutable")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
185 let g:GPGExecutable = "gpg --trust-model always" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
186 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
187 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
188 " check if gpg-agent is allowed |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
189 if (!exists("g:GPGUseAgent")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
190 let g:GPGUseAgent = 1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
191 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
192 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
193 " check if symmetric encryption is preferred |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
194 if (!exists("g:GPGPreferSymmetric")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
195 let g:GPGPreferSymmetric = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
196 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
197 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
198 " check if armored files are preferred |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
199 if (!exists("g:GPGPreferArmor")) |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
200 let g:GPGPreferArmor = 0 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
201 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
202 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
203 " check if signed files are preferred |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
204 if (!exists("g:GPGPreferSign")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
205 let g:GPGPreferSign = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
206 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
207 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
208 " start with empty default recipients if none is defined so far |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
209 if (!exists("g:GPGDefaultRecipients")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
210 let g:GPGDefaultRecipients = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
211 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
212 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
213 " print version |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
214 call s:GPGDebug(1, "gnupg.vim ". g:loaded_gnupg) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
215 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
216 " determine if gnupg can use the gpg-agent |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
217 if (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
218 if (!exists("$GPG_TTY") && !has("gui_running")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
219 let $GPG_TTY = system("tty") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
220 if (v:shell_error) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
221 let $GPG_TTY = "" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
222 echohl GPGError |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
223 echom "The GPG_TTY is not set and no TTY could be found using the `tty` command!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
224 echom "gpg-agent might not work." |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
225 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
226 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
227 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
228 let s:GPGCommand = g:GPGExecutable . " --use-agent" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
229 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
230 let s:GPGCommand = g:GPGExecutable . " --no-use-agent" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
231 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
232 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
233 " don't use tty in gvim |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
234 " FIXME find a better way to avoid an error. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
235 " with this solution only --use-agent will work |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
236 if (has("gui_running")) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
237 let s:GPGCommand = s:GPGCommand . " --no-tty" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
238 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
239 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
240 " setup shell environment for unix and windows |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
241 let s:shellredirsave = &shellredir |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
242 let s:shellsave = &shell |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
243 if (has("unix")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
244 " unix specific settings |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
245 let s:shellredir = ">%s 2>&1" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
246 let s:shell = '/bin/sh' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
247 let s:stderrredirnull = '2>/dev/null' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
248 let s:GPGCommand = "LANG=C LC_ALL=C " . s:GPGCommand |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
249 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
250 " windows specific settings |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
251 let s:shellredir = '>%s' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
252 let s:shell = &shell |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
253 let s:stderrredirnull = '2>nul' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
254 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
255 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
256 call s:GPGDebug(3, "shellredirsave: " . s:shellredirsave) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
257 call s:GPGDebug(3, "shellsave: " . s:shellsave) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
258 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
259 call s:GPGDebug(3, "shell: " . s:shell) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
260 call s:GPGDebug(3, "shellcmdflag: " . &shellcmdflag) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
261 call s:GPGDebug(3, "shellxquote: " . &shellxquote) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
262 call s:GPGDebug(3, "shellredir: " . s:shellredir) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
263 call s:GPGDebug(3, "stderrredirnull: " . s:stderrredirnull) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
264 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
265 call s:GPGDebug(3, "shell implementation: " . resolve(s:shell)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
266 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
267 " find the supported algorithms |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
268 let commandline = s:GPGCommand . " --version" |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
269 call s:GPGDebug(2, "command: ". commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
270 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
271 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
272 let output = system(commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
273 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
274 let &shell = s:shellsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
275 call s:GPGDebug(2, "output: ". output) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
276 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
277 let s:GPGPubkey = substitute(output, ".*Pubkey: \\(.\\{-}\\)\n.*", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
278 let s:GPGCipher = substitute(output, ".*Cipher: \\(.\\{-}\\)\n.*", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
279 let s:GPGHash = substitute(output, ".*Hash: \\(.\\{-}\\)\n.*", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
280 let s:GPGCompress = substitute(output, ".*Compress.\\{-}: \\(.\\{-}\\)\n.*", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
281 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
282 call s:GPGDebug(2, "public key algorithms: " . s:GPGPubkey) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
283 call s:GPGDebug(2, "cipher algorithms: " . s:GPGCipher) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
284 call s:GPGDebug(2, "hashing algorithms: " . s:GPGHash) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
285 call s:GPGDebug(2, "compression algorithms: " . s:GPGCompress) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
286 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGInit()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
287 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
288 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
289 " Function: s:GPGCleanup() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
290 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
291 " cleanup on leaving vim |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
292 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
293 function s:GPGCleanup() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
294 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCleanup()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
295 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
296 " wipe out screen |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
297 new +only |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
298 redraw! |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
299 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
300 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCleanup()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
301 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
302 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
303 " Function: s:GPGDecrypt() {{{2 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
304 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
305 " decrypt the buffer and find all recipients of the encrypted file |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
306 " |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
307 function s:GPGDecrypt() |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
308 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGDecrypt()") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
309 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
310 " switch to binary mode to read the encrypted file |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
311 set bin |
92 | 312 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
313 " get the filename of the current buffer |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
314 let filename = escape(expand("%:p"), '\"') |
92 | 315 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
316 " clear GPGEncrypted, GPGRecipients and GPGOptions |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
317 let b:GPGEncrypted = 0 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
318 let b:GPGRecipients = [] |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
319 let b:GPGOptions = [] |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
320 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
321 " find the recipients of the file |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
322 let commandline = s:GPGCommand . " --verbose --decrypt --list-only --dry-run --batch --no-use-agent --logger-fd 1 \"" . filename . "\"" |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
323 call s:GPGDebug(3, "command: " . commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
324 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
325 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
326 let output = system(commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
327 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
328 let &shell = s:shellsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
329 call s:GPGDebug(3, "output: ". output) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
330 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
331 " check if the file is symmetric/asymmetric encrypted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
332 if (match(output, "gpg: encrypted with [[:digit:]]\\+ passphrase") >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
333 " file is symmetric encrypted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
334 let b:GPGEncrypted = 1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
335 call s:GPGDebug(1, "this file is symmetric encrypted") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
336 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
337 let b:GPGOptions += ["symmetric"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
338 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
339 " find the used cipher algorithm |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
340 let cipher = substitute(output, ".*gpg: \\([^ ]\\+\\) encrypted data.*", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
341 if (match(s:GPGCipher, "\\<" . cipher . "\\>") >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
342 let b:GPGOptions += ["cipher-algo " . cipher] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
343 call s:GPGDebug(1, "cipher-algo is " . cipher) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
344 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
345 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
346 echom "The cipher " . cipher . " is not known by the local gpg command. Using default!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
347 echo |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
348 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
349 endif |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
350 elseif (match(output, "gpg: public key is [[:xdigit:]]\\{8}") >= 0) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
351 " file is asymmetric encrypted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
352 let b:GPGEncrypted = 1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
353 call s:GPGDebug(1, "this file is asymmetric encrypted") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
354 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
355 let b:GPGOptions += ["encrypt"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
356 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
357 " find the used public keys |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
358 let start = match(output, "gpg: public key is [[:xdigit:]]\\{8}") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
359 while (start >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
360 let start = start + strlen("gpg: public key is ") |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
361 let recipient = strpart(output, start, 8) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
362 call s:GPGDebug(1, "recipient is " . recipient) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
363 let name = s:GPGNameToID(recipient) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
364 if (strlen(name) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
365 let b:GPGRecipients += [name] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
366 call s:GPGDebug(1, "name of recipient is " . name) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
367 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
368 let b:GPGRecipients += [recipient] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
369 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
370 echom "The recipient \"" . recipient . "\" is not in your public keyring!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
371 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
372 end |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
373 let start = match(output, "gpg: public key is [[:xdigit:]]\\{8}", start) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
374 endwhile |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
375 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
376 " file is not encrypted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
377 let b:GPGEncrypted = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
378 call s:GPGDebug(1, "this file is not encrypted") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
379 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
380 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
381 echohl None |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
382 set nobin |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
383 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
384 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
385 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
386 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
387 " check if the message is armored |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
388 if (match(output, "gpg: armor header") >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
389 call s:GPGDebug(1, "this file is armored") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
390 let b:GPGOptions += ["armor"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
391 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
392 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
393 " finally decrypt the buffer content |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
394 " since even with the --quiet option passphrase typos will be reported, |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
395 " we must redirect stderr (using shell temporarily) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
396 call s:GPGDebug(1, "decrypting file") |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
397 let commandline = "'[,']!" . s:GPGCommand . " --quiet --decrypt " . s:stderrredirnull |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
398 call s:GPGDebug(1, "command: " . commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
399 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
400 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
401 execute commandline |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
402 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
403 let &shell = s:shellsave |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
404 if (v:shell_error) " message could not be decrypted |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
405 silent u |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
406 echohl GPGError |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
407 let blackhole = input("Message could not be decrypted! (Press ENTER)") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
408 echohl None |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
409 bwipeout |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
410 set nobin |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
411 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
412 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
413 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
414 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
415 " turn off binary mode |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
416 set nobin |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
417 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
418 " call the autocommand for the file minus .gpg$ |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
419 execute ":doautocmd BufReadPost " . escape(expand("%:r"), ' *?\"'."'") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
420 call s:GPGDebug(2, "called autocommand for " . escape(expand("%:r"), ' *?\"'."'")) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
421 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
422 " refresh screen |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
423 redraw! |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
424 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
425 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
426 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
427 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
428 " Function: s:GPGEncrypt() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
429 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
430 " encrypts the buffer to all previous recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
431 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
432 function s:GPGEncrypt() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
433 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEncrypt()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
434 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
435 " save window view |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
436 let s:GPGWindowView = winsaveview() |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
437 call s:GPGDebug(2, "saved window view " . string(s:GPGWindowView)) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
438 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
439 " store encoding and switch to a safe one |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
440 if (&fileencoding != &encoding) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
441 let s:GPGEncoding = &encoding |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
442 let &encoding = &fileencoding |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
443 call s:GPGDebug(2, "encoding was \"" . s:GPGEncoding . "\", switched to \"" . &encoding . "\"") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
444 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
445 let s:GPGEncoding = "" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
446 call s:GPGDebug(2, "encoding and fileencoding are the same (\"" . &encoding . "\"), not switching") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
447 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
448 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
449 " switch buffer to binary mode |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
450 set bin |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
451 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
452 " guard for unencrypted files |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
453 if (!exists("b:GPGEncrypted") || b:GPGEncrypted == 0) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
454 echohl GPGError |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
455 let blackhole = input("Message could not be encrypted! File might be empty! (Press ENTER)") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
456 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
457 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
458 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
459 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
460 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
461 " initialize GPGOptions if not happened before |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
462 if (!exists("b:GPGOptions") || len(b:GPGOptions) == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
463 let b:GPGOptions = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
464 if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
465 let b:GPGOptions += ["symmetric"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
466 let b:GPGRecipients = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
467 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
468 let b:GPGOptions += ["encrypt"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
469 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
470 if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
471 let b:GPGOptions += ["armor"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
472 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
473 if (exists("g:GPGPreferSign") && g:GPGPreferSign == 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
474 let b:GPGOptions += ["sign"] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
475 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
476 call s:GPGDebug(1, "no options set, so using default options: " . string(b:GPGOptions)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
477 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
478 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
479 " built list of options |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
480 let options = "" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
481 for option in b:GPGOptions |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
482 let options = options . " --" . option . " " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
483 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
484 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
485 " check here again if all recipients are available in the keyring |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
486 let [ recipients, unknownrecipients ] = s:GPGCheckRecipients(b:GPGRecipients) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
487 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
488 " check if there are unknown recipients and warn |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
489 if (len(unknownrecipients) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
490 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
491 echom "Please use GPGEditRecipients to correct!!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
492 echo |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
493 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
494 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
495 " Let user know whats happend and copy known_recipients back to buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
496 let dummy = input("Press ENTER to quit") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
497 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
498 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
499 " built list of recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
500 if (len(recipients) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
501 for gpgid in recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
502 let options = options . " -r " . gpgid |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
503 endfor |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
504 else |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
505 if (match(b:GPGOptions, "encrypt") >= 0) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
506 echohl GPGError |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
507 echom "There are no recipients!!" |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
508 echom "Please use GPGEditRecipients to correct!!" |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
509 echo |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
510 echohl None |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
511 endif |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
512 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
513 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
514 " encrypt the buffer |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
515 let commandline = "'[,']!" . s:GPGCommand . " --quiet --no-encrypt-to " . options . " " . s:stderrredirnull |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
516 call s:GPGDebug(1, "command: " . commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
517 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
518 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
519 silent execute commandline |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
520 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
521 let &shell = s:shellsave |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
522 if (v:shell_error) " message could not be encrypted |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
523 " delete content of the buffer to be sure no data is written unencrypted |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
524 " content will be recovered in GPGEncryptPost() |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
525 silent normal! 1GdG |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
526 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
527 echohl GPGError |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
528 let blackhole = input("Message could not be encrypted! File might be empty! (Press ENTER)") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
529 echohl None |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
530 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
531 return |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
532 endif |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
533 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
534 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
535 endfunction |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
536 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
537 " Function: s:GPGEncryptPost() {{{2 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
538 " |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
539 " undo changes don by encrypt, after writing |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
540 " |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
541 function s:GPGEncryptPost() |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
542 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEncryptPost()") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
543 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
544 " guard for unencrypted files |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
545 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
546 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncryptPost()") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
547 return |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
548 endif |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
549 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
550 " undo encryption of buffer content |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
551 silent u |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
552 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
553 " switch back from binary mode |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
554 set nobin |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
555 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
556 " restore encoding |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
557 if (s:GPGEncoding != "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
558 let &encoding = s:GPGEncoding |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
559 call s:GPGDebug(2, "restored encoding \"" . &encoding . "\"") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
560 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
561 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
562 " restore window view |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
563 call winrestview(s:GPGWindowView) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
564 call s:GPGDebug(2, "restored window view" . string(s:GPGWindowView)) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
565 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
566 " refresh screen |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
567 redraw! |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
568 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
569 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncryptPost()") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
570 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
571 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
572 " Function: s:GPGViewRecipients() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
573 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
574 " echo the recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
575 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
576 function s:GPGViewRecipients() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
577 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
578 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
579 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
580 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
581 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
582 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
583 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
584 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
585 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
586 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
587 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
588 let [ recipients, unknownrecipients ] = s:GPGCheckRecipients(b:GPGRecipients) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
589 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
590 echo 'This file has following recipients (Unknown recipients have a prepended "!"):' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
591 " echo the recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
592 for name in recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
593 let name = s:GPGIDToName(name) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
594 echo name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
595 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
596 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
597 " echo the unknown recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
598 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
599 for name in unknownrecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
600 let name = "!" . name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
601 echo name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
602 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
603 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
604 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
605 " check if there is any known recipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
606 if (len(recipients) == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
607 echohl GPGError |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
608 echom 'There are no known recipients!' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
609 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
610 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
611 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
612 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
613 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
614 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
615 " Function: s:GPGEditRecipients() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
616 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
617 " create a scratch buffer with all recipients to add/remove recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
618 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
619 function s:GPGEditRecipients() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
620 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
621 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
622 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
623 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
624 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
625 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
626 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
627 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
628 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
629 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
630 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
631 " only do this if it isn't already a GPGRecipients_* buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
632 if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
633 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
634 " save buffer name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
635 let buffername = bufname("%") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
636 let editbuffername = "GPGRecipients_" . buffername |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
637 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
638 " check if this buffer exists |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
639 if (!bufexists(editbuffername)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
640 " create scratch buffer |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
641 execute 'silent! split ' . escape(editbuffername, ' *?\"'."'") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
642 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
643 " add a autocommand to regenerate the recipients after a write |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
644 autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
645 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
646 if (bufwinnr(editbuffername) >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
647 " switch to scratch buffer window |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
648 execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
649 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
650 " split scratch buffer window |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
651 execute 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
652 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
653 " add a autocommand to regenerate the recipients after a write |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
654 autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
655 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
656 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
657 " empty the buffer |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
658 silent normal! 1GdG |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
659 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
660 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
661 " Mark the buffer as a scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
662 setlocal buftype=acwrite |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
663 setlocal bufhidden=hide |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
664 setlocal noswapfile |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
665 setlocal nowrap |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
666 setlocal nobuflisted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
667 setlocal nonumber |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
668 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
669 " so we know for which other buffer this edit buffer is |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
670 let b:GPGCorrespondingTo = buffername |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
671 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
672 " put some comments to the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
673 silent put ='GPG: ----------------------------------------------------------------------' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
674 silent put ='GPG: Please edit the list of recipients, one recipient per line.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
675 silent put ='GPG: Unknown recipients have a prepended \"!\".' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
676 silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
677 silent put ='GPG: Data after recipients between and including \"(\" and \")\" is ignored.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
678 silent put ='GPG: Closing this buffer commits changes.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
679 silent put ='GPG: ----------------------------------------------------------------------' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
680 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
681 " get the recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
682 let [ recipients, unknownrecipients ] = s:GPGCheckRecipients(getbufvar(b:GPGCorrespondingTo, "GPGRecipients")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
683 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
684 " if there are no known or unknown recipients, use the default ones |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
685 if (len(recipients) == 0 && len(unknownrecipients) == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
686 if (type(g:GPGDefaultRecipients) == type([])) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
687 let [ recipients, unknownrecipients ] = s:GPGCheckRecipients(g:GPGDefaultRecipients) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
688 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
689 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
690 echom "g:GPGDefaultRecipients is not a Vim list, please correct this in your vimrc!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
691 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
692 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
693 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
694 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
695 " put the recipients in the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
696 for name in recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
697 let name = s:GPGIDToName(name) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
698 silent put =name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
699 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
700 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
701 " put the unknown recipients in the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
702 let syntaxPattern = "\\(nonexxistinwordinthisbuffer" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
703 for name in unknownrecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
704 let name = "!" . name |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
705 let syntaxPattern = syntaxPattern . "\\|" . name |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
706 silent put =name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
707 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
708 let syntaxPattern = syntaxPattern . "\\)" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
709 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
710 " define highlight |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
711 if (has("syntax") && exists("g:syntax_on")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
712 execute 'syntax match GPGUnknownRecipient "' . syntaxPattern . '"' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
713 highlight clear GPGUnknownRecipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
714 highlight link GPGUnknownRecipient GPGHighlightUnknownRecipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
715 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
716 syntax match GPGComment "^GPG:.*$" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
717 execute 'syntax match GPGComment "' . s:GPGMagicString . '.*$"' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
718 highlight clear GPGComment |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
719 highlight link GPGComment Comment |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
720 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
721 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
722 " delete the empty first line |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
723 silent normal! 1Gdd |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
724 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
725 " jump to the first recipient |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
726 silent normal! G |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
727 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
728 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
729 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
730 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
731 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
732 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
733 " Function: s:GPGFinishRecipientsBuffer() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
734 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
735 " create a new recipient list from RecipientsBuffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
736 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
737 function s:GPGFinishRecipientsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
738 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishRecipientsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
739 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
740 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
741 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
742 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
743 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
744 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
745 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
746 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
747 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
748 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
749 " go to buffer before doing work |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
750 if (bufnr("%") != expand("<abuf>")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
751 " switch to scratch buffer window |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
752 execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
753 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
754 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
755 " delete the autocommand |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
756 autocmd! * <buffer> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
757 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
758 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
759 " get the recipients from the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
760 let recipients = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
761 let lines = getline(1,"$") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
762 for recipient in lines |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
763 " delete all text after magic string |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
764 let recipient = substitute(recipient, s:GPGMagicString . ".*$", "", "") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
765 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
766 " delete all spaces at beginning and end of the recipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
767 " also delete a '!' at the beginning of the recipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
768 let recipient = substitute(recipient, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
769 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
770 " delete comment lines |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
771 let recipient = substitute(recipient, "^GPG:.*$", "", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
772 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
773 " only do this if the line is not empty |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
774 if (strlen(recipient) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
775 let gpgid = s:GPGNameToID(recipient) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
776 if (strlen(gpgid) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
777 if (match(recipients, gpgid) < 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
778 let recipients += [gpgid] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
779 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
780 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
781 if (match(recipients, recipient) < 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
782 let recipients += [recipient] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
783 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
784 echom "The recipient \"" . recipient . "\" is not in your public keyring!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
785 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
786 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
787 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
788 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
789 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
790 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
791 " write back the new recipient list to the corresponding buffer and mark it |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
792 " as modified. Buffer is now for sure a encrypted buffer. |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
793 call setbufvar(b:GPGCorrespondingTo, "GPGRecipients", recipients) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
794 call setbufvar(b:GPGCorrespondingTo, "&mod", 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
795 call setbufvar(b:GPGCorrespondingTo, "GPGEncrypted", 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
796 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
797 " check if there is any known recipient |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
798 if (len(recipients) == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
799 echohl GPGError |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
800 echom 'There are no known recipients!' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
801 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
802 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
803 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
804 " reset modified flag |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
805 set nomodified |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
806 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
807 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
808 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
809 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
810 " Function: s:GPGViewOptions() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
811 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
812 " echo the recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
813 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
814 function s:GPGViewOptions() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
815 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
816 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
817 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
818 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
819 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
820 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
821 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
822 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
823 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
824 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
825 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
826 if (exists("b:GPGOptions")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
827 echo 'This file has following options:' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
828 " echo the options |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
829 for option in b:GPGOptions |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
830 echo option |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
831 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
832 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
833 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
834 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
835 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
836 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
837 " Function: s:GPGEditOptions() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
838 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
839 " create a scratch buffer with all recipients to add/remove recipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
840 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
841 function s:GPGEditOptions() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
842 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
843 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
844 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
845 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
846 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
847 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
848 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
849 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
850 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
851 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
852 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
853 " only do this if it isn't already a GPGOptions_* buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
854 if (match(bufname("%"), "^\\(GPGRecipients_\\|GPGOptions_\\)") != 0 && match(bufname("%"), "\.\\(gpg\\|asc\\|pgp\\)$") >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
855 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
856 " save buffer name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
857 let buffername = bufname("%") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
858 let editbuffername = "GPGOptions_" . buffername |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
859 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
860 " check if this buffer exists |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
861 if (!bufexists(editbuffername)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
862 " create scratch buffer |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
863 execute 'silent! split ' . escape(editbuffername, ' *?\"'."'") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
864 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
865 " add a autocommand to regenerate the options after a write |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
866 autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
867 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
868 if (bufwinnr(editbuffername) >= 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
869 " switch to scratch buffer window |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
870 execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
871 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
872 " split scratch buffer window |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
873 execute 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
874 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
875 " add a autocommand to regenerate the options after a write |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
876 autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
877 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
878 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
879 " empty the buffer |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
880 silent normal! 1GdG |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
881 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
882 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
883 " Mark the buffer as a scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
884 setlocal buftype=nofile |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
885 setlocal noswapfile |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
886 setlocal nowrap |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
887 setlocal nobuflisted |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
888 setlocal nonumber |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
889 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
890 " so we know for which other buffer this edit buffer is |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
891 let b:GPGCorrespondingTo = buffername |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
892 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
893 " put some comments to the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
894 silent put ='GPG: ----------------------------------------------------------------------' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
895 silent put ='GPG: THERE IS NO CHECK OF THE ENTERED OPTIONS!' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
896 silent put ='GPG: YOU NEED TO KNOW WHAT YOU ARE DOING!' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
897 silent put ='GPG: IF IN DOUBT, QUICKLY EXIT USING :x OR :bd.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
898 silent put ='GPG: Please edit the list of options, one option per line.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
899 silent put ='GPG: Please refer to the gpg documentation for valid options.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
900 silent put ='GPG: Lines beginning with \"GPG:\" are removed automatically.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
901 silent put ='GPG: Closing this buffer commits changes.' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
902 silent put ='GPG: ----------------------------------------------------------------------' |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
903 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
904 " put the options in the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
905 let options = getbufvar(b:GPGCorrespondingTo, "GPGOptions") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
906 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
907 for option in options |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
908 silent put =option |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
909 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
910 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
911 " delete the empty first line |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
912 silent normal! 1Gdd |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
913 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
914 " jump to the first option |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
915 silent normal! G |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
916 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
917 " define highlight |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
918 if (has("syntax") && exists("g:syntax_on")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
919 syntax match GPGComment "^GPG:.*$" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
920 highlight clear GPGComment |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
921 highlight link GPGComment Comment |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
922 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
923 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
924 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
925 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
926 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
927 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
928 " Function: s:GPGFinishOptionsBuffer() {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
929 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
930 " create a new option list from OptionsBuffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
931 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
932 function s:GPGFinishOptionsBuffer() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
933 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishOptionsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
934 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
935 " guard for unencrypted files |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
936 if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
937 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
938 echom "File is not encrypted, all GPG functions disabled!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
939 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
940 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
941 return |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
942 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
943 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
944 " go to buffer before doing work |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
945 if (bufnr("%") != expand("<abuf>")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
946 " switch to scratch buffer window |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
947 execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
948 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
949 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
950 " clear options and unknownOptions |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
951 let options = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
952 let unknownOptions = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
953 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
954 " delete the autocommand |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
955 autocmd! * <buffer> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
956 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
957 " get the options from the scratch buffer |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
958 let lines = getline(1, "$") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
959 for option in lines |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
960 " delete all spaces at beginning and end of the option |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
961 " also delete a '!' at the beginning of the option |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
962 let option = substitute(option, "^[[:space:]!]*\\(.\\{-}\\)[[:space:]]*$", "\\1", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
963 " delete comment lines |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
964 let option = substitute(option, "^GPG:.*$", "", "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
965 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
966 " only do this if the line is not empty |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
967 if (strlen(option) > 0 && match(options, option) < 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
968 let options += [option] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
969 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
970 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
971 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
972 " write back the new option list to the corresponding buffer and mark it |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
973 " as modified |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
974 call setbufvar(b:GPGCorrespondingTo, "GPGOptions", options) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
975 call setbufvar(b:GPGCorrespondingTo, "&mod", 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
976 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
977 " reset modified flag |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
978 set nomodified |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
979 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
980 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
981 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
982 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
983 " Function: s:GPGCheckRecipients(tocheck) {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
984 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
985 " check if recipients are known |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
986 " Returns: two lists recipients and unknownrecipients |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
987 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
988 function s:GPGCheckRecipients(tocheck) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
989 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGCheckRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
990 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
991 let recipients = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
992 let unknownrecipients = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
993 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
994 if (type(a:tocheck) == type([])) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
995 for recipient in a:tocheck |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
996 let gpgid = s:GPGNameToID(recipient) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
997 if (strlen(gpgid) > 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
998 if (match(recipients, gpgid) < 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
999 let recipients += [gpgid] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1000 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1001 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1002 if (match(unknownrecipients, recipient) < 0) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1003 let unknownrecipients += [recipient] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1004 echohl GPGWarning |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1005 echom "The recipient \"" . recipient . "\" is not in your public keyring!" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1006 echohl None |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1007 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1008 end |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1009 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1010 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1011 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1012 call s:GPGDebug(2, "recipients are: " . string(recipients)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1013 call s:GPGDebug(2, "unknown recipients are: " . string(unknownrecipients)) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1014 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1015 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGCheckRecipients()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1016 return [ recipients, unknownrecipients ] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1017 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1018 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1019 " Function: s:GPGNameToID(name) {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1020 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1021 " find GPG key ID corresponding to a name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1022 " Returns: ID for the given name |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1023 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1024 function s:GPGNameToID(name) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1025 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGNameToID()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1026 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1027 " ask gpg for the id for a name |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1028 let commandline = s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys \"" . a:name . "\"" |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1029 call s:GPGDebug(2, "command: ". commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1030 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1031 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1032 let output = system(commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1033 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1034 let &shell = s:shellsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1035 call s:GPGDebug(2, "output: ". output) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1036 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1037 " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8, |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1038 " so convert it, if necessary |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1039 if (&encoding != "utf-8") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1040 let output = iconv(output, "utf-8", &encoding) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1041 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1042 let lines = split(output, "\n") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1043 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1044 " parse the output of gpg |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1045 let pubseen = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1046 let counter = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1047 let gpgids = [] |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1048 let choices = "The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1049 for line in lines |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1050 let fields = split(line, ":") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1051 " search for the next uid |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1052 if (pubseen == 1) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1053 if (fields[0] == "uid") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1054 let choices = choices . " " . fields[9] . "\n" |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1055 else |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1056 let pubseen = 0 |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1057 endif |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1058 endif |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1059 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1060 " search for the next pub |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1061 if (pubseen == 0) |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1062 if (fields[0] == "pub") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1063 let identity = fields[4] |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1064 let gpgids += [identity] |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1065 if exists("*strftime") |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1066 let choices = choices . counter . ": ID: 0x" . identity . " created at " . strftime("%c", fields[5]) . "\n" |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1067 else |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1068 let choices = choices . counter . ": ID: 0x" . identity . "\n" |
92 | 1069 endif |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1070 let counter = counter+1 |
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1071 let pubseen = 1 |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1072 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1073 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1074 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1075 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1076 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1077 " counter > 1 means we have more than one results |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1078 let answer = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1079 if (counter > 1) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1080 let choices = choices . "Enter number: " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1081 let answer = input(choices, "0") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1082 while (answer == "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1083 let answer = input("Enter number: ", "0") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1084 endwhile |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1085 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1086 |
94
2b81c74b6dda
Nevermind, those all require 7.2.
Steve Huston <huston@srhuston.net>
parents:
93
diff
changeset
|
1087 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGIDToName()") |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1088 return get(gpgids, answer, "") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1089 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1090 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1091 " Function: s:GPGIDToName(identity) {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1092 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1093 " find name corresponding to a GPG key ID |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1094 " Returns: Name for the given ID |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1095 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1096 function s:GPGIDToName(identity) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1097 call s:GPGDebug(3, ">>>>>>>> Entering s:GPGIDToName()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1098 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1099 " TODO is the encryption subkey really unique? |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1100 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1101 " ask gpg for the id for a name |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1102 let commandline = s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys " . a:identity |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1103 call s:GPGDebug(2, "command: ". commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1104 let &shellredir = s:shellredir |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1105 let &shell = s:shell |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1106 let output = system(commandline) |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1107 let &shellredir = s:shellredirsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1108 let &shell = s:shellsave |
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1109 call s:GPGDebug(2, "output: ". output) |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1110 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1111 " when called with "--with-colons" gpg encodes its output _ALWAYS_ as UTF-8, |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1112 " so convert it, if necessary |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1113 if (&encoding != "utf-8") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1114 let output = iconv(output, "utf-8", &encoding) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1115 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1116 let lines = split(output, "\n") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1117 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1118 " parse the output of gpg |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1119 let pubseen = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1120 let uid = "" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1121 for line in lines |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1122 let fields = split(line, ":") |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1123 if (pubseen == 0) " search for the next pub |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1124 if (fields[0] == "pub") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1125 let pubseen = 1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1126 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1127 else " search for the next uid |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1128 if (fields[0] == "uid") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1129 let pubseen = 0 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1130 if exists("*strftime") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1131 let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . " created at " . strftime("%c", fields[5]) . ")" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1132 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1133 let uid = fields[9] . s:GPGMagicString . "(ID: 0x" . a:identity . ")" |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1134 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1135 break |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1136 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1137 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1138 endfor |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1139 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1140 call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGIDToName()") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1141 return uid |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1142 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1143 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1144 " Function: s:GPGDebug(level, text) {{{2 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1145 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1146 " output debug message, if this message has high enough importance |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1147 " only define function if GPGDebugLevel set at all |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1148 " |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1149 function s:GPGDebug(level, text) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1150 if exists("g:GPGDebugLevel") && g:GPGDebugLevel >= a:level |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1151 if exists("g:GPGDebugLog") |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1152 execute "redir >> " . g:GPGDebugLog |
93
ab30008c9e93
Older version for 7.0 compatibility
Steve Huston <huston@srhuston.net>
parents:
92
diff
changeset
|
1153 echom "GnuPG: " . a:text |
41
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1154 redir END |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1155 else |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1156 echom "GnuPG: " . a:text |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1157 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1158 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1159 endfunction |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1160 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1161 " Section: Commands {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1162 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1163 command! GPGViewRecipients call s:GPGViewRecipients() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1164 command! GPGEditRecipients call s:GPGEditRecipients() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1165 command! GPGViewOptions call s:GPGViewOptions() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1166 command! GPGEditOptions call s:GPGEditOptions() |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1167 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1168 " Section: Menu {{{1 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1169 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1170 if (has("menu")) |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1171 amenu <silent> Plugin.GnuPG.View\ Recipients :GPGViewRecipients<CR> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1172 amenu <silent> Plugin.GnuPG.Edit\ Recipients :GPGEditRecipients<CR> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1173 amenu <silent> Plugin.GnuPG.View\ Options :GPGViewOptions<CR> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1174 amenu <silent> Plugin.GnuPG.Edit\ Options :GPGEditOptions<CR> |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1175 endif |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1176 |
2bea356b1032
* Added default screenrc from Linux (and the Screen installation) to .screenrc
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff
changeset
|
1177 " vim600: set foldmethod=marker foldlevel=0 : |