Closed zbelial closed 2 years ago
I feel like it would be better to instead make the mapping from e.g. initialism
to prescient--initials-regexp
into a public user option, and make all of the built-in regexp functions public. We do this, for example, to address the same problem in CTRLF:
https://github.com/raxod502/ctrlf/blob/2279f684f8d75a75f6b98ddaa908182f08c0d877/ctrlf.el#L77-L111
(defcustom ctrlf-style-alist
'((literal . (:prompt "literal"
:translator regexp-quote
:case-fold ctrlf-no-uppercase-literal-p))
(regexp . (:prompt "regexp"
:translator identity
:case-fold ctrlf-no-uppercase-regexp-p))
(fuzzy . (:prompt "fuzzy"
:translator ctrlf-translate-fuzzy-literal
:case-fold ctrlf-no-uppercase-literal-p))
(fuzzy-regexp . (:prompt "fuzzy regexp"
:translator ctrlf-translate-fuzzy-regexp
:case-fold ctrlf-no-uppercase-regexp-p))
(symbol . (:prompt "symbol"
:translator ctrlf-translate-symbol
:case-fold ctrlf-no-uppercase-literal-p)))
"Alist of CTRLF search styles.
Each search style defines a different way to interpret your
query, for example as a literal string or as a regexp. The keys
are unique identifying symbols which can be passed to
`ctrlf-forward' and `ctrlf-backward'. The values are property
lists with the following keys (all mandatory):
- `:prompt': string to be displayed in minibuffer prompt after
\"CTRLF\".
- `:translator': function which takes your query string and
returns a regexp, e.g. `regexp-quote' for a literal search.
- `:case-fold': function which takes your query string and
returns a value for `case-fold-search' to use by default (for
example, non-nil only if the query does not contain any
uppercase letters)."
:type '(alist
:key-type symbol
:value-type (list (const :prompt) string
(const :translator) function
(const :case-fold) function)))
Do you think that would also satisfy your use case? I agree it's not ideal that there is no extensibility currently.
Thanks. Yes, that would satisfy my use case, and I agree that it's better.
This was implemented over a year ago, so I'm closing this issue.
Please see prescient-filter-method
and the added prescient-filter-alist
.
Hi, thanks for this great package.
I know that prescient supports several filter methods, but it will be better if users can add customized filter method(e.g. Chinese users may use pinyin to filter candidates).
Here is my thought:
custom
toprescient-filter-method
prescient-custom-filter-function
, which users can customizeprescient-filter-regexps
to handlecustom
Does this way sound decent? If so, I guess I can make a PR.