comparison lisp/package-get.el @ 2151:f33f1487208d

[xemacs-hg @ 2004-06-25 21:24:36 by youngs] 2004-06-26 Steve Youngs <steve@youngs.au.com> * package-get.el (package-get-info-name-array): New. (package-get-info-info-array): New. (package-get-info): Use them, adding completion. (package-get-list-packages-where): Add completion.
author youngs
date Fri, 25 Jun 2004 21:24:36 +0000
parents cac9e42fd31d
children 52d126cb63af
comparison
equal deleted inserted replaced
2150:2bb817b25741 2151:f33f1487208d
852 (if (not (package-get-load-package-file lispdir "auto-autoloads")) 852 (if (not (package-get-load-package-file lispdir "auto-autoloads"))
853 (package-get-load-package-file lispdir "_pkg")) 853 (package-get-load-package-file lispdir "_pkg"))
854 t) 854 t)
855 nil))) 855 nil)))
856 856
857 (defun package-get-info-name-array ()
858 "Internal, used by `package-get-info'."
859 (let ((pkgs package-get-base)
860 names)
861 (while pkgs
862 (setq names (let ((name (caar pkgs)))
863 (push (cons (format "%s" name) name) names)))
864 (setq pkgs (cdr pkgs)))
865 names))
866
867 (defconst package-get-info-info-array
868 '(("standards-version" . standards-version)
869 ("version" . version)
870 ("author-version" . author-version)
871 ("date" . date)
872 ("build-date" . build-date)
873 ("maintainer" . maintainer)
874 ("distribution" . distribution)
875 ("priority" . priority)
876 ("category" . category)
877 ("dump" . dump)
878 ("description" . description)
879 ("filename" . filename)
880 ("md5sum" . md5sum)
881 ("size" . size)
882 ("provides" . provides)
883 ("requires" . requires)
884 ("type" . type))
885 "Internal, used by `package-get-info'.")
886
857 ;;;###autoload 887 ;;;###autoload
858 (defun package-get-info (package information &optional arg remote) 888 (defun package-get-info (package information &optional arg remote)
859 "Get information about a package. 889 "Get information about a package.
860 890
861 Quite similar to `package-get-info-prop', but can retrieve a lot more 891 Quite similar to `package-get-info-prop', but can retrieve a lot more
882 size The size in bytes of filename. 912 size The size in bytes of filename.
883 provides A list of symbols that this package provides. 913 provides A list of symbols that this package provides.
884 requires A list of packages that this package requires. 914 requires A list of packages that this package requires.
885 type Can be either \"regular\" or \"single-file\". 915 type Can be either \"regular\" or \"single-file\".
886 916
887 If optional argument ARG is non-nil insert INFORMATION into current 917 Optional argument ARG is a prefix arg. Without a value, ie, just
888 buffer at point. This is very useful for doing things like inserting 918 doing `C-u M-x package-get-info' will insert the information at point
889 a maintainer's email address into a mail buffer. 919 in the current buffer using a local package list.
920
921 ARG can also be given a value of 2 or 3. If 2, use a remote package
922 list, displaying the information in the minubuffer. If 3, use a remote
923 package list and insert the information at point in the current buffer.
890 924
891 If optional argument REMOTE is non-nil use a package list from a 925 If optional argument REMOTE is non-nil use a package list from a
892 remote site. For this to work `package-get-remote' must be non-nil. 926 remote site.
927
928 To use a remote package list, either via the prefix argument ARG or
929 via the REMOTE argument `package-get-remote' must be non-nil. If
930 `package-get-remote' is nil, the local package list will be used.
893 931
894 If this function is called interactively it will display INFORMATION 932 If this function is called interactively it will display INFORMATION
895 in the minibuffer." 933 in the minibuffer."
896 (interactive "SPackage: \nSInfo: \nP") 934 (interactive "i\ni\np")
897 (if remote 935 (if (and package-get-remote
898 (package-get-require-base t) 936 (or (eq arg 2)
899 (package-get-require-base nil)) 937 (eq arg 3)
900 (let ((all-pkgs package-get-base) 938 remote))
901 info) 939 (package-get-require-base t)
940 (package-get-require-base nil))
941 (let ((all-pkgs package-get-base)
942 (package (or package
943 (intern (completing-read
944 "Package: "
945 (package-get-info-name-array) nil t))))
946 (information (or information
947 (intern (completing-read
948 "Info: "
949 package-get-info-info-array nil t))))
950 info)
902 (loop until (equal package (caar all-pkgs)) 951 (loop until (equal package (caar all-pkgs))
903 do (setq all-pkgs (cdr all-pkgs)) 952 do (setq all-pkgs (cdr all-pkgs))
904 do (if (not all-pkgs) 953 do (if (not all-pkgs)
905 (error 'invalid-argument 954 (error 'invalid-argument
906 (format "%s is not a valid package" package)))) 955 (format "%s is not a valid package" package))))
907 (setq info (plist-get (cadar all-pkgs) information)) 956 (setq info (plist-get (cadar all-pkgs) information))
908 (if (interactive-p) 957 (if (interactive-p)
909 (if arg 958 (if (or (eq arg 3)
959 (eq arg 4))
910 (insert (format "%s" info)) 960 (insert (format "%s" info))
911 (if (package-get-key package :version) 961 (if (package-get-key package :version)
912 (message "%s" info) 962 (message "%s" info)
913 (message "%s (Package: %s is not installed)" info package))) 963 (message "%s (Package: %s is not installed)" info package)))
914 (if arg 964 info)))
915 (insert (format "%s" info))
916 info))))
917 965
918 ;;;###autoload 966 ;;;###autoload
919 (defun package-get-list-packages-where (item field &optional arg) 967 (defun package-get-list-packages-where (item field &optional arg)
920 "Return a list of packages that fulfill certain criteria. 968 "Return a list of packages that fulfill certain criteria.
921 969
939 provides any symbol 987 provides any symbol
940 priority `low', `medium', or `high' 988 priority `low', `medium', or `high'
941 989
942 Optional Argument ARG, a prefix arg, insert output at point in the 990 Optional Argument ARG, a prefix arg, insert output at point in the
943 current buffer." 991 current buffer."
944 (interactive "SList packages that have (item): \nSin their (field): \nP") 992 (interactive
993 (list (intern (read-string "List packages that contain (text): "))
994 (intern (completing-read "in their package-info field (completion available): "
995 '(("description" . description)
996 ("category" . category)
997 ("maintainer" . maintainer)
998 ("build-date" . build-date)
999 ("date" . date)
1000 ("type" . type)
1001 ("requires" . requires)
1002 ("provides" . provides)
1003 ("priority" . priority)) nil t))
1004 current-prefix-arg))
945 (package-get-require-base nil) 1005 (package-get-require-base nil)
946 (let ((pkgs package-get-base) 1006 (let ((pkgs package-get-base)
947 (strings '(description category maintainer build-date date)) 1007 (strings '(description category maintainer build-date date))
948 (symbols '(type requires provides priority)) 1008 (symbols '(type requires provides priority))
949 results) 1009 results)