From 0e2af5cc3726d6e661f0f396a843185326ed5e7d Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 18 Feb 2020 16:59:00 +0100 Subject: Improve and add doc-strings * lisp/epa-file.el (epa-file-select-keys): lisp/epa-hook.el (epa-file-name-regexp): lisp/epa.el (epa-exit-buffer): Improve doc-string. * lisp/epa-hook.el (epa-file-name-regexp-update): Add doc-string. --- lisp/epa-file.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/epa-file.el') diff --git a/lisp/epa-file.el b/lisp/epa-file.el index dedf20b0d77..22c3dc1146b 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -40,9 +40,9 @@ Note that this option has no effect if you use GnuPG 2.0." (defcustom epa-file-select-keys nil "Control whether or not to pop up the key selection dialog. -If t, always asks user to select recipients. +If t, always ask user to select recipients. If nil, query user only when `epa-file-encrypt-to' is not set. -If neither t nor nil, doesn't ask user. In this case, symmetric +If neither t nor nil, don't ask user. In this case, symmetric encryption is used." :type '(choice (const :tag "Ask always" t) (const :tag "Ask when recipients are not set" nil) -- cgit v1.2.3 From e78c15acf679259caea6566446f61966cea032aa Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 18 Feb 2020 16:58:31 +0100 Subject: Drop unnecessary backward compatibility aliases We can assume that `encode-coding-string' and `decode-coding-string' are available; they were added in 1997. * lisp/epa-file.el (epa-file--encode-coding-string) (epa-file--decode-coding-string): Remove aliases for encode-coding-string and decode-coding-string. * lisp/epa-file.el (epa-file-write-region): Use encode-coding-string instead of removed epa-file--encode-coding-string. --- lisp/epa-file.el | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'lisp/epa-file.el') diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 22c3dc1146b..14a169b13fb 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -51,16 +51,6 @@ encryption is used." (defvar epa-file-passphrase-alist nil) -(eval-and-compile - (if (fboundp 'encode-coding-string) - (defalias 'epa-file--encode-coding-string 'encode-coding-string) - (defalias 'epa-file--encode-coding-string 'identity))) - -(eval-and-compile - (if (fboundp 'decode-coding-string) - (defalias 'epa-file--decode-coding-string 'decode-coding-string) - (defalias 'epa-file--decode-coding-string 'identity))) - (defun epa-file-passphrase-callback-function (context key-id file) (if (and epa-file-cache-passphrase-for-symmetric-encryption (eq key-id 'SYM)) @@ -236,11 +226,7 @@ encryption is used." (setq file (expand-file-name file)) (let* ((coding-system (or coding-system-for-write (if (fboundp 'select-safe-coding-system) - ;; This is needed since Emacs 22 has - ;; no-conversion setting for *.gpg in - ;; `auto-coding-alist'. - (let ((buffer-file-name - (file-name-sans-extension file))) + (let ((buffer-file-name file)) (select-safe-coding-system (point-min) (point-max))) buffer-file-coding-system))) @@ -266,7 +252,7 @@ encryption is used." (epg-encrypt-string context (if (stringp start) - (epa-file--encode-coding-string start coding-system) + (encode-coding-string start coding-system) (unless start (setq start (point-min) end (point-max))) @@ -280,8 +266,8 @@ encryption is used." ;; decrypted contents. (format-encode-buffer (with-current-buffer buffer buffer-file-format)) - (epa-file--encode-coding-string (buffer-string) - coding-system))) + (encode-coding-string (buffer-string) + coding-system))) (if (or (eq epa-file-select-keys t) (and (null epa-file-select-keys) (not (local-variable-p 'epa-file-encrypt-to -- cgit v1.2.3 From 9f82622d33b7e7558d1ba30781b209b599b24b52 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 18 Feb 2020 16:56:16 +0100 Subject: Cosmetic changes to epa libraries These changes make the code more readable. * lisp/epa-dired.el (epa-dired-do-decrypt, epa-dired-do-verify) (epa-dired-do-sign, epa-dired-do-encrypt): Use dolist instead of while. * lisp/epa-file.el (epa-file-passphrase-callback-function): Set just one variable per setq call. --- lisp/epa-dired.el | 44 ++++++++++++++++++-------------------------- lisp/epa-file.el | 4 ++-- 2 files changed, 20 insertions(+), 28 deletions(-) (limited to 'lisp/epa-file.el') diff --git a/lisp/epa-dired.el b/lisp/epa-dired.el index f601d426566..9269ea97070 100644 --- a/lisp/epa-dired.el +++ b/lisp/epa-dired.el @@ -29,48 +29,40 @@ (defun epa-dired-do-decrypt () "Decrypt marked files." (interactive) - (let ((file-list (dired-get-marked-files))) - (while file-list - (epa-decrypt-file (expand-file-name (car file-list))) - (setq file-list (cdr file-list))) - (revert-buffer))) + (dolist (file (dired-get-marked-files)) + (epa-decrypt-file (expand-file-name file))) + (revert-buffer)) ;;;###autoload (defun epa-dired-do-verify () "Verify marked files." (interactive) - (let ((file-list (dired-get-marked-files))) - (while file-list - (epa-verify-file (expand-file-name (car file-list))) - (setq file-list (cdr file-list))))) + (dolist (file (dired-get-marked-files)) + (epa-verify-file (expand-file-name file)))) ;;;###autoload (defun epa-dired-do-sign () "Sign marked files." (interactive) - (let ((file-list (dired-get-marked-files))) - (while file-list - (epa-sign-file - (expand-file-name (car file-list)) - (epa-select-keys (epg-make-context) "Select keys for signing. + (dolist (file (dired-get-marked-files)) + (epa-sign-file + (expand-file-name file) + (epa-select-keys (epg-make-context) "Select keys for signing. If no one is selected, default secret key is used. " - nil t) - (y-or-n-p "Make a detached signature? ")) - (setq file-list (cdr file-list))) - (revert-buffer))) + nil t) + (y-or-n-p "Make a detached signature? "))) + (revert-buffer)) ;;;###autoload (defun epa-dired-do-encrypt () "Encrypt marked files." (interactive) - (let ((file-list (dired-get-marked-files))) - (while file-list - (epa-encrypt-file - (expand-file-name (car file-list)) - (epa-select-keys (epg-make-context) "Select recipients for encryption. -If no one is selected, symmetric encryption will be performed. ")) - (setq file-list (cdr file-list))) - (revert-buffer))) + (dolist (file (dired-get-marked-files)) + (epa-encrypt-file + (expand-file-name file) + (epa-select-keys (epg-make-context) "Select recipients for encryption. +If no one is selected, symmetric encryption will be performed. "))) + (revert-buffer)) (provide 'epa-dired) diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 14a169b13fb..20043a9eae4 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -61,8 +61,8 @@ encryption is used." (or (copy-sequence (cdr entry)) (progn (unless entry - (setq entry (list file) - epa-file-passphrase-alist + (setq entry (list file)) + (setq epa-file-passphrase-alist (cons entry epa-file-passphrase-alist))) (setq passphrase (epa-passphrase-callback-function context -- cgit v1.2.3