Subject: Re: bug#14714: 24.3.50; `isearch-filter-predicate(s)'

From: Juri Linkov <[email-masked]>
Date: Fri, 28 Jun 2013 02:39:37 +0300

> Basically, replace
>
>     (add-hook 'isearch-filter-predicate #'foo nil t)
> with
>     (add-function :before-while (local isearch-filter-predicate) #'foo)
>
>> (defvar isearch-filter-predicate nil)
>
> For add-function to work well, you want to change this default value to
> be a function, such as (lambda () t).

I'm trying this, but not sure how to implement toggling like
in `dired-isearch-filenames-toggle':

  (setq isearch-filter-predicates
	(if (memq 'dired-isearch-filter-filenames isearch-filter-predicates)
	    (delq 'dired-isearch-filter-filenames isearch-filter-predicates)
	  (cons 'dired-isearch-filter-filenames isearch-filter-predicates)))

Whereas it's clear how to add and remove an advice function, it's unclear
how to check its existence instead of `memq'.  Is `advice-member-p' intended
to do what `memq' does?  When I tried

  (defvar-local isearch-filter-predicate (lambda (b e) t))
  (defun test-b (b e) (message "b"))
  (defun test-a (b e) (message "a"))
  (add-function :before-while (local isearch-filter-predicate) #'test-b)
  (add-function :after-while  (local isearch-filter-predicate) #'test-a)

then

  (funcall isearch-filter-predicate 1 2)

works fine, but

  (advice-member-p #'test-a 'isearch-filter-predicate)

returns nil.