benma / visual-regexp.el

A regexp/replace command for Emacs with interactive visual feedback
392 stars 28 forks source link

Newlines not saved in history properly #41

Closed CyberShadow closed 7 years ago

CyberShadow commented 7 years ago

After performing a replace where the search expression contains a literal newline (inserted e.g. via C-q C-j), when attempting to repeat the replace, the newline character in the query default is replaced with ^J. However, even though they're formatted as a special character, they are two distinct characters (^ and J). As such, they will no longer match a newline. Attempting to repeat the replace a third time will remove the highlighting.

benma commented 7 years ago

Unfortunately, I can't reproduce this.

What I did:

In the scratch buffer, I used vr/replace. The search string I used:

evaluation\.
;;

The replace string:

TEST

The replacement worked fine. Repeating vr/replace and going back in history one step, the minibuffer shows:

evaluation\.^J;; → TEST

Where the ^J are treated as one character (I couldn't put the point in the middle of it). The replacement worked fine for a 2nd, and 3rd time.

Please try it again and if it does not work, explain in greater detail what you did. Please also post your emacs and visual-regexp version.

CyberShadow commented 7 years ago

I can reproduce the problem, including your example steps, on GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.6) with visual-regexp 20160806.610. The problem is reproducible when running emacs with -q and loading only visual-regexp.

benma commented 7 years ago

Can you reproduce the problem on Emacs 25.1? I am tempted to only support the latest version of Emacs, as the previous round of Emacs 24 incompatibilities incurred quiet a bit of work, and I'd like to avoid doing more work for it.

I will accept simple pull requests though for emacs 24, if that helps.

CyberShadow commented 7 years ago

Not reproducible with Emacs 25.1.

This fixes the problem for me, but a lot of distributions will remain on Emacs 24 for a while.

benma commented 7 years ago

Thanks.