Skip to content

Commit

Permalink
Add fzf-native slab support
Browse files Browse the repository at this point in the history
  • Loading branch information
jojojames committed Jun 6, 2022
1 parent 7240323 commit fe4e4eb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions fussy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1017,15 +1017,20 @@ highlighting."
(list (sublime-fuzzy-score query str)))))

;; `fzf-native' integration
(defvar fussy--fzf-native-slab nil)
(defun fussy--fzf-native-slab ()
"Return lazy loaded slab for `fzf-native'."
(or fussy--fzf-native-slab
(when (fboundp 'fzf-native-make-default-slab)
(setf fussy--fzf-native-slab (fzf-native-make-default-slab)))))

(defun fussy-fzf-native-score (str query &rest _args)
"Score STR for QUERY using `fzf-native'."
(require 'fzf-native)
(when (fboundp 'fzf-native-score)
(let ((str
(funcall fussy-remove-bad-char-fn str))
(query
(fussy-encode-coding-string query)))
(fzf-native-score str query))))
(let ((str (funcall fussy-remove-bad-char-fn str))
(query (fussy-encode-coding-string query)))
(fzf-native-score str query (fussy--fzf-native-slab)))))

;; `hotfuzz' integration
(declare-function "hotfuzz--cost" "hotfuzz")
Expand Down

2 comments on commit fe4e4eb

@jojojames
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcs090218 example of cache support in the native module and passing a c pointer through the slab can be found in the fzf-native repo, not sure if that would help the flx-rs implementation or not.

@jcs090218
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think emacs-rs-module has the same concept.

I am trying to use once_cell to implement cache but might need some time, see jcs-elpa/flx-rs#6. I might further investigate this feature (cache) since I don't know what's the best solution here.

Please sign in to comment.