From ac65ffa2071fc427667d1b9c4bd42ce14f226e6b Mon Sep 17 00:00:00 2001 From: Lars Tveito Date: Wed, 3 Feb 2016 00:27:40 +0100 Subject: [PATCH] Clean up completion --- try.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/try.el b/try.el index 5be176f..b6ee082 100644 --- a/try.el +++ b/try.el @@ -100,6 +100,12 @@ "Compose two functions." (lambda (&rest x) (funcall f (apply g x)))) +(defun try-complete (archive) + "Complete from available package names." + (let* ((f (try-compose #'symbol-name #'car)) + (pkgs (mapcar f archive))) + (completing-read "url or package: " pkgs))) + (defun try-and-refresh () "Refreshes package-list before calling `try'." (interactive) @@ -112,10 +118,7 @@ to a raw .el file. Packages are stored in `try-tmp-dir' and raw .el files are not stored at all." (interactive) ;; Completions for packages. - (let* ((url-or-package (completing-read - "url or package: " - (mapcar (try-compose 'symbol-name 'car) - package-archive-contents))) + (let* ((url-or-package (try-complete package-archive-contents)) (package-symbol (intern url-or-package))) (cond ((try-raw-link-p url-or-package) (try-raw-link url-or-package)) ((try-package-exists-p package-symbol)