]> code.delx.au - gnu-emacs-elpa/commitdiff
Go to isearch left end when starting replace
authorMichael Heerdegen <michael_heerdegen@web.de>
Sun, 10 Jan 2016 05:34:45 +0000 (06:34 +0100)
committerMichael Heerdegen <michael_heerdegen@web.de>
Tue, 9 Feb 2016 18:18:45 +0000 (19:18 +0100)
with el-search from isearch

This partially reverts

"When coming from isearch, don't move to other end".

packages/el-search/el-search.el

index f6c8c48e0f008e331cafb20dd1482bc931931093..2f69f5f87c6c100df8bac663ed71c14d0ffa68bc 100644 (file)
@@ -952,8 +952,13 @@ Hit any key to proceed."
   (barf-if-buffer-read-only)
   (el-search-search-and-replace-pattern from to mapping))
 
-(defun el-search--take-over-from-isearch ()
-  (prog1 isearch-string (isearch-exit)))
+(defun el-search--take-over-from-isearch (&optional goto-left-end)
+  (let ((other-end (and goto-left-end isearch-other-end))
+        (input isearch-string))
+    (isearch-exit)
+    (when (and other-end (< other-end (point)))
+      (goto-char other-end))
+    input))
 
 ;;;###autoload
 (defun el-search-search-from-isearch ()
@@ -968,7 +973,7 @@ Hit any key to proceed."
 ;;;###autoload
 (defun el-search-replace-from-isearch ()
   (interactive)
-  (let ((el-search--initial-mb-contents (concat "'" (el-search--take-over-from-isearch))))
+  (let ((el-search--initial-mb-contents (concat "'" (el-search--take-over-from-isearch t))))
     (call-interactively #'el-search-query-replace)))