Move custom org-password function to db-org

This is where it belongs, even if there's a warning about free variable
referencing.
This commit is contained in:
Daniel - 2023-08-17 17:04:56 +02:00
parent e30ab3f260
commit a6324a668d
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
2 changed files with 26 additions and 25 deletions

29
init.el
View File

@ -773,7 +773,8 @@
db/org-add-link-to-current-clock
hydra-org-linking/body
org-dblock-write:db/org-backlinks
db/org-clock-goto-first-open-checkbox))
db/org-clock-goto-first-open-checkbox
org-password-manager-get-password-by-id))
(use-package org
:pin "gnu"
@ -1999,30 +2000,8 @@ point to the beginning of buffer first."
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))))))
:commands (org-password-manager-get-username
org-password-manager-get-password))
;; * Appearance

View File

@ -996,6 +996,28 @@ cache if that's in use."
(when (derived-mode-p 'org-agenda-mode)
(org-agenda-redo)))
(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))))
;;; Checklist Handling