branch: elpa/helm commit 0e78bd5b0c20a8834f1a334d4610fab8a7961dfe Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Provide affix fn for library category --- helm-mode.el | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/helm-mode.el b/helm-mode.el index 5ee84a36ed..0f72d38b48 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -1013,7 +1013,10 @@ that use `helm-comp-read'. See `helm-M-x' for example." (category . coding-system))) (color . (metadata (affixation-function . helm-completion-color-affixation) - (category . color)))) + (category . color))) + (library . (metadata + (affixation-function . helm-completion-library-affixation) + (category . library)))) "Extra metadata for completing-read. Alist composed of (CATEGORY . METADATA). @@ -1270,6 +1273,23 @@ is used." (helm-aand (propertize rgb 'face `(:background ,rgb :distant-foreground "black")) (propertize " " 'display (concat sep it))))))) + +(defun helm-completion-library-affixation (_comps) + (lambda (comp) + (let* ((sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate) + (length comp))) + ? )) + (path (or (assoc-default comp helm-locate-library-cache) + (let ((p (find-library-name comp))) + (push (cons comp p) helm-locate-library-cache) + p))) + (doc (or (gethash comp helm-locate-library-doc-cache) + (puthash comp (helm-locate-lib-get-summary path) + helm-locate-library-doc-cache)))) + (list comp + "" + (helm-aand (propertize doc 'face 'font-lock-warning-face) + (propertize " " 'display (concat sep it))))))) ;;; Generic completing read ;;