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

Ivy-occur edit mode doesn't affect original file #2156

Closed
Opioid opened this issue Jul 22, 2019 · 18 comments
Closed

Ivy-occur edit mode doesn't affect original file #2156

Opioid opened this issue Jul 22, 2019 · 18 comments

Comments

@Opioid
Copy link

@Opioid Opioid commented Jul 22, 2019

I make a swiper search and type C-c C-o to open Ivy-occur buffer. With M-x occur-edit-mode I make the buffer editable and do some changes. Then I commit by typing C-c C-c. But nothing gets reflected in the original file. The built-in occur command plus e works like that, so I assumed it would be similar with Ivy-occur. Is the workflow different?

@leungbk
Copy link
Contributor

@leungbk leungbk commented Jul 22, 2019

C-x C-q in the ivy-occur buffer puts you into the editing mode, and after making your edits, C-x C-s should commit the changes.

@Opioid
Copy link
Author

@Opioid Opioid commented Jul 22, 2019

Ah, thanks! I saw wgrep in the help text but didn't think it is the thing I want, so never tried...

@Opioid Opioid closed this Jul 22, 2019
@Opioid Opioid reopened this Jul 23, 2019
@Opioid
Copy link
Author

@Opioid Opioid commented Jul 23, 2019

I just tried it on a different machine. After editing the occur buffer and typing C-x C-s, I get the message "There are X unapplied changes. (0 changed)". Nothing changes in the original file. I don't know why it worked on one machine, but not the other. I don't remember having done anything differently.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 23, 2019

@Opioid

Please test on your other machine by using make plain.

@Opioid
Copy link
Author

@Opioid Opioid commented Jul 23, 2019

I'm sorry, but I searched and couldn't find what make plain means. Is it some command I should run?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 23, 2019

Yes, it's basically Emacs without any config, except ivy:

git clone https://github.com/abo-abo/swiper/
cd swiper
make plain

You do need to have wgrep though, so do:

(add-to-list 'load-path "...wgrep")
(require 'wgrep)

@Opioid
Copy link
Author

@Opioid Opioid commented Jul 24, 2019

OK, I finally managed to do this. The result however still is: There are X unapplied changes. (0 changed)

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 24, 2019

Please add more info: a sample buffer contents, and a sequence of commands that you called.

@Opioid
Copy link
Author

@Opioid Opioid commented Jul 24, 2019

Sample buffer:

asoiernkvxc patter nas;oiukdlnf
er906jkdlfgkn pattern adsfl;xcbnopd
;lkdfukdcn pattern xvcoidrtkl

  1. Put cursor on between the tt of patter in first line
  2. M-x swiper-thing-at-point
  3. C-c C-o
  4. C-x C-q
  5. Edit each line
  6. C-x C-s
  7. There are X unapplied changes. (0 changed)

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 24, 2019

Thanks, I can reproduce.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 24, 2019

Seems that swiper-isearch-thing-at-point doesn't have this problem.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 24, 2019

Thanks, please test.

abo-abo added a commit that referenced this issue Jul 24, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 24, 2019

We now have an automated test that check this behavior.

@Opioid
Copy link
Author

@Opioid Opioid commented Jul 24, 2019

It works now, thanks!

@allenryb
Copy link

@allenryb allenryb commented Feb 6, 2020

I come across the same problem under the latest swiper and wgrep.

M-x swiper and M-x swiper-thing-at-point will lead unapplied changes after wgrep-finish-edit in ivy-occur.
But M-x swiper-isearch-thing-at-point and M-x swiper-isearch work fine.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Feb 7, 2020

@allenryb Can't reproduce it. If you can reliably reproduce it, please open a new issue.

@allenryb
Copy link

@allenryb allenryb commented Feb 8, 2020

@abo-abo Thanks for your reply!

It's strange for me that all things are fine today.

astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
Didn't work before because every line had one extra space.

Fixes abo-abo#2156
astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
@shoukei
Copy link

@shoukei shoukei commented Feb 17, 2022

I had the same problem. In my case I found out that it didn't commit changes if the buffer was in "Visual Line mode". Changing it to "Truncate Long Lines" or "Wrap at Window Edge" solved the problem. Hope that this helps.

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

5 participants