[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog 75ec7290be 096/166: ADDED: sweep-load-buffer
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog 75ec7290be 096/166: ADDED: sweep-load-buffer |
Date: |
Fri, 30 Sep 2022 04:59:29 -0400 (EDT) |
branch: elpa/sweeprolog
commit 75ec7290beced5ec6d1c41d471ba2fb42c0fe81b
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
ADDED: sweep-load-buffer
---
sweep.el | 14 ++++++++++++++
sweep.pl | 24 ++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/sweep.el b/sweep.el
index 9dcc1166db..ac15758d8f 100644
--- a/sweep.el
+++ b/sweep.el
@@ -867,6 +867,20 @@ module name, F is a functor name and N is its arity."
(sweep-close-query)
sol)))))
+(defun sweep-load-buffer (&optional buffer)
+ (interactive)
+ (with-current-buffer (or buffer (current-buffer))
+ (let* ((beg (point-min))
+ (end (point-max))
+ (contents (buffer-substring-no-properties beg end)))
+ (sweep-open-query "user"
+ "sweep"
+ "sweep_load_buffer"
+ (cons contents (buffer-file-name)))
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ sol))))
+
;;;###autoload
(defun sweep-top-level (&optional buffer)
"Run a Prolog top-level in BUFFER.
diff --git a/sweep.pl b/sweep.pl
index 3313d8cc13..0f8f06d0fd 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -40,6 +40,7 @@
sweep_identifier_at_point/2,
sweep_expand_file_name/2,
sweep_path_module/2,
+ sweep_load_buffer/2,
sweep_colourise_query/2,
sweep_predicate_references/2,
sweep_predicate_location/2,
@@ -66,6 +67,8 @@
:- use_module(library(help)).
:- use_module(library(prolog_server)).
+:- meta_predicate with_buffer_stream(-, +, 0).
+
:- dynamic sweep_current_color/3,
sweep_open/2,
sweep_source_time/2,
@@ -633,3 +636,24 @@ should_handle_message_kind(error, "error").
should_handle_message_kind(warning, "warning").
should_handle_message_kind(informational, "informational").
should_handle_message_kind(debug(Topic0), ["debug"|Topic]) :-
atom_string(Topic0, Topic).
+
+sweep_load_buffer([String|Path0], Result) :-
+ atom_string(Path, Path0),
+ with_buffer_stream(Stream,
+ String,
+ sweep_load_buffer_(Stream, Path, Result)).
+
+sweep_load_buffer_(Stream, Path, []) :-
+ set_stream(Stream, file_name(Path)),
+ load_files(Path, [stream(Stream)]).
+
+with_buffer_stream(Stream, String, Goal) :-
+ setup_call_cleanup(( new_memory_file(H),
+ insert_memory_file(H, 0, String),
+ open_memory_file(H, read, Stream, [encoding(utf8)]),
+ set_stream(Stream, encoding(utf8))
+ ),
+ Goal,
+ ( close(Stream),
+ free_memory_file(H)
+ )).
- [nongnu] elpa/sweeprolog a26ca14c81 053/166: ENHANCED: show more relevant candidates in top-level completion, (continued)
- [nongnu] elpa/sweeprolog a26ca14c81 053/166: ENHANCED: show more relevant candidates in top-level completion, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7fa11fdcdd 055/166: FIXED: hide predicates starting with '$' in sweep-find-predicate, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog e70b4aef2f 057/166: ADDED: sweep-file-name-handler, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 10516034be 061/166: ADDED: sweep-indent-line, an indent-line-function for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog face064afa 062/166: ADDED: custom font-lock-fontify-region-function for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 6363ddef3a 073/166: ADDED: implemented all xref backend callback functions, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8dc9359dca 082/166: ADDED: sweep-set-prolog-flag for setting Prolog flags, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0f86b23be9 080/166: ENHANCED: emit Prolog messages with color coding, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1f4b1a6dcc 079/166: MODIFIED: use executable-find to locate the swipl executable..., ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog f772a136e4 081/166: DOC: fix typos, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 75ec7290be 096/166: ADDED: sweep-load-buffer,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 3717572348 091/166: FIXED: handle more missing color terms, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1744b29cc2 092/166: FIXED: off by one in sweep-colourise-some-terms, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 16d1a380ab 122/166: FIXED: (sweep-beginning-of-top-term): possible infinite loop, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog f887a4b3f0 085/166: ENHANCED: provide caller predicate in xref-find-references, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 49214a669b 109/166: PORT: don't depend on pos-bol added in Emacs 29, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1aefaea2ab 106/166: ADDED: (sweep-find-file-at-point): new function, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ce88557fdc 104/166: DOC: NEWS.org: new file, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 28170f629f 124/166: FIXED: (sweep--colourise): handle the dict_content color term, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 6d1509a06a 090/166: FIXED: sweep-beginning-of-top-term stopping at comment start, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 9dfbbf9e9b 128/166: ADDED: new user option for choosing indentation increments, ELPA Syncer, 2022/09/30