[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r104835: Add plstore-delete.
From: |
Daiki Ueno |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r104835: Add plstore-delete. |
Date: |
Fri, 01 Jul 2011 16:35:39 +0900 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 104835
committer: Daiki Ueno <address@hidden>
branch nick: trunk
timestamp: Fri 2011-07-01 16:35:39 +0900
message:
Add plstore-delete.
* auth-source.el (plstore-delete): Autoload.
(auth-source-plstore-search): Support delete operation.
* plstore.el (plstore-delete): New function.
modified:
lisp/gnus/ChangeLog
lisp/gnus/auth-source.el
lisp/gnus/plstore.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog 2011-07-01 07:29:00 +0000
+++ b/lisp/gnus/ChangeLog 2011-07-01 07:35:39 +0000
@@ -1,3 +1,9 @@
+2011-07-01 Daiki Ueno <address@hidden>
+
+ * auth-source.el (plstore-delete): Autoload.
+ (auth-source-plstore-search): Support delete operation.
+ * plstore.el (plstore-delete): New function.
+
2011-07-01 Katsumi Yamaoka <address@hidden>
* gnus-draft.el (gnus-draft-clear-marks): Revert last change;
=== modified file 'lisp/gnus/auth-source.el'
--- a/lisp/gnus/auth-source.el 2011-07-01 01:25:21 +0000
+++ b/lisp/gnus/auth-source.el 2011-07-01 07:35:39 +0000
@@ -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 @@
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 @@
'(: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 @@
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 @@
;; 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
=== modified file 'lisp/gnus/plstore.el'
--- a/lisp/gnus/plstore.el 2011-07-01 02:07:32 +0000
+++ b/lisp/gnus/plstore.el 2011-07-01 07:35:39 +0000
@@ -337,6 +337,24 @@
(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."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r104835: Add plstore-delete.,
Daiki Ueno <=