-
While using (defun mp--package-annotator (pkg-list pkg-name)
"Annotate the candidate PKG-NAME using metadata in PKG-LIST."
(let* ((pkg (assoc (intern pkg-name) pkg-list))
(description (cdr (assoc 'description pkg)))
(version (cdr (assoc 'version pkg))))
(if (fboundp 'marginalia--fields)
(marginalia--fields
(version :face 'marginalia-version)
(description :face 'marginalia-documentation))
(format " %s - %s" version description))))
(defun mp-install-package ()
"Query for one or more MicroPython packages to install using `mip install`."
(interactive)
(when (boundp 'marginalia-command-categories)
(unless (assoc (intern "mp-install-package") marginalia-command-categories)
(add-to-list 'marginalia-command-categories
'(mp-install-package . not-emacs-package))))
(let* ((pkg-list (mp--fetch-index))
(completion-extra-properties `(:annotation-function ,(apply-partially 'mp--package-annotator pkg-list)))
(pkgs (completing-read-multiple "Package: " pkg-list)))
(message (format "installing: %s ..." (string-join pkgs " ")))
(mp--install pkgs t))) Any suggestions/corrections appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Please note that Marginalia is a user facing package and is not intended to be used as a library. |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks for the clarification. I misunderstood the previous version of the README when it referenced Perhaps it would help to use the Also, maybe the annotator regex's should be tighter so developers could use a prompt like "Python package: " and not trigger the marginalia default. I used the following to insure my (when (require 'marginalia nil t)
(add-to-list 'marginalia-command-categories
'(mp-install-package . not-emacs-package))) |
Beta Was this translation helpful? Give feedback.
Please note that Marginalia is a user facing package and is not intended to be used as a library.