aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/auth-source.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-08-04 16:50:06 +0200
committerLars Ingebrigtsen2022-08-04 16:50:06 +0200
commitd92c11845a28f017d86471b523a3270e3345c707 (patch)
tree12752b6c8ae433a85f41172757184bfc1cfe62be /lisp/auth-source.el
parentf038695085d872124cbb87f2a0382d572014c540 (diff)
downloademacs-d92c11845a28f017d86471b523a3270e3345c707.tar.gz
emacs-d92c11845a28f017d86471b523a3270e3345c707.zip
Add new function auth-source-netrc-parse-all
* lisp/auth-source.el (auth-source-netrc-parse-all): New function (bug#56976). (auth-source-netrc-parse): Partially revert behaviour in previous change -- require :allow-null to match.
Diffstat (limited to 'lisp/auth-source.el')
-rw-r--r--lisp/auth-source.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 55dbaab3eed..48f9517683d 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -909,10 +909,16 @@ Remove trailing \": \"."
909(defun auth-source--aget (alist key) 909(defun auth-source--aget (alist key)
910 (cdr (assoc key alist))) 910 (cdr (assoc key alist)))
911 911
912(defun auth-source-netrc-parse-all (file)
913 "Parse FILE and return all entries."
914 (auth-source-netrc-parse :file file :allow-null t))
915
912;; (auth-source-netrc-parse :file "~/.authinfo.gpg") 916;; (auth-source-netrc-parse :file "~/.authinfo.gpg")
913(cl-defun auth-source-netrc-parse (&key file max host user port require 917(cl-defun auth-source-netrc-parse (&key file max host user port require
914 &allow-other-keys) 918 allow-null &allow-other-keys)
915 "Parse FILE and return a list of all entries in the file. 919 "Parse FILE and return a list of matching entries in the file.
920If ALLOW-NULL, allow nil values of HOST, USER and PORT to match.
921
916Note that the MAX parameter is used so we can exit the parse early." 922Note that the MAX parameter is used so we can exit the parse early."
917 (if (listp file) 923 (if (listp file)
918 ;; We got already parsed contents; just return it. 924 ;; We got already parsed contents; just return it.
@@ -928,7 +934,7 @@ Note that the MAX parameter is used so we can exit the parse early."
928 (check (lambda (alist) 934 (check (lambda (alist)
929 (and alist 935 (and alist
930 (or 936 (or
931 (null host) 937 (and allow-null (null host))
932 (auth-source-search-collection 938 (auth-source-search-collection
933 host 939 host
934 (or 940 (or
@@ -936,7 +942,7 @@ Note that the MAX parameter is used so we can exit the parse early."
936 (auth-source--aget alist "host") 942 (auth-source--aget alist "host")
937 t))) 943 t)))
938 (or 944 (or
939 (null user) 945 (and allow-null (null user))
940 (auth-source-search-collection 946 (auth-source-search-collection
941 user 947 user
942 (or 948 (or
@@ -945,7 +951,7 @@ Note that the MAX parameter is used so we can exit the parse early."
945 (auth-source--aget alist "user") 951 (auth-source--aget alist "user")
946 t))) 952 t)))
947 (or 953 (or
948 (null port) 954 (and allow-null (null port))
949 (auth-source-search-collection 955 (auth-source-search-collection
950 port 956 port
951 (or 957 (or