Function: auth-source-netrc-search

auth-source-netrc-search is a byte-compiled function defined in auth-source.el.gz.

Signature

(auth-source-netrc-search &rest SPEC &key BACKEND REQUIRE CREATE TYPE MAX HOST USER PORT &allow-other-keys)

Documentation

Given a property list SPEC, return search matches from the :backend.

See auth-source-search for details on SPEC.

Source Code

;; Defined in /usr/src/emacs/lisp/auth-source.el.gz
(cl-defun auth-source-netrc-search (&rest spec
                                    &key backend require create
                                    type max host user port
                                    &allow-other-keys)
  "Given a property list SPEC, return search matches from the `:backend'.
See `auth-source-search' for details on SPEC."
  ;; just in case, check that the type is correct (null or same as the backend)
  (cl-assert (or (null type) (eq type (oref backend type)))
             t "Invalid netrc search: %s %s")

  (let ((results (auth-source-netrc-normalize
                  (auth-source-netrc-parse
                   :max max
                   :require require
                   :file (oref backend source)
                   :host (or host t)
                   :user (or user t)
                   :port (or port t))
                  (oref backend source))))

    ;; if we need to create an entry AND none were found to match
    (when (and create
               (not results))

      ;; 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))