Extend id-manager functionality
Add new macros that can fetch the account-id and password for a given account.
This commit is contained in:
parent
7f90feb9bd
commit
d0fba2c7c6
1
init.el
1
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
|
||||
|
21
lisp/idm.el
Normal file
21
lisp/idm.el
Normal 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))
|
Loading…
Reference in New Issue
Block a user