[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog 99fc2242d8 009/166: Document sweep-find-predica
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog 99fc2242d8 009/166: Document sweep-find-predicate |
Date: |
Fri, 30 Sep 2022 04:59:21 -0400 (EDT) |
branch: elpa/sweeprolog
commit 99fc2242d8700551aa3396ae90e8c5676549ea5f
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Document sweep-find-predicate
---
README.org | 11 +++++++++--
sweep.el | 15 ++++++++++++---
sweep.pl | 51 ++++++++++++++++++++++++++++++++++-----------------
3 files changed, 55 insertions(+), 22 deletions(-)
diff --git a/README.org b/README.org
index 8156cd57dc..56ee5d3d64 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}
-# The "kbd" macro turns KBD into @kbd{KBD}. Additionally, it
-# encloses case-sensitive special keys (SPC, RET...) within @key{...}.
#+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
@@ -31,19 +29,23 @@ embedded SWI-Prolog runtime inside of Emacs.
#+begin_src sh
git clone --recursive https://git.sr.ht/~eshel/sweep
#+end_src
+
2. Optionally, build the C module =sweep-module=:
#+begin_src sh
cd sweep
make
#+end_src
+
3. Add =sweep= to Emacs' =load-path=:
#+begin_src emacs-lisp
(add-to-list 'load-path "/path/to/sweep")
#+end_src
+
4. Load =sweep= into Emacs:
#+begin_src emacs-lisp
(require 'sweep)
#+end_src
+
If =sweep-module= is not already built, =sweep= will suggest to build
it when loaded. Note that this may take a couple of minutes as the
SWI-Prolog runtime may need to be built as well.
@@ -85,6 +87,11 @@ 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
+loaded or auto-loadable Prolog predicate.
+
* Indices
:PROPERTIES:
:END:
diff --git a/sweep.el b/sweep.el
index 88f6c99e5a..88dfe1b0a2 100644
--- a/sweep.el
+++ b/sweep.el
@@ -62,8 +62,10 @@
(sweep-open-query "user" "sweep" "sweep_predicates_collection" nil)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (when (eq '! (car sol))
- (cdr sol))))
+ (let ((car (car sol)))
+ (when (or (eq car '!)
+ (eq car t))
+ (cdr sol)))))
(defun sweep-predicate-location (mfn)
(sweep-open-query "user" "sweep" "sweep_predicate_location" mfn)
@@ -76,7 +78,14 @@
(defun sweep-read-predicate ()
"Read a Prolog predicate (M:F/N) from the minibuffer, with completion."
- (let* ((col (sweep-predicates-collection)))
+ (let* ((col (sweep-predicates-collection))
+ (completion-extra-properties
+ (list :annotation-function
+ (lambda (key)
+ (let* ((val (cdr (assoc-string key col))))
+ (if val
+ (concat (make-string (- 64 (length key)) ? ) (car val))
+ nil))))))
(completing-read "Predicate: " col)))
(defun sweep-find-predicate (mfn)
diff --git a/sweep.pl b/sweep.pl
index 57f20cfa7d..ee9bb66e10 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -1,9 +1,11 @@
-:- module(sweep, [ sweep_colors/2,
- sweep_documentation/2,
- sweep_predicate_location/2,
- sweep_predicates_collection/2,
- sweep_modules_collection/2,
- sweep_module_path/2]).
+:- module(sweep,
+ [ sweep_colors/2,
+ sweep_documentation/2,
+ sweep_predicate_location/2,
+ sweep_predicates_collection/2,
+ sweep_modules_collection/2,
+ sweep_module_path/2
+ ]).
:- use_module(library(pldoc)).
:- use_module(library(listing)).
@@ -176,7 +178,7 @@ sweep_modules_collection([], Modules) :-
maplist(sweep_module_description, Modules1, Modules).
sweep_module_description([M0|P], [M|[P|D]]) :-
- pldoc_process:doc_comment(M0:module(D0), _, _, _),
+ doc_comment(M0:module(D0), _, _, _),
atom_string(M0, M),
atom_string(D0, D).
sweep_module_description([M0|P], [M|[P]]) :- atom_string(M0, M).
@@ -188,18 +190,33 @@ sweep_predicate_location(MFN, [Path|Line]) :-
predicate_property(M:H, file(Path0)), atom_string(Path0, Path).
sweep_predicates_collection([], Preds) :-
- findall(Pred,
- ( current_predicate(M0:P0/N),
- pi_head(P0/N, H),
- \+ (predicate_property(M0:H, imported_from(M)), M \= M0),
- format(string(Pred), '~w:~w/~w', [M0, P0, N])
+ findall(M:F/N,
+ ( current_predicate(M:F/N),
+ pi_head(F/N, H),
+ \+ (predicate_property(M:H, imported_from(M1)), M \= M1)
),
Preds0,
Tail),
- findall(Pred,
- ( '$autoload':library_index(F, M0, _),
- pi_head(P0/N, F),
- format(string(Pred), '~w:~w/~w', [M0, P0, N])
+ findall(M:F/N,
+ ( '$autoload':library_index(H, M, _),
+ pi_head(F/N, H)
),
Tail),
- list_to_set(Preds0, Preds).
+ list_to_set(Preds0, Preds1),
+ maplist(sweep_predicate_description, Preds1, Preds).
+
+sweep_predicate_description(M:F/N, [S|T]) :-
+ sweep_predicate_description_(M, F, N, T), format(string(S), '~w:~w/~w',
[M, F, N]).
+
+sweep_predicate_description_(M, F, N, [D]) :-
+ doc_comment(M:F/N, _, D0, _), !, atom_string(D0, D).
+% sweep_predicate_description_(_M, F, N, [D]) :-
+% pldoc_man:load_man_object(F/N, _, _, Dom),
+% with_output_to(string(DomS), html_text(Dom, [])),
+% sub_string(DomS, EOL, _, _, '\n'),
+% sub_string(DomS, EOL, _, 0, Rest),
+% ( sub_string(Rest, EOS, _, _, '. ')
+% -> sub_string(Rest, 0, EOS, _, D)
+% ; D=Rest
+% ).
+sweep_predicate_description_(_, _, _, []).
- [nongnu] branch elpa/sweeprolog created (now cada0d3871), ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 89733a1b7f 001/166: Initial commit, ELPA Syncer, 2022/09/30
- [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 <=
- [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, 2022/09/30
- [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