[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/autocrypt 7334fcf0a3 61/94: Transform autocrypt-backend
From: |
ELPA Syncer |
Subject: |
[elpa] externals/autocrypt 7334fcf0a3 61/94: Transform autocrypt-backends into a hook |
Date: |
Sun, 26 Mar 2023 07:58:01 -0400 (EDT) |
branch: externals/autocrypt
commit 7334fcf0a3d1fd431988861df55df9a4147554bd
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Transform autocrypt-backends into a hook
---
autocrypt.el | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/autocrypt.el b/autocrypt.el
index 93e9466dfe..2b95200567 100644
--- a/autocrypt.el
+++ b/autocrypt.el
@@ -100,14 +100,17 @@ Every member of this list has to be an instance of the
;;; MUA TRANSLATION LAYER
(defvar autocrypt-backends
- '(((mu4e-main-mode mu4e-view-mode) . mu4e)
- ((gnus-mode) . gnus)
- ((rmail-mode) . rmail)
- ((message-mode) . message))
- "Alist of known backends.
-Each entry has the form (MODES . NAME), where MODES is a list of
-major modes where the backend applies, and NAME is a symbol to
-designate this backend.")
+ (list (lambda () (and (derived-mode-p 'mu4e-main-mode 'mu4e-view-mode)
'mu4e))
+ (lambda () (and (derived-mode-p 'gnus-mode) 'gnus))
+ (lambda () (and (derived-mode-p 'rmail-mode) 'rmail))
+ (lambda () (and (derived-mode-p 'message-mode) 'message))
+ (lambda ()
+ ;; Guess backend from major mode
+ (when (string-match "-mode\\'" (symbol-name major-mode))
+ (intern (substring (symbol-name major-mode) 0 (match-beginning
0))))))
+ "Hook for finding a backend.
+Each function is called without any further arguments, and should
+return a symbol designating the backend to use.")
(defvar-local autocrypt-backend-function nil
"Override the function called by `autocrypt-find-function'.
@@ -119,19 +122,18 @@ with the right signature.")
"Return a function for handling COMMAND."
(if autocrypt-backend-function
(funcall autocrypt-backend-function command)
- (catch 'ok
- (dolist (backend-data autocrypt-backends)
- (let ((modes (car backend-data))
- (backend (cdr backend-data)))
- (when (apply #'derived-mode-p modes)
- (dolist (fn (mapcar
- #'intern
- (list (format "autocrypt-%S--%S" backend command)
- (format "%S-autocrypt-%S" backend command)
- (format "%S--autocrypt-%S" backend command))))
- (when (and fn (fboundp fn))
- (throw 'ok fn))))))
- (error "No autocrypt backend found"))))
+ (let ((backend (run-hook-with-args-until-success 'autocrypt-backends)))
+ (unless backend
+ (error "No backend found"))
+ (catch 'ok
+ (dolist (fn (mapcar
+ #'intern-soft
+ (list (format "autocrypt-%S--%S" backend command)
+ (format "%S-autocrypt-%S" backend command)
+ (format "%S--autocrypt-%S" backend command))))
+ (when (and fn (fboundp fn))
+ (throw 'ok fn)))
+ (error "Missing %S implementation for %S" command backend)))))
(defun autocrypt-make-function (command signature)
"Return a function to handle COMMAND.
- [elpa] externals/autocrypt 50686561d7 09/94: added gitignore, (continued)
- [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, 2023/03/26
- [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 <=
- [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
- [elpa] externals/autocrypt 754af378cc 40/94: Fix broken method invocations, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt a06cd2685b 46/94: Remove unwanted autoload cookies, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt f55388cc6e 51/94: Suppress message when autocrypt file is modified, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 39c06eb402 52/94: Rename autocrypt-load for Rmail, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 5b55f8d375 55/94: Add comments on extending autocrypt.el in the README, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt a5d67301c1 57/94: Revert to custom generic backend system, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt 8965ce57c7 74/94: Add references to autocrypt-backends to all generic functions, ELPA Syncer, 2023/03/26
- [elpa] externals/autocrypt c439cbe029 76/94: Update "How to use" section to demonstrate configuring without setup, ELPA Syncer, 2023/03/26