I wanted to replace interactively all numbers in the text of an org-mode
document with the number in words, so I tried:
`C-M-% [0-9]+ RET \? RET'
But this gives me an error like this:
> Debugger entered--Lisp error: (error "Invalid use of `\\' in replacement text")
> replace-match("\\?" t nil #("2" 0 1 (fontified t)) nil)
> match-substitute-replacement("\\?" t nil)
> perform-replace("[0-9]+" "\\?" t t nil nil nil nil nil)
> query-replace-regexp("[0-9]+" "\\?" nil nil nil)
> call-interactively(query-replace-regexp nil nil)
> recursive-edit()
> perform-replace("[0-9]+" "?" t t nil nil nil nil nil)
> query-replace-regexp("[0-9]+" "?" nil nil nil)
> call-interactively(query-replace-regexp nil nil)
Since the doc string of `query-replace-regexp' says the following:
> ...
> In TO-STRING, ...
> `\?' lets you edit the replacement text in the minibuffer
> at the given position for each replacement.
> ...
I am not sure what I did wrong. I am using GNU Emacs 24.0.50.1
(x86_64-unknown-linux-gnu, GTK+ Version 2.22.0)
Thanks for any thoughts.
--
Suvayu
Open source is the future. It sets us free.
Weird, it doesn't work for me either. However, if I use
M-x replace-regexp it does work. In "(emacs) Regexp Replace" it also
mentions \?.
"If you want to enter part of the replacement string by hand each
time, use `\?' in the replacement string. Each replacement will ask
you to edit the replacement string in the minibuffer, putting point
where the `\?' was."
--
Deniz Dogan
> 2011/3/2 suvayu ali <fatkasuv...@gmail.com>:
> > Hi Emacs users,
> >
> > I wanted to replace interactively all numbers in the text of an
> > org-mode document with the number in words, so I tried:
> >
> > `C-M-% [0-9]+ RET \? RET'
> >
> > But this gives me an error like this:
> > ...
> >
>
> Weird, it doesn't work for me either. However, if I use
> M-x replace-regexp it does work. In "(emacs) Regexp Replace" it also
> mentions \?.
>
Thank you for looking into this, I can also confirm that it works for me
with replace-regexp but not query-replace-regexp.
Could it be a bug?
Hi,
can confirm this with
GNU Emacs 23.2.94.1 (i686-pc-linux-gnu, GTK+ Version 2.18.6) of 2011-02-25
Seems worth a bug-report
Thanks
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/
I'm by no means an expert on the subject, I didn't even know about the
"\?" feature, but now we're two people confused by the documentation
vs. the behavior. If it's not a functionality bug, it's a
documentation bug. Please file a report.
Thanks,
Deniz Dogan
I have filed a bug report,
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8161
Thanks,