Skip to content

Commit

Permalink
Add racket-doc-index-predicate-function
Browse files Browse the repository at this point in the history
Allows user to configure showing subset of search results, such as for
a certain language family.
  • Loading branch information
greghendershott committed Oct 11, 2024
1 parent 40d5256 commit 75c5fbc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/generate.el
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
racket-repl-command-file
"Other variables"
racket-doc-index-directory
racket-doc-index-predicate-function
racket-indent-curly-as-sequence
racket-indent-sequence-depth
racket-pretty-lambda
Expand Down
17 changes: 17 additions & 0 deletions doc/racket-mode.texi
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ REPL variables
Other variables
* racket-doc-index-directory::
* racket-doc-index-predicate-function::
* racket-indent-curly-as-sequence::
* racket-indent-sequence-depth::
* racket-pretty-lambda::
Expand Down Expand Up @@ -3567,6 +3568,7 @@ Name of the file used by @ref{racket-repl}.

@menu
* racket-doc-index-directory::
* racket-doc-index-predicate-function::
* racket-indent-curly-as-sequence::
* racket-indent-sequence-depth::
* racket-pretty-lambda::
Expand All @@ -3582,6 +3584,21 @@ Name of the file used by @ref{racket-repl}.

Directory for @ref{racket-describe-search} doc index files.

@node racket-doc-index-predicate-function
@subsection racket-doc-index-predicate-function

A function used by @ref{racket-describe-search} to filter results.

The default value, the @code{always} function, filters nothing.

The function is given four string arguments -- TERM, WHAT,
FROM-LIBS, and FAMILIES -- and should return whether to include
the item in the list of completion candidates. An example that
limits candidates to the ``Rhombus'' family:

(lambda (@math{_term} _what _from-libs families)
(string-equal families ``Rhombus'')

@node racket-indent-curly-as-sequence
@subsection racket-indent-curly-as-sequence

Expand Down
17 changes: 17 additions & 0 deletions racket-custom.el
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@ Scribble text, use the face `racket-hash-lang-text'."
"Directory for `racket-describe-search' doc index files."
:type 'file)

(defcustom racket-doc-index-predicate-function
'always
"A function used by `racket-describe-search' to filter results.
The default value, the `always' function, filters nothing.
The function is given four string arguments -- TERM, WHAT,
FROM-LIBS, and FAMILIES -- and should return whether to include
the item in the list of completion candidates. An example that
limits candidates to the \"Rhombus\" family:
(lambda (_term _what _from-libs families)
(string-equal families \"Rhombus\")
"
:type 'function
:risky t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; racket-repl group

Expand Down
4 changes: 3 additions & 1 deletion racket-describe.el
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ the symbol at point into the minibuffer."
(racket--doc-index)
`((category . ,racket--identifier-category)
(affixation-function . ,#'racket--doc-index-affixator)))
nil ;predicate
(lambda (v)
(apply racket-doc-index-predicate-function
(get-text-property 0 'racket-affix (car v))))
t ;require-match
nil ;initial-input
nil ;hist
Expand Down

0 comments on commit 75c5fbc

Please sign in to comment.