[gnus git] branch master updated: =1= Do smarter auth-source creation if needed and still work without creation.
Ted Zlatanov <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 9f8ec3b0649842332bb2ea590997236088965721 (commit)
from d3688d0bb275d5d3dcca7cc741bddc8021ac06e7 (commit)
- Log -----------------------------------------------------------------
commit 9f8ec3b0649842332bb2ea590997236088965721
Author: Ted Zlatanov <[email protected]>
Date: Wed Feb 16 12:22:36 2011 -0600
Do smarter auth-source creation if needed and still work without creation.
* nnimap.el (nnimap-credentials): Remove the `inhibit-create'
parameter. Create entry if necessary by using :create t.
(nnimap-open-connection-1): Don't pass `inhibit-create'.
* auth-source.el (auth-source-netrc-create): Return a synthetic search
result when the user doesn't want to write to the file.
(auth-source-netrc-search): Expect a synthetic result and proceed
accordingly.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8e0c467..2577934 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-16 Teodor Zlatanov <[email protected]>
+
+ * auth-source.el (auth-source-netrc-create): Return a synthetic search
+ result when the user doesn't want to write to the file.
+ (auth-source-netrc-search): Expect a synthetic result and proceed
+ accordingly.
+
+ * nnimap.el (nnimap-credentials): Remove the `inhibit-create'
+ parameter. Create entry if necessary by using :create t.
+ (nnimap-open-connection-1): Don't pass `inhibit-create'.
+
2011-02-15 Teodor Zlatanov <[email protected]>
* auth-source.el (auth-source-debug): Enable by default and don't
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index a259c5c..29829eb 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -808,14 +808,17 @@ See `auth-source-search' for details on SPEC."
(when (and create
(= 0 (length results)))
- ;; create based on the spec
+ ;; create based on the spec and record the value
+ (setq results (or
+ ;; if the user did not want to create the entry
+ ;; in the file, it will be returned
(apply (slot-value backend 'create-function) spec)
- ;; turn off the :create key
- (setq spec (plist-put spec :create nil))
- ;; run the search again to get the updated data
- ;; the result will be returned, even if the search fails
- (setq results (apply 'auth-source-netrc-search spec)))
+ ;; if not, we do the search again without :create
+ ;; to get the updated data.
+ ;; the result will be returned, even if the search fails
+ (apply 'auth-source-netrc-search
+ (plist-put spec :create nil)))))
results))
;;; (auth-source-search :host "nonesuch" :type 'netrc :max 1 :create t)
@@ -833,7 +836,9 @@ See `auth-source-search' for details on SPEC."
(file (oref backend source))
(add "")
;; `valist' is an alist
- valist)
+ valist
+ ;; `artificial' will be returned if no creation is needed
+ artificial)
;; only for base required elements (defined as function parameters):
;; fill in the valist with whatever data we may have from the search
@@ -902,6 +907,14 @@ See `auth-source-search' for details on SPEC."
nil nil default))
(t data))))
+ (when data
+ (setq artificial (plist-put artificial
+ (intern (concat ":" (symbol-name r)))
+ (if (eq r 'secret)
+ (lexical-let ((data data))
+ (lambda () data))
+ data))))
+
;; when r is not an empty string...
(when (and (stringp data)
(< 0 (length data)))
@@ -935,14 +948,17 @@ See `auth-source-search' for details on SPEC."
(goto-char (point-max))
;; ask AFTER we've successfully opened the file
- (when (y-or-n-p (format "Add to file %s: line [%s]" file add))
+ (if (y-or-n-p (format "Add to file %s: line [%s]" file add))
+ (progn
(unless (bolp)
(insert "\n"))
(insert add "\n")
(write-region (point-min) (point-max) file nil 'silent)
(auth-source-do-debug
"auth-source-netrc-create: wrote 1 new line to %s"
- file)))))
+ file)
+ nil)
+ (list artificial)))))
;;; Backend specific parsing: Secrets API backend
diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index a5a001f..4e220bc 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -276,13 +276,11 @@ textual parts.")
(push (current-buffer) nnimap-process-buffers)
(current-buffer)))
-(defun nnimap-credentials (address ports &optional inhibit-create)
+(defun nnimap-credentials (address ports)
(let* ((found (nth 0 (auth-source-search :max 1
:host address
:port ports
- :create (if inhibit-create
- nil
- (null ports)))))
+ :create t)))
(user (plist-get found :user))
(secret (plist-get found :secret))
(secret (if (functionp secret) (funcall secret) secret)))
@@ -389,7 +387,7 @@ textual parts.")
(list
(nnoo-current-server 'nnimap)
nnimap-address)
- ports t))))
+ ports))))
(setq nnimap-object nil)
(let ((nnimap-inhibit-logging t))
(setq login-result
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 11 +++++++++++
lisp/auth-source.el | 50 +++++++++++++++++++++++++++++++++-----------------
lisp/nnimap.el | 8 +++-----
3 files changed, 47 insertions(+), 22 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project