diff options
| author | Daiki Ueno | 2011-07-01 16:35:39 +0900 |
|---|---|---|
| committer | Daiki Ueno | 2011-07-01 16:35:39 +0900 |
| commit | f3078a00412e29aac774f9a6780963313d4aebc9 (patch) | |
| tree | f062178deca413ec88a0015f2f91fe2082735394 | |
| parent | 85e428791ed26d2094d13a74b0e578e624885d92 (diff) | |
| download | emacs-f3078a00412e29aac774f9a6780963313d4aebc9.tar.gz emacs-f3078a00412e29aac774f9a6780963313d4aebc9.zip | |
Add plstore-delete.
* auth-source.el (plstore-delete): Autoload.
(auth-source-plstore-search): Support delete operation.
* plstore.el (plstore-delete): New function.
| -rw-r--r-- | lisp/gnus/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/gnus/auth-source.el | 19 | ||||
| -rw-r--r-- | lisp/gnus/plstore.el | 18 |
3 files changed, 35 insertions, 8 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 9bb234a1189..1b0b31c0088 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-07-01 Daiki Ueno <ueno@unixuser.org> | ||
| 2 | |||
| 3 | * auth-source.el (plstore-delete): Autoload. | ||
| 4 | (auth-source-plstore-search): Support delete operation. | ||
| 5 | * plstore.el (plstore-delete): New function. | ||
| 6 | |||
| 1 | 2011-07-01 Katsumi Yamaoka <yamaoka@jpl.org> | 7 | 2011-07-01 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 8 | ||
| 3 | * gnus-draft.el (gnus-draft-clear-marks): Revert last change; | 9 | * gnus-draft.el (gnus-draft-clear-marks): Revert last change; |
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el index 9d62d6a81c4..1b5b4840085 100644 --- a/lisp/gnus/auth-source.el +++ b/lisp/gnus/auth-source.el | |||
| @@ -60,6 +60,7 @@ | |||
| 60 | (autoload 'plstore-open "plstore") | 60 | (autoload 'plstore-open "plstore") |
| 61 | (autoload 'plstore-find "plstore") | 61 | (autoload 'plstore-find "plstore") |
| 62 | (autoload 'plstore-put "plstore") | 62 | (autoload 'plstore-put "plstore") |
| 63 | (autoload 'plstore-delete "plstore") | ||
| 63 | (autoload 'plstore-save "plstore") | 64 | (autoload 'plstore-save "plstore") |
| 64 | (autoload 'plstore-get-file "plstore") | 65 | (autoload 'plstore-get-file "plstore") |
| 65 | 66 | ||
| @@ -1523,11 +1524,6 @@ authentication tokens: | |||
| 1523 | type max host user port | 1524 | type max host user port |
| 1524 | &allow-other-keys) | 1525 | &allow-other-keys) |
| 1525 | "Search the PLSTORE; spec is like `auth-source'." | 1526 | "Search the PLSTORE; spec is like `auth-source'." |
| 1526 | |||
| 1527 | ;; TODO | ||
| 1528 | (assert (not delete) nil | ||
| 1529 | "The PLSTORE auth-source backend doesn't support deletion yet") | ||
| 1530 | |||
| 1531 | (let* ((store (oref backend data)) | 1527 | (let* ((store (oref backend data)) |
| 1532 | (max (or max 5000)) ; sanity check: default to stop at 5K | 1528 | (max (or max 5000)) ; sanity check: default to stop at 5K |
| 1533 | (ignored-keys '(:create :delete :max :backend :require)) | 1529 | (ignored-keys '(:create :delete :max :backend :require)) |
| @@ -1551,6 +1547,7 @@ authentication tokens: | |||
| 1551 | '(:host :login :port :secret) | 1547 | '(:host :login :port :secret) |
| 1552 | search-keys))) | 1548 | search-keys))) |
| 1553 | (items (plstore-find store search-spec)) | 1549 | (items (plstore-find store search-spec)) |
| 1550 | (item-names (mapcar #'car items)) | ||
| 1554 | (items (butlast items (- (length items) max))) | 1551 | (items (butlast items (- (length items) max))) |
| 1555 | ;; convert the item to a full plist | 1552 | ;; convert the item to a full plist |
| 1556 | (items (mapcar (lambda (item) | 1553 | (items (mapcar (lambda (item) |
| @@ -1574,9 +1571,10 @@ authentication tokens: | |||
| 1574 | returned-keys)) | 1571 | returned-keys)) |
| 1575 | plist)) | 1572 | plist)) |
| 1576 | items))) | 1573 | items))) |
| 1577 | ;; if we need to create an entry AND none were found to match | 1574 | (cond |
| 1578 | (when (and create | 1575 | ;; if we need to create an entry AND none were found to match |
| 1579 | (not items)) | 1576 | ((and create |
| 1577 | (not items)) | ||
| 1580 | 1578 | ||
| 1581 | ;; create based on the spec and record the value | 1579 | ;; create based on the spec and record the value |
| 1582 | (setq items (or | 1580 | (setq items (or |
| @@ -1589,6 +1587,11 @@ authentication tokens: | |||
| 1589 | ;; the result will be returned, even if the search fails | 1587 | ;; the result will be returned, even if the search fails |
| 1590 | (apply 'auth-source-plstore-search | 1588 | (apply 'auth-source-plstore-search |
| 1591 | (plist-put spec :create nil))))) | 1589 | (plist-put spec :create nil))))) |
| 1590 | ((and delete | ||
| 1591 | item-names) | ||
| 1592 | (dolist (item-name item-names) | ||
| 1593 | (plstore-delete store item-name)) | ||
| 1594 | (plstore-save store))) | ||
| 1592 | items)) | 1595 | items)) |
| 1593 | 1596 | ||
| 1594 | (defun* auth-source-plstore-create (&rest spec | 1597 | (defun* auth-source-plstore-create (&rest spec |
diff --git a/lisp/gnus/plstore.el b/lisp/gnus/plstore.el index 360388d002e..8d973a9b0ae 100644 --- a/lisp/gnus/plstore.el +++ b/lisp/gnus/plstore.el | |||
| @@ -337,6 +337,24 @@ SECRET-KEYS is a plist containing secret data." | |||
| 337 | (cons (cons name secret-plist) (plstore--get-secret-alist plstore))))) | 337 | (cons (cons name secret-plist) (plstore--get-secret-alist plstore))))) |
| 338 | (plstore--merge-secret plstore))) | 338 | (plstore--merge-secret plstore))) |
| 339 | 339 | ||
| 340 | (defun plstore-delete (plstore name) | ||
| 341 | "Delete an entry with NAME from PLSTORE." | ||
| 342 | (let ((entry (assoc name (plstore--get-alist plstore)))) | ||
| 343 | (if entry | ||
| 344 | (plstore--set-alist | ||
| 345 | plstore | ||
| 346 | (delq entry (plstore--get-alist plstore)))) | ||
| 347 | (setq entry (assoc name (plstore--get-secret-alist plstore))) | ||
| 348 | (if entry | ||
| 349 | (plstore--set-secret-alist | ||
| 350 | plstore | ||
| 351 | (delq entry (plstore--get-secret-alist plstore)))) | ||
| 352 | (setq entry (assoc name (plstore--get-merged-alist plstore))) | ||
| 353 | (if entry | ||
| 354 | (plstore--set-merged-alist | ||
| 355 | plstore | ||
| 356 | (delq entry (plstore--get-merged-alist plstore)))))) | ||
| 357 | |||
| 340 | (defvar pp-escape-newlines) | 358 | (defvar pp-escape-newlines) |
| 341 | (defun plstore-save (plstore) | 359 | (defun plstore-save (plstore) |
| 342 | "Save the contents of PLSTORE associated with a FILE." | 360 | "Save the contents of PLSTORE associated with a FILE." |