From 2a4302c88360c6602d35687a6bdcb0f216ea54a3 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 27 Jan 2019 12:10:44 +0100 Subject: [PATCH] [Utils] Move S/MIME lookup function to init.el --- gnus.el | 22 ---------------------- init.el | 3 ++- site-lisp/db-utils.el | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/gnus.el b/gnus.el index 11a3e4c..20ce343 100644 --- a/gnus.el +++ b/gnus.el @@ -417,28 +417,6 @@ METHOD specifies the encrypt method used. Can be either (add-hook 'gnus-message-setup-hook #'db/signencrypt-message-when-possible) -;; inspired by https://www.emacswiki.org/emacs/ExtendSMIME - -(defun db/lookup-smime-key (mail) - "Look up `MAIL' on ldap-server of the DFN. - -If found, imports the certificate via gpgsm." - (interactive "sMail: ") - (when (get-buffer " *ldap-value*") - (kill-buffer " *ldap-value*")) - (ldap-search (format "(mail=%s)" mail)) - (let ((bufval (get-buffer " *ldap-value*"))) - (when bufval - (with-current-buffer bufval - (save-restriction - (widen) ; just to be sure - (let ((result (call-process-region (point-min) (point-max) - "gpgsm" - nil nil nil - "--import"))) - (if (zerop result) - (message "Successfully imported certificate for <%s>" mail) - (error "Could not import certificate for <%s>" mail)))))))) ;; Fix diff --git a/init.el b/init.el index bdeb0cc..564f372 100644 --- a/init.el +++ b/init.el @@ -539,7 +539,8 @@ db/one-monitor-xrandr db/pretty-print-xml db/bookmark-add-external - db/bookmark-add-url)) + db/bookmark-add-url + db/lookup-smime-key)) (use-package hydra :commands (defhydra)) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 4f6065e..0c70afe 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -268,6 +268,29 @@ are assumed to be of the form *.crt." ;; Indent (indent-region (point-min) (point-max)))) +(defun db/lookup-smime-key (mail) + "Look up `MAIL' on ldap-server of the DFN. + +If found, imports the certificate via gpgsm." + ;; inspired by https://www.emacswiki.org/emacs/ExtendSMIME + (interactive "sMail: ") + (require 'ldap) + (when (get-buffer " *ldap-value*") + (kill-buffer " *ldap-value*")) + (ldap-search (format "(mail=%s)" mail)) + (let ((bufval (get-buffer " *ldap-value*"))) + (when bufval + (with-current-buffer bufval + (save-restriction + (widen) ; just to be sure + (let ((result (call-process-region (point-min) (point-max) + "gpgsm" + nil nil nil + "--import"))) + (if (zerop result) + (message "Successfully imported certificate for <%s>" mail) + (error "Could not import certificate for <%s>" mail)))))))) + ;;; helm configuration