Commit f3078a00 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Add plstore-delete.

* auth-source.el (plstore-delete): Autoload.
(auth-source-plstore-search): Support delete operation.
* plstore.el (plstore-delete): New function.
parent 85e42879
2011-07-01 Daiki Ueno <ueno@unixuser.org>
* auth-source.el (plstore-delete): Autoload.
(auth-source-plstore-search): Support delete operation.
* plstore.el (plstore-delete): New function.
2011-07-01 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-draft.el (gnus-draft-clear-marks): Revert last change;
......
......@@ -60,6 +60,7 @@
(autoload 'plstore-open "plstore")
(autoload 'plstore-find "plstore")
(autoload 'plstore-put "plstore")
(autoload 'plstore-delete "plstore")
(autoload 'plstore-save "plstore")
(autoload 'plstore-get-file "plstore")
......@@ -1523,11 +1524,6 @@ authentication tokens:
type max host user port
&allow-other-keys)
"Search the PLSTORE; spec is like `auth-source'."
;; TODO
(assert (not delete) nil
"The PLSTORE auth-source backend doesn't support deletion yet")
(let* ((store (oref backend data))
(max (or max 5000)) ; sanity check: default to stop at 5K
(ignored-keys '(:create :delete :max :backend :require))
......@@ -1551,6 +1547,7 @@ authentication tokens:
'(:host :login :port :secret)
search-keys)))
(items (plstore-find store search-spec))
(item-names (mapcar #'car items))
(items (butlast items (- (length items) max)))
;; convert the item to a full plist
(items (mapcar (lambda (item)
......@@ -1574,9 +1571,10 @@ authentication tokens:
returned-keys))
plist))
items)))
;; if we need to create an entry AND none were found to match
(when (and create
(not items))
(cond
;; if we need to create an entry AND none were found to match
((and create
(not items))
;; create based on the spec and record the value
(setq items (or
......@@ -1589,6 +1587,11 @@ authentication tokens:
;; the result will be returned, even if the search fails
(apply 'auth-source-plstore-search
(plist-put spec :create nil)))))
((and delete
item-names)
(dolist (item-name item-names)
(plstore-delete store item-name))
(plstore-save store)))
items))
(defun* auth-source-plstore-create (&rest spec
......
......@@ -337,6 +337,24 @@ SECRET-KEYS is a plist containing secret data."
(cons (cons name secret-plist) (plstore--get-secret-alist plstore)))))
(plstore--merge-secret plstore)))
(defun plstore-delete (plstore name)
"Delete an entry with NAME from PLSTORE."
(let ((entry (assoc name (plstore--get-alist plstore))))
(if entry
(plstore--set-alist
plstore
(delq entry (plstore--get-alist plstore))))
(setq entry (assoc name (plstore--get-secret-alist plstore)))
(if entry
(plstore--set-secret-alist
plstore
(delq entry (plstore--get-secret-alist plstore))))
(setq entry (assoc name (plstore--get-merged-alist plstore)))
(if entry
(plstore--set-merged-alist
plstore
(delq entry (plstore--get-merged-alist plstore))))))
(defvar pp-escape-newlines)
(defun plstore-save (plstore)
"Save the contents of PLSTORE associated with a FILE."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment