The answer is given in the doc string of isearch-forward
:
If this function is called non-interactively with a nil NO-RECURSIVE-EDIT,
it does not return to the calling function until the search is done.
See the function isearch-mode
for more information.
In your first form
(let ((isearch-filter-predicate (lambda (a b) nil)))
(funcall 'isearch-forward))
you use a nil value for the optional argument no-recursive-edit
of isearch-forward
. In that case the incremental search runs in a recursive-edit
call within isearch-forward
and the control flow does not leave the local scope of your let
-form while isearch-mode
is active.
In the second form
(let ((isearch-filter-predicate (lambda (a b) nil)))
(call-interactively 'isearch-forward))
you start the isearch with the interactive call of isearch-forward
. The command isearch-forward
just starts isearch-mode
and exits. The control flow is not within the isearch-forward
function form while the incremental search is running.
An alternative way to call isearch-forward
with user-defined isearch-filter-predicate
that uses call-interactively
is given in the answer to the question about searching for bold text.
call-interactively
for keys such asC-n
to quit Isearch? What are you trying to do - are you trying to define a command? If so, add aninteractive
spec. If not, useisearch-mode
.C-n
does quit isearch, but does not go to the next line when called usingfuncall
. My ultimate goal is to have a command thatread-key-sequence
s and executes the associated function with a specificisearch-filter-predicate
.call-interactively
is that the original interactive spec is used for the called command. One only needs(interactive)
for the caller. Injection of(interactive-form 'old-command)
makes debugging withedebug
a pain.