[Utils] Move S/MIME lookup function to init.el

This commit is contained in:
Daniel - 2019-01-27 12:10:44 +01:00
parent ace325c1f9
commit 2a4302c883
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
3 changed files with 25 additions and 23 deletions

22
gnus.el
View File

@ -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

View File

@ -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))

View File

@ -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