summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2018-04-30 08:49:11 -0400
committerNoam Postavsky <npostavs@gmail.com>2018-05-23 07:53:57 -0400
commit21ab346a07eff8ba43cb2738dc6752f012b77670 (patch)
tree649652b71d097f51d0273dff34acba4e98e392e2 /lisp
parentbab73230d1be1fe394b7269c1365ef6fb1a5d9b3 (diff)
downloademacs-21ab346a07eff8ba43cb2738dc6752f012b77670.tar.gz
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/epa-mail.el4
-rw-r--r--lisp/epa.el28
-rw-r--r--lisp/epg-config.el6
-rw-r--r--lisp/epg.el118
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."
(forward-line))
(setq epa-last-coding-system-specified
(or coding-system-for-write
- (epa--select-safe-coding-system (point) (point-max))))
+ (select-safe-coding-system (point) (point-max))))
(let ((verbose current-prefix-arg))
(list (point) (point-max)
(if verbose
@@ -222,7 +222,7 @@ If no one is selected, symmetric encryption will be performed. "
(setq epa-last-coding-system-specified
(or coding-system-for-write
- (epa--select-safe-coding-system (point) (point-max)))))
+ (select-safe-coding-system (point) (point-max)))))
;; Don't let some read-only text stop us from encrypting.
(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.")
(epg-sub-key-id (car (epg-key-sub-key-list
(widget-get widget :value))))))
-(defalias 'epa--encode-coding-string
- (if (fboundp 'encode-coding-string) #'encode-coding-string #'identity))
-
-(defalias 'epa--decode-coding-string
- (if (fboundp 'decode-coding-string) #'decode-coding-string #'identity))
-
(define-derived-mode epa-key-list-mode special-mode "Keys"
"Major mode for `epa-list-keys'."
(buffer-disable-undo)
@@ -879,7 +873,7 @@ For example:
(epa-display-error context)
(signal (car error) (cdr error))))
(message "Decrypting...done")
- (setq plain (epa--decode-coding-string
+ (setq plain (decode-coding-string
plain
(or coding-system-for-read
(get-text-property start 'epa-coding-system-used)
@@ -973,7 +967,7 @@ For example:
(condition-case error
(setq plain (epg-verify-string
context
- (epa--encode-coding-string
+ (encode-coding-string
(buffer-substring start end)
(or coding-system-for-write
(get-text-property start 'epa-coding-system-used)))))
@@ -981,7 +975,7 @@ For example:
(epa-display-error context)
(signal (car error) (cdr error))))
(message "Verifying...done")
- (setq plain (epa--decode-coding-string
+ (setq plain (decode-coding-string
plain
(or coding-system-for-read
(get-text-property start 'epa-coding-system-used)
@@ -1029,12 +1023,6 @@ See the reason described in the `epa-verify-region' documentation."
(error "No cleartext tail"))
(epa-verify-region cleartext-start cleartext-end))))))
-(defalias 'epa--select-safe-coding-system
- (if (fboundp 'select-safe-coding-system)
- #'select-safe-coding-system
- (lambda (_from _to)
- buffer-file-coding-system)))
-
;;;###autoload
(defun epa-sign-region (start end signers mode)
"Sign the current region between START and END by SIGNERS keys selected.
@@ -1057,7 +1045,7 @@ For example:
(let ((verbose current-prefix-arg))
(setq epa-last-coding-system-specified
(or coding-system-for-write
- (epa--select-safe-coding-system
+ (select-safe-coding-system
(region-beginning) (region-end))))
(list (region-beginning) (region-end)
(if verbose
@@ -1086,7 +1074,7 @@ If no one is selected, default secret key is used. "
(message "Signing...")
(condition-case error
(setq signature (epg-sign-string context
- (epa--encode-coding-string
+ (encode-coding-string
(buffer-substring start end)
epa-last-coding-system-specified)
mode))
@@ -1098,7 +1086,7 @@ If no one is selected, default secret key is used. "
(goto-char start)
(add-text-properties (point)
(progn
- (insert (epa--decode-coding-string
+ (insert (decode-coding-string
signature
(or coding-system-for-read
epa-last-coding-system-specified)))
@@ -1146,7 +1134,7 @@ For example:
sign)
(setq epa-last-coding-system-specified
(or coding-system-for-write
- (epa--select-safe-coding-system
+ (select-safe-coding-system
(region-beginning) (region-end))))
(list (region-beginning) (region-end)
(epa-select-keys context
@@ -1175,7 +1163,7 @@ If no one is selected, symmetric encryption will be performed. ")
(message "Encrypting...")
(condition-case error
(setq cipher (epg-encrypt-string context
- (epa--encode-coding-string
+ (encode-coding-string
(buffer-substring start end)
epa-last-coding-system-specified)
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 @@
Setting this variable directly does not take effect;
instead use \\[customize] (see the info node `Easy Customization')."
:version "25.1"
- :group 'epg
:type 'string)
(defcustom epg-gpgsm-program "gpgsm"
"The `gpgsm' executable.
Setting this variable directly does not take effect;
instead use \\[customize] (see the info node `Easy Customization')."
- :group 'epg
:type 'string)
(defcustom epg-gpgconf-program "gpgconf"
"The `gpgconf' executable."
:version "25.1"
- :group 'epg
:type 'string)
(defcustom epg-gpg-home-directory nil
"The directory which contains the configuration files of `epg-gpg-program'."
- :group 'epg
:type '(choice (const :tag "Default" nil) directory))
(defcustom epg-passphrase-coding-system nil
"Coding system to use with messages from `epg-gpg-program'."
- :group 'epg
:type 'symbol)
(defcustom epg-debug nil
"If non-nil, debug output goes to the \" *epg-debug*\" buffer.
Note that the buffer name starts with a space."
- :group 'epg
:type 'boolean)
(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)."
(file-exists-p (epg-context-output-file context)))
(delete-file (epg-context-output-file context))))
-(eval-and-compile
- (if (fboundp 'decode-coding-string)
- (defalias 'epg--decode-coding-string 'decode-coding-string)
- (defalias 'epg--decode-coding-string 'identity)))
-
(defun epg--status-USERID_HINT (_context string)
(if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string)
(let* ((key-id (match-string 1 string))
(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8))
(error))
@@ -790,17 +785,6 @@ callback data (if any)."
(defun epg--status-NEED_PASSPHRASE_PIN (_context _string)
(setq epg-key-id 'PIN))
-(eval-and-compile
- (if (fboundp 'clear-string)
- (defalias 'epg--clear-string 'clear-string)
- (defun epg--clear-string (string)
- (fillarray string 0))))
-
-(eval-and-compile
- (if (fboundp 'encode-coding-string)
- (defalias 'epg--encode-coding-string 'encode-coding-string)
- (defalias 'epg--encode-coding-string 'identity)))
-
(defun epg--status-GET_HIDDEN (context string)
(when (and epg-key-id
(string-match "\\`passphrase\\." string))
@@ -821,16 +805,16 @@ callback data (if any)."
(cdr (epg-context-passphrase-callback context))))
(when passphrase
(setq passphrase-with-new-line (concat passphrase "\n"))
- (epg--clear-string passphrase)
+ (clear-string passphrase)
(setq passphrase nil)
(if epg-passphrase-coding-system
(progn
(setq encoded-passphrase-with-new-line
- (epg--encode-coding-string
+ (encode-coding-string
passphrase-with-new-line
(coding-system-change-eol-conversion
epg-passphrase-coding-system 'unix)))
- (epg--clear-string passphrase-with-new-line)
+ (clear-string passphrase-with-new-line)
(setq passphrase-with-new-line nil))
(setq encoded-passphrase-with-new-line
passphrase-with-new-line
@@ -844,11 +828,11 @@ callback data (if any)."
(epg-context-result-for context 'error)))
(delete-process (epg-context-process context))))
(if passphrase
- (epg--clear-string passphrase))
+ (clear-string passphrase))
(if passphrase-with-new-line
- (epg--clear-string passphrase-with-new-line))
+ (clear-string passphrase-with-new-line))
(if encoded-passphrase-with-new-line
- (epg--clear-string encoded-passphrase-with-new-line))))))
+ (clear-string encoded-passphrase-with-new-line))))))
(defun epg--prompt-GET_BOOL (_context string)
(let ((entry (assoc string epg-prompt-alist)))
@@ -911,7 +895,7 @@ callback data (if any)."
(condition-case nil
(if (eq (epg-context-protocol context) 'CMS)
(setq user-id (epg-dn-from-string user-id))
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8)))
(error))
@@ -1192,7 +1176,7 @@ callback data (if any)."
(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string
+ (setq user-id (decode-coding-string
(epg--decode-percent-escape user-id)
'utf-8))
(error))
@@ -1349,7 +1333,7 @@ NAME is either a string or a list of strings."
(setq string (replace-match "\\\"" t t string)
index (1+ (match-end 0))))
(condition-case nil
- (setq string (epg--decode-coding-string
+ (setq string (decode-coding-string
(car (read-from-string (concat "\"" string "\"")))
'utf-8))
(error
@@ -1394,62 +1378,6 @@ NAME is either a string or a list of strings."
(setq pointer (cdr pointer)))
keys))
-(eval-and-compile
- (if (fboundp 'make-temp-file)
- (defalias 'epg--make-temp-file 'make-temp-file)
- (defvar temporary-file-directory)
- ;; stolen from poe.el.
- (defun epg--make-temp-file (prefix)
- "Create a temporary file.
-The returned file name (created by appending some random characters at the end
-of PREFIX, and expanding against `temporary-file-directory' if necessary),
-is guaranteed to point to a newly created empty file.
-You can then use `write-region' to write new data into the file."
- (let ((orig-modes (default-file-modes))
- tempdir tempfile)
- (setq prefix (expand-file-name prefix
- (if (featurep 'xemacs)
- (temp-directory)
- temporary-file-directory)))
- (unwind-protect
- (let (file)
- ;; First, create a temporary directory.
- (set-default-file-modes #o700)
- (while (condition-case ()
- (progn
- (setq tempdir (make-temp-name
- (concat
- (file-name-directory prefix)
- "DIR")))
- ;; return nil or signal an error.
- (make-directory tempdir))
- ;; let's try again.
- (file-already-exists t)))
- ;; Second, create a temporary file in the tempdir.
- ;; There *is* a race condition between `make-temp-name'
- ;; and `write-region', but we don't care it since we are
- ;; in a private directory now.
- (setq tempfile (make-temp-name (concat tempdir "/EMU")))
- (write-region "" nil tempfile nil 'silent)
- ;; Finally, make a hard-link from the tempfile.
- (while (condition-case ()
- (progn
- (setq file (make-temp-name prefix))
- ;; return nil or signal an error.
- (add-name-to-file tempfile file))
- ;; let's try again.
- (file-already-exists t)))
- file)
- (set-default-file-modes orig-modes)
- ;; Cleanup the tempfile.
- (and tempfile
- (file-exists-p tempfile)
- (delete-file tempfile))
- ;; Cleanup the tempdir.
- (and tempdir
- (file-directory-p tempdir)
- (delete-directory tempdir)))))))
-
(defun epg--args-from-sig-notations (notations)
(apply #'nconc
(mapcar
@@ -1513,7 +1441,7 @@ If PLAIN is nil, it returns the result as a string."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or plain (epg--make-temp-file "epg-output")))
+ (or plain (make-temp-file "epg-output")))
(epg-start-decrypt context (epg-make-data-from-file cipher))
(epg-wait-for-completion context)
(epg--check-error-for-decrypt context)
@@ -1525,13 +1453,13 @@ If PLAIN is nil, it returns the result as a string."
(defun epg-decrypt-string (context cipher)
"Decrypt a string CIPHER and return the plain text."
- (let ((input-file (epg--make-temp-file "epg-input"))
+ (let ((input-file (make-temp-file "epg-input"))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(write-region cipher nil input-file nil 'quiet)
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(epg-start-decrypt context (epg-make-data-from-file input-file))
(epg-wait-for-completion context)
(epg--check-error-for-decrypt context)
@@ -1602,7 +1530,7 @@ which will return a list of `epg-signature' object."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or plain (epg--make-temp-file "epg-output")))
+ (or plain (make-temp-file "epg-output")))
(if signed-text
(epg-start-verify context
(epg-make-data-from-file signature)
@@ -1639,10 +1567,10 @@ which will return a list of `epg-signature' object."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if signed-text
(progn
- (setq input-file (epg--make-temp-file "epg-signature"))
+ (setq input-file (make-temp-file "epg-signature"))
(write-region signature nil input-file nil 'quiet)
(epg-start-verify context
(epg-make-data-from-file input-file)
@@ -1710,7 +1638,7 @@ Otherwise, it makes a cleartext signature."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or signature (epg--make-temp-file "epg-output")))
+ (or signature (make-temp-file "epg-output")))
(epg-start-sign context (epg-make-data-from-file plain) mode)
(epg-wait-for-completion context)
(unless (epg-context-result-for context 'sign)
@@ -1730,12 +1658,12 @@ If it is nil or `normal', it makes a normal signature.
Otherwise, it makes a cleartext signature."
(let ((input-file
(unless (eq (epg-context-protocol context) 'CMS)
- (epg--make-temp-file "epg-input")))
+ (make-temp-file "epg-input")))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if input-file
(write-region plain nil input-file nil 'quiet))
(epg-start-sign context
@@ -1812,7 +1740,7 @@ If RECIPIENTS is nil, it performs symmetric encryption."
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or cipher (epg--make-temp-file "epg-output")))
+ (or cipher (make-temp-file "epg-output")))
(epg-start-encrypt context (epg-make-data-from-file plain)
recipients sign always-trust)
(epg-wait-for-completion context)
@@ -1837,12 +1765,12 @@ If RECIPIENTS is nil, it performs symmetric encryption."
(let ((input-file
(unless (or (not sign)
(eq (epg-context-protocol context) 'CMS))
- (epg--make-temp-file "epg-input")))
+ (make-temp-file "epg-input")))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (epg--make-temp-file "epg-output"))
+ (make-temp-file "epg-output"))
(if input-file
(write-region plain nil input-file nil 'quiet))
(epg-start-encrypt context
@@ -1887,7 +1815,7 @@ If you are unsure, use synchronous version of this function
(unwind-protect
(progn
(setf (epg-context-output-file context)
- (or file (epg--make-temp-file "epg-output")))
+ (or file (make-temp-file "epg-output")))
(epg-start-export-keys context keys)
(epg-wait-for-completion context)
(let ((errors (epg-context-result-for context 'error)))