That's not so easy to do: the exact command is concealed inside the helper
function in another package (xref). I suppose it's possible to rearrange
things such that command creation and its execution are two different
phases, but TBH I wouldn't love the result. Though I agree it might
be handy.
This is the simplest implementation:
#+begin_src emacs-lisp
(defun project-find-word (regexp)
"Word-based version of ‘project-find-regexp’.
Modifies the ‘xref-search-program-alist’ template
to add the option ‘-w’ that matches whole words."
(interactive (list (project--read-regexp)))
(let ((xref-search-program-alist
(mapcar (lambda (p)
(cons (car p) (replace-regexp-in-string "<C>" "-w \\&" (cdr
p))))
xref-search-program-alist)))
(project-find-regexp regexp)))
#+end_src
It has one minor issue:
while it correctly filters out lines without word matches,
when a line with a word match contains also the same string
that is not a complete word, then both are highlighted as matches.
There is no such problem in grep where matches are highlighted
by the grep program itself.
BTW, the above implementation was based on a similar command for rgrep:
To sum up, if we managed to create some visual interface for specifying the
options that project-find-regexp has control over, maybe it would both
result in a less complex interaction between packages, as well as in a more
powerful UI which more people will be happy with.
Sounds like a widget-based form-filling with fields. Actually, such fields
already exist in xref-search-program-alist template with placeholders
<D>, <X>, <F>, <C>, <R> that are expanded by grep-expand-template.