Move idm related functions to the Org config

This commit is contained in:
Gergely Polonkai 2018-07-29 19:18:20 +02:00
parent 7ee19f492a
commit 1cc81ac9d3
3 changed files with 27 additions and 23 deletions

View File

@ -421,6 +421,33 @@ Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
(signal (car err) (cdr err))))))
#+END_SRC
** ~idm~ (ID manager) related functions
*** Get specific fields from a record in ~idm~
#+BEGIN_SRC emacs-lisp
(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 nil))
(dolist (record (funcall db 'get-all-records) password)
(when (string= account (idm-record-name record))
(setq lookup-record (gpolonkai/idm-record-get-field record field))))
lookup-record))
(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))
#+END_SRC
* UI preferences
** Tweak window chrome

View File

@ -539,7 +539,6 @@
(use-package id-manager
:config
(load "idm")
(setq idm-database-file (expand-file-name "idm-db.gpg" user-emacs-directory))
:bind
(:map gpolonkai/pers-map

View File

@ -1,22 +0,0 @@
;; 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 nil))
(dolist (record (funcall db 'get-all-records) password)
(when (string= account (idm-record-name record))
(setq lookup-record (gpolonkai/idm-record-get-field record field))))
lookup-record))
(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))