Handle `query-replace-from-to-separator' correctly