Extend id-manager functionality

Add new macros that can fetch the account-id and password for a given
account.
This commit is contained in:
Gergely Polonkai 2016-11-18 13:25:12 +01:00
parent 7f90feb9bd
commit d0fba2c7c6
2 changed files with 22 additions and 0 deletions

View File

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

21
lisp/idm.el Normal file
View File

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