(cl-return 'no)))
'no))))
-(defun auth-source-pick-first-password (&rest spec)
- "Pick the first secret found from applying SPEC to `auth-source-search'."
- (let* ((result (nth 0 (apply #'auth-source-search (plist-put spec :max 1))))
- (secret (plist-get result :secret)))
-
+(defun auth-info-password (auth-info)
+ "Return the :secret password from the AUTH-INFO."
+ (let ((secret (plist-get auth-info :secret)))
(if (functionp secret)
(funcall secret)
secret)))
+(defun auth-source-pick-first-password (&rest spec)
+ "Pick the first secret found from applying SPEC to `auth-source-search'."
+ (auth-info-password (car (apply #'auth-source-search (plist-put spec :max 1)))))
+
(defun auth-source-format-prompt (prompt alist)
"Format PROMPT using %x (for any character x) specifiers in ALIST.
Remove trailing \": \"."
(plist-put
artificial
:save-function
- (let* ((collection collection)
- (item (plist-get artificial :label))
- (secret (plist-get artificial :secret))
- (secret (if (functionp secret) (funcall secret) secret)))
+ (let ((collection collection)
+ (item (plist-get artificial :label))
+ (secret (auth-info-password artificial)))
(lambda ()
(auth-source-secrets-saver collection item secret args)))))
:require '(:user :secret)
:create nil))))
(user (plist-get auth-info :user))
- (password (plist-get auth-info :secret)))
- (when (functionp password)
- (setq password (funcall password)))
+ (password (auth-info-password auth-info)))
(list user password auth-info)))
;;; Tiny mode for editing .netrc/.authinfo modes (that basically just
(cl-second (assoc network
erc-nickserv-passwords)))))
(when erc-use-auth-source-for-nickserv-password
- (let ((secret (cl-first (auth-source-search
- :max 1 :require '(:secret)
- :host server
- ;; Ensure a string for :port
- :port (format "%s" port)
- :user nick))))
- (when secret
- (let ((passwd (plist-get secret :secret)))
- (if (functionp passwd) (funcall passwd) passwd)))))
+ (auth-source-pick-first-password
+ :require '(:secret)
+ :host server
+ ;; Ensure a string for :port
+ :port (format "%s" port)
+ :user nick))
(when erc-prompt-for-nickserv-password
(read-passwd
(format "NickServ password for %s on %s (RET to cancel): "
;; password stuff
(setq erc-session-password
(or passwd
- (let ((secret
- (plist-get
- (nth 0
- (auth-source-search :host server
- :max 1
- :user nick
- ;; secrets.el wouldn’t accept a number
- :port (if (numberp port) (number-to-string port) port)
- :require '(:secret)))
- :secret)))
- (if (functionp secret)
- (funcall secret)
- secret))))
+ (auth-source-pick-first-password
+ :host server
+ :user nick
+ ;; secrets.el wouldn’t accept a number
+ :port (if (numberp port) (number-to-string port) port)
+ :require '(:secret))))
;; client certificate (only useful if connecting over TLS)
(setq erc-session-client-certificate client-certificate)
;; debug output buffer
(put 'erc-cmd-HELP 'process-not-needed t)
(defun erc-server-join-channel (server channel &optional secret)
- (let* ((secret (or secret
- (plist-get (nth 0 (auth-source-search
- :max 1
- :host server
- :port "irc"
- :user channel))
- :secret)))
- (password (if (functionp secret)
- (funcall secret)
- secret)))
+ (let ((password
+ (or secret
+ (auth-source-pick-first-password
+ :host server
+ :port "irc"
+ :user channel))))
(erc-log (format "cmd: JOIN: %s" channel))
(erc-server-send (concat "JOIN " channel
(if password
search))))
:user)))
user-auth)
- ((and
+ ((and ; cf. 'auth-source-pick-first-password'
(eq keyword :password)
(setq pass-auth
(plist-get
(autoload 'auth-source-forget+ "auth-source")
(autoload 'auth-source-search "auth-source")
+(autoload 'auth-info-password "auth-source")
(nnoo-declare nnimap)
:create t))))
(if found
(list (plist-get found :user)
- (let ((secret (plist-get found :secret)))
- (if (functionp secret)
- (funcall secret)
- secret))
+ (auth-info-password found)
(plist-get found :save-function))
nil)))
(eval-when-compile (require 'cl-lib))
(autoload 'auth-source-search "auth-source")
+(autoload 'auth-info-password "auth-source")
(defgroup nntp nil
"NNTP access for Gnus."
"563" "nntps" "snews"))))
(auth-user (plist-get auth-info :user))
(auth-force (plist-get auth-info :force))
- (auth-passwd (plist-get auth-info :secret))
- (auth-passwd (if (functionp auth-passwd)
- (funcall auth-passwd)
- auth-passwd))
+ (auth-passwd (auth-info-password auth-info))
(force (or (netrc-get alist "force")
nntp-authinfo-force
auth-force))
:max 1 :user user :host host
:require '(:secret)))))
(if found
- (let ((secret (plist-get found :secret)))
- (if (functionp secret)
- (funcall secret)
- secret))
+ (auth-info-password found)
(read-passwd (if imap
"IMAP password: "
"POP password: "))))))
:create ask-for-password)))
(mech (or (plist-get auth-info :smtp-auth) (car mechs)))
(user (plist-get auth-info :user))
- (password (plist-get auth-info :secret))
+ (password (auth-info-password auth-info))
(save-function (and ask-for-password
(plist-get auth-info :save-function))))
- (when (functionp password)
- (setq password (funcall password)))
(when (and user
(not password))
;; The user has stored the user name, but not the password, so
:user smtpmail-smtp-user
:require '(:user :secret)
:create t))
- password (plist-get auth-info :secret)))
- (when (functionp password)
- (setq password (funcall password)))
+ password (auth-info-password auth-info)))
(let ((result (catch 'done
(if (and mech user password)
(smtpmail-try-auth-method process mech user password)
(auth (auth-source-search :host server
:user user-name
:port port))
- (fn (plist-get (car auth) :secret)))
- (setq password (funcall fn)))
+ (pwd (auth-info-password (car auth))))
+ (setq password pwd))
(when server
(let (connected)
(dolist (p (rcirc-process-list))
(require 'sasl)
(autoload 'sasl-find-mechanism "sasl")
(autoload 'auth-source-search "auth-source")
+(autoload 'auth-info-password "auth-source")
;; User customizable variables:
:max 1
:create t))
(user-name (or (plist-get (nth 0 auth-info) :user) ""))
- (user-password (or (plist-get (nth 0 auth-info) :secret) ""))
- (user-password (if (functionp user-password)
- (funcall user-password)
- user-password))
+ (user-password (or (auth-info-password (nth 0 auth-info)) ""))
(client (sasl-make-client (sasl-find-mechanism (list mech))
user-name "sieve" sieve-manage-server))
(sasl-read-passphrase
:create t))
tramp-password-save-function
(plist-get auth-info :save-function)
- auth-passwd (plist-get auth-info :secret)))
- (while (functionp auth-passwd)
- (setq auth-passwd (funcall auth-passwd)))
- auth-passwd)
+ auth-passwd (auth-info-password auth-info))))
;; Try the password cache.
(progn