GNU bug report logs - #15836
24.3; query-replace-regexp does not detect incorrect usage of \#

Previous Next

Package: emacs;

Reported by: Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>

Date: Fri, 8 Nov 2013 16:49:02 UTC

Severity: wishlist

Found in version 24.3

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15836 in the body.
You can then email your comments to 15836 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Fri, 08 Nov 2013 16:49:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 08 Nov 2013 16:49:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; query-replace-regexp does not detect incorrect usage of \#
Date: Fri, 08 Nov 2013 11:24:14 +0100
I made mistake while entering regexp replacement, and got very
confusing error message.

Try the following: enter non-empty buffer and

   M-x query-replace-regexp
   ^
   \,(\#)

{ I  got this after correcting from earlier used \,(+ 1 \#)  }

Effect: 

   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.

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4)
 of 2013-10-03 on louvi, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11303000
System Description:	Ubuntu 13.04

-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Fri, 08 Nov 2013 20:28:02 GMT) Full text and rfc822 format available.

Message #8 received at 15836 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>
Cc: 15836 <at> debbugs.gnu.org
Subject: Re: bug#15836: 24.3;
 query-replace-regexp does not detect incorrect usage of \#
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Fri, 08 Nov 2013 20:36:01 GMT) Full text and rfc822 format available.

Message #11 received at 15836 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>
Cc: 15836 <at> debbugs.gnu.org
Subject: Re: bug#15836: 24.3;
 query-replace-regexp does not detect incorrect usage of \#
Date: Fri, 08 Nov 2013 15:35:46 -0500
Hmm, perhaps replace-eval-replacement could temporarily bind
the function definition of replace-count to some informative error
message ("\# used in function context")?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Fri, 08 Nov 2013 23:16:02 GMT) Full text and rfc822 format available.

Message #14 received at 15836 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>, 15836 <at> debbugs.gnu.org
Subject: Re: bug#15836: 24.3;
 query-replace-regexp does not detect incorrect usage of \#
Date: Fri, 08 Nov 2013 18:15:16 -0500
> Hmm, perhaps replace-eval-replacement could temporarily bind
> the function definition of replace-count to some informative error
> message ("\# used in function context")?

Sorry, I don't like this idea.  Much too specific to the particular way
the user screwed up.

I guess we could byte-compile the expression, which would give the user
actual warnings about his code before running it, but I'm afraid this
medicine would be worse than the disease.

Another approach would be to refrain from substituting \# and
instead to let-bind it during the evaluation.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Wed, 13 Nov 2013 20:41:02 GMT) Full text and rfc822 format available.

Message #17 received at 15836 <at> debbugs.gnu.org (full text, mbox):

From: Marcin Kasperski <Marcin.Kasperski <at> mekk.waw.pl>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 15836 <at> debbugs.gnu.org,
 Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl>
Subject: Re: bug#15836: 24.3; query-replace-regexp does not detect incorrect
 usage of \#
Date: Wed, 13 Nov 2013 21:34:58 +0100
"Error evaluating replacement expression: ... " would be a bit better,
it would point toward replacement expression as something suspicious.


On Sat, Nov 9, 2013 at 12:15 AM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>> Hmm, perhaps replace-eval-replacement could temporarily bind
>> the function definition of replace-count to some informative error
>> message ("\# used in function context")?
>
> Sorry, I don't like this idea.  Much too specific to the particular way
> the user screwed up.
>
> I guess we could byte-compile the expression, which would give the user
> actual warnings about his code before running it, but I'm afraid this
> medicine would be worse than the disease.
>
> Another approach would be to refrain from substituting \# and
> instead to let-bind it during the evaluation.
>
>
>         Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15836; Package emacs. (Wed, 13 Nov 2013 20:51:03 GMT) Full text and rfc822 format available.

Message #20 received at 15836 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Marcin Kasperski <Marcin.Kasperski <at> mekk.waw.pl>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 15836 <at> debbugs.gnu.org
Subject: Re: bug#15836: 24.3;
 query-replace-regexp does not detect incorrect usage of \#
Date: Wed, 13 Nov 2013 15:50:07 -0500
Marcin Kasperski wrote:

> "Error evaluating replacement expression: ... " would be a bit better,
> it would point toward replacement expression as something suspicious.

OK, done.

Not sure anything else can usefully be done, so will probably close this
at some point unless a good idea comes up.




bug marked as fixed in version 24.4, send any further explanations to 15836 <at> debbugs.gnu.org and Marcin Kasperski <Marcin.Kasperski <at> softax.com.pl> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 23 Nov 2013 03:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 21 Dec 2013 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 139 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.