Commit 4310ef9d authored by Ryan C. Thompson's avatar Ryan C. Thompson

Reimplement el-get-update-specific-backend as el-get-update-packages-of-type

New definition is more canonical elisp, and uses two new el-get-core
functions "el-get-plist-keys" and "el-get-keyword-name".

Intended to improve #1412.
parent e71ba4c1
......@@ -38,6 +38,26 @@ the original object."
(defun el-get-verbose-message (format &rest arguments)
(when el-get-verbose (apply 'message format arguments)))
(defsubst el-get-plist-keys (plist)
"Return a list of all keys in PLIST.
Duplicates are removed."
(loop for (k _) on plist by #'cddr
collect k)
:test #'eq))
(defsubst el-get-keyword-name (keyword)
"Return the name of KEYWORD.
This is equivalent to `symbol-name' but it only works on keywords
and it strips the leading colon.
This raises an error if KEYWORD is not a keyword."
(or (keywordp keyword)
(error "Not a keyword: %S" keyword))
(substring (symbol-name keyword) 1))
;; el-get-methods support, those are like backends.
......@@ -844,21 +844,23 @@ itself.")
(mapc 'el-get-update (el-get-list-package-names-with-status "installed"))))))
(defun el-get-update-specific-backend (&optional backend)
"Perform update of user specified BACKEND."
(let* ((backends
;; FIXME what's the proper way to get all keys in a plist
(remq nil (mapcar (lambda (e)
(if (symbolp e)
(substring (format "%s" e) 1)))
(be (or backend (not (called-interactively-p)) (completing-read
"Backend name: " backends nil t nil))))
(if (and be (member be backends))
(mapcar 'el-get-update (remq nil (mapcar 'car (el-get-package-types-alist
"installed" (intern be)))))
(user-error "Unknown backend \"%s\"" be))))
(defun el-get-update-packages-of-type (type)
"Update all installed packages of type TYPE."
;; TODO Update info file about this new command
(let ((types
(mapcar #'el-get-keyword-name
(el-get-plist-keys el-get-methods))))
(list (completing-read
"Type name: " types nil t))))
(when (not (el-get-method-defined-p type))
(user-error "Unknown package type \"%s\"" type))
(let ((pkgnames
(mapcar 'car (el-get-package-types-alist
"installed" (intern type)))))
(if pkgnames
(mapcar 'el-get-update pkgnames)
(message "No installed packages of type \"%s\"" type))))
(defun el-get-self-update ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment