Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can markdown-mode cause problems with query-replace? #104

Closed
chairraver opened this issue Feb 24, 2016 · 8 comments
Closed

Can markdown-mode cause problems with query-replace? #104

chairraver opened this issue Feb 24, 2016 · 8 comments

Comments

@chairraver
Copy link

Hi there.

I believe, I'm experiencing an issue with the Emacs query-replace function, which in the end might be caused by the latest development versions of markdown-mode from Melpa.

Let my try to explain. Let's say I've a simple Markdown file, which contains a simple bulleted list of links to a number of images in a directory

* [abcdeg](/xyz/pic[1-20].jpg)
* [abcdeg](/xyz/pic[1-20].jpg)
…

and the latest markdown-mode loaded (20160223.537 after having Emacs terminated and restarted).

Then I execute "M-x query-replace" and enter "/xyz/" to be replaced by "/klm/". Then all occurrences of "/xyz/" are highlighted and I should be able to replace all occurrences one by one by using the Space key or all at once by hitting the ! key. What I'm experiencing however is, that the first occurrence is replaced and then query-replace basically stops and I'm back to editing. In the message buffer I see "replace-match-maybe-edit: Args out of range: 1336".

The reason, why I believe markdown-mode might have something to do with this behavior is, that I put the buffer into simple text-mode (M-x text-mode). Then query-replace worked as expected.

Additionally I also replaced the markdown-down.el file with the one from 2.1 and byte-compiled it and completely restarted Emacs (simple loading of the byte-compiled file does not seem enough). And with the 2.1 markdown-mode loaded query-replace also worked as expected.

Hopefully I don't pickup any residue from something else I've configure in my Emacs startup. I'm experiencing the described behavior on Windows and Linux Emacsen, which share cloud synced initialization files.

BTW, really thank you so much for a really great Emacs Major mode.

@syohex
Copy link
Collaborator

syohex commented Feb 24, 2016

Which emacs version do you use ?

@chairraver
Copy link
Author

On Windows:
GNU Emacs 24.5.1 (x86_64-w64-mingw32) of 2015-09-02 on WARLOCK
On Linux:
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.6) of 2016-01-11 on utensil

@syohex
Copy link
Collaborator

syohex commented Feb 24, 2016

I cannot reproduce this issue as below on Ubuntu 15.10 with Emacs 24.5.

markdown-104

Can you reproduce this issue by emacs -Q -l markdown-mode.el ?

@chairraver
Copy link
Author

Funny thing. It's there, then it isn't.

Since I'm currently @work I'm under Windows. Setup is:

working directory: ~\AppData\Roaming.emacs.d\elpa\markdown-mode-20160223.537

$ md5sum.exe markdown-mode.el markdown-mode-2_1.el
483fb4f4f18b4856247d823068bb8c70 *markdown-mode.el
9a5b233ff6cc83cc9ab68c059c534620 *markdown-mode-2_1.el

emacs -Q -l ./markdown-mode.el test.md

query-replace /salsa/ with /sals/ -> error args out of range

emacs -Q -l ./markdown-mode-2_1.el test.md

query-replay /salsa/ with /sals/ -> no problem.

I've attached a ZIP with the test.md file. I'm really curious, if you're now going to see the same problem.

test.zip

@jrblevin
Copy link
Owner

Thanks for this report. Indeed, markdown-mode can cause problems with query-replace and it has happened before, back in 2011. The fix (eacccad) required placing save-match-data around a function used in after-change-functions. Therefore, if it is due to markdown-mode in this case it is probably related to my changes yesterday in da1cf8d, which removed save-match-data in two places to speed up fontification. I will look into it.

@chairraver
Copy link
Author

Thanks a lot. That I see the "args out of range" error is basically fresh. I believe I'm seeing this with my update of markdown-mode to 20160223.537. Before that, I only saw the effect, that only the first item was replaced during a query-replace. I would say, that I noticed it about a week ago, that query-replace behaved not quite kosher in markdown buffers.

@chairraver
Copy link
Author

Hi, I just noticed the commit to #105, download markdown-mode.el from a2a1b5f, byte-compiled it and restarted Emacs.

I'm more than happy to confirm, that my query-replace problem really is gone now.

Great work, Thank you so much.

@jrblevin
Copy link
Owner

Great, thanks for reporting this and for confirming that it is fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants