Make swiper-query-replace a standalone command#2777
Make swiper-query-replace a standalone command#2777astoff wants to merge 6 commits intoabo-abo:masterfrom
Conversation
|
I realized that providing candidates in the replacement text query isn't a great idea, because it's too easy to mistakenly select one of them instead of the current input. (If More importantly, though, I implemented the idea sketched in my previous comment, and
There's still something awry with the overlays (sometimes they stick around after the command quits). Unfortunately that part of the code looks quite arcane to me. If you like the general idea, we can see what to do about that part. |
|
Thanks. I can't say whether or in what form these changes will be accepted, but I just wanted to inform you that large contributions require copyright to be assigned to the Free Software Foundation, as Ivy is copyrighted by the FSF. Do you have such a CA on file already? If not, would you be willing to submit one? If you're unfamiliar with this, the process is relatively straightforward, and there's more info at |
|
Of course I'm willing to sign the CA papers (which I haven't done so far), as long as there is some indication I'll need them :-) |
|
Hi. The PR looks good to me. Please proceed with the CA 👍 |
|
Ok, I completed the CA paperwork. I've also pushed a commit to refine the start point of the replacement. With that in place, I think the logic of the command is good, but of course I'm happy to discuss all the details. It remains to sort out some issues with the overlays. I think you can address those things more effectively and reliably, @abo-abo. How should we organize this? |
| "Swiper query replace: " | ||
| #'swiper-isearch-function | ||
| :initial-input initial-regexp | ||
| :keymap swiper-isearch-map |
There was a problem hiding this comment.
This gives a "reference to free variable swiper-isearch-map" byte-compiler warning, which probably means you need to define that variable before this function.
There was a problem hiding this comment.
I've replaced this with swiper-map. Then M-n will not quote the query, but at least no large reorganizing of the code is needed.
There was a problem hiding this comment.
I don't know which is better, but FWIW moving a defvar verbatim doesn't qualify as "large reorganizing of the code".
There was a problem hiding this comment.
True; but then a random piece of swiper-isearch will be outside of the corresponding ;;*-section of the file. I was assuming this is undesired.
There was a problem hiding this comment.
Rules are made to be broken ;).
There was a problem hiding this comment.
Or rather, there are always exceptions that prove the rule.
Apparently it's not possible to resume a previous
swiper-query-replaceoperartion, so I would like to propose the attached change.The candidates in the
swiper-query-replaceprompt will be the previous replacement texts used for the given replacement subject. The history in that query will be the full history of replacement texts.I frankly never understood what that old
:defparameter in theivy-readcall is supposed to be telling me, and I removed it. If I'm missing something clever here, let me know :-).Another idea, which I could work on if there is interest, would be to modify
swiper-query-replaceso that it also makes sense when called outside of swiper. This would be a variant of swiper where hittingRETasks for a replacement text instead of just exiting the search. This is closer to the usualquery-replaceand might feel more familiar to some people.