]> git.eshelyaron.com Git - sweep.git/commitdiff
ADDED: (sweep-prefix-operators): New function
authorEshel Yaron <me@eshelyaron.com>
Mon, 12 Sep 2022 07:38:40 +0000 (10:38 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 12 Sep 2022 07:38:40 +0000 (10:38 +0300)
sweep.el
sweep.pl

index 66dbb5a386179af1e2e14c0d760cb601ab05b682..914155704f7bf49fdfd7f00733ada7ae616f14a3 100644 (file)
--- a/sweep.el
+++ b/sweep.el
@@ -342,6 +342,15 @@ FLAG and VALUE are specified as strings and read as Prolog terms."
               (forward-char))
             (cons start (point))))))))
 
+(defun sweep-prefix-operators (&optional file)
+  (sweep-open-query "user"
+                    "sweep" "sweep_prefix_ops"
+                    (or file (buffer-file-name)))
+  (let ((sol (sweep-next-solution)))
+    (sweep-close-query)
+    (when (sweep-true-p sol)
+      (cdr sol))))
+
 (defun sweep-completion-at-point-function ()
   (when-let ((bounds (sweep-predicate-prefix-boundaries)))
     (let ((start (car bounds))
@@ -1101,6 +1110,7 @@ Interactively, a prefix arg means to prompt for BUFFER."
        ((sweep-indent-line-ends-with-else point))
        ((sweep-indent-line-ends-with-arg point))
        ((sweep-indent-line-ends-with-neck-p)              4)
+       ;; ((sweep-indent-line-ends-with-prefix-operator))
        (t (sweep-indent-line-fallback))))))
 
 (defun sweep-indent-line-fallback ()
index 56a25be01cf6a6dc06494edba622c865c32ba1c2..8d6297420aae353be2cf3647b3e870efdc394560 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -51,6 +51,7 @@
             sweep_modules_collection/2,
             sweep_packs_collection/2,
             sweep_pack_install/2,
+            sweep_prefix_ops/2,
             sweep_module_path/2
           ]).
 
@@ -668,6 +669,15 @@ 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_prefix_ops(Path0, Ops) :-
+    atom_string(Path, Path0),
+    findall(Op, current_op(_, fx, Op),        Ops0, Tail0),
+    findall(Op, current_op(_, fy, Op),        Tail0, Tail1),
+    findall(Op, xref_op(Path, op(_, fx, Op)), Tail1, Tail),
+    findall(Op, xref_op(Path, op(_, fy, Op)), Tail),
+    maplist(atom_string, Ops0, Ops1),
+    list_to_set(Ops1, Ops).
+
 sweep_load_buffer([String|Path0], Result) :-
     atom_string(Path, Path0),
     with_buffer_stream(Stream,