diff --git a/init.el b/init.el index 66a6372..f10c27e 100644 --- a/init.el +++ b/init.el @@ -513,6 +513,7 @@ (use-package id-manager :ensure t :config + (load "idm") (setq idm-database-file (expand-file-name "idm-db.gpg" user-emacs-directory)) :bind (:map gpolonkai/pers-map diff --git a/lisp/idm.el b/lisp/idm.el new file mode 100644 index 0000000..aeb31c3 --- /dev/null +++ b/lisp/idm.el @@ -0,0 +1,21 @@ +;; id-manager extensions + +(defun gpolonkai/idm-record-get-field (record field) + "Get FIELD of an id-manager RECORD." + (let ((funcname (intern (concat "idm-record-" (symbol-name field))))) + (when (fboundp funcname) + (funcall funcname record)))) + +(defun gpolonkai/idm-get-field-for-account (account field) + "Get id-manager password for ACCOUNT." + (let ((db (idm-load-db)) + (lookup-record)) + (dolist (record (funcall db 'get-all-records) password) + (when (string= "WikEmacs" (idm-record-name record)) + (setq password (gpolonkai/idm-record-get-field record field)))))) + +(defmacro gpolonkai/idm-get-password-for-account (account) + `(gpolonkai/idm-get-field-for-account ,account 'password)) + +(defmacro gpolonkai/idm-get-id-for-account (account) + `(gpolonkai/idm-get-field-for-account ,account 'account-id))