From e93e03705fb5b81f3af85f04c07ad0ee2190b6aa Mon Sep 17 00:00:00 2001 From: ibizaman Date: Fri, 28 Jun 2019 10:35:28 -0700 Subject: emacs: require matching password for completion --- contrib/emacs/password-store.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'contrib/emacs/password-store.el') diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index fe9271d..a08fec9 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -177,9 +177,11 @@ Nil arguments are ignored. Output is discarded." "Return entry name corresponding to FILE." (f-no-ext (f-relative file (password-store-dir)))) -(defun password-store--completing-read () - "Read a password entry in the minibuffer, with completion." - (completing-read "Password entry: " (password-store-list))) +(defun password-store--completing-read (&optional require-match) + "Read a password entry in the minibuffer, with completion. + +Require a matching password if `REQUIRE-MATCH' is 't'." + (completing-read "Password entry: " (password-store-list) nil require-match)) (defun password-store-list (&optional subdir) "List password entries under SUBDIR." @@ -193,7 +195,7 @@ Nil arguments are ignored. Output is discarded." ;;;###autoload (defun password-store-edit (entry) "Edit password for ENTRY." - (interactive (list (password-store--completing-read))) + (interactive (list (password-store--completing-read t))) (password-store--run-edit entry)) ;;;###autoload @@ -228,7 +230,7 @@ When CALLBACK is non-`NIL', call CALLBACK with the first line instead." Clear previous password from kill ring. Pointer to kill ring is stored in `password-store-kill-ring-pointer'. Password is cleared after `password-store-timeout' seconds." - (interactive (list (password-store--completing-read))) + (interactive (list (password-store--completing-read t))) (password-store-get entry (lambda (password) @@ -275,13 +277,13 @@ Default PASSWORD-LENGTH is `password-store-password-length'." ;;;###autoload (defun password-store-remove (entry) "Remove existing password for ENTRY." - (interactive (list (password-store--completing-read))) + (interactive (list (password-store--completing-read t))) (message "%s" (password-store--run-remove entry t))) ;;;###autoload (defun password-store-rename (entry new-entry) "Rename ENTRY to NEW-ENTRY." - (interactive (list (password-store--completing-read) + (interactive (list (password-store--completing-read t) (read-string "Rename entry to: "))) (message "%s" (password-store--run-rename entry new-entry t))) @@ -297,7 +299,7 @@ Default PASSWORD-LENGTH is `password-store-password-length'." This will only browse URLs that start with http:// or https:// to avoid sending a password to the browser." - (interactive (list (password-store--completing-read))) + (interactive (list (password-store--completing-read t))) (let ((url (password-store-get entry))) (if (or (string-prefix-p "http://" url) (string-prefix-p "https://" url)) -- cgit v1.2.3-59-g8ed1b