diff options
| author | Noam Postavsky | 2018-04-30 08:49:11 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-05-23 07:53:57 -0400 |
| commit | 21ab346a07eff8ba43cb2738dc6752f012b77670 (patch) | |
| tree | 649652b71d097f51d0273dff34acba4e98e392e2 | |
| parent | bab73230d1be1fe394b7269c1365ef6fb1a5d9b3 (diff) | |
| download | emacs-21ab346a07eff8ba43cb2738dc6752f012b77670.tar.gz emacs-21ab346a07eff8ba43cb2738dc6752f012b77670.zip | |
Drop some epg/epa backwards compat code for ancient Emacs versions
* lisp/epa.el (epa--select-safe-coding-system): Remove,
`select-safe-coding-system' has been present since Emacs 20.3.
(epa--encode-coding-string, epa--decode-coding-string):
* lisp/epg.el (epg--decode-coding-string, epg--encode-coding-string)
(epg--clear-string): Remove, the corresponding Emacs functions are so
old they don't show up in NEWS. Furthermore, the fallback for
the *-coding-string functions was `identity' which wouldn't have
worked anyway, since it only takes a single argument.
(epg--make-temp-file): Remove, `make-temp-file' has been present since
Emacs 21.1.
* lisp/epg-config.el (epg-gpg-program, epg-gpgsm-program)
(epg-gpgconf-program, epg-gpg-home-directory)
(epg-passphrase-coding-system, epg-debug): Remove unneeded :group
parameter.
| -rw-r--r-- | lisp/epa-mail.el | 4 | ||||
| -rw-r--r-- | lisp/epa.el | 28 | ||||
| -rw-r--r-- | lisp/epg-config.el | 6 | ||||
| -rw-r--r-- | lisp/epg.el | 118 |
4 files changed, 33 insertions, 123 deletions
diff --git a/lisp/epa-mail.el b/lisp/epa-mail.el index c819f6734c7..7f4c28e9670 100644 --- a/lisp/epa-mail.el +++ b/lisp/epa-mail.el | |||
| @@ -95,7 +95,7 @@ The buffer is expected to contain a mail message." | |||
| 95 | (forward-line)) | 95 | (forward-line)) |
| 96 | (setq epa-last-coding-system-specified | 96 | (setq epa-last-coding-system-specified |
| 97 | (or coding-system-for-write | 97 | (or coding-system-for-write |
| 98 | (epa--select-safe-coding-system (point) (point-max)))) | 98 | (select-safe-coding-system (point) (point-max)))) |
| 99 | (let ((verbose current-prefix-arg)) | 99 | (let ((verbose current-prefix-arg)) |
| 100 | (list (point) (point-max) | 100 | (list (point) (point-max) |
| 101 | (if verbose | 101 | (if verbose |
| @@ -222,7 +222,7 @@ If no one is selected, symmetric encryption will be performed. " | |||
| 222 | 222 | ||
| 223 | (setq epa-last-coding-system-specified | 223 | (setq epa-last-coding-system-specified |
| 224 | (or coding-system-for-write | 224 | (or coding-system-for-write |
| 225 | (epa--select-safe-coding-system (point) (point-max))))) | 225 | (select-safe-coding-system (point) (point-max))))) |
| 226 | 226 | ||
| 227 | ;; Don't let some read-only text stop us from encrypting. | 227 | ;; Don't let some read-only text stop us from encrypting. |
| 228 | (let ((inhibit-read-only t)) | 228 | (let ((inhibit-read-only t)) |
diff --git a/lisp/epa.el b/lisp/epa.el index 70f27e272fc..a375cd61707 100644 --- a/lisp/epa.el +++ b/lisp/epa.el | |||
| @@ -307,12 +307,6 @@ You should bind this variable with `let', but do not set it globally.") | |||
| 307 | (epg-sub-key-id (car (epg-key-sub-key-list | 307 | (epg-sub-key-id (car (epg-key-sub-key-list |
| 308 | (widget-get widget :value)))))) | 308 | (widget-get widget :value)))))) |
| 309 | 309 | ||
| 310 | (defalias 'epa--encode-coding-string | ||
| 311 | (if (fboundp 'encode-coding-string) #'encode-coding-string #'identity)) | ||
| 312 | |||
| 313 | (defalias 'epa--decode-coding-string | ||
| 314 | (if (fboundp 'decode-coding-string) #'decode-coding-string #'identity)) | ||
| 315 | |||
| 316 | (define-derived-mode epa-key-list-mode special-mode "Keys" | 310 | (define-derived-mode epa-key-list-mode special-mode "Keys" |
| 317 | "Major mode for `epa-list-keys'." | 311 | "Major mode for `epa-list-keys'." |
| 318 | (buffer-disable-undo) | 312 | (buffer-disable-undo) |
| @@ -879,7 +873,7 @@ For example: | |||
| 879 | (epa-display-error context) | 873 | (epa-display-error context) |
| 880 | (signal (car error) (cdr error)))) | 874 | (signal (car error) (cdr error)))) |
| 881 | (message "Decrypting...done") | 875 | (message "Decrypting...done") |
| 882 | (setq plain (epa--decode-coding-string | 876 | (setq plain (decode-coding-string |
| 883 | plain | 877 | plain |
| 884 | (or coding-system-for-read | 878 | (or coding-system-for-read |
| 885 | (get-text-property start 'epa-coding-system-used) | 879 | (get-text-property start 'epa-coding-system-used) |
| @@ -973,7 +967,7 @@ For example: | |||
| 973 | (condition-case error | 967 | (condition-case error |
| 974 | (setq plain (epg-verify-string | 968 | (setq plain (epg-verify-string |
| 975 | context | 969 | context |
| 976 | (epa--encode-coding-string | 970 | (encode-coding-string |
| 977 | (buffer-substring start end) | 971 | (buffer-substring start end) |
| 978 | (or coding-system-for-write | 972 | (or coding-system-for-write |
| 979 | (get-text-property start 'epa-coding-system-used))))) | 973 | (get-text-property start 'epa-coding-system-used))))) |
| @@ -981,7 +975,7 @@ For example: | |||
| 981 | (epa-display-error context) | 975 | (epa-display-error context) |
| 982 | (signal (car error) (cdr error)))) | 976 | (signal (car error) (cdr error)))) |
| 983 | (message "Verifying...done") | 977 | (message "Verifying...done") |
| 984 | (setq plain (epa--decode-coding-string | 978 | (setq plain (decode-coding-string |
| 985 | plain | 979 | plain |
| 986 | (or coding-system-for-read | 980 | (or coding-system-for-read |
| 987 | (get-text-property start 'epa-coding-system-used) | 981 | (get-text-property start 'epa-coding-system-used) |
| @@ -1029,12 +1023,6 @@ See the reason described in the `epa-verify-region' documentation." | |||
| 1029 | (error "No cleartext tail")) | 1023 | (error "No cleartext tail")) |
| 1030 | (epa-verify-region cleartext-start cleartext-end)))))) | 1024 | (epa-verify-region cleartext-start cleartext-end)))))) |
| 1031 | 1025 | ||
| 1032 | (defalias 'epa--select-safe-coding-system | ||
| 1033 | (if (fboundp 'select-safe-coding-system) | ||
| 1034 | #'select-safe-coding-system | ||
| 1035 | (lambda (_from _to) | ||
| 1036 | buffer-file-coding-system))) | ||
| 1037 | |||
| 1038 | ;;;###autoload | 1026 | ;;;###autoload |
| 1039 | (defun epa-sign-region (start end signers mode) | 1027 | (defun epa-sign-region (start end signers mode) |
| 1040 | "Sign the current region between START and END by SIGNERS keys selected. | 1028 | "Sign the current region between START and END by SIGNERS keys selected. |
| @@ -1057,7 +1045,7 @@ For example: | |||
| 1057 | (let ((verbose current-prefix-arg)) | 1045 | (let ((verbose current-prefix-arg)) |
| 1058 | (setq epa-last-coding-system-specified | 1046 | (setq epa-last-coding-system-specified |
| 1059 | (or coding-system-for-write | 1047 | (or coding-system-for-write |
| 1060 | (epa--select-safe-coding-system | 1048 | (select-safe-coding-system |
| 1061 | (region-beginning) (region-end)))) | 1049 | (region-beginning) (region-end)))) |
| 1062 | (list (region-beginning) (region-end) | 1050 | (list (region-beginning) (region-end) |
| 1063 | (if verbose | 1051 | (if verbose |
| @@ -1086,7 +1074,7 @@ If no one is selected, default secret key is used. " | |||
| 1086 | (message "Signing...") | 1074 | (message "Signing...") |
| 1087 | (condition-case error | 1075 | (condition-case error |
| 1088 | (setq signature (epg-sign-string context | 1076 | (setq signature (epg-sign-string context |
| 1089 | (epa--encode-coding-string | 1077 | (encode-coding-string |
| 1090 | (buffer-substring start end) | 1078 | (buffer-substring start end) |
| 1091 | epa-last-coding-system-specified) | 1079 | epa-last-coding-system-specified) |
| 1092 | mode)) | 1080 | mode)) |
| @@ -1098,7 +1086,7 @@ If no one is selected, default secret key is used. " | |||
| 1098 | (goto-char start) | 1086 | (goto-char start) |
| 1099 | (add-text-properties (point) | 1087 | (add-text-properties (point) |
| 1100 | (progn | 1088 | (progn |
| 1101 | (insert (epa--decode-coding-string | 1089 | (insert (decode-coding-string |
| 1102 | signature | 1090 | signature |
| 1103 | (or coding-system-for-read | 1091 | (or coding-system-for-read |
| 1104 | epa-last-coding-system-specified))) | 1092 | epa-last-coding-system-specified))) |
| @@ -1146,7 +1134,7 @@ For example: | |||
| 1146 | sign) | 1134 | sign) |
| 1147 | (setq epa-last-coding-system-specified | 1135 | (setq epa-last-coding-system-specified |
| 1148 | (or coding-system-for-write | 1136 | (or coding-system-for-write |
| 1149 | (epa--select-safe-coding-system | 1137 | (select-safe-coding-system |
| 1150 | (region-beginning) (region-end)))) | 1138 | (region-beginning) (region-end)))) |
| 1151 | (list (region-beginning) (region-end) | 1139 | (list (region-beginning) (region-end) |
| 1152 | (epa-select-keys context | 1140 | (epa-select-keys context |
| @@ -1175,7 +1163,7 @@ If no one is selected, symmetric encryption will be performed. ") | |||
| 1175 | (message "Encrypting...") | 1163 | (message "Encrypting...") |
| 1176 | (condition-case error | 1164 | (condition-case error |
| 1177 | (setq cipher (epg-encrypt-string context | 1165 | (setq cipher (epg-encrypt-string context |
| 1178 | (epa--encode-coding-string | 1166 | (encode-coding-string |
| 1179 | (buffer-substring start end) | 1167 | (buffer-substring start end) |
| 1180 | epa-last-coding-system-specified) | 1168 | epa-last-coding-system-specified) |
| 1181 | recipients | 1169 | recipients |
diff --git a/lisp/epg-config.el b/lisp/epg-config.el index d30ebea2d66..bf9360cdb4f 100644 --- a/lisp/epg-config.el +++ b/lisp/epg-config.el | |||
| @@ -48,36 +48,30 @@ | |||
| 48 | Setting this variable directly does not take effect; | 48 | Setting this variable directly does not take effect; |
| 49 | instead use \\[customize] (see the info node `Easy Customization')." | 49 | instead use \\[customize] (see the info node `Easy Customization')." |
| 50 | :version "25.1" | 50 | :version "25.1" |
| 51 | :group 'epg | ||
| 52 | :type 'string) | 51 | :type 'string) |
| 53 | 52 | ||
| 54 | (defcustom epg-gpgsm-program "gpgsm" | 53 | (defcustom epg-gpgsm-program "gpgsm" |
| 55 | "The `gpgsm' executable. | 54 | "The `gpgsm' executable. |
| 56 | Setting this variable directly does not take effect; | 55 | Setting this variable directly does not take effect; |
| 57 | instead use \\[customize] (see the info node `Easy Customization')." | 56 | instead use \\[customize] (see the info node `Easy Customization')." |
| 58 | :group 'epg | ||
| 59 | :type 'string) | 57 | :type 'string) |
| 60 | 58 | ||
| 61 | (defcustom epg-gpgconf-program "gpgconf" | 59 | (defcustom epg-gpgconf-program "gpgconf" |
| 62 | "The `gpgconf' executable." | 60 | "The `gpgconf' executable." |
| 63 | :version "25.1" | 61 | :version "25.1" |
| 64 | :group 'epg | ||
| 65 | :type 'string) | 62 | :type 'string) |
| 66 | 63 | ||
| 67 | (defcustom epg-gpg-home-directory nil | 64 | (defcustom epg-gpg-home-directory nil |
| 68 | "The directory which contains the configuration files of `epg-gpg-program'." | 65 | "The directory which contains the configuration files of `epg-gpg-program'." |
| 69 | :group 'epg | ||
| 70 | :type '(choice (const :tag "Default" nil) directory)) | 66 | :type '(choice (const :tag "Default" nil) directory)) |
| 71 | 67 | ||
| 72 | (defcustom epg-passphrase-coding-system nil | 68 | (defcustom epg-passphrase-coding-system nil |
| 73 | "Coding system to use with messages from `epg-gpg-program'." | 69 | "Coding system to use with messages from `epg-gpg-program'." |
| 74 | :group 'epg | ||
| 75 | :type 'symbol) | 70 | :type 'symbol) |
| 76 | 71 | ||
| 77 | (defcustom epg-debug nil | 72 | (defcustom epg-debug nil |
| 78 | "If non-nil, debug output goes to the \" *epg-debug*\" buffer. | 73 | "If non-nil, debug output goes to the \" *epg-debug*\" buffer. |
| 79 | Note that the buffer name starts with a space." | 74 | Note that the buffer name starts with a space." |
| 80 | :group 'epg | ||
| 81 | :type 'boolean) | 75 | :type 'boolean) |
| 82 | 76 | ||
| 83 | (defconst epg-gpg-minimum-version "1.4.3") | 77 | (defconst epg-gpg-minimum-version "1.4.3") |
diff --git a/lisp/epg.el b/lisp/epg.el index 091021936ad..e6b4af2b36e 100644 --- a/lisp/epg.el +++ b/lisp/epg.el | |||
| @@ -760,18 +760,13 @@ callback data (if any)." | |||
| 760 | (file-exists-p (epg-context-output-file context))) | 760 | (file-exists-p (epg-context-output-file context))) |
| 761 | (delete-file (epg-context-output-file context)))) | 761 | (delete-file (epg-context-output-file context)))) |
| 762 | 762 | ||
| 763 | (eval-and-compile | ||
| 764 | (if (fboundp 'decode-coding-string) | ||
| 765 | (defalias 'epg--decode-coding-string 'decode-coding-string) | ||
| 766 | (defalias 'epg--decode-coding-string 'identity))) | ||
| 767 | |||
| 768 | (defun epg--status-USERID_HINT (_context string) | 763 | (defun epg--status-USERID_HINT (_context string) |
| 769 | (if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string) | 764 | (if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string) |
| 770 | (let* ((key-id (match-string 1 string)) | 765 | (let* ((key-id (match-string 1 string)) |
| 771 | (user-id (match-string 2 string)) | 766 | (user-id (match-string 2 string)) |
| 772 | (entry (assoc key-id epg-user-id-alist))) | 767 | (entry (assoc key-id epg-user-id-alist))) |
| 773 | (condition-case nil | 768 | (condition-case nil |
| 774 | (setq user-id (epg--decode-coding-string | 769 | (setq user-id (decode-coding-string |
| 775 | (epg--decode-percent-escape user-id) | 770 | (epg--decode-percent-escape user-id) |
| 776 | 'utf-8)) | 771 | 'utf-8)) |
| 777 | (error)) | 772 | (error)) |
| @@ -790,17 +785,6 @@ callback data (if any)." | |||
| 790 | (defun epg--status-NEED_PASSPHRASE_PIN (_context _string) | 785 | (defun epg--status-NEED_PASSPHRASE_PIN (_context _string) |
| 791 | (setq epg-key-id 'PIN)) | 786 | (setq epg-key-id 'PIN)) |
| 792 | 787 | ||
| 793 | (eval-and-compile | ||
| 794 | (if (fboundp 'clear-string) | ||
| 795 | (defalias 'epg--clear-string 'clear-string) | ||
| 796 | (defun epg--clear-string (string) | ||
| 797 | (fillarray string 0)))) | ||
| 798 | |||
| 799 | (eval-and-compile | ||
| 800 | (if (fboundp 'encode-coding-string) | ||
| 801 | (defalias 'epg--encode-coding-string 'encode-coding-string) | ||
| 802 | (defalias 'epg--encode-coding-string 'identity))) | ||
| 803 | |||
| 804 | (defun epg--status-GET_HIDDEN (context string) | 788 | (defun epg--status-GET_HIDDEN (context string) |
| 805 | (when (and epg-key-id | 789 | (when (and epg-key-id |
| 806 | (string-match "\\`passphrase\\." string)) | 790 | (string-match "\\`passphrase\\." string)) |
| @@ -821,16 +805,16 @@ callback data (if any)." | |||
| 821 | (cdr (epg-context-passphrase-callback context)))) | 805 | (cdr (epg-context-passphrase-callback context)))) |
| 822 | (when passphrase | 806 | (when passphrase |
| 823 | (setq passphrase-with-new-line (concat passphrase "\n")) | 807 | (setq passphrase-with-new-line (concat passphrase "\n")) |
| 824 | (epg--clear-string passphrase) | 808 | (clear-string passphrase) |
| 825 | (setq passphrase nil) | 809 | (setq passphrase nil) |
| 826 | (if epg-passphrase-coding-system | 810 | (if epg-passphrase-coding-system |
| 827 | (progn | 811 | (progn |
| 828 | (setq encoded-passphrase-with-new-line | 812 | (setq encoded-passphrase-with-new-line |
| 829 | (epg--encode-coding-string | 813 | (encode-coding-string |
| 830 | passphrase-with-new-line | 814 | passphrase-with-new-line |
| 831 | (coding-system-change-eol-conversion | 815 | (coding-system-change-eol-conversion |
| 832 | epg-passphrase-coding-system 'unix))) | 816 | epg-passphrase-coding-system 'unix))) |
| 833 | (epg--clear-string passphrase-with-new-line) | 817 | (clear-string passphrase-with-new-line) |
| 834 | (setq passphrase-with-new-line nil)) | 818 | (setq passphrase-with-new-line nil)) |
| 835 | (setq encoded-passphrase-with-new-line | 819 | (setq encoded-passphrase-with-new-line |
| 836 | passphrase-with-new-line | 820 | passphrase-with-new-line |
| @@ -844,11 +828,11 @@ callback data (if any)." | |||
| 844 | (epg-context-result-for context 'error))) | 828 | (epg-context-result-for context 'error))) |
| 845 | (delete-process (epg-context-process context)))) | 829 | (delete-process (epg-context-process context)))) |
| 846 | (if passphrase | 830 | (if passphrase |
| 847 | (epg--clear-string passphrase)) | 831 | (clear-string passphrase)) |
| 848 | (if passphrase-with-new-line | 832 | (if passphrase-with-new-line |
| 849 | (epg--clear-string passphrase-with-new-line)) | 833 | (clear-string passphrase-with-new-line)) |
| 850 | (if encoded-passphrase-with-new-line | 834 | (if encoded-passphrase-with-new-line |
| 851 | (epg--clear-string encoded-passphrase-with-new-line)))))) | 835 | (clear-string encoded-passphrase-with-new-line)))))) |
| 852 | 836 | ||
| 853 | (defun epg--prompt-GET_BOOL (_context string) | 837 | (defun epg--prompt-GET_BOOL (_context string) |
| 854 | (let ((entry (assoc string epg-prompt-alist))) | 838 | (let ((entry (assoc string epg-prompt-alist))) |
| @@ -911,7 +895,7 @@ callback data (if any)." | |||
| 911 | (condition-case nil | 895 | (condition-case nil |
| 912 | (if (eq (epg-context-protocol context) 'CMS) | 896 | (if (eq (epg-context-protocol context) 'CMS) |
| 913 | (setq user-id (epg-dn-from-string user-id)) | 897 | (setq user-id (epg-dn-from-string user-id)) |
| 914 | (setq user-id (epg--decode-coding-string | 898 | (setq user-id (decode-coding-string |
| 915 | (epg--decode-percent-escape user-id) | 899 | (epg--decode-percent-escape user-id) |
| 916 | 'utf-8))) | 900 | 'utf-8))) |
| 917 | (error)) | 901 | (error)) |
| @@ -1192,7 +1176,7 @@ callback data (if any)." | |||
| 1192 | (user-id (match-string 2 string)) | 1176 | (user-id (match-string 2 string)) |
| 1193 | (entry (assoc key-id epg-user-id-alist))) | 1177 | (entry (assoc key-id epg-user-id-alist))) |
| 1194 | (condition-case nil | 1178 | (condition-case nil |
| 1195 | (setq user-id (epg--decode-coding-string | 1179 | (setq user-id (decode-coding-string |
| 1196 | (epg--decode-percent-escape user-id) | 1180 | (epg--decode-percent-escape user-id) |
| 1197 | 'utf-8)) | 1181 | 'utf-8)) |
| 1198 | (error)) | 1182 | (error)) |
| @@ -1349,7 +1333,7 @@ NAME is either a string or a list of strings." | |||
| 1349 | (setq string (replace-match "\\\"" t t string) | 1333 | (setq string (replace-match "\\\"" t t string) |
| 1350 | index (1+ (match-end 0)))) | 1334 | index (1+ (match-end 0)))) |
| 1351 | (condition-case nil | 1335 | (condition-case nil |
| 1352 | (setq string (epg--decode-coding-string | 1336 | (setq string (decode-coding-string |
| 1353 | (car (read-from-string (concat "\"" string "\""))) | 1337 | (car (read-from-string (concat "\"" string "\""))) |
| 1354 | 'utf-8)) | 1338 | 'utf-8)) |
| 1355 | (error | 1339 | (error |
| @@ -1394,62 +1378,6 @@ NAME is either a string or a list of strings." | |||
| 1394 | (setq pointer (cdr pointer))) | 1378 | (setq pointer (cdr pointer))) |
| 1395 | keys)) | 1379 | keys)) |
| 1396 | 1380 | ||
| 1397 | (eval-and-compile | ||
| 1398 | (if (fboundp 'make-temp-file) | ||
| 1399 | (defalias 'epg--make-temp-file 'make-temp-file) | ||
| 1400 | (defvar temporary-file-directory) | ||
| 1401 | ;; stolen from poe.el. | ||
| 1402 | (defun epg--make-temp-file (prefix) | ||
| 1403 | "Create a temporary file. | ||
| 1404 | The returned file name (created by appending some random characters at the end | ||
| 1405 | of PREFIX, and expanding against `temporary-file-directory' if necessary), | ||
| 1406 | is guaranteed to point to a newly created empty file. | ||
| 1407 | You can then use `write-region' to write new data into the file." | ||
| 1408 | (let ((orig-modes (default-file-modes)) | ||
| 1409 | tempdir tempfile) | ||
| 1410 | (setq prefix (expand-file-name prefix | ||
| 1411 | (if (featurep 'xemacs) | ||
| 1412 | (temp-directory) | ||
| 1413 | temporary-file-directory))) | ||
| 1414 | (unwind-protect | ||
| 1415 | (let (file) | ||
| 1416 | ;; First, create a temporary directory. | ||
| 1417 | (set-default-file-modes #o700) | ||
| 1418 | (while (condition-case () | ||
| 1419 | (progn | ||
| 1420 | (setq tempdir (make-temp-name | ||
| 1421 | (concat | ||
| 1422 | (file-name-directory prefix) | ||
| 1423 | "DIR"))) | ||
| 1424 | ;; return nil or signal an error. | ||
| 1425 | (make-directory tempdir)) | ||
| 1426 | ;; let's try again. | ||
| 1427 | (file-already-exists t))) | ||
| 1428 | ;; Second, create a temporary file in the tempdir. | ||
| 1429 | ;; There *is* a race condition between `make-temp-name' | ||
| 1430 | ;; and `write-region', but we don't care it since we are | ||
| 1431 | ;; in a private directory now. | ||
| 1432 | (setq tempfile (make-temp-name (concat tempdir "/EMU"))) | ||
| 1433 | (write-region "" nil tempfile nil 'silent) | ||
| 1434 | ;; Finally, make a hard-link from the tempfile. | ||
| 1435 | (while (condition-case () | ||
| 1436 | (progn | ||
| 1437 | (setq file (make-temp-name prefix)) | ||
| 1438 | ;; return nil or signal an error. | ||
| 1439 | (add-name-to-file tempfile file)) | ||
| 1440 | ;; let's try again. | ||
| 1441 | (file-already-exists t))) | ||
| 1442 | file) | ||
| 1443 | (set-default-file-modes orig-modes) | ||
| 1444 | ;; Cleanup the tempfile. | ||
| 1445 | (and tempfile | ||
| 1446 | (file-exists-p tempfile) | ||
| 1447 | (delete-file tempfile)) | ||
| 1448 | ;; Cleanup the tempdir. | ||
| 1449 | (and tempdir | ||
| 1450 | (file-directory-p tempdir) | ||
| 1451 | (delete-directory tempdir))))))) | ||
| 1452 | |||
| 1453 | (defun epg--args-from-sig-notations (notations) | 1381 | (defun epg--args-from-sig-notations (notations) |
| 1454 | (apply #'nconc | 1382 | (apply #'nconc |
| 1455 | (mapcar | 1383 | (mapcar |
| @@ -1513,7 +1441,7 @@ If PLAIN is nil, it returns the result as a string." | |||
| 1513 | (unwind-protect | 1441 | (unwind-protect |
| 1514 | (progn | 1442 | (progn |
| 1515 | (setf (epg-context-output-file context) | 1443 | (setf (epg-context-output-file context) |
| 1516 | (or plain (epg--make-temp-file "epg-output"))) | 1444 | (or plain (make-temp-file "epg-output"))) |
| 1517 | (epg-start-decrypt context (epg-make-data-from-file cipher)) | 1445 | (epg-start-decrypt context (epg-make-data-from-file cipher)) |
| 1518 | (epg-wait-for-completion context) | 1446 | (epg-wait-for-completion context) |
| 1519 | (epg--check-error-for-decrypt context) | 1447 | (epg--check-error-for-decrypt context) |
| @@ -1525,13 +1453,13 @@ If PLAIN is nil, it returns the result as a string." | |||
| 1525 | 1453 | ||
| 1526 | (defun epg-decrypt-string (context cipher) | 1454 | (defun epg-decrypt-string (context cipher) |
| 1527 | "Decrypt a string CIPHER and return the plain text." | 1455 | "Decrypt a string CIPHER and return the plain text." |
| 1528 | (let ((input-file (epg--make-temp-file "epg-input")) | 1456 | (let ((input-file (make-temp-file "epg-input")) |
| 1529 | (coding-system-for-write 'binary)) | 1457 | (coding-system-for-write 'binary)) |
| 1530 | (unwind-protect | 1458 | (unwind-protect |
| 1531 | (progn | 1459 | (progn |
| 1532 | (write-region cipher nil input-file nil 'quiet) | 1460 | (write-region cipher nil input-file nil 'quiet) |
| 1533 | (setf (epg-context-output-file context) | 1461 | (setf (epg-context-output-file context) |
| 1534 | (epg--make-temp-file "epg-output")) | 1462 | (make-temp-file "epg-output")) |
| 1535 | (epg-start-decrypt context (epg-make-data-from-file input-file)) | 1463 | (epg-start-decrypt context (epg-make-data-from-file input-file)) |
| 1536 | (epg-wait-for-completion context) | 1464 | (epg-wait-for-completion context) |
| 1537 | (epg--check-error-for-decrypt context) | 1465 | (epg--check-error-for-decrypt context) |
| @@ -1602,7 +1530,7 @@ which will return a list of `epg-signature' object." | |||
| 1602 | (unwind-protect | 1530 | (unwind-protect |
| 1603 | (progn | 1531 | (progn |
| 1604 | (setf (epg-context-output-file context) | 1532 | (setf (epg-context-output-file context) |
| 1605 | (or plain (epg--make-temp-file "epg-output"))) | 1533 | (or plain (make-temp-file "epg-output"))) |
| 1606 | (if signed-text | 1534 | (if signed-text |
| 1607 | (epg-start-verify context | 1535 | (epg-start-verify context |
| 1608 | (epg-make-data-from-file signature) | 1536 | (epg-make-data-from-file signature) |
| @@ -1639,10 +1567,10 @@ which will return a list of `epg-signature' object." | |||
| 1639 | (unwind-protect | 1567 | (unwind-protect |
| 1640 | (progn | 1568 | (progn |
| 1641 | (setf (epg-context-output-file context) | 1569 | (setf (epg-context-output-file context) |
| 1642 | (epg--make-temp-file "epg-output")) | 1570 | (make-temp-file "epg-output")) |
| 1643 | (if signed-text | 1571 | (if signed-text |
| 1644 | (progn | 1572 | (progn |
| 1645 | (setq input-file (epg--make-temp-file "epg-signature")) | 1573 | (setq input-file (make-temp-file "epg-signature")) |
| 1646 | (write-region signature nil input-file nil 'quiet) | 1574 | (write-region signature nil input-file nil 'quiet) |
| 1647 | (epg-start-verify context | 1575 | (epg-start-verify context |
| 1648 | (epg-make-data-from-file input-file) | 1576 | (epg-make-data-from-file input-file) |
| @@ -1710,7 +1638,7 @@ Otherwise, it makes a cleartext signature." | |||
| 1710 | (unwind-protect | 1638 | (unwind-protect |
| 1711 | (progn | 1639 | (progn |
| 1712 | (setf (epg-context-output-file context) | 1640 | (setf (epg-context-output-file context) |
| 1713 | (or signature (epg--make-temp-file "epg-output"))) | 1641 | (or signature (make-temp-file "epg-output"))) |
| 1714 | (epg-start-sign context (epg-make-data-from-file plain) mode) | 1642 | (epg-start-sign context (epg-make-data-from-file plain) mode) |
| 1715 | (epg-wait-for-completion context) | 1643 | (epg-wait-for-completion context) |
| 1716 | (unless (epg-context-result-for context 'sign) | 1644 | (unless (epg-context-result-for context 'sign) |
| @@ -1730,12 +1658,12 @@ If it is nil or `normal', it makes a normal signature. | |||
| 1730 | Otherwise, it makes a cleartext signature." | 1658 | Otherwise, it makes a cleartext signature." |
| 1731 | (let ((input-file | 1659 | (let ((input-file |
| 1732 | (unless (eq (epg-context-protocol context) 'CMS) | 1660 | (unless (eq (epg-context-protocol context) 'CMS) |
| 1733 | (epg--make-temp-file "epg-input"))) | 1661 | (make-temp-file "epg-input"))) |
| 1734 | (coding-system-for-write 'binary)) | 1662 | (coding-system-for-write 'binary)) |
| 1735 | (unwind-protect | 1663 | (unwind-protect |
| 1736 | (progn | 1664 | (progn |
| 1737 | (setf (epg-context-output-file context) | 1665 | (setf (epg-context-output-file context) |
| 1738 | (epg--make-temp-file "epg-output")) | 1666 | (make-temp-file "epg-output")) |
| 1739 | (if input-file | 1667 | (if input-file |
| 1740 | (write-region plain nil input-file nil 'quiet)) | 1668 | (write-region plain nil input-file nil 'quiet)) |
| 1741 | (epg-start-sign context | 1669 | (epg-start-sign context |
| @@ -1812,7 +1740,7 @@ If RECIPIENTS is nil, it performs symmetric encryption." | |||
| 1812 | (unwind-protect | 1740 | (unwind-protect |
| 1813 | (progn | 1741 | (progn |
| 1814 | (setf (epg-context-output-file context) | 1742 | (setf (epg-context-output-file context) |
| 1815 | (or cipher (epg--make-temp-file "epg-output"))) | 1743 | (or cipher (make-temp-file "epg-output"))) |
| 1816 | (epg-start-encrypt context (epg-make-data-from-file plain) | 1744 | (epg-start-encrypt context (epg-make-data-from-file plain) |
| 1817 | recipients sign always-trust) | 1745 | recipients sign always-trust) |
| 1818 | (epg-wait-for-completion context) | 1746 | (epg-wait-for-completion context) |
| @@ -1837,12 +1765,12 @@ If RECIPIENTS is nil, it performs symmetric encryption." | |||
| 1837 | (let ((input-file | 1765 | (let ((input-file |
| 1838 | (unless (or (not sign) | 1766 | (unless (or (not sign) |
| 1839 | (eq (epg-context-protocol context) 'CMS)) | 1767 | (eq (epg-context-protocol context) 'CMS)) |
| 1840 | (epg--make-temp-file "epg-input"))) | 1768 | (make-temp-file "epg-input"))) |
| 1841 | (coding-system-for-write 'binary)) | 1769 | (coding-system-for-write 'binary)) |
| 1842 | (unwind-protect | 1770 | (unwind-protect |
| 1843 | (progn | 1771 | (progn |
| 1844 | (setf (epg-context-output-file context) | 1772 | (setf (epg-context-output-file context) |
| 1845 | (epg--make-temp-file "epg-output")) | 1773 | (make-temp-file "epg-output")) |
| 1846 | (if input-file | 1774 | (if input-file |
| 1847 | (write-region plain nil input-file nil 'quiet)) | 1775 | (write-region plain nil input-file nil 'quiet)) |
| 1848 | (epg-start-encrypt context | 1776 | (epg-start-encrypt context |
| @@ -1887,7 +1815,7 @@ If you are unsure, use synchronous version of this function | |||
| 1887 | (unwind-protect | 1815 | (unwind-protect |
| 1888 | (progn | 1816 | (progn |
| 1889 | (setf (epg-context-output-file context) | 1817 | (setf (epg-context-output-file context) |
| 1890 | (or file (epg--make-temp-file "epg-output"))) | 1818 | (or file (make-temp-file "epg-output"))) |
| 1891 | (epg-start-export-keys context keys) | 1819 | (epg-start-export-keys context keys) |
| 1892 | (epg-wait-for-completion context) | 1820 | (epg-wait-for-completion context) |
| 1893 | (let ((errors (epg-context-result-for context 'error))) | 1821 | (let ((errors (epg-context-result-for context 'error))) |