[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog ea04f467b9 027/166: ADDED: sweep-pack-install f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog ea04f467b9 027/166: ADDED: sweep-pack-install for interactively installing packs |
Date: |
Fri, 30 Sep 2022 04:59:23 -0400 (EDT) |
branch: elpa/sweeprolog
commit ea04f467b9c498cfd313c93b9d572c25535101a6
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
ADDED: sweep-pack-install for interactively installing packs
---
sweep.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++
sweep.pl | 16 ++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/sweep.el b/sweep.el
index 012bd05abd..437d1efe34 100644
--- a/sweep.el
+++ b/sweep.el
@@ -31,6 +31,12 @@
:type 'string
:group 'sweep)
+(defcustom sweep-read-pack-prompt "Pack: "
+ "Prompt used for reading a Prolog pack name from the minibuffer."
+ :package-version '((sweep . "0.1.0"))
+ :type 'string
+ :group 'sweep)
+
(defvar sweep-install-buffer-name "*Install sweep*"
"Name of the buffer used for compiling sweep-module.")
@@ -155,6 +161,46 @@ module name, F is a functor name and N is its arity."
(interactive (list (sweep-read-module-name)))
(find-file (sweep-module-path mod)))
+
+(defun sweep-packs-collection ()
+ (sweep-open-query "user" "sweep" "sweep_packs_collection" "")
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ (when (or (eq (car sol) '!)
+ (eq (car sol) t))
+ (cdr sol))))
+
+(defun sweep-read-pack-name ()
+ "Read a Prolog pack name from the minibuffer, with completion."
+ (let* ((col (sweep-packs-collection))
+ (completion-extra-properties
+ (list :annotation-function
+ (lambda (key)
+ (message key)
+ (let* ((val (cdr (assoc-string key col)))
+ (des (car val))
+ (ver (cadr val)))
+ (concat (make-string (max 0 (- 32 (length key))) ? )
+ (if des
+ (concat ver (make-string (max 0 (- 16 (length
ver))) ? ) des)
+ ver)))))))
+ (completing-read sweep-read-pack-prompt col)))
+
+(defun sweep-true-p (sol)
+ (or (eq (car sol) '!)
+ (eq (car sol) t)))
+
+;;;###autoload
+(defun sweep-pack-install (pack)
+ "Install or upgrade Prolog package PACK."
+ (interactive (list (sweep-read-pack-name)))
+ (sweep-open-query "user" "sweep" "sweep_pack_install" pack)
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ (if (sweep-true-p sol)
+ (message "Package install successful.")
+ (user-error "Pacakge installation failed"))))
+
;;;; Testing:
;; (add-to-list 'load-path (file-name-directory (buffer-file-name)))
diff --git a/sweep.pl b/sweep.pl
index 3a2991b4d9..6f9ef2a01b 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -4,6 +4,8 @@
sweep_predicate_location/2,
sweep_predicates_collection/2,
sweep_modules_collection/2,
+ sweep_packs_collection/2,
+ sweep_pack_install/2,
sweep_module_path/2
]).
@@ -17,6 +19,7 @@
:- use_module(library(pldoc/doc_man)).
:- use_module(library(pldoc/man_index)).
:- use_module(library(lynx/html_text)).
+:- use_module(library(prolog_pack)).
:- dynamic sweep_current_color/3,
sweep_open/2,
@@ -214,3 +217,16 @@ sweep_predicate_description_(M, F, N, [D]) :-
sweep_predicate_description_(_M, F, N, [D]) :-
man_object_property(F/N, summary(D0)), !, atom_string(D0, D).
sweep_predicate_description_(_, _, _, []).
+
+sweep_packs_collection(SearchString, Packs) :-
+ prolog_pack:query_pack_server(search(SearchString), true(Packs0), []),
+ maplist(sweep_pack_info, Packs0, Packs).
+
+sweep_pack_info(pack(Name0, _, Desc0, Version0, URLS0), [Name, Desc, Version,
URLS]) :-
+ atom_string(Name0, Name),
+ atom_string(Desc0, Desc),
+ atom_string(Version0, Version),
+ maplist(atom_string, URLS0, URLS).
+
+sweep_pack_install(PackName, []) :-
+ atom_string(Pack, PackName), pack_install(Pack, [silent(true),
upgrade(true), interactive(false)]).
- [nongnu] elpa/sweeprolog cada0d3871 166/166: DOC: document quasi-quotation highlighting in the manual, (continued)
- [nongnu] elpa/sweeprolog cada0d3871 166/166: DOC: document quasi-quotation highlighting in the manual, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 85af4010e8 158/166: Use a public mailing list in the Maintainer package header, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 353ef846fb 035/166: ENHANCED: Pass keystrokes to the top-level directly when appropriate, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 72cc4d516b 014/166: PORT: detect linux vs macOS shared object extension in Makefile, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog e029eb3e3c 016/166: update .build.yml, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0aa0a46631 017/166: PORT: don't use clang's -fdiagnostics-absolute-paths, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog d4a501e9af 020/166: PORT: use rpath linker option, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b75179cc6e 022/166: Revert rpath tweaks, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 2f5dd9f13c 024/166: FIXED: Use more robust Prolog to C string conversion, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5f0f223318 023/166: Use LD_PRELOAD for testing, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ea04f467b9 027/166: ADDED: sweep-pack-install for interactively installing packs,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 25bda86c48 032/166: Use load-file-path instead of custom hack, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog c5b1504ca8 033/166: ADDED: sweep-top-level command and appropriate mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a06906287f 036/166: ADDED: sweep_funcall/2, 3 for calling Elisp functions from Prolog, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5b23e9819b 038/166: DOC: Add Prolog initialization section to the manual, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4e4d8508cd 039/166: ENHANCED: Allow using swipl compiled with GMP, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4b4b28f15a 007/166: Add module descriptions to sweep-find-module annotation function, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0078ef8ff0 060/166: ENHANCED: syntax errors coloring, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog e38825d0e2 066/166: ENHANCED: use a distinct face for structured comments, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 84e6182685 077/166: FIXED: detect "|:" prompt in the top-level, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 6e5c822fc8 116/166: ADDED: sweep-colourise-buffer-on-idle user option, on by default, ELPA Syncer, 2022/09/30