mirror of
https://github.com/dimitri/el-get.git
synced 2024-09-29 13:08:51 +08:00
Merge pull request #641 from DarwinAwardWinner/new-status-fixes
New status fixes
This commit is contained in:
commit
68fa0ebd30
|
@ -64,7 +64,7 @@
|
|||
;; make sure we can actually byte-compile it
|
||||
(el-get-ensure-byte-compilable-autoload-file generated-autoload-file)
|
||||
|
||||
(when (string= (el-get-package-status package) "installed")
|
||||
(when (el-get-package-is-installed package)
|
||||
(apply 'update-directory-autoloads (el-get-load-path package)))
|
||||
|
||||
(el-get-save-and-kill el-get-autoload-file)
|
||||
|
|
|
@ -303,7 +303,7 @@ matching REGEX with TYPE and ARGS as parameter."
|
|||
((string= el-get-package-menu-sort-key "Status")
|
||||
#'(lambda (package)
|
||||
(let ((package-name (el-get-as-string (plist-get package :name))))
|
||||
(el-get-package-status package-name))))
|
||||
(el-get-read-package-status package-name))))
|
||||
((string= el-get-package-menu-sort-key "Description")
|
||||
#'(lambda (package)
|
||||
(plist-get package :description)))
|
||||
|
@ -319,7 +319,7 @@ matching REGEX with TYPE and ARGS as parameter."
|
|||
(mapc (lambda (package)
|
||||
(let ((package-name (el-get-as-string (plist-get package :name))))
|
||||
(el-get-print-package package-name
|
||||
(el-get-package-status package-name)
|
||||
(el-get-read-package-status package-name)
|
||||
(plist-get package :description))))
|
||||
packages))
|
||||
(goto-char (point-min))
|
||||
|
|
|
@ -19,11 +19,19 @@
|
|||
;; miserably.
|
||||
;;
|
||||
|
||||
(require 'cl)
|
||||
(require 'el-get-core)
|
||||
|
||||
(defvar el-get-status-file-cache nil
|
||||
"Cache variable used to avoid re-reading status file from disk.
|
||||
|
||||
This variable may safely be set to nil at any time. Doing so
|
||||
would force the package statuses to be re-read from disk.")
|
||||
|
||||
(defun el-get-save-package-status (package status)
|
||||
"Save given package status"
|
||||
(let* ((recipe (el-get-package-def package))
|
||||
(let* ((package (el-get-as-symbol package))
|
||||
(recipe (el-get-package-def package))
|
||||
(package-status-alist
|
||||
(assq-delete-all package (el-get-read-status-file)))
|
||||
(new-package-status-alist
|
||||
|
@ -35,70 +43,75 @@
|
|||
(el-get-as-string (car p2)))))))
|
||||
(with-temp-file el-get-status-file
|
||||
(pp new-package-status-alist (current-buffer)))
|
||||
new-package-status-alist))
|
||||
;; Cache and return the new alist
|
||||
(setq el-get-status-file-cache
|
||||
new-package-status-alist)))
|
||||
|
||||
(defun el-get-read-status-file ()
|
||||
"read `el-get-status-file' and return an alist of plist like:
|
||||
(PACKAGE . (status \"status\" recipe (:name ...)))"
|
||||
(let ((ps
|
||||
(when (file-exists-p el-get-status-file)
|
||||
(car (with-temp-buffer
|
||||
(insert-file-contents-literally el-get-status-file)
|
||||
(read-from-string (buffer-string)))))))
|
||||
(if (consp (car ps)) ; check for an alist, new format
|
||||
ps
|
||||
;; convert to the new format, fetching recipes as we go
|
||||
(loop for (p s) on ps by 'cddr
|
||||
for x = (el-get-as-symbol (el-get-package-name p))
|
||||
when x
|
||||
collect (cons x (list 'status s
|
||||
'recipe (el-get-package-def x)))))))
|
||||
(or el-get-status-file-cache
|
||||
(setq
|
||||
el-get-status-file-cache
|
||||
(let ((ps
|
||||
(when (file-exists-p el-get-status-file)
|
||||
(car (with-temp-buffer
|
||||
(insert-file-contents-literally el-get-status-file)
|
||||
(read-from-string (buffer-string)))))))
|
||||
(if (consp (car ps)) ; check for an alist, new format
|
||||
ps)
|
||||
;; convert to the new format, fetching recipes as we go
|
||||
(loop for (p s) on ps by 'cddr
|
||||
for x = (el-get-as-symbol (el-get-package-name p))
|
||||
when x
|
||||
collect (cons x (list 'status s
|
||||
'recipe (el-get-package-def x))))))))
|
||||
|
||||
(defun el-get-package-status-alist (&optional package-status-alist)
|
||||
"return an alist of (PACKAGE . STATUS)"
|
||||
(loop for (p . prop) in (or package-status-alist
|
||||
(el-get-convert-status-format))
|
||||
(el-get-read-status-file))
|
||||
collect (cons p (plist-get prop 'status))))
|
||||
|
||||
(defun el-get-read-package-status (package &optional package-status-alist)
|
||||
"return current status for PACKAGE"
|
||||
(let ((p-alist (or package-status-alist (el-get-read-status-file))))
|
||||
(plist-get (cdr (assq package p-alist)) 'status)))
|
||||
(plist-get (cdr (assq (el-get-as-symbol package) p-alist)) 'status)))
|
||||
|
||||
(define-obsolete-function-alias 'el-get-package-status 'el-get-read-package-status)
|
||||
|
||||
(defun el-get-read-package-status-recipe (package &optional package-status-alist)
|
||||
"return current status for PACKAGE"
|
||||
(let ((p-alist (or package-status-alist (el-get-read-status-file))))
|
||||
(plist-get (cdr (assq package p-alist)) 'recipe)))
|
||||
(plist-get (cdr (assq (el-get-as-symbol package) p-alist)) 'recipe)))
|
||||
|
||||
(defun el-get-list-package-names-with-status (&rest status)
|
||||
"Return package names that are currently in given status"
|
||||
(loop for (p . prop) in (el-get-read-status-file)
|
||||
for s = (plist-get prop 'status)
|
||||
when (member s status)
|
||||
collect (el-get-as-string p)))
|
||||
|
||||
(defun el-get-filter-package-alist-with-status (package-status-alist &rest status)
|
||||
(defun el-get-filter-package-alist-with-status (package-status-alist &rest statuses)
|
||||
"Return package names that are currently in given status"
|
||||
(loop for (p . prop) in package-status-alist
|
||||
for s = (plist-get prop 'status)
|
||||
when (member s status)
|
||||
when (member s statuses)
|
||||
collect (el-get-as-string p)))
|
||||
|
||||
(defun el-get-read-package-with-status (action &rest status)
|
||||
(defun el-get-list-package-names-with-status (&rest statuses)
|
||||
"Return package names that are currently in given status"
|
||||
(apply #'el-get-filter-package-alist-with-status
|
||||
(el-get-read-status-file)
|
||||
statuses))
|
||||
|
||||
(defun el-get-read-package-with-status (action &rest statuses)
|
||||
"Read a package name in given status"
|
||||
(completing-read (format "%s package: " action)
|
||||
(apply 'el-get-list-package-names-with-status status)))
|
||||
(apply 'el-get-list-package-names-with-status statuses)))
|
||||
|
||||
(defun el-get-count-package-with-status (&rest status)
|
||||
(defun el-get-count-package-with-status (&rest statuses)
|
||||
"Return how many packages are currently in given status"
|
||||
(loop for (p . prop) in (el-get-read-status-file)
|
||||
count (member (plist-get prop 'status) status)))
|
||||
(length (apply #'el-get-list-package-names-with-status statuses)))
|
||||
|
||||
(defun el-get-count-packages-with-status (packages &rest status)
|
||||
(defun el-get-count-packages-with-status (packages &rest statuses)
|
||||
"Return how many packages are currently in given status in PACKAGES"
|
||||
(loop for (p . prop) in (el-get-read-status-file)
|
||||
count (and (member (el-get-as-symbol p) packages)
|
||||
(member (plist-get prop 'status) status))))
|
||||
(length (intersection
|
||||
(mapcar #'el-get-as-symbol (apply #'el-get-list-package-names-with-status statuses))
|
||||
(mapcar #'el-get-as-symbol packages))))
|
||||
|
||||
(defun el-get-extra-packages (&rest packages)
|
||||
"Return installed or required packages that are not in given package list"
|
||||
|
|
|
@ -319,8 +319,10 @@ package names."
|
|||
(error "el-get: package `%s' has incomplete recipe (no :type)" package))))
|
||||
|
||||
(defun el-get-package-is-installed (package)
|
||||
"Raise an error if PACKAGE is already installed"
|
||||
(string= "installed" (el-get-package-status (el-get-as-string package))))
|
||||
"Return true if PACKAGE is installed"
|
||||
(and (file-directory-p (el-get-package-directory package))
|
||||
(string= "installed"
|
||||
(el-get-read-package-status package))))
|
||||
|
||||
(defun el-get-read-package-name (action &optional filtered)
|
||||
"Ask user for a package name in minibuffer, with completion.
|
||||
|
@ -601,7 +603,7 @@ PACKAGE may be either a string or the corresponding symbol."
|
|||
(defun el-get-do-install (package)
|
||||
"Install any PACKAGE for which you have a recipe."
|
||||
(el-get-error-unless-package-p package)
|
||||
(if (string= (el-get-package-status package) "installed")
|
||||
(if (el-get-package-is-installed package)
|
||||
(el-get-init package)
|
||||
(let* ((status (el-get-read-package-status package))
|
||||
(source (el-get-package-def package))
|
||||
|
|
|
@ -17,6 +17,7 @@ set_default EL_GET_LIB_DIR "$(dirname "$(dirname "$(readlink -f "$0")")")"
|
|||
set_default TMPDIR "$(dirname "$(mktemp --dry-run)")"
|
||||
set_default TEST_HOME "$TMPDIR/el-get-test-home"
|
||||
set_default EMACS "$(which emacs)"
|
||||
set_default TEST_DIR "$(dirname $0)"
|
||||
|
||||
run_test () {
|
||||
for x in "$1" "$TEST_DIR/$1" "$TEST_DIR/$1.el" "$TEST_DIR/el-get-issue-$1.el"; do
|
||||
|
|
Loading…
Reference in New Issue
Block a user