#+startup: content indent
#+export_file_name: sweep.texi
#+texinfo_filename: sweep.info
-#+texinfo_dir_category: Prolog
+#+texinfo_dir_category: Emacs
#+texinfo_dir_title: Sweep: (sweep)
#+texinfo_dir_desc: SWI-Prolog Embedded in Emacs
#+texinfo_header: @set MAINTAINERSITE @uref{https://eshelyaron.com,maintainer webpage}
[[info:emacs#Find Identifiers][Find Identifiers in the Emacs manual]] for an overview of the available
commands.
-
* The Prolog top-level
:PROPERTIES:
:CUSTOM_ID: prolog-top-level
(require 'sweep-module))
(error "Sweep will not work until `sweep-module' is compiled!"))))
+
+(defvar sweep-messages-buffer nil)
+
+(defun sweep-setup-message-hook ()
+ (with-current-buffer
+ (setq sweep-messages-buffer (get-buffer-create "*sweep-messages*"))
+ (compilation-minor-mode))
+ (sweep-open-query "user"
+ "sweep"
+ "sweep_setup_message_hook"
+ nil)
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ sol))
+
+(defun sweep-message (message)
+ (with-current-buffer sweep-messages-buffer
+ (save-excursion
+ (goto-char (point-max))
+ (insert message)
+ (newline))))
+
(defun sweep-start-prolog-server ()
(sweep-open-query "user"
"prolog_server"
(cons (expand-file-name "bin/swipl" (file-name-directory
load-file-name))
(cons "-q" (cons "--no-signals" sweep-init-args))))
+ (sweep-setup-message-hook)
(sweep-start-prolog-server))
-
(defvar sweep-predicate-completion-collection nil)
(defvar-local sweep-buffer-module "user")
:- module(sweep,
[ sweep_colourise_buffer/2,
sweep_colourise_some_terms/2,
+ sweep_setup_message_hook/2,
sweep_documentation/2,
sweep_identifier_at_point/2,
sweep_expand_file_name/2,
atom_string(Path, Path0),
xref_module(Path, Module0),
atom_string(Module0, Module).
+
+
+sweep_setup_message_hook(_, _) :-
+ retractall(user:thread_message_hook(_, _, _)),
+ asserta((
+ user:thread_message_hook(Term, Kind, Lines) :-
+ sweep_message_hook(Term, Kind, Lines)
+ )).
+
+sweep_message_hook(Term, Kind, _Lines) :-
+ should_handle_message_kind(Kind),
+ !,
+ message_to_string(Term, String),
+ sweep_funcall("sweep-message", String, _).
+
+should_handle_message_kind(error).
+should_handle_message_kind(warning).
+should_handle_message_kind(debug(_)).