+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;
(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")
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))
'(: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)
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
;; 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
(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."