jojojames/fussy

Latest orderless changes break integration

Opened this issue · 1 comments

The following orderless PR replaces the orderless--prefix+pattern function, thereby breaking fussy-filter-orderless & fussy-filter-orderless-flex:
Optimizations and refactoring #161

I tried to adapt fussy-filter-orderless with the following changes, by copying the new implementation of orderless-all-completions:

diff --git a/fussy.el b/fussy.el
index 267fdd3..6a7e128 100644
--- a/fussy.el
+++ b/fussy.el
@@ -925,13 +925,21 @@ Use `orderless' for filtering by passing STRING, TABLE and PRED to
   (require 'orderless)
   (when (and (fboundp 'orderless-filter)
              (fboundp 'orderless-highlight-matches)
-             (fboundp 'orderless--prefix+pattern))
-    (let* ((completions (orderless-filter string table pred)))
-      (when completions
-        (pcase-let* ((`(,prefix . ,pattern)
-                      (orderless--prefix+pattern string table pred)))
-          (list (orderless-highlight-matches pattern completions)
-                pattern prefix))))))
+             (fboundp 'orderless--compile))
+    (pcase-let ((`(,prefix ,regexps ,ignore-case ,pred)
+                 (orderless--compile string table pred)))
+      (when-let ((completions (orderless--filter prefix regexps ignore-case table pred)))
+        (if (bound-and-true-p completion-lazy-hilit)
+            (setq completion-lazy-hilit-fn
+                  (apply-partially #'orderless--highlight regexps ignore-case))
+          (cl-loop for str in-ref completions do
+                   (setf str (orderless--highlight regexps ignore-case (substring str)))))
+        (let ((result (list
+                       completions
+                       regexps prefix)))
+          ;; (message "fn: %S result: %S"
+          ;;          'fussy-filter-orderless result)
+          result)))))
 
 (defun fussy-filter-flex (string table pred point)
   "Match STRING to the entries in TABLE.

It seems to work, but I don't know if regexps is a drop-in replacement for pattern...
Also, do you think it could be worth it to split the orderless-all-completions function in orderless.el, adding a separate internal function which handles orderless--compile + highlighting, but also returns prefix & regexps; which could then be used by fussy?

It seems to work, but I don't know if regexps is a drop-in replacement for pattern...

This is just for the orderless integration right? You could PR it and we can slowly iterate on it if there are problems. Probably better than it being broken.

Also, do you think it could be worth it to split the orderless-all-completions function in orderless.el, adding a separate internal function which handles orderless--compile + highlighting, but also returns prefix & regexps; which could then be used by fussy?

No comment, the orderless integration & everything surrounding it is a little hazy for me now.