I'm not entirely sure why you're getting those errors (my guess is that you probably need to use ad-return-value
), but why use advice? Usually it should be a last resort, and in this case it is very easy to avoid advising.
Also, don't prefix your function names with "isearch". Since emacs only has one namespace (I'm not talking about lisp1 vs. lisp2), it's good practice to name your variables and functions uniquely. Personally, I use a prefix "jpk/", but I've used "my-" here.
(defun my-isearch-mangle-str (str)
"For input STR \"abc\", it will return \"a[ ]*b[ ]*c[ ]*\"."
(let ((i 0) (out ""))
(dotimes (i (length str))
(setq out (concat out (substring str i (1+ i)) "[ ]" "*")))
out))
(defun my-isearch-str-forward (str &optional bound noerror)
"Search forward for STR."
(let ((string (my-isearch-mangle-str str)))
(re-search-forward string bound noerror)))
(defun my-isearch-str-backward (str &optional bound noerror)
"Search backward for STR."
(let ((string (my-isearch-mangle-str str)))
(re-search-backward string bound noerror)))
(defvar my-isearch-p t)
(defun my-isearch-search-fun ()
(if my-isearch-p
(if isearch-forward 'my-isearch-str-forward 'my-isearch-str-backward)
(isearch-search-fun-default)))
(setq isearch-search-fun-function 'my-isearch-search-fun)
Also, I'm not sure exactly what you want, but it seems similar to my package flex-isearch.