+2011-02-16 Lars Ingebrigtsen <larsi@gnus.org>
+
+ * gnus-sum.el (gnus-propagate-marks): Change default to t again, since
+ nil means that nnimap doesn't get updated.
+
+2011-02-16 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * 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.
+ (auth-source-cache-expiry): New variable to override
+ `password-cache-expiry'.
+ (auth-source-remember): Use it.
+
+ * 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 <tzz@lifelogs.com>
* auth-source.el (auth-source-debug): Enable by default and don't
:version "23.1" ;; No Gnus
:group 'gnus)
+;;;###autoload
+(defcustom auth-source-cache-expiry 7200
+ "How many seconds passwords are cached, or nil to disable
+expiring. Overrides `password-cache-expiry' through a
+let-binding."
+ :group 'auth-source
+ :type '(choice (const :tag "Never" nil)
+ (const :tag "All Day" 86400)
+ (const :tag "2 Hours" 7200)
+ (const :tag "30 Minutes" 1800)
+ (integer :tag "Seconds")))
+
(defclass auth-source-backend ()
((type :initarg :type
:initform 'netrc
(defun auth-source-remember (spec found)
"Remember FOUND search results for SPEC."
- (password-cache-add
- (concat auth-source-magic (format "%S" spec)) found))
+ (let ((password-cache-expiry auth-source-cache-expiry))
+ (password-cache-add
+ (concat auth-source-magic (format "%S" spec)) found)))
(defun auth-source-recall (spec)
"Recall FOUND search results for SPEC."
(when (and create
(= 0 (length results)))
- ;; create based on the spec
- (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)))
-
+ ;; 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)
+ ;; 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)
(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
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)))
(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))
- (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)))))
+ (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)
+ nil)
+ (list artificial)))))
;;; Backend specific parsing: Secrets API backend
(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)))
(list
(nnoo-current-server 'nnimap)
nnimap-address)
- ports t))))
+ ports))))
(setq nnimap-object nil)
(let ((nnimap-inhibit-logging t))
(setq login-result