comparison lisp/package-get.el @ 1832:5d8dcaecc32b

[xemacs-hg @ 2003-12-19 11:24:58 by youngs] 2003-12-15 Steve Youngs <sryoungs@bigpond.net.au> * package-get.el (package-get-list-packages-where): New. A function that allows searching for groups of packages. For example, find all packages that require the fsf-compat package.
author youngs
date Fri, 19 Dec 2003 11:24:59 +0000
parents dc1a3d060f4f
children cac9e42fd31d
comparison
equal deleted inserted replaced
1831:c05c2d638def 1832:5d8dcaecc32b
912 (if arg 912 (if arg
913 (insert (format "%s" info)) 913 (insert (format "%s" info))
914 info)))) 914 info))))
915 915
916 ;;;###autoload 916 ;;;###autoload
917 (defun package-get-list-packages-where (item field &optional arg)
918 "Return a list of packages that fulfill certain criteria.
919
920 Argument ITEM, a symbol, is what you want to check for. ITEM must be a
921 symbol even when it doesn't make sense to be a symbol \(think, searching
922 maintainers, descriptions, etc\). The function will convert the symbol
923 to a string if a string is what is needed. The downside to this is that
924 ITEM can only ever be a single word.
925
926 Argument FIELD, a symbol, is the field to check in. You can specify
927 any one of:
928
929 Field Sane or Allowable Content
930 description any single word
931 category `standard' or `mule'
932 maintainer any single word
933 build-date yyyy-mm-dd
934 date yyyy-mm-dd
935 type `regular' or `single'
936 requires any package name
937 provides any symbol
938 priority `low', `medium', or `high'
939
940 Optional Argument ARG, a prefix arg, insert output at point in the
941 current buffer."
942 (interactive "SList packages that have (item): \nSin their (field): \nP")
943 (package-get-require-base nil)
944 (let ((pkgs package-get-base)
945 (strings '(description category maintainer build-date date))
946 (symbols '(type requires provides priority))
947 results)
948 (cond ((memq field strings)
949 (setq item (symbol-name item))
950 (while pkgs
951 (when (string-match item (package-get-info (caar pkgs) field))
952 (setq results (push (caar pkgs) results)))
953 (setq pkgs (cdr pkgs))))
954 ((memq field symbols)
955 (if (or (eq field 'type)
956 (eq field 'priority))
957 (while pkgs
958 (when (eq item (package-get-info (caar pkgs) field))
959 (setq results (push (caar pkgs) results)))
960 (setq pkgs (cdr pkgs)))
961 (while pkgs
962 (when (memq item (package-get-info (caar pkgs) field))
963 (setq results (push (caar pkgs) results)))
964 (setq pkgs (cdr pkgs)))))
965 (t
966 (error 'wrong-type-argument field)))
967 (if (interactive-p)
968 (if arg
969 (insert (format "%s" results))
970 (message "%s" results)))
971 results))
972
973 ;;;###autoload
917 (defun package-get (package &optional version conflict install-dir) 974 (defun package-get (package &optional version conflict install-dir)
918 "Fetch PACKAGE from remote site. 975 "Fetch PACKAGE from remote site.
919 Optional arguments VERSION indicates which version to retrieve, nil 976 Optional arguments VERSION indicates which version to retrieve, nil
920 means most recent version. CONFLICT indicates what happens if the 977 means most recent version. CONFLICT indicates what happens if the
921 package is already installed. Valid values for CONFLICT are: 978 package is already installed. Valid values for CONFLICT are: