(put 'load-library 'minibuffer-action "load")
+(defun load-libraries-for-prefix (prefix)
+ "Load libraries that define symbols whose name starts with PREFIX."
+ (interactive
+ (let* ((str (thing-at-point 'symbol))
+ (def (if (gethash str definition-prefixes) str
+ (when (gethash (setq str (concat str "-")) definition-prefixes)
+ str))))
+ (list (completing-read
+ (format-prompt "Load libraries for prefix" def)
+ (completion-table-with-metadata
+ definition-prefixes
+ `((affixation-function
+ . ,(lambda (cands)
+ (let ((max (seq-max (cons 0 (mapcar #'string-width cands)))))
+ (mapcar
+ (lambda (cand)
+ (list cand ""
+ (concat (make-string (1+ (- max (string-width cand))) ?\s)
+ (propertize
+ (string-join (seq-uniq (gethash cand definition-prefixes)) ",")
+ 'face 'completions-annotations
+ 'help-echo "library"))))
+ cands))))))
+ (lambda (_prefix libraries)
+ (seq-some (lambda (library)
+ (not (featurep (intern-soft library))))
+ libraries))
+ t nil nil def))))
+ (mapc #'load (gethash prefix definition-prefixes)))
+
+(put 'load-libraries-for-prefix 'minibuffer-action "load")
+
(defun require-with-check (feature &optional filename noerror)
"If FEATURE is not already loaded, load it from FILENAME.
This is like `require' except if FEATURE is already a member of the list