Move `setSearchPat` operation from cpp to script