unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21663: Subject: 25.0.50; isearch-edit-string dont resume multi isearches
@ 2015-10-11  4:57 Tino Calancha
       [not found] ` <handler.21663.B.144453929427612.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Tino Calancha @ 2015-10-11  4:57 UTC (permalink / raw)
  To: 21663

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]


Start fresh session:
emacs -Q

C-x C-b
M-x multi-isearch-buffer RET *scratch* RET *Buffer List* RET RET s
(Using C-s several times will search "s" on the two buffers).

M-s e
(Now C-s should keep searching the same string "s" in the two buffers,
  but the string is searched just in the current buffer).

[-- Attachment #2: Type: text/plain, Size: 730 bytes --]

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..5440be7 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1086,7 +1086,10 @@ isearch-done
       ;; Update the ring data.
       (isearch-update-ring isearch-string isearch-regexp))
 
-  (let ((isearch-mode-end-hook-quit (and nopush (not edit))))
+  (let ((isearch-mode-end-hook-quit (and nopush (not edit)))
+        (isearch-mode-end-hook      (if (and nopush edit multi-isearch-buffer-list)
+                                        (delq 'multi-isearch-end isearch-mode-end-hook)
+                                      isearch-mode-end-hook)))
     (run-hooks 'isearch-mode-end-hook))
 
   ;; If there was movement, mark the starting position.

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* bug#21684: 25.0.50; undo in query-replace w/o exit
@ 2015-10-14 13:26 Tino Calancha
  2015-10-14 16:23 ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Tino Calancha @ 2015-10-14 13:26 UTC (permalink / raw)
  To: 21684

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]



In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
  of 2015-10-14
Repository revision: 38f99a02b83e9e408970cb7abdb685725b2004f9


Quite often, performing query-replace, i just hit the [space] quicky
with no much attention. If i replace one string by mistake, i can
comeback to it with "^", but if i edit the string with "E" to reset it 
to its original value, the interactive query-replace session ends.

I found useful if we can undo such replacements without exiting the 
query-replace.

The attached patch implement such behaviour for `query-replace'.
Having this also working for `query-replace-regexp' would be very nice,
but harder to implement.


[-- Attachment #2: Type: text/plain, Size: 2767 bytes --]

diff --git a/lisp/replace.el b/lisp/replace.el
index 3a908ac..e3c906b 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1802,6 +1802,7 @@ query-replace-help
 C-l to clear the screen, redisplay, and offer same replacement again,
 ! to replace all remaining matches in this buffer with no more questions,
 ^ to move point back to previous match,
+U to undo previous replacement (queries w/ regexp not supported),
 E to edit the replacement string.
 In multi-buffer replacements type `Y' to replace all remaining
 matches in all remaining buffers with no more questions,
@@ -1831,6 +1832,8 @@ query-replace-map
     (define-key map "\C-l" 'recenter)
     (define-key map "!" 'automatic)
     (define-key map "^" 'backup)
+    (define-key map "u" 'undo)
+    (define-key map "U" 'undo)
     (define-key map "\C-h" 'help)
     (define-key map [f1] 'help)
     (define-key map [help] 'help)
@@ -1856,7 +1859,7 @@ query-replace-map
 `act-and-exit', `exit', `exit-prefix', `recenter', `scroll-up',
 `scroll-down', `scroll-other-window', `scroll-other-window-down',
 `edit', `edit-replacement', `delete-and-edit', `automatic',
-`backup', `quit', and `help'.
+`backup', `undo', `quit', and `help'.
 
 This keymap is used by `y-or-n-p' as well as `query-replace'.")
 
@@ -2332,6 +2335,32 @@ perform-replace
 			   (message "No previous match")
 			   (ding 'no-terminate)
 			   (sit-for 1)))
+			((eq def 'undo)
+			 (cond (regexp-flag
+					(message "Undo not supported in queries with regexp")
+					(ding 'no-terminate)
+					(sit-for 1))
+				   (t
+					 ;; bind locally swapped values (search-string/replacement)
+					(let* ((search-string-1   next-replacement)
+					       (next-replacement  search-string)
+                                               (search-string     search-string-1)
+                                               (elt               (if stack (pop stack) (match-data))))
+					  (goto-char (nth 0 elt))
+					  (setq replaced (nth 1 elt))
+					  (and replaced (goto-char (- (point) (length next-replacement))))
+
+					  (replace-match-maybe-edit
+					   next-replacement nocasify literal
+					   noedit real-match-data backward)
+
+					  (setq noedit nil
+                                                       replace-count (1- replace-count)
+                                                       replaced nil
+                                                       real-match-data
+                                                       (replace-match-data
+                                                        t real-match-data
+                                                        (nth 2 elt)))))))
 			((eq def 'act)
 			 (or replaced
 			     (setq noedit

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-04 22:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-11  4:57 bug#21663: Subject: 25.0.50; isearch-edit-string dont resume multi isearches Tino Calancha
     [not found] ` <handler.21663.B.144453929427612.ack@debbugs.gnu.org>
2015-10-12 15:25   ` bug#21663: 25.0.50; isearch-edit-string dont resume multi-isearch-files Tino Calancha
2015-10-12 20:17     ` Juri Linkov
2015-10-13  1:35       ` Tino Calancha
2015-10-13  5:18   ` bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches Tino Calancha
2015-10-13 22:04     ` Juri Linkov
2015-10-14  6:48       ` Tino Calancha
2015-10-14 16:17         ` Juri Linkov
  -- strict thread matches above, loose matches on Subject: below --
2015-10-14 13:26 bug#21684: 25.0.50; undo in query-replace w/o exit Tino Calancha
2015-10-14 16:23 ` Juri Linkov
2015-10-17 13:04   ` Tino Calancha
2015-10-17 21:49     ` Juri Linkov
2015-10-18  9:45       ` Tino Calancha
2015-10-18 15:58         ` Richard Stallman
2015-10-19  1:20           ` Tino Calancha
2015-10-19 22:04             ` Juri Linkov
2015-10-20 12:02               ` Tino Calancha
2016-02-23  8:40                 ` Lars Ingebrigtsen
2016-02-23 16:46                   ` Tino Calancha
2016-02-24  1:36                     ` Lars Ingebrigtsen
2016-05-31 22:32                       ` Glenn Morris
2016-06-04 22:06                         ` bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).