Add function to retrieve password from Org item by ID
This function is experimental and may need to be extended to search for IDs in a specific password file that are is not necessarily a member of `org-agenda-files`.
This commit is contained in:
parent
f064305a07
commit
a496ef9734
26
init.el
26
init.el
|
@ -1917,6 +1917,32 @@ respectively."
|
|||
:init (setq epg-debug t
|
||||
epg-gpg-program "gpg"))
|
||||
|
||||
(use-package org-password-manager
|
||||
:commands (org-password-manager-get-password-by-id)
|
||||
:config (progn
|
||||
|
||||
(defun org-password-manager-get-password-by-id (id)
|
||||
"Retrieve password from Org item identified by ID.
|
||||
|
||||
The password is assumed to be stored at the PASSWORD property."
|
||||
|
||||
(let ((pom (org-id-find id 'marker)))
|
||||
(unless (markerp pom)
|
||||
(user-error "Cannot find item with id %s" id))
|
||||
|
||||
(let ((heading (org-entry-get pom "ITEM"))
|
||||
(pw (org-entry-get pom "PASSWORD")))
|
||||
(when (null pw)
|
||||
(user-error "PASSWORD property not set for “%s”" heading))
|
||||
|
||||
(funcall interprogram-cut-function pw)
|
||||
(run-at-time org-password-manager-default-password-wait-time
|
||||
nil
|
||||
(lambda () (funcall interprogram-cut-function "")))
|
||||
(message "Password for “%s” securly copied to system clipboard; will be overwritten in %s."
|
||||
heading
|
||||
org-password-manager-default-password-wait-time))))))
|
||||
|
||||
|
||||
;; * Appearance
|
||||
|
||||
|
|
Loading…
Reference in New Issue