diff options
| author | Teodor Zlatanov | 2014-04-27 22:08:43 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2014-04-27 22:08:43 +0000 |
| commit | 8f25c2bc56c65825e59651522ceb7b4855eb8205 (patch) | |
| tree | f4cca306d527ad087c5b6115fb15637006a659e7 | |
| parent | 5ba339c7f48f3a9e92087b590375102f9a8cc0b0 (diff) | |
| download | emacs-8f25c2bc56c65825e59651522ceb7b4855eb8205.tar.gz emacs-8f25c2bc56c65825e59651522ceb7b4855eb8205.zip | |
lisp/gnus.auth-source.el (auth-source-search): return boolean on :max 0
* lisp/gnus.auth-source.el (auth-source-search, auth-source-search-backends):
Treat :max 0 as an indicator that a boolean return is wanted, as
documented. Reported by Joe Bloggs.
| -rw-r--r-- | lisp/gnus/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/gnus/auth-source.el | 22 |
2 files changed, 21 insertions, 7 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index ca3071495db..f766dd539cf 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-04-27 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * auth-source.el (auth-source-search, auth-source-search-backends): | ||
| 4 | Treat :max 0 as an indicator that a boolean return is wanted, as | ||
| 5 | documented. Reported by Joe Bloggs. | ||
| 6 | |||
| 1 | 2014-04-20 Katsumi Yamaoka <yamaoka@jpl.org> | 7 | 2014-04-20 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 8 | ||
| 3 | * gnus-icalendar.el: Require gnus-art. | 9 | * gnus-icalendar.el: Require gnus-art. |
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el index 42db423ac8a..2efb16b8611 100644 --- a/lisp/gnus/auth-source.el +++ b/lisp/gnus/auth-source.el | |||
| @@ -654,9 +654,11 @@ Use `auth-source-delete' in ELisp code instead of calling | |||
| 654 | 'secrets are the only ones supported right now. | 654 | 'secrets are the only ones supported right now. |
| 655 | 655 | ||
| 656 | :max N means to try to return at most N items (defaults to 1). | 656 | :max N means to try to return at most N items (defaults to 1). |
| 657 | When 0 the function will return just t or nil to indicate if any | 657 | More than N items may be returned, depending on the search and |
| 658 | matches were found. More than N items may be returned, depending | 658 | the backend. |
| 659 | on the search and the backend. | 659 | |
| 660 | When :max is 0 the function will return just t or nil to indicate | ||
| 661 | if any matches were found. | ||
| 660 | 662 | ||
| 661 | :host (X Y Z) means to match only hosts X, Y, or Z according to | 663 | :host (X Y Z) means to match only hosts X, Y, or Z according to |
| 662 | the match rules above. Defaults to t. | 664 | the match rules above. Defaults to t. |
| @@ -757,18 +759,22 @@ must call it to obtain the actual value." | |||
| 757 | (when auth-source-do-cache | 759 | (when auth-source-do-cache |
| 758 | (auth-source-remember spec found))) | 760 | (auth-source-remember spec found))) |
| 759 | 761 | ||
| 760 | found)) | 762 | (if (zerop max) |
| 763 | (not (null found)) | ||
| 764 | found))) | ||
| 761 | 765 | ||
| 762 | (defun auth-source-search-backends (backends spec max create delete require) | 766 | (defun auth-source-search-backends (backends spec max create delete require) |
| 763 | (let (matches) | 767 | (let ((max (if (zerop max) 1 max)) ; stop with 1 match if we're asked for zero |
| 768 | matches) | ||
| 764 | (dolist (backend backends) | 769 | (dolist (backend backends) |
| 765 | (when (> max (length matches)) ; when we need more matches... | 770 | (when (> max (length matches)) ; if we need more matches... |
| 766 | (let* ((bmatches (apply | 771 | (let* ((bmatches (apply |
| 767 | (slot-value backend 'search-function) | 772 | (slot-value backend 'search-function) |
| 768 | :backend backend | 773 | :backend backend |
| 769 | :type (slot-value backend :type) | 774 | :type (slot-value backend :type) |
| 770 | ;; note we're overriding whatever the spec | 775 | ;; note we're overriding whatever the spec |
| 771 | ;; has for :require, :create, and :delete | 776 | ;; has for :max, :require, :create, and :delete |
| 777 | :max max | ||
| 772 | :require require | 778 | :require require |
| 773 | :create create | 779 | :create create |
| 774 | :delete delete | 780 | :delete delete |
| @@ -783,6 +789,7 @@ must call it to obtain the actual value." | |||
| 783 | (setq matches (append matches bmatches)))))) | 789 | (setq matches (append matches bmatches)))))) |
| 784 | matches)) | 790 | matches)) |
| 785 | 791 | ||
| 792 | ;; (auth-source-search :max 0) | ||
| 786 | ;; (auth-source-search :max 1) | 793 | ;; (auth-source-search :max 1) |
| 787 | ;; (funcall (plist-get (nth 0 (auth-source-search :max 1)) :secret)) | 794 | ;; (funcall (plist-get (nth 0 (auth-source-search :max 1)) :secret)) |
| 788 | ;; (auth-source-search :host "nonesuch" :type 'netrc :K 1) | 795 | ;; (auth-source-search :host "nonesuch" :type 'netrc :K 1) |
| @@ -1653,6 +1660,7 @@ authentication tokens: | |||
| 1653 | 1660 | ||
| 1654 | ;; (let ((auth-sources '("macos-keychain-internet:/Users/tzz/Library/Keychains/login.keychain"))) (auth-source-search :max 1)) | 1661 | ;; (let ((auth-sources '("macos-keychain-internet:/Users/tzz/Library/Keychains/login.keychain"))) (auth-source-search :max 1)) |
| 1655 | ;; (let ((auth-sources '("macos-keychain-generic:Login"))) (auth-source-search :max 1 :host "git.gnus.org")) | 1662 | ;; (let ((auth-sources '("macos-keychain-generic:Login"))) (auth-source-search :max 1 :host "git.gnus.org")) |
| 1663 | ;; (let ((auth-sources '("macos-keychain-generic:Login"))) (auth-source-search :max 1)) | ||
| 1656 | 1664 | ||
| 1657 | (defun* auth-source-macos-keychain-search (&rest | 1665 | (defun* auth-source-macos-keychain-search (&rest |
| 1658 | spec | 1666 | spec |