all messages for Emacs-related lists mirrored at yhetil.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; 8+ 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] 8+ messages in thread

* bug#21663: 25.0.50; isearch-edit-string dont resume multi-isearch-files
       [not found] ` <handler.21663.B.144453929427612.ack@debbugs.gnu.org>
@ 2015-10-12 15:25   ` Tino Calancha
  2015-10-12 20:17     ` Juri Linkov
  2015-10-13  5:18   ` bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches Tino Calancha
  1 sibling, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2015-10-12 15:25 UTC (permalink / raw)
  To: 21663

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


Previous patch would not work for `multi-isearch-files'
because it is not checking `multi-isearch-file-list', so that
`multi-isearch-end' would be called.

We may replace
(if (and nopush edit multi-isearch-buffer-list)
with
(if (and nopush edit (or multi-isearch-buffer-list multi-isearch-file-list))
but just
(if (and nopush edit)
wold work in any situation and its shorter.


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

gdiff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..6107bd5 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)
+                                        (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] 8+ messages in thread

* bug#21663: 25.0.50; isearch-edit-string dont resume multi-isearch-files
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2015-10-12 20:17 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21663

>> 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).
>
> Previous patch would not work for `multi-isearch-files'
> because it is not checking `multi-isearch-file-list', so that
> `multi-isearch-end' would be called.
>
> We may replace
> (if (and nopush edit multi-isearch-buffer-list)
> with
> (if (and nopush edit (or multi-isearch-buffer-list multi-isearch-file-list))
> but just
> (if (and nopush edit)
> wold work in any situation and its shorter.

I wonder why ‘isearch-mode-end-hook-quit’ is not initialized as
‘(and nopush edit)’ in the first place?  If it was so, then
you could just check for it in ‘multi-isearch-end’.

But please note that not finishing multi-isearch correctly has such
side effects as e.g. after ‘M-s e’ switching from the minibuffer
to another buffer and starting another ordinary search in it will still
use multi-isearch, etc.  Instead of not finishing multi-isearch,
have you tried to re-initialize multi-isearch on resuming isearch
after exiting from the minibuffer?  (This could be achieved by
remembering its state variables).





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

* bug#21663: 25.0.50; isearch-edit-string dont resume multi-isearch-files
  2015-10-12 20:17     ` Juri Linkov
@ 2015-10-13  1:35       ` Tino Calancha
  0 siblings, 0 replies; 8+ messages in thread
From: Tino Calancha @ 2015-10-13  1:35 UTC (permalink / raw)
  To: 21663; +Cc: Tino Calancha

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


> I wonder why ‘isearch-mode-end-hook-quit’ is not initialized as
> ‘(and nopush edit)’ in the first place?  If it was so, then
> you could just check for it in ‘multi-isearch-end’.

My understanding about that variable (i may be wrong) is that is should
be non nil just when the user quit the search with
C-g
we dont want this variable being non nil in the case of editing the string
with the idea to resume the same kind of search.

> have you tried to re-initialize multi-isearch on resuming isearch
> after exiting from the minibuffer?  (This could be achieved by
> remembering its state variables).

I like your proposal: this way is more consistent with the original code.
See attached new patch.

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

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..74b1250 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1242,6 +1242,14 @@ with-isearch-suspended
 	      (isearch-adjusted isearch-adjusted)
 	      (isearch-yank-flag isearch-yank-flag)
 	      (isearch-error isearch-error)
+              ;;  multi isearch variables
+	      (multi-isearch-file-list multi-isearch-file-list)
+	      (multi-isearch-buffer-list multi-isearch-buffer-list)
+	      (multi-isearch-next-buffer-current-function multi-isearch-next-buffer-current-function)
+	      (multi-isearch-current-buffer multi-isearch-current-buffer)
+	      (isearch-push-state-function isearch-push-state-function)
+	      (isearch-wrap-function isearch-wrap-function)
+	      (isearch-search-fun-function isearch-search-fun-function)
   ;;; Don't bind this.  We want isearch-search, below, to set it.
   ;;; And the old value won't matter after that.
   ;;;	    (isearch-other-end isearch-other-end)

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

* bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches
       [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-13  5:18   ` Tino Calancha
  2015-10-13 22:04     ` Juri Linkov
  1 sibling, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2015-10-13  5:18 UTC (permalink / raw)
  To: 21663; +Cc: Tino Calancha

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


In previous patch (isearch_3.patch) the variables are not
restored because they were bind to the same symbol name, and
multi-isearch-end will set them to nil.

In addition, multi-isearch-end need to be added again to 
isearch-mode-end-hook, otherwise, even after exiting with C-g, C-s will 
start a multisearch instead of a normal isearch in the current buffer.

See attached patch: isearch_4.patch

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

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..617f3e7 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1242,6 +1242,15 @@ with-isearch-suspended
 	      (isearch-adjusted isearch-adjusted)
 	      (isearch-yank-flag isearch-yank-flag)
 	      (isearch-error isearch-error)
+              ;; multi isearch variables
+              (is-multi-isearch (or multi-isearch-buffer-list multi-isearch-file-list))
+	      (multi-isearch-file-list-new multi-isearch-file-list)
+	      (multi-isearch-buffer-list-new multi-isearch-buffer-list)
+ 	      (multi-isearch-next-buffer-current-function-new multi-isearch-next-buffer-current-function)
+	      (multi-isearch-current-buffer-new multi-isearch-current-buffer)
+	      (isearch-push-state-function isearch-push-state-function)
+	      (isearch-wrap-function isearch-wrap-function)
+	      (isearch-search-fun-function isearch-search-fun-function)
   ;;; Don't bind this.  We want isearch-search, below, to set it.
   ;;; And the old value won't matter after that.
   ;;;	    (isearch-other-end isearch-other-end)
@@ -1298,12 +1307,17 @@ with-isearch-suspended
 			  nil
 			  isearch-word)
 
+            (when is-multi-isearch (add-hook 'isearch-mode-end-hook  'multi-isearch-end))
 	    ;; Copy new local values to isearch globals
 	    (setq isearch-string isearch-new-string
 		  isearch-message isearch-new-message
 		  isearch-forward isearch-new-forward
 		  isearch-word isearch-new-word
-		  isearch-case-fold-search isearch-new-case-fold))
+		  isearch-case-fold-search isearch-new-case-fold
+                  multi-isearch-file-list multi-isearch-file-list-new
+                  multi-isearch-buffer-list multi-isearch-buffer-list-new
+                  multi-isearch-current-buffer multi-isearch-current-buffer-new
+                  multi-isearch-next-buffer-current-function multi-isearch-next-buffer-current-function-new))
 
 	  ;; Empty isearch-string means use default.
 	  (when (= 0 (length isearch-string))

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

* bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2015-10-13 22:04 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21663

> In previous patch (isearch_3.patch) the variables are not
> restored because they were bind to the same symbol name, and
> multi-isearch-end will set them to nil.

Thanks, it's a safer approach to restore them explicitly.

> In addition, multi-isearch-end need to be added again to
> isearch-mode-end-hook, otherwise, even after exiting with C-g, C-s will
> start a multisearch instead of a normal isearch in the current buffer.

To avoid the need to add multi-isearch-end to isearch-mode-end-hook,
you could try to restore saved variables before calling isearch-mode.
Then multi-isearch-setup called from isearch-mode should take care of
adding multi-isearch-end to isearch-mode-end-hook when necessary
variables are already restored, i.e. when you save the variable
multi-isearch-next-buffer-function instead of
multi-isearch-next-buffer-current-function.  But OTOH
multi-isearch-current-buffer still needs to be restored after
isearch-mode in the same place where you already added it in your patch.
This way restarting isearch will emulate binding local variables
multi-isearch-next-buffer-function and multi-isearch-buffer-list in
multi-isearch-buffers before starting multi-buffer search.





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

* bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches
  2015-10-13 22:04     ` Juri Linkov
@ 2015-10-14  6:48       ` Tino Calancha
  2015-10-14 16:17         ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2015-10-14  6:48 UTC (permalink / raw)
  To: 21663

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


Thank you Juri for your help on this.

I have tested the attached patch (isearch-5.patch)
with `multi-isearch-buffers'/`multi-isearch-files': it seems
OK now.

< To avoid the need to add multi-isearch-end to isearch-mode-end-hook,
< you could try to restore saved variables before calling isearch-mode.
< Then multi-isearch-setup called from isearch-mode should take care of
< adding multi-isearch-end to isearch-mode-end-hook when necessary
< variables are already restored, i.e. when you save the variable
< multi-isearch-next-buffer-function instead of
< multi-isearch-next-buffer-current-function.
I got the point. Actually I bind multi-isearch-next-buffer-function
to multi-isearch-next-buffer-current-function, because the former was nil
and multi-isearch-setup makes a non-nil test for this variable at the
beginning


< multi-isearch-current-buffer still needs to be restored after
< isearch-mode in the same place where you already added it in your patch.
OK.

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

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..4c7187b 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1242,6 +1242,11 @@ with-isearch-suspended
 	      (isearch-adjusted isearch-adjusted)
 	      (isearch-yank-flag isearch-yank-flag)
 	      (isearch-error isearch-error)
+
+	      (multi-isearch-file-list-new multi-isearch-file-list)
+	      (multi-isearch-buffer-list-new multi-isearch-buffer-list)
+              (multi-isearch-next-buffer-function multi-isearch-next-buffer-current-function)
+	      (multi-isearch-current-buffer-new multi-isearch-current-buffer)
   ;;; Don't bind this.  We want isearch-search, below, to set it.
   ;;; And the old value won't matter after that.
   ;;;	    (isearch-other-end isearch-other-end)
@@ -1303,7 +1308,10 @@ with-isearch-suspended
 		  isearch-message isearch-new-message
 		  isearch-forward isearch-new-forward
 		  isearch-word isearch-new-word
-		  isearch-case-fold-search isearch-new-case-fold))
+		  isearch-case-fold-search isearch-new-case-fold
+                  multi-isearch-current-buffer multi-isearch-current-buffer-new
+                  multi-isearch-file-list multi-isearch-file-list-new
+                  multi-isearch-buffer-list multi-isearch-buffer-list-new))
 
 	  ;; Empty isearch-string means use default.
 	  (when (= 0 (length isearch-string))

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

* bug#21663: 25.0.50; isearch-edit-string dont resume multi isearches
  2015-10-14  6:48       ` Tino Calancha
@ 2015-10-14 16:17         ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2015-10-14 16:17 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21663

Thank you Tino, I have tested your patch and it works OK,
so please commit it.





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

end of thread, other threads:[~2015-10-14 16:17 UTC | newest]

Thread overview: 8+ 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.