Question

I've been using Emacs for a while now and am trying out Icicles. When I run the sequence of commands

C-c`\([a-z]*\)

S-TAB

C-| x\1y

it transforms the scratch buffer from

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

to

;; Xy xy xy xy xy xy xy'xy xy xy xy, xy xy Xy xy.
;; Xy xy xy xy xy xy xy, xy xy xy xy XY-xy XY-xy,
;; xy xy xy xy xy xy xy'xy xy xy.

My understanding is that it should instead attach an 'x' to the start of each word and a 'y' to the end of each word. What am I doing wrong here? I have tried this with emacs -Q and gotten the same results. Also, icicle-search-replace-literally-flag is unchanged from its default value of nil. What am I doing wrong? Thanks!

Edit: Sorry, I omitted the group in the regexp in the original post; however, I did use it in the test and still get the same result.

Was it helpful?

Solution 2

Be sure that your version of file icicles-cmd2.el is dated after 2013-12-10. I fixed a bug wrt \N replacements on that date.

Other suggestions:

  • Proceed slowly, rather than immediately jumping into complex replacements etc. Icicles search and replacement are different from what you might be used to or expect.

  • Check the current values of all of the user options that affect Icicles search and replacement.

OTHER TIPS

I do not use icicles but the effect is reproducible with the ordinary query-replace-regexp.

The problem is that you just do not define any group in your regular expression which you refer to in the replacement. Therefore the group reference \1 in the replacement string is empty.

Furthermore, you should use [a-z]+ instead of [a-z]* since [a-z]* also matches the empty string what you probably do not want.

To put the stuff you want to refer to into a group wrap it by paranthesis \(\). In your example the regular expression would look like \([a-z]+\). With this regular expression you can directly use your replacement string.

The alternative is to leave the regular expression as it is and refer to the whole match with \& instead of \1 in your replacement string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top