branch: elpa/nix-mode
commit 3aeec264e09caa2f9bb5e651d7c70105257bfcd9
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>

    nix-search: add nix-search-read-attr
    
    This can be used for completion
---
 nix-search.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/nix-search.el b/nix-search.el
index f82f3cc3d3..e60e16923e 100644
--- a/nix-search.el
+++ b/nix-search.el
@@ -42,7 +42,19 @@ NIX-FILE a Nix expression to search in."
                     (alist-get 'description (cdr entry)))))
          )
        (display-buffer display 'display-buffer-pop-up-window)))
+    (kill-buffer stdout)
     result))
 
+(defun nix-search-read-attr (nix-file)
+  "Read from a list of attributes.
+NIX-FILE the nix file to look in."
+  (let ((collection
+        (sort (mapcar (lambda (x) (symbol-name (car x)))
+                      (nix-search "" nix-file))
+              'string<))
+       (read (cond ((fboundp 'ivy-read) 'ivy-read)
+                   (t 'completing-read))))
+    (funcall read "Attribute: " collection)))
+
 (provide 'nix-search)
 ;;; nix-search.el ends here

Reply via email to