[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog b92f25f764 030/166: Cleanup sweep.el
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog b92f25f764 030/166: Cleanup sweep.el |
Date: |
Fri, 30 Sep 2022 04:59:23 -0400 (EDT) |
branch: elpa/sweeprolog
commit b92f25f76493a9473530f7de25e58cb4b8464ac9
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Cleanup sweep.el
---
README.org | 15 ++++++----
sweep.el | 99 +++++++++++++++++++++++++++++++++++---------------------------
2 files changed, 65 insertions(+), 49 deletions(-)
diff --git a/README.org b/README.org
index 415f821a81..96d090cf19 100644
--- a/README.org
+++ b/README.org
@@ -14,8 +14,6 @@
#+texinfo_header: @set MAINTAINEREMAIL @email{me@eshelyaron.com}
#+texinfo_header: @set MAINTAINERCONTACT
@uref{mailto:me@eshelyaron.com,contact the maintainer}
-#+macro: kbd (eval (let ((case-fold-search nil) (regexp (regexp-opt '("SPC"
"RET" "LFD" "TAB" "BS" "ESC" "DELETE" "SHIFT" "Ctrl" "Meta" "Alt" "Cmd" "Super"
"UP" "LEFT" "RIGHT" "DOWN") 'words))) (format
"@@texinfo:@kbd{@@%s@@texinfo:}@@" (replace-regexp-in-string regexp
"@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t))))
-
This manual describes the Emacs package =sweep=, which provides an
embedded SWI-Prolog runtime inside of Emacs.
@@ -84,6 +82,11 @@ The different parts of =sweep= are structured as follows:
it when loaded. Note that this may take a couple of minutes as the
SWI-Prolog runtime may need to be built as well.
+* TODO Prolog initialization and cleanup
+
+#+VINDEX: sweep-init-on-load
+#+VINDEX: sweep-init-args
+
* Querying Prolog
:PROPERTIES:
:CUSTOM_ID: querying-prolog
@@ -194,21 +197,21 @@ permutations of the list =(1 2 3 4 5)=:
:END:
#+FINDEX: sweep-find-module
-=sweep= provides the command {{{kbd(M-x sweep-find-module)}}} for
+=sweep= provides the command =M-x sweep-find-module= for
selecting and jumping to the source code of a loaded or auto-loadable
Prolog module. =sweep= integrates with Emacs' standard completion API
to annotate candidate modules in the completion UI with their =PLDoc=
description when available.
#+FINDEX: sweep-find-predicate
-Along with {{{kbd(M-x sweep-find-module)}}}, =sweep= provides the
-command {{{kbd(M-x sweep-find-predicate)}}} jumping to the definition a
+Along with =M-x sweep-find-module=, =sweep= provides the
+command =M-x sweep-find-predicate= jumping to the definition a
loaded or auto-loadable Prolog predicate.
* Installing Prolog packages
#+FINDEX: sweep-pack-install
-The command {{{kbd(M-x sweep-pack-install)}}} can be used to install
+The command =M-x sweep-pack-install= can be used to install
or upgrade a SWI-Prolog =pack=. When selecting a =pack= to install, the
completion candidates are annotated with description and the version
of each package.
diff --git a/sweep.el b/sweep.el
index 437d1efe34..4b21eb130f 100644
--- a/sweep.el
+++ b/sweep.el
@@ -1,20 +1,35 @@
-;;; sweep.el --- SWI-Prolog Embedded in Emacs -*- lexical-binding:t -*-
+;;; sweep.el --- Embedded SWI-Prolog -*- lexical-binding:t -*-
;; Copyright (C) 2022 Eshel Yaron
-;; Authors: Eshel Yaron <me(at)eshelyaron(dot)com>
+;; Author: Eshel Yaron <me(at)eshelyaron(dot)com>
;; Maintainer: Eshel Yaron <me(at)eshelyaron(dot)com>
-;; Keywords: prolog programming
+;; Keywords: prolog languages extensions
+;; URL: https://git.sr.ht/~protesilaos/denote
+;; Mailing-List: https://lists.sr.ht/~protesilaos/denote
+;; Package-Version: 0.1.0
+;; Package-Requires: ((emacs "27"))
;; This file is NOT part of GNU Emacs.
-;;; Package-Version: 0.1.0
-;;; Package-Requires: ((emacs "28"))
-
;;; Commentary:
+;;
+;; sweep is an embedding of SWI-Prolog in Emacs. It uses the C
+;; interfaces of both SWI-Prolog and Emacs Lisp to create a
+;; dynamically loaded Emacs module that contains the SWI-Prolog
+;; runtime. As such, =sweep= has parts written in C, in Prolog and in
+;; Emacs Lisp.
+;;
+;; For more information, see the sweep manual at
+;; <https://eshelyaron.com/sweep.html>. The manual can also be read
+;; locally by evaluating (info "(sweep) Top")
;;; Code:
+(defun sweep-home-directory ()
+ "Return the installation directory of `sweep'."
+ (file-name-directory (locate-library "sweep.el" t)))
+
(defgroup sweep nil
"SWI-Prolog Embedded in Emacs."
:group 'prolog)
@@ -40,8 +55,19 @@
(defvar sweep-install-buffer-name "*Install sweep*"
"Name of the buffer used for compiling sweep-module.")
-(defun sweep-home-directory ()
- (file-name-directory (locate-library "sweep.el" t)))
+(defcustom sweep-init-on-load t
+ "If non-nil, initialize Prolog when `sweep' is loaded."
+ :package-version '((sweep "0.1.0"))
+ :type 'boolean
+ :group 'sweep)
+
+(defcustom sweep-init-args (list (expand-file-name
+ "sweep.pl"
+ (sweep-home-directory)))
+ "List of strings used as initialization arguments for Prolog."
+ :package-version '((sweep "0.1.0"))
+ :type '(list string)
+ :group 'sweep)
;;;###autoload
(defun sweep-module-compile ()
@@ -60,44 +86,32 @@
(message "Compilation of `sweep' module succeeded")
(error "Compilation of `sweep' module failed!"))))
-(unless (require 'sweep-module nil t)
- (if (y-or-n-p "Sweep needs `sweep-module' to work. Compile it now? ")
- (progn
- (sweep-module-compile)
- (require 'sweep-module))
- (error "Sweep will not work until `sweep-module' is compiled!")))
-
-(sweep-initialize (expand-file-name "bin/swipl"
- (sweep-home-directory))
- "-q"
- (expand-file-name "sweep.pl"
- (sweep-home-directory)))
-
-(declare-function sweep-initialize "sweep-module")
-(declare-function sweep-initialized-p "sweep-module")
-(declare-function sweep-open-query "sweep-module")
-(declare-function sweep-cut-query "sweep-module")
-(declare-function sweep-close-query "sweep-module")
-(declare-function sweep-next-solution "sweep-module")
-(declare-function sweep-cleanup "sweep-module")
+(defun sweep--ensure-module ()
+ (unless (require 'sweep-module nil t)
+ (if (y-or-n-p "Sweep needs `sweep-module' to work. Compile it now? ")
+ (progn
+ (sweep-module-compile)
+ (require 'sweep-module))
+ (error "Sweep will not work until `sweep-module' is compiled!"))))
+
+(defun sweep-init ()
+ (apply #'sweep-initialize
+ (cons (expand-file-name "bin/swipl" (sweep-home-directory))
+ (cons "-q" sweep-init-args))))
(defun sweep-predicates-collection ()
(sweep-open-query "user" "sweep" "sweep_predicates_collection" nil)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (let ((car (car sol)))
- (when (or (eq car '!)
- (eq car t))
- (cdr sol)))))
+ (when (sweep-true-p sol)
+ (cdr sol))))
(defun sweep-predicate-location (mfn)
(sweep-open-query "user" "sweep" "sweep_predicate_location" mfn)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (let ((car (car sol)))
- (when (or (eq car '!)
- (eq car t))
- (cdr sol)))))
+ (when (sweep-true-p sol)
+ (cdr sol))))
(defun sweep-read-predicate ()
"Read a Prolog predicate (M:F/N) from the minibuffer, with completion."
@@ -128,16 +142,14 @@ module name, F is a functor name and N is its arity."
(sweep-open-query "user" "sweep" "sweep_modules_collection" nil)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (when (or (eq (car sol) '!)
- (eq (car sol) t))
+ (when (sweep-true-p sol)
(cdr sol))))
(defun sweep-module-path (mod)
(sweep-open-query "user" "sweep" "sweep_module_path" mod)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (when (or (eq (car sol) '!)
- (eq (car sol) t))
+ (when (sweep-true-p sol)
(cdr sol))))
(defun sweep-read-module-name ()
@@ -161,13 +173,11 @@ 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))
+ (when (sweep-true-p sol)
(cdr sol))))
(defun sweep-read-pack-name ()
@@ -206,6 +216,9 @@ module name, F is a functor name and N is its arity."
;; (add-to-list 'load-path (file-name-directory (buffer-file-name)))
;; (require 'sweep)
+(sweep--ensure-module)
+(when sweep-init-on-load (sweep-init))
+
(provide 'sweep)
;;; sweep.el ends here
- [nongnu] elpa/sweeprolog 929e39e392 003/166: Vendor emacs-module.h, (continued)
- [nongnu] elpa/sweeprolog 929e39e392 003/166: Vendor emacs-module.h, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 38edf9e3f2 005/166: FIXED: really initialize on load, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 99fc2242d8 009/166: Document sweep-find-predicate, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b5b65517e2 010/166: DOC: Don't number manual headings, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog bfac04872f 013/166: DOC: fix typo, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0ad4a77604 015/166: BUILD: set locale for CI, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b71b13aba2 008/166: DOC: Document sweep-find-module in the manual, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 6425d68bad 006/166: Add README.org, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4ee4291703 018/166: TEST: Add ERT based tests, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 268df47cfc 021/166: More rpath tweaks, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b92f25f764 030/166: Cleanup sweep.el,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 972337d6d0 040/166: FIXED: accidentally left debugging remnants, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0de5109bf8 064/166: ENHANCED: add completion-at-point in sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5dfb1366e3 012/166: DOC: fix typo, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog d9546b9414 025/166: ENHANCED: make the prompts used in sweep-find-* customizable, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog e62d23140f 019/166: FIXED: Makefile setting SOEXT to dylib on linux hosts, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7c15ebc4f1 026/166: ENHANCED: annotate predicates with the summaries from the manual, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 59b9dde951 028/166: DOC: Document sweep-pack-install, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b67e5b5e3d 029/166: DOC: Expand the manual section about Querying Prolog, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5455c53eaf 031/166: ENHANCED: Add optional "reverse" argument flag to sweep-open-query, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ff13d97396 034/166: DOC: Add CUSTOM_ID properties to README.org headings where needed, ELPA Syncer, 2022/09/30