Skip to content

Commit

Permalink
Add compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jojojames committed Dec 1, 2024
1 parent cd2c93b commit 2cb0387
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
1 change: 1 addition & 0 deletions Eask
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

(depends-on "emacs" "28.2")
(depends-on "flx")
(depends-on "compat")

(development
(depends-on "f")
Expand Down
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This package is intended to be used with packages that leverage
~completion-styles~, e.g. ~completing-read~ and ~completion-at-point-functions~.

It is usable with ~icomplete~ (as well as ~fido-mode~), ~selectrum~,
~vertico~, ~corfu~, ~helm~ and ~company-mode~'.
~vertico~, ~corfu~, ~helm~ and ~company-mode~.

It is not currently usable with ~ido~ which doesn't support
~completion-styles~ and has its own sorting and filtering system.
Expand Down
19 changes: 4 additions & 15 deletions fussy.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: James Nguyen <james@jojojames.com>
;; Version: 1.0
;; Package-Requires: ((emacs "28.2") (flx "0.5"))
;; Package-Requires: ((emacs "28.2") (flx "0.5") (compat "30.0.0.0"))
;; Keywords: matching
;; Homepage: https://github.com/jojojames/fussy

Expand Down Expand Up @@ -60,6 +60,7 @@
;; https://github.com/jojojames/fussy#scoring-backends

(require 'flx)
(require 'compat)
(eval-when-compile (require 'subr-x))

;;; Code:
Expand Down Expand Up @@ -876,18 +877,6 @@ Check C1 and C2 in `minibuffer-history-variable' which is stored in
;; (@* "Utils" )
;;

(defun fussy--length< (sequence n)
"Return non-nil if SEQUENCE has fewer than N elements.
Handle sequences like lists, vectors, and strings.
Terminate early if the condition is met."
(< (length sequence) n))

(defun fussy--length> (sequence n)
"Return non-nil if SEQUENCE has more than N elements.
Handle sequences like lists, vectors, and strings.
Terminate early if the condition is met."
(> (length sequence) n))

(defun fussy--orderless-p ()
"Return whether or not we're using `orderless' for filtering."
(or (eq fussy-filter-fn 'fussy-filter-orderless)
Expand Down Expand Up @@ -1186,7 +1175,7 @@ result: LIST ^a"

(defun fussy-company--transformer (f &rest args)
"Advise `company--transform-candidates'."
(if (fussy--length< company-prefix fussy-company-prefix-length)
(if (length< company-prefix fussy-company-prefix-length)
;; Transform normally for short prefixes.
(let ((fussy-can-adjust-metadata-p nil))
(apply f args))
Expand All @@ -1204,7 +1193,7 @@ result: LIST ^a"
"Advise `company--fetch-candidates'."
(let ((prefix (nth 0 args))
(_suffix (nth 1 args)))
(if (fussy--length< prefix fussy-company-prefix-length)
(if (length< prefix fussy-company-prefix-length)
(let ((completion-styles (remq 'fussy completion-styles))
(completion-category-overrides nil)
(fussy-can-adjust-metadata-p nil))
Expand Down

0 comments on commit 2cb0387

Please sign in to comment.