Subject: Re: bug#15836: 24.3; query-replace-regexp does not detect incorrect usage of \#

From: Glenn Morris <[email-masked]>
Date: Fri, 08 Nov 2013 15:27:48 -0500

Marcin Kasperski wrote:

>    M-x query-replace-regexp
>    ^
>    \,(\#)
[...]
>    Symbol's function definition is void: replace-count
>
> (which made me look for uninstalled libraries, spoiled files etc)
>
> Expected effect:
>
>    Some error pointing on regexp syntax.

I'm not sure how to make this any better. You basically got exactly what
you asked for, given how it's documented to work:

    In interactive calls, the replacement text may contain `\,' followed
    by a Lisp expression used as part of the replacement text. [...]
    `\#' itself [stands] for `replace-count', the number of replacements
    occurred so far

So you wrote:

(replace-count)

which is indeed not a function.

The error message could perhaps be wrapped in "Error evaluating
replacement expression: <actual error message>"; but I'm not sure that
would have helped you decide whether it was an internal issue or a
mistake on your part. Special-casing your particular error does not seem
worth it to me.