[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/autocrypt 51a9463206 10/94: split autocrypt into multip
From: |
ELPA Syncer |
Subject: |
[elpa] externals/autocrypt 51a9463206 10/94: split autocrypt into multiple autoloaded files |
Date: |
Sun, 26 Mar 2023 07:57:56 -0400 (EDT) |
branch: externals/autocrypt
commit 51a94632065d48242ca4e780d3c8d0115974f92e
Author: Philip K <philip@warpmail.net>
Commit: Philip K <philip@warpmail.net>
split autocrypt into multiple autoloaded files
---
autocrypt-gnus.el | 38 ++++++++++++
autocrypt-message.el | 101 ++++++++++++++++++++++++++++++++
autocrypt-mu4e.el | 41 +++++++++++++
autocrypt-rmail.el | 40 +++++++++++++
autocrypt.el | 159 ++++++---------------------------------------------
5 files changed, 237 insertions(+), 142 deletions(-)
diff --git a/autocrypt-gnus.el b/autocrypt-gnus.el
new file mode 100644
index 0000000000..2004ccba82
--- /dev/null
+++ b/autocrypt-gnus.el
@@ -0,0 +1,38 @@
+;;; autocrypt-gnus.el --- Autocrypt for Gnus -*- lexical-binding:t -*-
+
+;; Author: Philip K. <philip@warpmail.net>
+;; Version: 0.4.0
+;; Keywords: comm
+;; Package-Requires: ((emacs "25.1"))
+;; URL: https://git.sr.ht/~zge/autocrypt
+
+;; This file is NOT part of Emacs.
+;;
+;; This file is in the public domain, to the extent possible under law,
+;; published under the CC0 1.0 Universal license.
+;;
+;; For a full copy of the CC0 license see
+;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
+
+;;; Commentary:
+
+;; MUA specific functions for Gnus
+;;
+;; Setup with (add-hook 'gnus-load-hook #'autocrypt-mode)
+
+;;; Code:
+
+(require 'autocrypt)
+(require 'gnus)
+
+(defun autocrypt-gnus-install ()
+ "Install autocrypt hooks for Gnus."
+ (add-hook 'gnus-view-mode-hook #'autocrypt-process-header))
+
+(defun autocrypt-gnus-uninstall ()
+ "Remove autocrypt hooks for Gnus."
+ (remove-hook 'gnus-view-mode-hook #'autocrypt-process-header))
+
+(defun autocrypt-gnus-header (field)
+ "Ask Gnus to return header FIELD."
+ (gnus-fetch-original-field field))
diff --git a/autocrypt-message.el b/autocrypt-message.el
new file mode 100644
index 0000000000..e8286172ab
--- /dev/null
+++ b/autocrypt-message.el
@@ -0,0 +1,101 @@
+;;; autocrypt-message.el --- Autocrypt for message-mode -*- lexical-binding:t
-*-
+
+;; Author: Philip K. <philip@warpmail.net>
+;; Version: 0.4.0
+;; Keywords: comm
+;; Package-Requires: ((emacs "25.1"))
+;; URL: https://git.sr.ht/~zge/autocrypt
+
+;; This file is NOT part of Emacs.
+;;
+;; This file is in the public domain, to the extent possible under law,
+;; published under the CC0 1.0 Universal license.
+;;
+;; For a full copy of the CC0 license see
+;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
+
+;;; Commentary:
+
+;; MUA specific functions for `message-mode'
+;;
+;; Setup with (add-hook 'message-mode-hook #'autocrypt-mode)
+
+;;; Code:
+
+(require 'autocrypt)
+(require 'message)
+
+(defun autocrypt-message-install ()
+ "Install autocrypt hooks for message-mode."
+ (add-hook 'message-setup-hook #'autocrypt-message-setup)
+ (add-hook 'message-send-hook #'autocrypt-message-pre-send)
+ (define-key message-mode-map (kbd "C-c RET C-a") #'autocrypt-message-setup))
+
+(defun autocrypt-message-uninstall ()
+ "Remove autocrypt hooks for message-mode."
+ (remove-hook 'message-setup-hook #'autocrypt-message-setup)
+ (remove-hook 'message-send-hook #'autocrypt-message-pre-send)
+ (define-key message-mode-map (kbd "C-c RET C-a") nil))
+
+;; https://autocrypt.org/level1.html#key-gossip-injection-in-outbound-messages
+(defun autocrypt-message-gossip-p (recipients)
+ "Find out if the current message should have gossip headers."
+ (and (mml-secure-is-encrypted-p)
+ (< 1 (length recipients))
+ (cl-every
+ (lambda (rec)
+ (let ((peer (cdr (assoc rec autocrypt-peers))))
+ (and peer (not (autocrypt-peer-deactivated peer)))))
+ recipients)))
+
+(defun autocrypt-message-setup ()
+ "Check if Autocrypt is possible, and add pseudo headers."
+ (interactive)
+ (let ((recs (autocrypt-list-recipients))
+ (from (autocrypt-canonicalise (message-field-value "from"))))
+ ;; encrypt message if applicable
+ (save-excursion
+ (cl-case (autocrypt-recommendation from recs)
+ (available
+ (message-add-header "Do-Autocrypt: no"))
+ (discourage
+ (message-add-header "Do-Discouraged-Autocrypt: no"))))))
+
+(defun autocrypt-message-pre-send ()
+ "Insert Autocrypt headers before sending a message.
+
+Will handle and remove \"Do-(Discourage-)Autocrypt\" if found."
+ (let* ((recs (autocrypt-list-recipients))
+ (from (autocrypt-canonicalise (message-field-value "from"))))
+ ;; encrypt message if applicable
+ (when (eq (autocrypt-recommendation from recs) 'encrypt)
+ (mml-secure-message-sign-encrypt "pgpmime"))
+ ;; check for manual autocrypt confirmations
+ (let ((do-autocrypt (message-fetch-field "Do-Autocrypt"))
+ (ddo-autocrypt (message-fetch-field "Do-Discouraged-Autocrypt"))
+ (query "Are you sure you want to use Autocrypt, even though it is
discouraged?"))
+ (when (and (not (mml-secure-is-encrypted-p))
+ (or (and do-autocrypt
+ (string= (downcase do-autocrypt) "yes"))
+ (and ddo-autocrypt
+ (string= (downcase ddo-autocrypt) "yes")
+ (yes-or-no-p query))))
+ (mml-secure-message-sign-encrypt "pgpmime")))
+ (message-remove-header "Do-Autocrypt")
+ (message-remove-header "Do-Discouraged-Autocrypt")
+ ;; insert gossip data
+ (when (autocrypt-message-gossip-p recs)
+ (let ((buf (generate-new-buffer " *autocrypt gossip*")))
+ (with-current-buffer buf
+ (dolist (addr (autocrypt-message-list-recipients))
+ (let ((header (autocrypt-generate-header addr t)))
+ (insert "Autocrypt-Gossip: " header "\n"))))
+ (mml-attach-buffer buf)
+ (mml-secure-part "pgpmime")
+ (add-hook 'message-send-hook
+ (lambda () (kill-buffer buf))
+ nil t)))
+ ;; insert autocrypt header
+ (let ((header (and from (autocrypt-generate-header from))))
+ (when header
+ (message-add-header (concat "Autocrypt: " header))))))
diff --git a/autocrypt-mu4e.el b/autocrypt-mu4e.el
new file mode 100644
index 0000000000..686a4852c2
--- /dev/null
+++ b/autocrypt-mu4e.el
@@ -0,0 +1,41 @@
+;;; autocrypt-mu4e.el --- Autocrypt for mu4e -*- lexical-binding:t -*-
+
+;; Author: Philip K. <philip@warpmail.net>
+;; Version: 0.4.0
+;; Keywords: comm
+;; Package-Requires: ((emacs "25.1"))
+;; URL: https://git.sr.ht/~zge/autocrypt
+
+;; This file is NOT part of Emacs.
+;;
+;; This file is in the public domain, to the extent possible under law,
+;; published under the CC0 1.0 Universal license.
+;;
+;; For a full copy of the CC0 license see
+;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
+
+;;; Commentary:
+
+;; MUA specific functions for mu4e
+;;
+;; Setup with (add-hook 'mu4e-main-mode-hook #'autocrypt-mode)
+
+;;; Code:
+
+(require 'autocrypt)
+(require 'mu4e)
+
+(defun autocrypt-mu4e-install ()
+ "Install autocrypt hooks for mu4e."
+ (add-hook 'mu4e-view-mode-hook #'autocrypt-process-header))
+
+(defun autocrypt-mu4e-uninstall ()
+ "Remove autocrypt hooks for mu4e."
+ (remove-hook 'mu4e-view-mode-hook #'autocrypt-process-header))
+
+(defun autocrypt-mu4e-header (field)
+ "Ask mu4e to return header field."
+ (save-window-excursion
+ (with-current-buffer (mu4e-view-raw-message)
+ (prog1 (mail-fetch-field field)
+ (kill-buffer (current-buffer))))))
diff --git a/autocrypt-rmail.el b/autocrypt-rmail.el
new file mode 100644
index 0000000000..662091421e
--- /dev/null
+++ b/autocrypt-rmail.el
@@ -0,0 +1,40 @@
+;;; autocrypt-gnus.el --- Autocrypt for Rmail -*- lexical-binding:t -*-
+
+;; Author: Philip K. <philip@warpmail.net>
+;; Version: 0.4.0
+;; Keywords: comm
+;; Package-Requires: ((emacs "25.1"))
+;; URL: https://git.sr.ht/~zge/autocrypt
+
+;; This file is NOT part of Emacs.
+;;
+;; This file is in the public domain, to the extent possible under law,
+;; published under the CC0 1.0 Universal license.
+;;
+;; For a full copy of the CC0 license see
+;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
+
+;;; Commentary:
+
+;; MUA specific functions for Rmail
+;;
+;; Setup with (add-hook 'rmail-mode-hook #'autocrypt-mode)
+
+;;; Code:
+
+(require 'autocrypt)
+(require 'rmail)
+
+(defun autocrypt-rmail-install ()
+ "Install autocrypt hooks for Rmail."
+ (add-hook 'rmail-show-message-hook #'autocrypt-process-header))
+
+(defun autocrypt-rmail-uninstall ()
+ "Remove autocrypt hooks for Rmail."
+ (remove-hook 'rmail-show-message-hook #'autocrypt-process-header))
+
+(defun autocrypt-rmail-header (field)
+ "Ask Rmail to return header field."
+ (rmail-apply-in-message
+ rmail-current-message
+ (lambda () (mail-fetch-field field)))))
diff --git a/autocrypt.el b/autocrypt.el
index b2991a9644..3062e976ad 100644
--- a/autocrypt.el
+++ b/autocrypt.el
@@ -25,7 +25,6 @@
;;; Code:
-(require 'message)
(require 'cl-lib)
(require 'rx)
@@ -72,7 +71,7 @@ process \"Autocrypt-Gossip\" headers when received."
(const :tag "Disable Gossip" nil)))
(defcustom autocrypt-save-file
- (expand-file-name "autocrypt-data.el" user-emacs-directory)
+ (locate-user-emacs-file "autocrypt-data.el")
"File where Autocrypt peer data should be saved."
:type '(file :must-match t))
@@ -104,6 +103,22 @@ Every member of this list has to be an instance of the
;;; MUA TRANSLATION LAYER
+(autoload 'autocrypt-gnus-install "autocrypt-gnus")
+(autoload 'autocrypt-gnus-uninstall "autocrypt-gnus")
+(autoload 'autocrypt-gnus-header "autocrypt-gnus")
+
+(autoload 'autocrypt-rmail-install "autocrypt-rmail")
+(autoload 'autocrypt-rmail-uninstall "autocrypt-rmail")
+(autoload 'autocrypt-rmail-header "autocrypt-rmail")
+
+(autoload 'autocrypt-mu4e-install "autocrypt-mu4e")
+(autoload 'autocrypt-mu4e-uninstall "autocrypt-mu4e")
+(autoload 'autocrypt-mu4e-header "autocrypt-mu4e")
+
+(autoload 'autocrypt-message-install "autocrypt-message")
+(autoload 'autocrypt-message-uninstall "autocrypt-message")
+(autoload 'autocrypt-message-header "autocrypt-message")
+
(defconst autocrypt-mua-func-alist
'((gnus
:install autocrypt-gnus-install
@@ -448,146 +463,6 @@ preference (\"prefer-encrypt\")."
email)))
-;;; GNUS SUPPORT
-
-(with-eval-after-load 'gnus
- ;; setup with (add-hook 'gnus-load-hook #'autocrypt-mode)
-
- (defun autocrypt-gnus-install ()
- "Install autocrypt hooks for Gnus."
- (add-hook 'gnus-view-mode-hook #'autocrypt-process-header))
-
- (defun autocrypt-gnus-uninstall ()
- "Remove autocrypt hooks for Gnus."
- (remove-hook 'gnus-view-mode-hook #'autocrypt-process-header))
-
- (defun autocrypt-gnus-header (field)
- "Ask Gnus to return header FIELD."
- (gnus-fetch-original-field field)))
-
-
-;;; RMAIL SUPPORT
-
-(with-eval-after-load 'rmail
- ;; setup with (add-hook 'rmail-mode-hook #'autocrypt-mode)
-
- (defun autocrypt-rmail-install ()
- "Install autocrypt hooks for Rmail."
- (add-hook 'rmail-show-message-hook #'autocrypt-process-header))
-
- (defun autocrypt-rmail-uninstall ()
- "Remove autocrypt hooks for Rmail."
- (remove-hook 'rmail-show-message-hook #'autocrypt-process-header))
-
- (defun autocrypt-rmail-header (field)
- "Ask Rmail to return header field."
- (rmail-apply-in-message
- rmail-current-message
- (lambda () (mail-fetch-field field)))))
-
-
-;;; MU4E SUPPORT
-
-(with-eval-after-load 'mu4e
- ;; setup with (add-hook 'mu4e-main-mode-hook #'autocrypt-mode)
-
- (defun autocrypt-mu4e-install ()
- "Install autocrypt hooks for mu4e."
- (add-hook 'mu4e-view-mode-hook #'autocrypt-process-header))
-
- (defun autocrypt-mu4e-uninstall ()
- "Remove autocrypt hooks for mu4e."
- (remove-hook 'mu4e-view-mode-hook #'autocrypt-process-header))
-
- (defun autocrypt-mu4e-header (field)
- "Ask mu4e to return header field."
- (save-window-excursion
- (with-current-buffer (mu4e-view-raw-message)
- (prog1 (mail-fetch-field field)
- (kill-buffer (current-buffer)))))))
-
-
-;;; MESSAGE SUPPORT
-
-(with-eval-after-load 'message
- ;; setup with (add-hook 'message-mode-hook #'autocrypt-mode)
-
- (defun autocrypt-message-install ()
- "Install autocrypt hooks for message-mode."
- (add-hook 'message-setup-hook #'autocrypt-message-setup)
- (add-hook 'message-send-hook #'autocrypt-message-pre-send)
- (define-key message-mode-map (kbd "C-c RET C-a")
#'autocrypt-message-setup))
-
- (defun autocrypt-message-uninstall ()
- "Remove autocrypt hooks for message-mode."
- (remove-hook 'message-setup-hook #'autocrypt-message-setup)
- (remove-hook 'message-send-hook #'autocrypt-message-pre-send)
- (define-key message-mode-map (kbd "C-c RET C-a") nil))
-
- ;;
https://autocrypt.org/level1.html#key-gossip-injection-in-outbound-messages
- (defun autocrypt-message-gossip-p (recipients)
- "Find out if the current message should have gossip headers."
- (and (mml-secure-is-encrypted-p)
- (< 1 (length recipients))
- (cl-every
- (lambda (rec)
- (let ((peer (cdr (assoc rec autocrypt-peers))))
- (and peer (not (autocrypt-peer-deactivated peer)))))
- recipients)))
-
- (defun autocrypt-message-setup ()
- "Check if Autocrypt is possible, and add pseudo headers."
- (interactive)
- (let ((recs (autocrypt-list-recipients))
- (from (autocrypt-canonicalise (message-field-value "from"))))
- ;; encrypt message if applicable
- (save-excursion
- (cl-case (autocrypt-recommendation from recs)
- (available
- (message-add-header "Do-Autocrypt: no"))
- (discourage
- (message-add-header "Do-Discouraged-Autocrypt: no"))))))
-
- (defun autocrypt-message-pre-send ()
- "Insert Autocrypt headers before sending a message.
-
-Will handle and remove \"Do-(Discourage-)Autocrypt\" if found."
- (let* ((recs (autocrypt-list-recipients))
- (from (autocrypt-canonicalise (message-field-value "from"))))
- ;; encrypt message if applicable
- (when (eq (autocrypt-recommendation from recs) 'encrypt)
- (mml-secure-message-sign-encrypt "pgpmime"))
- ;; check for manual autocrypt confirmations
- (let ((do-autocrypt (message-fetch-field "Do-Autocrypt"))
- (ddo-autocrypt (message-fetch-field "Do-Discouraged-Autocrypt"))
- (query "Are you sure you want to use Autocrypt, even though it is
discouraged?"))
- (when (and (not (mml-secure-is-encrypted-p))
- (or (and do-autocrypt
- (string= (downcase do-autocrypt) "yes"))
- (and ddo-autocrypt
- (string= (downcase ddo-autocrypt) "yes")
- (yes-or-no-p query))))
- (mml-secure-message-sign-encrypt "pgpmime")))
- (message-remove-header "Do-Autocrypt")
- (message-remove-header "Do-Discouraged-Autocrypt")
- ;; insert gossip data
- (when (autocrypt-message-gossip-p recs)
- (let ((buf (generate-new-buffer " *autocrypt gossip*")))
- (with-current-buffer buf
- (dolist (addr (autocrypt-message-list-recipients))
- (let ((header (autocrypt-generate-header addr t)))
- (insert "Autocrypt-Gossip: " header "\n"))))
- (mml-attach-buffer buf)
- (mml-secure-part "pgpmime")
- (add-hook 'message-send-hook
- (lambda () (kill-buffer buf))
- nil t)))
- ;; insert autocrypt header
- (let ((header (and from (autocrypt-generate-header from))))
- (when header
- (message-add-header (concat "Autocrypt: " header)))))))
-
-
;;; MINOR MODES
;;;###autoload
- [elpa] branch externals/autocrypt created (now a90aa6b644), ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 25635d8441 01/94: initial import, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 374b5f2e5e 06/94: fixed section headers, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 50686561d7 09/94: added gitignore, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt ea9697885e 02/94: added readme, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 51a9463206 10/94: split autocrypt into multiple autoloaded files,
ELPA Syncer <=
- [elpa] externals/autocrypt 4b87cc8cc1 12/94: fixed byte-compilation issues, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 283c9ade36 14/94: fixed checkdoc complaints, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt b263a7ddfa 18/94: replaced customize-set-variable with customize-save-variable, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt b712fbc71c 20/94: fixed missing preference bug, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 71384d8f37 21/94: insert newline before inserting keydata, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt e93e90febd 24/94: fixed autocrypt-compose-setup bind-check in message interface, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 4f482b21d9 59/94: Change mode of save file to emacs-lisp, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 7334fcf0a3 61/94: Transform autocrypt-backends into a hook, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 82d4e3586b 72/94: Modify message-mode-map when installing autocrypt for message-mode, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 758ef48ec5 37/94: Quote autocrypt-loaded-version to check if was bound, ELPA Syncer, 2023/03/26